repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
| partition
stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
infusephp/auth
|
src/Libs/Strategy/TraditionalStrategy.php
|
TraditionalStrategy.buildUsernameWhere
|
private function buildUsernameWhere($username)
{
$userClass = $this->auth->getUserClass();
$conditions = array_map(
function ($prop, $username) { return $prop." = '".$username."'"; },
$userClass::$usernameProperties,
array_fill(0, count($userClass::$usernameProperties),
addslashes($username)));
return '('.implode(' OR ', $conditions).')';
}
|
php
|
private function buildUsernameWhere($username)
{
$userClass = $this->auth->getUserClass();
$conditions = array_map(
function ($prop, $username) { return $prop." = '".$username."'"; },
$userClass::$usernameProperties,
array_fill(0, count($userClass::$usernameProperties),
addslashes($username)));
return '('.implode(' OR ', $conditions).')';
}
|
[
"private",
"function",
"buildUsernameWhere",
"(",
"$",
"username",
")",
"{",
"$",
"userClass",
"=",
"$",
"this",
"->",
"auth",
"->",
"getUserClass",
"(",
")",
";",
"$",
"conditions",
"=",
"array_map",
"(",
"function",
"(",
"$",
"prop",
",",
"$",
"username",
")",
"{",
"return",
"$",
"prop",
".",
"\" = '\"",
".",
"$",
"username",
".",
"\"'\"",
";",
"}",
",",
"$",
"userClass",
"::",
"$",
"usernameProperties",
",",
"array_fill",
"(",
"0",
",",
"count",
"(",
"$",
"userClass",
"::",
"$",
"usernameProperties",
")",
",",
"addslashes",
"(",
"$",
"username",
")",
")",
")",
";",
"return",
"'('",
".",
"implode",
"(",
"' OR '",
",",
"$",
"conditions",
")",
".",
"')'",
";",
"}"
] |
Builds a query string for matching the username.
@param string $username username to match
@return string
|
[
"Builds",
"a",
"query",
"string",
"for",
"matching",
"the",
"username",
"."
] |
720280b4b2635572f331afe8d082e3e88cf54eb7
|
https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Libs/Strategy/TraditionalStrategy.php#L185-L196
|
train
|
simpleapisecurity/php
|
src/Encryption.php
|
Encryption.encryptMessage
|
public static function encryptMessage($message, $key, $hashKey = '')
{
// Test the key for string validity.
Helpers::isString($message, 'Encryption', 'encryptMessage');
Helpers::isString($key, 'Encryption', 'encryptMessage');
Helpers::isString($hashKey, 'Encryption', 'encryptMessage');
// Create a special hashed key for encryption.
$key = Hash::hash($key, $hashKey, Constants::SECRETBOX_KEYBYTES);
// Generate a nonce for the communication.
$nonce = Entropy::generateNonce();
// Serialize and encrypt the message object
$ciphertext = \Sodium\crypto_secretbox(serialize($message), $nonce, $key);
$nonce = base64_encode($nonce);
$ciphertext = base64_encode($ciphertext);
$json = json_encode(compact('nonce', 'ciphertext'));
if (! is_string($json)) {
throw new Exceptions\EncryptionException('Failed to encrypt message using key');
}
return base64_encode($json);
}
|
php
|
public static function encryptMessage($message, $key, $hashKey = '')
{
// Test the key for string validity.
Helpers::isString($message, 'Encryption', 'encryptMessage');
Helpers::isString($key, 'Encryption', 'encryptMessage');
Helpers::isString($hashKey, 'Encryption', 'encryptMessage');
// Create a special hashed key for encryption.
$key = Hash::hash($key, $hashKey, Constants::SECRETBOX_KEYBYTES);
// Generate a nonce for the communication.
$nonce = Entropy::generateNonce();
// Serialize and encrypt the message object
$ciphertext = \Sodium\crypto_secretbox(serialize($message), $nonce, $key);
$nonce = base64_encode($nonce);
$ciphertext = base64_encode($ciphertext);
$json = json_encode(compact('nonce', 'ciphertext'));
if (! is_string($json)) {
throw new Exceptions\EncryptionException('Failed to encrypt message using key');
}
return base64_encode($json);
}
|
[
"public",
"static",
"function",
"encryptMessage",
"(",
"$",
"message",
",",
"$",
"key",
",",
"$",
"hashKey",
"=",
"''",
")",
"{",
"// Test the key for string validity.",
"Helpers",
"::",
"isString",
"(",
"$",
"message",
",",
"'Encryption'",
",",
"'encryptMessage'",
")",
";",
"Helpers",
"::",
"isString",
"(",
"$",
"key",
",",
"'Encryption'",
",",
"'encryptMessage'",
")",
";",
"Helpers",
"::",
"isString",
"(",
"$",
"hashKey",
",",
"'Encryption'",
",",
"'encryptMessage'",
")",
";",
"// Create a special hashed key for encryption.",
"$",
"key",
"=",
"Hash",
"::",
"hash",
"(",
"$",
"key",
",",
"$",
"hashKey",
",",
"Constants",
"::",
"SECRETBOX_KEYBYTES",
")",
";",
"// Generate a nonce for the communication.",
"$",
"nonce",
"=",
"Entropy",
"::",
"generateNonce",
"(",
")",
";",
"// Serialize and encrypt the message object",
"$",
"ciphertext",
"=",
"\\",
"Sodium",
"\\",
"crypto_secretbox",
"(",
"serialize",
"(",
"$",
"message",
")",
",",
"$",
"nonce",
",",
"$",
"key",
")",
";",
"$",
"nonce",
"=",
"base64_encode",
"(",
"$",
"nonce",
")",
";",
"$",
"ciphertext",
"=",
"base64_encode",
"(",
"$",
"ciphertext",
")",
";",
"$",
"json",
"=",
"json_encode",
"(",
"compact",
"(",
"'nonce'",
",",
"'ciphertext'",
")",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"json",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"EncryptionException",
"(",
"'Failed to encrypt message using key'",
")",
";",
"}",
"return",
"base64_encode",
"(",
"$",
"json",
")",
";",
"}"
] |
Returns an encrypted message in the form of a JSON string.
@param string $message The message to be encrypted.
@param string $key The key to encrypt the message with.
@param string $hashKey The key to hash the key with.
@return string The JSON string for the encrypted message.
@throws Exceptions\EncryptionException
@throws Exceptions\InvalidTypeException
@throws Exceptions\OutOfRangeException
|
[
"Returns",
"an",
"encrypted",
"message",
"in",
"the",
"form",
"of",
"a",
"JSON",
"string",
"."
] |
e6cebf3213f4d7be54aa3a188d95a00113e3fda0
|
https://github.com/simpleapisecurity/php/blob/e6cebf3213f4d7be54aa3a188d95a00113e3fda0/src/Encryption.php#L38-L57
|
train
|
simpleapisecurity/php
|
src/Encryption.php
|
Encryption.decryptMessage
|
public static function decryptMessage($message, $key, $hashKey = '')
{
// Test the message and key for string validity.
Helpers::isString($message, 'Encryption', 'decryptMessage');
Helpers::isString($key, 'Encryption', 'decryptMessage');
Helpers::isString($hashKey, 'Encryption', 'decryptMessage');
// Create a special hashed key for encryption.
$key = Hash::hash($key, $hashKey, Constants::SECRETBOX_KEYBYTES);
// Validate and decode the paylload.
$payload = self::getJsonPayload($message);
$nonce = base64_decode($payload['nonce']);
$ciphertext = base64_decode($payload['ciphertext']);
// Open the secret box using the data provided.
$plaintext = \Sodium\crypto_secretbox_open($ciphertext, $nonce, $key);
// Test if the secret box returned usable data.
if ($plaintext === false) {
throw new Exceptions\DecryptionException("Failed to decrypt message using key.");
}
return unserialize($plaintext);
}
|
php
|
public static function decryptMessage($message, $key, $hashKey = '')
{
// Test the message and key for string validity.
Helpers::isString($message, 'Encryption', 'decryptMessage');
Helpers::isString($key, 'Encryption', 'decryptMessage');
Helpers::isString($hashKey, 'Encryption', 'decryptMessage');
// Create a special hashed key for encryption.
$key = Hash::hash($key, $hashKey, Constants::SECRETBOX_KEYBYTES);
// Validate and decode the paylload.
$payload = self::getJsonPayload($message);
$nonce = base64_decode($payload['nonce']);
$ciphertext = base64_decode($payload['ciphertext']);
// Open the secret box using the data provided.
$plaintext = \Sodium\crypto_secretbox_open($ciphertext, $nonce, $key);
// Test if the secret box returned usable data.
if ($plaintext === false) {
throw new Exceptions\DecryptionException("Failed to decrypt message using key.");
}
return unserialize($plaintext);
}
|
[
"public",
"static",
"function",
"decryptMessage",
"(",
"$",
"message",
",",
"$",
"key",
",",
"$",
"hashKey",
"=",
"''",
")",
"{",
"// Test the message and key for string validity.",
"Helpers",
"::",
"isString",
"(",
"$",
"message",
",",
"'Encryption'",
",",
"'decryptMessage'",
")",
";",
"Helpers",
"::",
"isString",
"(",
"$",
"key",
",",
"'Encryption'",
",",
"'decryptMessage'",
")",
";",
"Helpers",
"::",
"isString",
"(",
"$",
"hashKey",
",",
"'Encryption'",
",",
"'decryptMessage'",
")",
";",
"// Create a special hashed key for encryption.",
"$",
"key",
"=",
"Hash",
"::",
"hash",
"(",
"$",
"key",
",",
"$",
"hashKey",
",",
"Constants",
"::",
"SECRETBOX_KEYBYTES",
")",
";",
"// Validate and decode the paylload.",
"$",
"payload",
"=",
"self",
"::",
"getJsonPayload",
"(",
"$",
"message",
")",
";",
"$",
"nonce",
"=",
"base64_decode",
"(",
"$",
"payload",
"[",
"'nonce'",
"]",
")",
";",
"$",
"ciphertext",
"=",
"base64_decode",
"(",
"$",
"payload",
"[",
"'ciphertext'",
"]",
")",
";",
"// Open the secret box using the data provided.",
"$",
"plaintext",
"=",
"\\",
"Sodium",
"\\",
"crypto_secretbox_open",
"(",
"$",
"ciphertext",
",",
"$",
"nonce",
",",
"$",
"key",
")",
";",
"// Test if the secret box returned usable data.",
"if",
"(",
"$",
"plaintext",
"===",
"false",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"DecryptionException",
"(",
"\"Failed to decrypt message using key.\"",
")",
";",
"}",
"return",
"unserialize",
"(",
"$",
"plaintext",
")",
";",
"}"
] |
Returns the encrypted message in plaintext format.
@param string $message The encrypted message portion.
@param string $key The encryption key used with the message.
@param string $hashKey The key to hash the key with.
@return string The encrypted message in plaintext format.
@throws Exceptions\DecryptionException
@throws Exceptions\InvalidTypeException
@throws Exceptions\OutOfRangeException
|
[
"Returns",
"the",
"encrypted",
"message",
"in",
"plaintext",
"format",
"."
] |
e6cebf3213f4d7be54aa3a188d95a00113e3fda0
|
https://github.com/simpleapisecurity/php/blob/e6cebf3213f4d7be54aa3a188d95a00113e3fda0/src/Encryption.php#L70-L89
|
train
|
simpleapisecurity/php
|
src/Encryption.php
|
Encryption.signMessage
|
public static function signMessage($message, $key, $hashKey = '')
{
# Test the message and key for string validity.
Helpers::isString($message, 'Encryption', 'signMessage');
Helpers::isString($key, 'Encryption', 'signMessage');
Helpers::isString($hashKey, 'Encryption', 'signMessage');
# Create a special hashed key for encryption.
$key = Hash::hash($key, $hashKey, Constants::AUTH_KEYBYTES);
# Generate a MAC for the message.
$mac = \Sodium\crypto_auth($message, $key);
return base64_encode(json_encode([
'mac' => Helpers::bin2hex($mac),
'msg' => $message,
]));
}
|
php
|
public static function signMessage($message, $key, $hashKey = '')
{
# Test the message and key for string validity.
Helpers::isString($message, 'Encryption', 'signMessage');
Helpers::isString($key, 'Encryption', 'signMessage');
Helpers::isString($hashKey, 'Encryption', 'signMessage');
# Create a special hashed key for encryption.
$key = Hash::hash($key, $hashKey, Constants::AUTH_KEYBYTES);
# Generate a MAC for the message.
$mac = \Sodium\crypto_auth($message, $key);
return base64_encode(json_encode([
'mac' => Helpers::bin2hex($mac),
'msg' => $message,
]));
}
|
[
"public",
"static",
"function",
"signMessage",
"(",
"$",
"message",
",",
"$",
"key",
",",
"$",
"hashKey",
"=",
"''",
")",
"{",
"# Test the message and key for string validity.",
"Helpers",
"::",
"isString",
"(",
"$",
"message",
",",
"'Encryption'",
",",
"'signMessage'",
")",
";",
"Helpers",
"::",
"isString",
"(",
"$",
"key",
",",
"'Encryption'",
",",
"'signMessage'",
")",
";",
"Helpers",
"::",
"isString",
"(",
"$",
"hashKey",
",",
"'Encryption'",
",",
"'signMessage'",
")",
";",
"# Create a special hashed key for encryption.",
"$",
"key",
"=",
"Hash",
"::",
"hash",
"(",
"$",
"key",
",",
"$",
"hashKey",
",",
"Constants",
"::",
"AUTH_KEYBYTES",
")",
";",
"# Generate a MAC for the message.",
"$",
"mac",
"=",
"\\",
"Sodium",
"\\",
"crypto_auth",
"(",
"$",
"message",
",",
"$",
"key",
")",
";",
"return",
"base64_encode",
"(",
"json_encode",
"(",
"[",
"'mac'",
"=>",
"Helpers",
"::",
"bin2hex",
"(",
"$",
"mac",
")",
",",
"'msg'",
"=>",
"$",
"message",
",",
"]",
")",
")",
";",
"}"
] |
Returns a signed message to the client for authentication.
@param string $message The message to be signed.
@param string $key The signing key used with the message.
@param string $hashKey The key to hash the key with.
@return string A JSON string including the signing information and message.
@throws Exceptions\InvalidTypeException
@throws Exceptions\OutOfRangeException
|
[
"Returns",
"a",
"signed",
"message",
"to",
"the",
"client",
"for",
"authentication",
"."
] |
e6cebf3213f4d7be54aa3a188d95a00113e3fda0
|
https://github.com/simpleapisecurity/php/blob/e6cebf3213f4d7be54aa3a188d95a00113e3fda0/src/Encryption.php#L129-L146
|
train
|
simpleapisecurity/php
|
src/Encryption.php
|
Encryption.verifyMessage
|
public static function verifyMessage($message, $key, $hashKey = '')
{
# Test the message and key for string validity.
Helpers::isString($message, 'Encryption', 'verifyMessage');
Helpers::isString($key, 'Encryption', 'verifyMessage');
Helpers::isString($hashKey, 'Encryption', 'verifyMessage');
# Create a special hashed key for encryption.
$key = Hash::hash($key, $hashKey, Constants::AUTH_KEYBYTES);
# Decode the message from JSON.
$message = base64_decode(json_decode($message, true));
if (\Sodium\crypto_auth_verify(Helpers::hex2bin($message['mac']), $message['msg'], $key)) {
\Sodium\memzero($key);
return $message['msg'];
} else {
\Sodium\memzero($key);
throw new Exceptions\SignatureException('Signature for message invalid.');
}
}
|
php
|
public static function verifyMessage($message, $key, $hashKey = '')
{
# Test the message and key for string validity.
Helpers::isString($message, 'Encryption', 'verifyMessage');
Helpers::isString($key, 'Encryption', 'verifyMessage');
Helpers::isString($hashKey, 'Encryption', 'verifyMessage');
# Create a special hashed key for encryption.
$key = Hash::hash($key, $hashKey, Constants::AUTH_KEYBYTES);
# Decode the message from JSON.
$message = base64_decode(json_decode($message, true));
if (\Sodium\crypto_auth_verify(Helpers::hex2bin($message['mac']), $message['msg'], $key)) {
\Sodium\memzero($key);
return $message['msg'];
} else {
\Sodium\memzero($key);
throw new Exceptions\SignatureException('Signature for message invalid.');
}
}
|
[
"public",
"static",
"function",
"verifyMessage",
"(",
"$",
"message",
",",
"$",
"key",
",",
"$",
"hashKey",
"=",
"''",
")",
"{",
"# Test the message and key for string validity.",
"Helpers",
"::",
"isString",
"(",
"$",
"message",
",",
"'Encryption'",
",",
"'verifyMessage'",
")",
";",
"Helpers",
"::",
"isString",
"(",
"$",
"key",
",",
"'Encryption'",
",",
"'verifyMessage'",
")",
";",
"Helpers",
"::",
"isString",
"(",
"$",
"hashKey",
",",
"'Encryption'",
",",
"'verifyMessage'",
")",
";",
"# Create a special hashed key for encryption.",
"$",
"key",
"=",
"Hash",
"::",
"hash",
"(",
"$",
"key",
",",
"$",
"hashKey",
",",
"Constants",
"::",
"AUTH_KEYBYTES",
")",
";",
"# Decode the message from JSON.",
"$",
"message",
"=",
"base64_decode",
"(",
"json_decode",
"(",
"$",
"message",
",",
"true",
")",
")",
";",
"if",
"(",
"\\",
"Sodium",
"\\",
"crypto_auth_verify",
"(",
"Helpers",
"::",
"hex2bin",
"(",
"$",
"message",
"[",
"'mac'",
"]",
")",
",",
"$",
"message",
"[",
"'msg'",
"]",
",",
"$",
"key",
")",
")",
"{",
"\\",
"Sodium",
"\\",
"memzero",
"(",
"$",
"key",
")",
";",
"return",
"$",
"message",
"[",
"'msg'",
"]",
";",
"}",
"else",
"{",
"\\",
"Sodium",
"\\",
"memzero",
"(",
"$",
"key",
")",
";",
"throw",
"new",
"Exceptions",
"\\",
"SignatureException",
"(",
"'Signature for message invalid.'",
")",
";",
"}",
"}"
] |
Validates a message signature and returns the signed message.
@param string $message The signed message JSON string.
@param string $key The signing key used with the message.
@param string $hashKey The key to hash the key with.
@return string A string returning the output of the signed message.
@throws Exceptions\InvalidTypeException
@throws Exceptions\SignatureException
|
[
"Validates",
"a",
"message",
"signature",
"and",
"returns",
"the",
"signed",
"message",
"."
] |
e6cebf3213f4d7be54aa3a188d95a00113e3fda0
|
https://github.com/simpleapisecurity/php/blob/e6cebf3213f4d7be54aa3a188d95a00113e3fda0/src/Encryption.php#L158-L179
|
train
|
simpleapisecurity/php
|
src/Encryption.php
|
Encryption.encryptSignMessage
|
public static function encryptSignMessage($message, $encryptionKey, $signatureKey, $hashKey = '')
{
# Test the message and key for string validity.
Helpers::isString($message, 'Encryption', 'encryptSignMessage');
Helpers::isString($encryptionKey, 'Encryption', 'encryptSignMessage');
Helpers::isString($signatureKey, 'Encryption', 'encryptSignMessage');
Helpers::isString($hashKey, 'Encryption', 'encryptSignMessage');
$message = self::encryptMessage($message, $encryptionKey, $hashKey);
return self::signMessage($message, $signatureKey, $hashKey);
}
|
php
|
public static function encryptSignMessage($message, $encryptionKey, $signatureKey, $hashKey = '')
{
# Test the message and key for string validity.
Helpers::isString($message, 'Encryption', 'encryptSignMessage');
Helpers::isString($encryptionKey, 'Encryption', 'encryptSignMessage');
Helpers::isString($signatureKey, 'Encryption', 'encryptSignMessage');
Helpers::isString($hashKey, 'Encryption', 'encryptSignMessage');
$message = self::encryptMessage($message, $encryptionKey, $hashKey);
return self::signMessage($message, $signatureKey, $hashKey);
}
|
[
"public",
"static",
"function",
"encryptSignMessage",
"(",
"$",
"message",
",",
"$",
"encryptionKey",
",",
"$",
"signatureKey",
",",
"$",
"hashKey",
"=",
"''",
")",
"{",
"# Test the message and key for string validity.",
"Helpers",
"::",
"isString",
"(",
"$",
"message",
",",
"'Encryption'",
",",
"'encryptSignMessage'",
")",
";",
"Helpers",
"::",
"isString",
"(",
"$",
"encryptionKey",
",",
"'Encryption'",
",",
"'encryptSignMessage'",
")",
";",
"Helpers",
"::",
"isString",
"(",
"$",
"signatureKey",
",",
"'Encryption'",
",",
"'encryptSignMessage'",
")",
";",
"Helpers",
"::",
"isString",
"(",
"$",
"hashKey",
",",
"'Encryption'",
",",
"'encryptSignMessage'",
")",
";",
"$",
"message",
"=",
"self",
"::",
"encryptMessage",
"(",
"$",
"message",
",",
"$",
"encryptionKey",
",",
"$",
"hashKey",
")",
";",
"return",
"self",
"::",
"signMessage",
"(",
"$",
"message",
",",
"$",
"signatureKey",
",",
"$",
"hashKey",
")",
";",
"}"
] |
Sign and encrypt a message for security.
@param string $message The message to be encrypted and signed for transport.
@param string $encryptionKey The encryption key used with the message.
@param string $signatureKey The signing key used with the message.
@param string $hashKey The key to hash the key with.
@return string The encrypted and signed JSON string with message data.
@throws Exceptions\InvalidTypeException
|
[
"Sign",
"and",
"encrypt",
"a",
"message",
"for",
"security",
"."
] |
e6cebf3213f4d7be54aa3a188d95a00113e3fda0
|
https://github.com/simpleapisecurity/php/blob/e6cebf3213f4d7be54aa3a188d95a00113e3fda0/src/Encryption.php#L191-L202
|
train
|
simpleapisecurity/php
|
src/Encryption.php
|
Encryption.decryptVerifyMessage
|
public static function decryptVerifyMessage($message, $encryptionKey, $signatureKey, $hashKey = '')
{
# Test the message and key for string validity.
Helpers::isString($message, 'Encryption', 'decryptVerifyMessage');
Helpers::isString($encryptionKey, 'Encryption', 'decryptVerifyMessage');
Helpers::isString($signatureKey, 'Encryption', 'decryptVerifyMessage');
Helpers::isString($hashKey, 'Encryption', 'decryptVerifyMessage');
$message = self::verifyMessage($message, $signatureKey, $hashKey);
return self::decryptMessage($message, $encryptionKey, $hashKey);
}
|
php
|
public static function decryptVerifyMessage($message, $encryptionKey, $signatureKey, $hashKey = '')
{
# Test the message and key for string validity.
Helpers::isString($message, 'Encryption', 'decryptVerifyMessage');
Helpers::isString($encryptionKey, 'Encryption', 'decryptVerifyMessage');
Helpers::isString($signatureKey, 'Encryption', 'decryptVerifyMessage');
Helpers::isString($hashKey, 'Encryption', 'decryptVerifyMessage');
$message = self::verifyMessage($message, $signatureKey, $hashKey);
return self::decryptMessage($message, $encryptionKey, $hashKey);
}
|
[
"public",
"static",
"function",
"decryptVerifyMessage",
"(",
"$",
"message",
",",
"$",
"encryptionKey",
",",
"$",
"signatureKey",
",",
"$",
"hashKey",
"=",
"''",
")",
"{",
"# Test the message and key for string validity.",
"Helpers",
"::",
"isString",
"(",
"$",
"message",
",",
"'Encryption'",
",",
"'decryptVerifyMessage'",
")",
";",
"Helpers",
"::",
"isString",
"(",
"$",
"encryptionKey",
",",
"'Encryption'",
",",
"'decryptVerifyMessage'",
")",
";",
"Helpers",
"::",
"isString",
"(",
"$",
"signatureKey",
",",
"'Encryption'",
",",
"'decryptVerifyMessage'",
")",
";",
"Helpers",
"::",
"isString",
"(",
"$",
"hashKey",
",",
"'Encryption'",
",",
"'decryptVerifyMessage'",
")",
";",
"$",
"message",
"=",
"self",
"::",
"verifyMessage",
"(",
"$",
"message",
",",
"$",
"signatureKey",
",",
"$",
"hashKey",
")",
";",
"return",
"self",
"::",
"decryptMessage",
"(",
"$",
"message",
",",
"$",
"encryptionKey",
",",
"$",
"hashKey",
")",
";",
"}"
] |
Verify and decrypt a message for security.
@param string $message The message to be encrypted and signed for transport.
@param string $encryptionKey The encryption key used with the message.
@param string $signatureKey The signing key used with the message.
@param string $hashKey The key to hash the key with.
@return string The string of the signed and decrypted message.
@throws Exceptions\InvalidTypeException
@throws Exceptions\SignatureException
|
[
"Verify",
"and",
"decrypt",
"a",
"message",
"for",
"security",
"."
] |
e6cebf3213f4d7be54aa3a188d95a00113e3fda0
|
https://github.com/simpleapisecurity/php/blob/e6cebf3213f4d7be54aa3a188d95a00113e3fda0/src/Encryption.php#L215-L226
|
train
|
anklimsk/cakephp-console-installer
|
View/Helper/CheckResultHelper.php
|
CheckResultHelper.getStateElement
|
public function getStateElement($state = null) {
if (is_bool($state) && ($state === true)) {
$state = 2;
}
switch ((int)$state) {
case 2:
$stateText = $this->Html->tag('span', '', ['class' => 'fas fa-check']);
$titleText = __d('cake_installer', 'Ok');
$labelClass = 'label-success';
break;
case 1:
$stateText = $this->Html->tag('span', '', ['class' => 'fas fa-minus']);
$titleText = __d('cake_installer', 'Ok');
$labelClass = 'label-warning';
break;
default:
$stateText = $this->Html->tag('span', '', ['class' => 'fas fa-times']);
$titleText = __d('cake_installer', 'Bad');
$labelClass = 'label-danger';
}
return $this->Html->tag('span', $stateText, [
'class' => 'label' . ' ' . $labelClass,
'title' => $titleText, 'data-toggle' => 'tooltip']);
}
|
php
|
public function getStateElement($state = null) {
if (is_bool($state) && ($state === true)) {
$state = 2;
}
switch ((int)$state) {
case 2:
$stateText = $this->Html->tag('span', '', ['class' => 'fas fa-check']);
$titleText = __d('cake_installer', 'Ok');
$labelClass = 'label-success';
break;
case 1:
$stateText = $this->Html->tag('span', '', ['class' => 'fas fa-minus']);
$titleText = __d('cake_installer', 'Ok');
$labelClass = 'label-warning';
break;
default:
$stateText = $this->Html->tag('span', '', ['class' => 'fas fa-times']);
$titleText = __d('cake_installer', 'Bad');
$labelClass = 'label-danger';
}
return $this->Html->tag('span', $stateText, [
'class' => 'label' . ' ' . $labelClass,
'title' => $titleText, 'data-toggle' => 'tooltip']);
}
|
[
"public",
"function",
"getStateElement",
"(",
"$",
"state",
"=",
"null",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"state",
")",
"&&",
"(",
"$",
"state",
"===",
"true",
")",
")",
"{",
"$",
"state",
"=",
"2",
";",
"}",
"switch",
"(",
"(",
"int",
")",
"$",
"state",
")",
"{",
"case",
"2",
":",
"$",
"stateText",
"=",
"$",
"this",
"->",
"Html",
"->",
"tag",
"(",
"'span'",
",",
"''",
",",
"[",
"'class'",
"=>",
"'fas fa-check'",
"]",
")",
";",
"$",
"titleText",
"=",
"__d",
"(",
"'cake_installer'",
",",
"'Ok'",
")",
";",
"$",
"labelClass",
"=",
"'label-success'",
";",
"break",
";",
"case",
"1",
":",
"$",
"stateText",
"=",
"$",
"this",
"->",
"Html",
"->",
"tag",
"(",
"'span'",
",",
"''",
",",
"[",
"'class'",
"=>",
"'fas fa-minus'",
"]",
")",
";",
"$",
"titleText",
"=",
"__d",
"(",
"'cake_installer'",
",",
"'Ok'",
")",
";",
"$",
"labelClass",
"=",
"'label-warning'",
";",
"break",
";",
"default",
":",
"$",
"stateText",
"=",
"$",
"this",
"->",
"Html",
"->",
"tag",
"(",
"'span'",
",",
"''",
",",
"[",
"'class'",
"=>",
"'fas fa-times'",
"]",
")",
";",
"$",
"titleText",
"=",
"__d",
"(",
"'cake_installer'",
",",
"'Bad'",
")",
";",
"$",
"labelClass",
"=",
"'label-danger'",
";",
"}",
"return",
"$",
"this",
"->",
"Html",
"->",
"tag",
"(",
"'span'",
",",
"$",
"stateText",
",",
"[",
"'class'",
"=>",
"'label'",
".",
"' '",
".",
"$",
"labelClass",
",",
"'title'",
"=>",
"$",
"titleText",
",",
"'data-toggle'",
"=>",
"'tooltip'",
"]",
")",
";",
"}"
] |
Build HTML element with status icon from status value
@param int $state State for build HTML elemeth.
Integer value:
- `0` - Bad;
- `1` - Warning;
- `2` - Success.
@return string Result HTML element with status text
|
[
"Build",
"HTML",
"element",
"with",
"status",
"icon",
"from",
"status",
"value"
] |
76136550e856ff4f8fd3634b77633f86510f63e9
|
https://github.com/anklimsk/cakephp-console-installer/blob/76136550e856ff4f8fd3634b77633f86510f63e9/View/Helper/CheckResultHelper.php#L38-L63
|
train
|
anklimsk/cakephp-console-installer
|
View/Helper/CheckResultHelper.php
|
CheckResultHelper.getStateItemClass
|
public function getStateItemClass($state = null) {
if (is_bool($state) && ($state === true)) {
$state = 2;
}
switch ((int)$state) {
case 2:
$classItem = '';
break;
case 1:
$classItem = 'list-group-item-warning';
break;
default:
$classItem = 'list-group-item-danger';
}
return $classItem;
}
|
php
|
public function getStateItemClass($state = null) {
if (is_bool($state) && ($state === true)) {
$state = 2;
}
switch ((int)$state) {
case 2:
$classItem = '';
break;
case 1:
$classItem = 'list-group-item-warning';
break;
default:
$classItem = 'list-group-item-danger';
}
return $classItem;
}
|
[
"public",
"function",
"getStateItemClass",
"(",
"$",
"state",
"=",
"null",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"state",
")",
"&&",
"(",
"$",
"state",
"===",
"true",
")",
")",
"{",
"$",
"state",
"=",
"2",
";",
"}",
"switch",
"(",
"(",
"int",
")",
"$",
"state",
")",
"{",
"case",
"2",
":",
"$",
"classItem",
"=",
"''",
";",
"break",
";",
"case",
"1",
":",
"$",
"classItem",
"=",
"'list-group-item-warning'",
";",
"break",
";",
"default",
":",
"$",
"classItem",
"=",
"'list-group-item-danger'",
";",
"}",
"return",
"$",
"classItem",
";",
"}"
] |
Return class for list element from status value
@param int $state State for build HTML elemeth.
Integer value:
- `0` - Bad;
- `1` - Warning;
- `2` - Success.
@return string Return class name
|
[
"Return",
"class",
"for",
"list",
"element",
"from",
"status",
"value"
] |
76136550e856ff4f8fd3634b77633f86510f63e9
|
https://github.com/anklimsk/cakephp-console-installer/blob/76136550e856ff4f8fd3634b77633f86510f63e9/View/Helper/CheckResultHelper.php#L75-L92
|
train
|
anklimsk/cakephp-console-installer
|
View/Helper/CheckResultHelper.php
|
CheckResultHelper.getStateList
|
public function getStateList($list = null) {
$result = '';
if (empty($list)) {
return $result;
}
$listText = '';
foreach ($list as $listItem) {
$classItem = '';
if (is_array($listItem)) {
if (!isset($listItem['textItem'])) {
continue;
}
$textItem = $listItem['textItem'];
if (isset($listItem['classItem']) && !empty($listItem['classItem'])) {
$classItem = ' ' . $listItem['classItem'];
}
} else {
$textItem = $listItem;
}
$listText .= $this->Html->tag('li', $textItem, ['class' => 'list-group-item' . $classItem]);
}
if (empty($listText)) {
return $result;
}
$result = $this->Html->tag('ul', $listText, ['class' => 'list-group']);
return $result;
}
|
php
|
public function getStateList($list = null) {
$result = '';
if (empty($list)) {
return $result;
}
$listText = '';
foreach ($list as $listItem) {
$classItem = '';
if (is_array($listItem)) {
if (!isset($listItem['textItem'])) {
continue;
}
$textItem = $listItem['textItem'];
if (isset($listItem['classItem']) && !empty($listItem['classItem'])) {
$classItem = ' ' . $listItem['classItem'];
}
} else {
$textItem = $listItem;
}
$listText .= $this->Html->tag('li', $textItem, ['class' => 'list-group-item' . $classItem]);
}
if (empty($listText)) {
return $result;
}
$result = $this->Html->tag('ul', $listText, ['class' => 'list-group']);
return $result;
}
|
[
"public",
"function",
"getStateList",
"(",
"$",
"list",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"''",
";",
"if",
"(",
"empty",
"(",
"$",
"list",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"listText",
"=",
"''",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"listItem",
")",
"{",
"$",
"classItem",
"=",
"''",
";",
"if",
"(",
"is_array",
"(",
"$",
"listItem",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"listItem",
"[",
"'textItem'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"textItem",
"=",
"$",
"listItem",
"[",
"'textItem'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"listItem",
"[",
"'classItem'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"listItem",
"[",
"'classItem'",
"]",
")",
")",
"{",
"$",
"classItem",
"=",
"' '",
".",
"$",
"listItem",
"[",
"'classItem'",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"textItem",
"=",
"$",
"listItem",
";",
"}",
"$",
"listText",
".=",
"$",
"this",
"->",
"Html",
"->",
"tag",
"(",
"'li'",
",",
"$",
"textItem",
",",
"[",
"'class'",
"=>",
"'list-group-item'",
".",
"$",
"classItem",
"]",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"listText",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"Html",
"->",
"tag",
"(",
"'ul'",
",",
"$",
"listText",
",",
"[",
"'class'",
"=>",
"'list-group'",
"]",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Return list of states
@param array $list List of states for rendering in format:
- key `textItem`, value - text of list item;
- key `classItem`, value - class of list item.
@return string Return list of states
|
[
"Return",
"list",
"of",
"states"
] |
76136550e856ff4f8fd3634b77633f86510f63e9
|
https://github.com/anklimsk/cakephp-console-installer/blob/76136550e856ff4f8fd3634b77633f86510f63e9/View/Helper/CheckResultHelper.php#L102-L133
|
train
|
fxpio/fxp-gluon
|
Twig/Extension/PropertyPathExtension.php
|
PropertyPathExtension.propertyPath
|
public function propertyPath($data, $propertyPath)
{
if (null !== $propertyPath && !$propertyPath instanceof PropertyPathInterface) {
$propertyPath = new PropertyPath($propertyPath);
}
if ($propertyPath instanceof PropertyPathInterface && (\is_object($data) || $data instanceof \ArrayAccess)) {
$data = $this->propertyAccessor->getValue($data, $propertyPath);
}
return $data;
}
|
php
|
public function propertyPath($data, $propertyPath)
{
if (null !== $propertyPath && !$propertyPath instanceof PropertyPathInterface) {
$propertyPath = new PropertyPath($propertyPath);
}
if ($propertyPath instanceof PropertyPathInterface && (\is_object($data) || $data instanceof \ArrayAccess)) {
$data = $this->propertyAccessor->getValue($data, $propertyPath);
}
return $data;
}
|
[
"public",
"function",
"propertyPath",
"(",
"$",
"data",
",",
"$",
"propertyPath",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"propertyPath",
"&&",
"!",
"$",
"propertyPath",
"instanceof",
"PropertyPathInterface",
")",
"{",
"$",
"propertyPath",
"=",
"new",
"PropertyPath",
"(",
"$",
"propertyPath",
")",
";",
"}",
"if",
"(",
"$",
"propertyPath",
"instanceof",
"PropertyPathInterface",
"&&",
"(",
"\\",
"is_object",
"(",
"$",
"data",
")",
"||",
"$",
"data",
"instanceof",
"\\",
"ArrayAccess",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"propertyAccessor",
"->",
"getValue",
"(",
"$",
"data",
",",
"$",
"propertyPath",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Get the data defined by property path.
@param mixed $data The data
@param PropertyPathInterface|string|null $propertyPath The property path
@return mixed
|
[
"Get",
"the",
"data",
"defined",
"by",
"property",
"path",
"."
] |
0548b7d598ef4b0785b5df3b849a10f439b2dc65
|
https://github.com/fxpio/fxp-gluon/blob/0548b7d598ef4b0785b5df3b849a10f439b2dc65/Twig/Extension/PropertyPathExtension.php#L59-L70
|
train
|
pmdevelopment/tool-bundle
|
Components/Helper/FileUtilityHelper.php
|
FileUtilityHelper.getIconByExtension
|
public static function getIconByExtension($extension)
{
if ('pdf' === $extension) {
return 'file-pdf-o';
}
if (true === in_array($extension, self::extensionsArchive())) {
return 'file-archive-o';
}
if (true === in_array($extension, self::extensionsImage())) {
return 'file-image-o';
}
if (true === in_array($extension, self::extensionsCode())) {
return 'file-code-o';
}
if (true === in_array($extension, self::extensionsVideo())) {
return 'file-video-o';
}
if (true === in_array($extension, self::extensionsAudio())) {
return 'file-audio-o';
}
if (true === in_array($extension, self::extensionsExcel())) {
return 'file-excel-o';
}
if (true === in_array($extension, self::extensionsPowerPoint())) {
return 'file-powerpoint-o';
}
if (true === in_array($extension, self::extensionsWord())) {
return 'file-word-o';
}
return null;
}
|
php
|
public static function getIconByExtension($extension)
{
if ('pdf' === $extension) {
return 'file-pdf-o';
}
if (true === in_array($extension, self::extensionsArchive())) {
return 'file-archive-o';
}
if (true === in_array($extension, self::extensionsImage())) {
return 'file-image-o';
}
if (true === in_array($extension, self::extensionsCode())) {
return 'file-code-o';
}
if (true === in_array($extension, self::extensionsVideo())) {
return 'file-video-o';
}
if (true === in_array($extension, self::extensionsAudio())) {
return 'file-audio-o';
}
if (true === in_array($extension, self::extensionsExcel())) {
return 'file-excel-o';
}
if (true === in_array($extension, self::extensionsPowerPoint())) {
return 'file-powerpoint-o';
}
if (true === in_array($extension, self::extensionsWord())) {
return 'file-word-o';
}
return null;
}
|
[
"public",
"static",
"function",
"getIconByExtension",
"(",
"$",
"extension",
")",
"{",
"if",
"(",
"'pdf'",
"===",
"$",
"extension",
")",
"{",
"return",
"'file-pdf-o'",
";",
"}",
"if",
"(",
"true",
"===",
"in_array",
"(",
"$",
"extension",
",",
"self",
"::",
"extensionsArchive",
"(",
")",
")",
")",
"{",
"return",
"'file-archive-o'",
";",
"}",
"if",
"(",
"true",
"===",
"in_array",
"(",
"$",
"extension",
",",
"self",
"::",
"extensionsImage",
"(",
")",
")",
")",
"{",
"return",
"'file-image-o'",
";",
"}",
"if",
"(",
"true",
"===",
"in_array",
"(",
"$",
"extension",
",",
"self",
"::",
"extensionsCode",
"(",
")",
")",
")",
"{",
"return",
"'file-code-o'",
";",
"}",
"if",
"(",
"true",
"===",
"in_array",
"(",
"$",
"extension",
",",
"self",
"::",
"extensionsVideo",
"(",
")",
")",
")",
"{",
"return",
"'file-video-o'",
";",
"}",
"if",
"(",
"true",
"===",
"in_array",
"(",
"$",
"extension",
",",
"self",
"::",
"extensionsAudio",
"(",
")",
")",
")",
"{",
"return",
"'file-audio-o'",
";",
"}",
"if",
"(",
"true",
"===",
"in_array",
"(",
"$",
"extension",
",",
"self",
"::",
"extensionsExcel",
"(",
")",
")",
")",
"{",
"return",
"'file-excel-o'",
";",
"}",
"if",
"(",
"true",
"===",
"in_array",
"(",
"$",
"extension",
",",
"self",
"::",
"extensionsPowerPoint",
"(",
")",
")",
")",
"{",
"return",
"'file-powerpoint-o'",
";",
"}",
"if",
"(",
"true",
"===",
"in_array",
"(",
"$",
"extension",
",",
"self",
"::",
"extensionsWord",
"(",
")",
")",
")",
"{",
"return",
"'file-word-o'",
";",
"}",
"return",
"null",
";",
"}"
] |
Get FontAwesome Icon By Extension
@param string $extension
@return null|string
|
[
"Get",
"FontAwesome",
"Icon",
"By",
"Extension"
] |
2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129
|
https://github.com/pmdevelopment/tool-bundle/blob/2cbc9f82c5b33fd7a9d389edd3676e9f70ea8129/Components/Helper/FileUtilityHelper.php#L147-L186
|
train
|
Vyki/mva-dbm
|
src/Mva/Dbm/Connection.php
|
Connection.getQuery
|
public function getQuery()
{
if (!$this->query) {
$this->query = new Query($this->driver, $this->preprocessor);
}
return $this->query;
}
|
php
|
public function getQuery()
{
if (!$this->query) {
$this->query = new Query($this->driver, $this->preprocessor);
}
return $this->query;
}
|
[
"public",
"function",
"getQuery",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"query",
")",
"{",
"$",
"this",
"->",
"query",
"=",
"new",
"Query",
"(",
"$",
"this",
"->",
"driver",
",",
"$",
"this",
"->",
"preprocessor",
")",
";",
"}",
"return",
"$",
"this",
"->",
"query",
";",
"}"
] |
Returns parameter builder
@return Query
|
[
"Returns",
"parameter",
"builder"
] |
587d840e0620331a9f63a6867f3400a293a9d3c6
|
https://github.com/Vyki/mva-dbm/blob/587d840e0620331a9f63a6867f3400a293a9d3c6/src/Mva/Dbm/Connection.php#L84-L91
|
train
|
Vyki/mva-dbm
|
src/Mva/Dbm/Connection.php
|
Connection.createDriver
|
private function createDriver(array $config)
{
if (empty($config['driver'])) {
throw new InvalidStateException('Undefined driver');
} elseif ($config['driver'] instanceof IDriver) {
return $config['driver'];
} else {
$name = ucfirst($config['driver']);
$class = "Mva\\Dbm\\Driver\\{$name}\\{$name}Driver";
return new $class;
}
}
|
php
|
private function createDriver(array $config)
{
if (empty($config['driver'])) {
throw new InvalidStateException('Undefined driver');
} elseif ($config['driver'] instanceof IDriver) {
return $config['driver'];
} else {
$name = ucfirst($config['driver']);
$class = "Mva\\Dbm\\Driver\\{$name}\\{$name}Driver";
return new $class;
}
}
|
[
"private",
"function",
"createDriver",
"(",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"config",
"[",
"'driver'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidStateException",
"(",
"'Undefined driver'",
")",
";",
"}",
"elseif",
"(",
"$",
"config",
"[",
"'driver'",
"]",
"instanceof",
"IDriver",
")",
"{",
"return",
"$",
"config",
"[",
"'driver'",
"]",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"ucfirst",
"(",
"$",
"config",
"[",
"'driver'",
"]",
")",
";",
"$",
"class",
"=",
"\"Mva\\\\Dbm\\\\Driver\\\\{$name}\\\\{$name}Driver\"",
";",
"return",
"new",
"$",
"class",
";",
"}",
"}"
] |
Creates a IDriver instance.
@param array $config
@return Driver\IDriver
|
[
"Creates",
"a",
"IDriver",
"instance",
"."
] |
587d840e0620331a9f63a6867f3400a293a9d3c6
|
https://github.com/Vyki/mva-dbm/blob/587d840e0620331a9f63a6867f3400a293a9d3c6/src/Mva/Dbm/Connection.php#L126-L137
|
train
|
MetaModels/attribute_translatedurl
|
src/Helper/UpgradeHandler.php
|
UpgradeHandler.ensureIndexNameAttIdLanguage
|
private function ensureIndexNameAttIdLanguage()
{
if (!($this->database->tableExists('tl_metamodel_translatedurl'))) {
return;
}
// Renamed in 2.0.0-alpha2 (due to database.sql => dca movement).
if (!$this->database->indexExists('att_lang', 'tl_metamodel_translatedurl', true)) {
return;
}
$this->database->execute(
'ALTER TABLE `tl_metamodel_translatedurl` DROP INDEX `att_lang`;'
);
$this->database->execute(
'ALTER TABLE `tl_metamodel_translatedurl` ADD KEY `att_id_language` (`att_id`, `language`);'
);
}
|
php
|
private function ensureIndexNameAttIdLanguage()
{
if (!($this->database->tableExists('tl_metamodel_translatedurl'))) {
return;
}
// Renamed in 2.0.0-alpha2 (due to database.sql => dca movement).
if (!$this->database->indexExists('att_lang', 'tl_metamodel_translatedurl', true)) {
return;
}
$this->database->execute(
'ALTER TABLE `tl_metamodel_translatedurl` DROP INDEX `att_lang`;'
);
$this->database->execute(
'ALTER TABLE `tl_metamodel_translatedurl` ADD KEY `att_id_language` (`att_id`, `language`);'
);
}
|
[
"private",
"function",
"ensureIndexNameAttIdLanguage",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"database",
"->",
"tableExists",
"(",
"'tl_metamodel_translatedurl'",
")",
")",
")",
"{",
"return",
";",
"}",
"// Renamed in 2.0.0-alpha2 (due to database.sql => dca movement).",
"if",
"(",
"!",
"$",
"this",
"->",
"database",
"->",
"indexExists",
"(",
"'att_lang'",
",",
"'tl_metamodel_translatedurl'",
",",
"true",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"database",
"->",
"execute",
"(",
"'ALTER TABLE `tl_metamodel_translatedurl` DROP INDEX `att_lang`;'",
")",
";",
"$",
"this",
"->",
"database",
"->",
"execute",
"(",
"'ALTER TABLE `tl_metamodel_translatedurl` ADD KEY `att_id_language` (`att_id`, `language`);'",
")",
";",
"}"
] |
Ensure that the index types are correct.
@return void
|
[
"Ensure",
"that",
"the",
"index",
"types",
"are",
"correct",
"."
] |
ad6b4967244614be49d382934043c766b5fa08d8
|
https://github.com/MetaModels/attribute_translatedurl/blob/ad6b4967244614be49d382934043c766b5fa08d8/src/Helper/UpgradeHandler.php#L65-L81
|
train
|
MetaModels/attribute_translatedurl
|
src/Helper/UpgradeHandler.php
|
UpgradeHandler.ensureHrefDefaultsToNull
|
private function ensureHrefDefaultsToNull()
{
if (!($this->database->tableExists('tl_metamodel_translatedurl'))) {
return;
}
foreach ($this->database->listFields('tl_metamodel_translatedurl', true) as $field) {
if ('href' == $field['name'] && $field['type'] != 'index') {
// Already updated?
if ('NOT NULL' === $field['null']) {
$this->database->execute(
'ALTER TABLE `tl_metamodel_translatedurl` CHANGE `href` `href` varchar(255) NULL;'
);
return;
}
// Found!
break;
}
}
}
|
php
|
private function ensureHrefDefaultsToNull()
{
if (!($this->database->tableExists('tl_metamodel_translatedurl'))) {
return;
}
foreach ($this->database->listFields('tl_metamodel_translatedurl', true) as $field) {
if ('href' == $field['name'] && $field['type'] != 'index') {
// Already updated?
if ('NOT NULL' === $field['null']) {
$this->database->execute(
'ALTER TABLE `tl_metamodel_translatedurl` CHANGE `href` `href` varchar(255) NULL;'
);
return;
}
// Found!
break;
}
}
}
|
[
"private",
"function",
"ensureHrefDefaultsToNull",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"database",
"->",
"tableExists",
"(",
"'tl_metamodel_translatedurl'",
")",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"database",
"->",
"listFields",
"(",
"'tl_metamodel_translatedurl'",
",",
"true",
")",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"'href'",
"==",
"$",
"field",
"[",
"'name'",
"]",
"&&",
"$",
"field",
"[",
"'type'",
"]",
"!=",
"'index'",
")",
"{",
"// Already updated?",
"if",
"(",
"'NOT NULL'",
"===",
"$",
"field",
"[",
"'null'",
"]",
")",
"{",
"$",
"this",
"->",
"database",
"->",
"execute",
"(",
"'ALTER TABLE `tl_metamodel_translatedurl` CHANGE `href` `href` varchar(255) NULL;'",
")",
";",
"return",
";",
"}",
"// Found!",
"break",
";",
"}",
"}",
"}"
] |
Ensure the default value for the href column is correct.
@return void
|
[
"Ensure",
"the",
"default",
"value",
"for",
"the",
"href",
"column",
"is",
"correct",
"."
] |
ad6b4967244614be49d382934043c766b5fa08d8
|
https://github.com/MetaModels/attribute_translatedurl/blob/ad6b4967244614be49d382934043c766b5fa08d8/src/Helper/UpgradeHandler.php#L88-L107
|
train
|
salernolabs/camelize
|
src/Uncamel.php
|
Uncamel.uncamelize
|
public function uncamelize($input)
{
$input = trim($input);
if (empty($input))
{
throw new \Exception("Can not uncamelize an empty string.");
}
$output = '';
for ($i = 0; $i < mb_strlen($input); ++$i)
{
$character = mb_substr($input, $i, 1);
$isCapital = ($character == mb_strtoupper($character));
if ($isCapital)
{
//We don't want to add the replacement character if its the first one in the list so we don't prepend
if ($i != 0)
{
$output .= $this->replacementCharacter;
}
if ($this->shouldCapitalizeFirstLetter)
{
$output .= $character;
}
else
{
$output .= mb_strtolower($character);
}
}
else
{
if ($i == 0 && $this->shouldCapitalizeFirstLetter)
{
$output .= mb_strtoupper($character);
}
else
{
$output .= $character;
}
}
}
return $output;
}
|
php
|
public function uncamelize($input)
{
$input = trim($input);
if (empty($input))
{
throw new \Exception("Can not uncamelize an empty string.");
}
$output = '';
for ($i = 0; $i < mb_strlen($input); ++$i)
{
$character = mb_substr($input, $i, 1);
$isCapital = ($character == mb_strtoupper($character));
if ($isCapital)
{
//We don't want to add the replacement character if its the first one in the list so we don't prepend
if ($i != 0)
{
$output .= $this->replacementCharacter;
}
if ($this->shouldCapitalizeFirstLetter)
{
$output .= $character;
}
else
{
$output .= mb_strtolower($character);
}
}
else
{
if ($i == 0 && $this->shouldCapitalizeFirstLetter)
{
$output .= mb_strtoupper($character);
}
else
{
$output .= $character;
}
}
}
return $output;
}
|
[
"public",
"function",
"uncamelize",
"(",
"$",
"input",
")",
"{",
"$",
"input",
"=",
"trim",
"(",
"$",
"input",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"input",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Can not uncamelize an empty string.\"",
")",
";",
"}",
"$",
"output",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"mb_strlen",
"(",
"$",
"input",
")",
";",
"++",
"$",
"i",
")",
"{",
"$",
"character",
"=",
"mb_substr",
"(",
"$",
"input",
",",
"$",
"i",
",",
"1",
")",
";",
"$",
"isCapital",
"=",
"(",
"$",
"character",
"==",
"mb_strtoupper",
"(",
"$",
"character",
")",
")",
";",
"if",
"(",
"$",
"isCapital",
")",
"{",
"//We don't want to add the replacement character if its the first one in the list so we don't prepend",
"if",
"(",
"$",
"i",
"!=",
"0",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"replacementCharacter",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"shouldCapitalizeFirstLetter",
")",
"{",
"$",
"output",
".=",
"$",
"character",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"mb_strtolower",
"(",
"$",
"character",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"i",
"==",
"0",
"&&",
"$",
"this",
"->",
"shouldCapitalizeFirstLetter",
")",
"{",
"$",
"output",
".=",
"mb_strtoupper",
"(",
"$",
"character",
")",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"$",
"character",
";",
"}",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] |
Uncamelize a string
@param $input
@return string
|
[
"Uncamelize",
"a",
"string"
] |
6098e9827fd21509592fc7062b653582d0dd00d1
|
https://github.com/salernolabs/camelize/blob/6098e9827fd21509592fc7062b653582d0dd00d1/src/Uncamel.php#L55-L103
|
train
|
phPoirot/ApiClient
|
AccessTokenObject.php
|
AccessTokenObject.setExpiresIn
|
function setExpiresIn($expiry)
{
$this->expiresIn = $expiry;
$this->datetimeExpiration = $this->getDateTimeExpiration();
return $this;
}
|
php
|
function setExpiresIn($expiry)
{
$this->expiresIn = $expiry;
$this->datetimeExpiration = $this->getDateTimeExpiration();
return $this;
}
|
[
"function",
"setExpiresIn",
"(",
"$",
"expiry",
")",
"{",
"$",
"this",
"->",
"expiresIn",
"=",
"$",
"expiry",
";",
"$",
"this",
"->",
"datetimeExpiration",
"=",
"$",
"this",
"->",
"getDateTimeExpiration",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set Expiry DateTime
@param \DateTime $expiry
@return $this
|
[
"Set",
"Expiry",
"DateTime"
] |
4753197be9f961ab1d915371a87757dbd8efcf9a
|
https://github.com/phPoirot/ApiClient/blob/4753197be9f961ab1d915371a87757dbd8efcf9a/AccessTokenObject.php#L112-L117
|
train
|
stackpr/quipxml
|
src/Contact/QuipContact.php
|
QuipContact.loadEmpty
|
static public function loadEmpty($defaults = NULL) {
$defaults = array_merge(array(
'FN' => '',
), (array) $defaults);
$ical = implode("\n", array(
'BEGIN:VCARD',
'VERSION:3.0',
'PRODID:QuipContact',
'N:',
'FN:' . QuipContactVcfFormatter::escape($defaults['FN']),
'END:VCARD',
));
return self::loadVcard($ical);
}
|
php
|
static public function loadEmpty($defaults = NULL) {
$defaults = array_merge(array(
'FN' => '',
), (array) $defaults);
$ical = implode("\n", array(
'BEGIN:VCARD',
'VERSION:3.0',
'PRODID:QuipContact',
'N:',
'FN:' . QuipContactVcfFormatter::escape($defaults['FN']),
'END:VCARD',
));
return self::loadVcard($ical);
}
|
[
"static",
"public",
"function",
"loadEmpty",
"(",
"$",
"defaults",
"=",
"NULL",
")",
"{",
"$",
"defaults",
"=",
"array_merge",
"(",
"array",
"(",
"'FN'",
"=>",
"''",
",",
")",
",",
"(",
"array",
")",
"$",
"defaults",
")",
";",
"$",
"ical",
"=",
"implode",
"(",
"\"\\n\"",
",",
"array",
"(",
"'BEGIN:VCARD'",
",",
"'VERSION:3.0'",
",",
"'PRODID:QuipContact'",
",",
"'N:'",
",",
"'FN:'",
".",
"QuipContactVcfFormatter",
"::",
"escape",
"(",
"$",
"defaults",
"[",
"'FN'",
"]",
")",
",",
"'END:VCARD'",
",",
")",
")",
";",
"return",
"self",
"::",
"loadVcard",
"(",
"$",
"ical",
")",
";",
"}"
] |
Initialize an empty contact.
@param array $defaults
@return \QuipXml\Xml\QuipXmlElement
|
[
"Initialize",
"an",
"empty",
"contact",
"."
] |
472e0d98a90aa0a283aac933158d830311480ff8
|
https://github.com/stackpr/quipxml/blob/472e0d98a90aa0a283aac933158d830311480ff8/src/Contact/QuipContact.php#L45-L58
|
train
|
AntonyThorpe/consumer
|
src/BulkLoaderResult.php
|
BulkLoaderResult.getUpdated
|
public function getUpdated()
{
$set = new ArrayList();
foreach ($this->updated as $arrItem) {
$set->push(ArrayData::create($arrItem));
}
return $set;
}
|
php
|
public function getUpdated()
{
$set = new ArrayList();
foreach ($this->updated as $arrItem) {
$set->push(ArrayData::create($arrItem));
}
return $set;
}
|
[
"public",
"function",
"getUpdated",
"(",
")",
"{",
"$",
"set",
"=",
"new",
"ArrayList",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"updated",
"as",
"$",
"arrItem",
")",
"{",
"$",
"set",
"->",
"push",
"(",
"ArrayData",
"::",
"create",
"(",
"$",
"arrItem",
")",
")",
";",
"}",
"return",
"$",
"set",
";",
"}"
] |
Return all updated objects
@return \SilverStripe\ORM\ArrayList
|
[
"Return",
"all",
"updated",
"objects"
] |
c9f464b901c09ab0bfbb62c94589637363af7bf0
|
https://github.com/AntonyThorpe/consumer/blob/c9f464b901c09ab0bfbb62c94589637363af7bf0/src/BulkLoaderResult.php#L122-L129
|
train
|
AntonyThorpe/consumer
|
src/BulkLoaderResult.php
|
BulkLoaderResult.getDeleted
|
public function getDeleted()
{
$set = new ArrayList();
foreach ($this->deleted as $arrItem) {
$set->push(ArrayData::create($arrItem));
}
return $set;
}
|
php
|
public function getDeleted()
{
$set = new ArrayList();
foreach ($this->deleted as $arrItem) {
$set->push(ArrayData::create($arrItem));
}
return $set;
}
|
[
"public",
"function",
"getDeleted",
"(",
")",
"{",
"$",
"set",
"=",
"new",
"ArrayList",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"deleted",
"as",
"$",
"arrItem",
")",
"{",
"$",
"set",
"->",
"push",
"(",
"ArrayData",
"::",
"create",
"(",
"$",
"arrItem",
")",
")",
";",
"}",
"return",
"$",
"set",
";",
"}"
] |
Return all deleted objects
@return \SilverStripe\ORM\ArrayList
|
[
"Return",
"all",
"deleted",
"objects"
] |
c9f464b901c09ab0bfbb62c94589637363af7bf0
|
https://github.com/AntonyThorpe/consumer/blob/c9f464b901c09ab0bfbb62c94589637363af7bf0/src/BulkLoaderResult.php#L135-L142
|
train
|
AntonyThorpe/consumer
|
src/BulkLoaderResult.php
|
BulkLoaderResult.getData
|
public function getData()
{
$data = new ArrayList();
if ($this->CreatedCount()) {
$data->push(ArrayData::create(array("Title" => _t('Consumer.CREATED', 'Created'))));
$data->merge($this->getCreated());
}
if ($this->UpdatedCount()) {
$data->push(ArrayData::create(array("Title" => _t('Consumer.UPDATED', 'Updated'))));
$data->merge($this->getUpdated());
}
if ($this->DeletedCount()) {
$data->push(ArrayData::create(array("Title" => _t('Consumer.DELETED', 'Deleted'))));
$data->merge($this->$this->getDeleted());
}
return $data;
}
|
php
|
public function getData()
{
$data = new ArrayList();
if ($this->CreatedCount()) {
$data->push(ArrayData::create(array("Title" => _t('Consumer.CREATED', 'Created'))));
$data->merge($this->getCreated());
}
if ($this->UpdatedCount()) {
$data->push(ArrayData::create(array("Title" => _t('Consumer.UPDATED', 'Updated'))));
$data->merge($this->getUpdated());
}
if ($this->DeletedCount()) {
$data->push(ArrayData::create(array("Title" => _t('Consumer.DELETED', 'Deleted'))));
$data->merge($this->$this->getDeleted());
}
return $data;
}
|
[
"public",
"function",
"getData",
"(",
")",
"{",
"$",
"data",
"=",
"new",
"ArrayList",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"CreatedCount",
"(",
")",
")",
"{",
"$",
"data",
"->",
"push",
"(",
"ArrayData",
"::",
"create",
"(",
"array",
"(",
"\"Title\"",
"=>",
"_t",
"(",
"'Consumer.CREATED'",
",",
"'Created'",
")",
")",
")",
")",
";",
"$",
"data",
"->",
"merge",
"(",
"$",
"this",
"->",
"getCreated",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"UpdatedCount",
"(",
")",
")",
"{",
"$",
"data",
"->",
"push",
"(",
"ArrayData",
"::",
"create",
"(",
"array",
"(",
"\"Title\"",
"=>",
"_t",
"(",
"'Consumer.UPDATED'",
",",
"'Updated'",
")",
")",
")",
")",
";",
"$",
"data",
"->",
"merge",
"(",
"$",
"this",
"->",
"getUpdated",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"DeletedCount",
"(",
")",
")",
"{",
"$",
"data",
"->",
"push",
"(",
"ArrayData",
"::",
"create",
"(",
"array",
"(",
"\"Title\"",
"=>",
"_t",
"(",
"'Consumer.DELETED'",
",",
"'Deleted'",
")",
")",
")",
")",
";",
"$",
"data",
"->",
"merge",
"(",
"$",
"this",
"->",
"$",
"this",
"->",
"getDeleted",
"(",
")",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Prepare the boby for an email or build task
@return \SilverStripe\ORM\ArrayList
|
[
"Prepare",
"the",
"boby",
"for",
"an",
"email",
"or",
"build",
"task"
] |
c9f464b901c09ab0bfbb62c94589637363af7bf0
|
https://github.com/AntonyThorpe/consumer/blob/c9f464b901c09ab0bfbb62c94589637363af7bf0/src/BulkLoaderResult.php#L148-L164
|
train
|
AntonyThorpe/consumer
|
src/BulkLoaderResult.php
|
BulkLoaderResult.getChangedFields
|
protected function getChangedFields($obj)
{
$changedFields = $obj->getChangedFields(true, 2);
foreach ($changedFields as $key => $value) {
$changedFields[$key]['before'] = '(' . gettype($value['before']) . ') ' . $value['before'];
$changedFields[$key]['after'] = '(' . gettype($value['after']) . ') ' . $value['after'];
unset($changedFields[$key]['level']);
}
return $changedFields;
}
|
php
|
protected function getChangedFields($obj)
{
$changedFields = $obj->getChangedFields(true, 2);
foreach ($changedFields as $key => $value) {
$changedFields[$key]['before'] = '(' . gettype($value['before']) . ') ' . $value['before'];
$changedFields[$key]['after'] = '(' . gettype($value['after']) . ') ' . $value['after'];
unset($changedFields[$key]['level']);
}
return $changedFields;
}
|
[
"protected",
"function",
"getChangedFields",
"(",
"$",
"obj",
")",
"{",
"$",
"changedFields",
"=",
"$",
"obj",
"->",
"getChangedFields",
"(",
"true",
",",
"2",
")",
";",
"foreach",
"(",
"$",
"changedFields",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"changedFields",
"[",
"$",
"key",
"]",
"[",
"'before'",
"]",
"=",
"'('",
".",
"gettype",
"(",
"$",
"value",
"[",
"'before'",
"]",
")",
".",
"') '",
".",
"$",
"value",
"[",
"'before'",
"]",
";",
"$",
"changedFields",
"[",
"$",
"key",
"]",
"[",
"'after'",
"]",
"=",
"'('",
".",
"gettype",
"(",
"$",
"value",
"[",
"'after'",
"]",
")",
".",
"') '",
".",
"$",
"value",
"[",
"'after'",
"]",
";",
"unset",
"(",
"$",
"changedFields",
"[",
"$",
"key",
"]",
"[",
"'level'",
"]",
")",
";",
"}",
"return",
"$",
"changedFields",
";",
"}"
] |
Modelled on the getChangedFields of DataObject, with the addition of the variable's type
@param \SilverStripe\ORM\DataObject $obj
@return array The before/after changes of each field
|
[
"Modelled",
"on",
"the",
"getChangedFields",
"of",
"DataObject",
"with",
"the",
"addition",
"of",
"the",
"variable",
"s",
"type"
] |
c9f464b901c09ab0bfbb62c94589637363af7bf0
|
https://github.com/AntonyThorpe/consumer/blob/c9f464b901c09ab0bfbb62c94589637363af7bf0/src/BulkLoaderResult.php#L209-L218
|
train
|
mojopollo/laravel-helpers
|
src/Mojopollo/Helpers/FileHelper.php
|
FileHelper.directoryFiles
|
public function directoryFiles($path)
{
$contents = [];
// Scan directory
$directoryFiles = scandir($path);
foreach ($directoryFiles as $index => $filePath) {
// Ommit . and ..
if ( ! in_array($filePath, ['.', '..'])) {
// Check if this is a directory
if (is_dir($path . DIRECTORY_SEPARATOR . $filePath)) {
// Rescan and get files in this directory
$contents = array_merge($contents, self::directoryFiles($path . DIRECTORY_SEPARATOR . $filePath));
} else {
// Add file to contens array
$contents[] = $path . DIRECTORY_SEPARATOR . $filePath;
}
}
}
return $contents;
}
|
php
|
public function directoryFiles($path)
{
$contents = [];
// Scan directory
$directoryFiles = scandir($path);
foreach ($directoryFiles as $index => $filePath) {
// Ommit . and ..
if ( ! in_array($filePath, ['.', '..'])) {
// Check if this is a directory
if (is_dir($path . DIRECTORY_SEPARATOR . $filePath)) {
// Rescan and get files in this directory
$contents = array_merge($contents, self::directoryFiles($path . DIRECTORY_SEPARATOR . $filePath));
} else {
// Add file to contens array
$contents[] = $path . DIRECTORY_SEPARATOR . $filePath;
}
}
}
return $contents;
}
|
[
"public",
"function",
"directoryFiles",
"(",
"$",
"path",
")",
"{",
"$",
"contents",
"=",
"[",
"]",
";",
"// Scan directory",
"$",
"directoryFiles",
"=",
"scandir",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"directoryFiles",
"as",
"$",
"index",
"=>",
"$",
"filePath",
")",
"{",
"// Ommit . and ..",
"if",
"(",
"!",
"in_array",
"(",
"$",
"filePath",
",",
"[",
"'.'",
",",
"'..'",
"]",
")",
")",
"{",
"// Check if this is a directory",
"if",
"(",
"is_dir",
"(",
"$",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"filePath",
")",
")",
"{",
"// Rescan and get files in this directory",
"$",
"contents",
"=",
"array_merge",
"(",
"$",
"contents",
",",
"self",
"::",
"directoryFiles",
"(",
"$",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"filePath",
")",
")",
";",
"}",
"else",
"{",
"// Add file to contens array",
"$",
"contents",
"[",
"]",
"=",
"$",
"path",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"filePath",
";",
"}",
"}",
"}",
"return",
"$",
"contents",
";",
"}"
] |
Return an array of files with their full paths contained in a directory and its subdirectories
@param string $path path to directtory
@return array full paths of directory files
|
[
"Return",
"an",
"array",
"of",
"files",
"with",
"their",
"full",
"paths",
"contained",
"in",
"a",
"directory",
"and",
"its",
"subdirectories"
] |
0becb5e0f4202a0f489fb5e384c01dacb8f29dc5
|
https://github.com/mojopollo/laravel-helpers/blob/0becb5e0f4202a0f489fb5e384c01dacb8f29dc5/src/Mojopollo/Helpers/FileHelper.php#L12-L39
|
train
|
ben-gibson/foursquare-venue-client
|
src/Client.php
|
Client.simple
|
public static function simple(Configuration $configuration, VenueFactory $venueFactory)
{
return new static(
$configuration,
new HttpMethodsClient(HttpClientDiscovery::find(), MessageFactoryDiscovery::find()),
$venueFactory
);
}
|
php
|
public static function simple(Configuration $configuration, VenueFactory $venueFactory)
{
return new static(
$configuration,
new HttpMethodsClient(HttpClientDiscovery::find(), MessageFactoryDiscovery::find()),
$venueFactory
);
}
|
[
"public",
"static",
"function",
"simple",
"(",
"Configuration",
"$",
"configuration",
",",
"VenueFactory",
"$",
"venueFactory",
")",
"{",
"return",
"new",
"static",
"(",
"$",
"configuration",
",",
"new",
"HttpMethodsClient",
"(",
"HttpClientDiscovery",
"::",
"find",
"(",
")",
",",
"MessageFactoryDiscovery",
"::",
"find",
"(",
")",
")",
",",
"$",
"venueFactory",
")",
";",
"}"
] |
Convenience factory method creating a standard Client configuration.
@param Configuration $configuration
@param VenueFactory $venueFactory
@return static
|
[
"Convenience",
"factory",
"method",
"creating",
"a",
"standard",
"Client",
"configuration",
"."
] |
ce5e7c308f87d5ccc28ab8d27a9cb51bd106d969
|
https://github.com/ben-gibson/foursquare-venue-client/blob/ce5e7c308f87d5ccc28ab8d27a9cb51bd106d969/src/Client.php#L50-L57
|
train
|
ben-gibson/foursquare-venue-client
|
src/Client.php
|
Client.getVenue
|
public function getVenue(Identifier $identifier)
{
$url = $this->getUrl(sprintf('venues/%s', urlencode($identifier)));
$response = $this->httpClient->get($url, $this->getDefaultHeaders());
$content = $this->parseResponse($response);
if (!isset($content->response->venue)) {
throw InvalidResponseException::invalidResponseBody($response, 'response.venue');
}
return $this->venueFactory->create(new Description($content->response->venue));
}
|
php
|
public function getVenue(Identifier $identifier)
{
$url = $this->getUrl(sprintf('venues/%s', urlencode($identifier)));
$response = $this->httpClient->get($url, $this->getDefaultHeaders());
$content = $this->parseResponse($response);
if (!isset($content->response->venue)) {
throw InvalidResponseException::invalidResponseBody($response, 'response.venue');
}
return $this->venueFactory->create(new Description($content->response->venue));
}
|
[
"public",
"function",
"getVenue",
"(",
"Identifier",
"$",
"identifier",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getUrl",
"(",
"sprintf",
"(",
"'venues/%s'",
",",
"urlencode",
"(",
"$",
"identifier",
")",
")",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"$",
"url",
",",
"$",
"this",
"->",
"getDefaultHeaders",
"(",
")",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"parseResponse",
"(",
"$",
"response",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"content",
"->",
"response",
"->",
"venue",
")",
")",
"{",
"throw",
"InvalidResponseException",
"::",
"invalidResponseBody",
"(",
"$",
"response",
",",
"'response.venue'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"venueFactory",
"->",
"create",
"(",
"new",
"Description",
"(",
"$",
"content",
"->",
"response",
"->",
"venue",
")",
")",
";",
"}"
] |
Get a venue by its unique identifier.
@param Identifier $identifier The venue identifier.
@return Venue
|
[
"Get",
"a",
"venue",
"by",
"its",
"unique",
"identifier",
"."
] |
ce5e7c308f87d5ccc28ab8d27a9cb51bd106d969
|
https://github.com/ben-gibson/foursquare-venue-client/blob/ce5e7c308f87d5ccc28ab8d27a9cb51bd106d969/src/Client.php#L66-L79
|
train
|
ben-gibson/foursquare-venue-client
|
src/Client.php
|
Client.search
|
public function search(Search $options)
{
$url = $this->getUrl('venues/search', $options->parametrise());
$response = $this->httpClient->get($url, $this->getDefaultHeaders());
$content = $this->parseResponse($response);
if (!isset($content->response->venues)) {
throw InvalidResponseException::invalidResponseBody($response, 'response.venues');
}
return array_map(function (\stdClass $venueDescription) {
return $this->venueFactory->create(new Description($venueDescription));
}, $content->response->venues);
}
|
php
|
public function search(Search $options)
{
$url = $this->getUrl('venues/search', $options->parametrise());
$response = $this->httpClient->get($url, $this->getDefaultHeaders());
$content = $this->parseResponse($response);
if (!isset($content->response->venues)) {
throw InvalidResponseException::invalidResponseBody($response, 'response.venues');
}
return array_map(function (\stdClass $venueDescription) {
return $this->venueFactory->create(new Description($venueDescription));
}, $content->response->venues);
}
|
[
"public",
"function",
"search",
"(",
"Search",
"$",
"options",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getUrl",
"(",
"'venues/search'",
",",
"$",
"options",
"->",
"parametrise",
"(",
")",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"$",
"url",
",",
"$",
"this",
"->",
"getDefaultHeaders",
"(",
")",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"parseResponse",
"(",
"$",
"response",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"content",
"->",
"response",
"->",
"venues",
")",
")",
"{",
"throw",
"InvalidResponseException",
"::",
"invalidResponseBody",
"(",
"$",
"response",
",",
"'response.venues'",
")",
";",
"}",
"return",
"array_map",
"(",
"function",
"(",
"\\",
"stdClass",
"$",
"venueDescription",
")",
"{",
"return",
"$",
"this",
"->",
"venueFactory",
"->",
"create",
"(",
"new",
"Description",
"(",
"$",
"venueDescription",
")",
")",
";",
"}",
",",
"$",
"content",
"->",
"response",
"->",
"venues",
")",
";",
"}"
] |
Search venues.
@param Search $options The search options.
@return Venue[]
|
[
"Search",
"venues",
"."
] |
ce5e7c308f87d5ccc28ab8d27a9cb51bd106d969
|
https://github.com/ben-gibson/foursquare-venue-client/blob/ce5e7c308f87d5ccc28ab8d27a9cb51bd106d969/src/Client.php#L88-L103
|
train
|
ben-gibson/foursquare-venue-client
|
src/Client.php
|
Client.explore
|
public function explore(Explore $options)
{
$url = $this->getUrl('venues/explore', $options->parametrise());
$response = $this->httpClient->get($url, $this->getDefaultHeaders());
$content = $this->parseResponse($response);
if (!isset($content->response->groups[0]->items)) {
throw InvalidResponseException::invalidResponseBody($response, 'response.groups[0].items');
}
return array_map(function (\stdClass $itemDescription) {
return $this->venueFactory->create(new Description($itemDescription->venue));
}, $content->response->groups[0]->items);
}
|
php
|
public function explore(Explore $options)
{
$url = $this->getUrl('venues/explore', $options->parametrise());
$response = $this->httpClient->get($url, $this->getDefaultHeaders());
$content = $this->parseResponse($response);
if (!isset($content->response->groups[0]->items)) {
throw InvalidResponseException::invalidResponseBody($response, 'response.groups[0].items');
}
return array_map(function (\stdClass $itemDescription) {
return $this->venueFactory->create(new Description($itemDescription->venue));
}, $content->response->groups[0]->items);
}
|
[
"public",
"function",
"explore",
"(",
"Explore",
"$",
"options",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getUrl",
"(",
"'venues/explore'",
",",
"$",
"options",
"->",
"parametrise",
"(",
")",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"$",
"url",
",",
"$",
"this",
"->",
"getDefaultHeaders",
"(",
")",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"parseResponse",
"(",
"$",
"response",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"content",
"->",
"response",
"->",
"groups",
"[",
"0",
"]",
"->",
"items",
")",
")",
"{",
"throw",
"InvalidResponseException",
"::",
"invalidResponseBody",
"(",
"$",
"response",
",",
"'response.groups[0].items'",
")",
";",
"}",
"return",
"array_map",
"(",
"function",
"(",
"\\",
"stdClass",
"$",
"itemDescription",
")",
"{",
"return",
"$",
"this",
"->",
"venueFactory",
"->",
"create",
"(",
"new",
"Description",
"(",
"$",
"itemDescription",
"->",
"venue",
")",
")",
";",
"}",
",",
"$",
"content",
"->",
"response",
"->",
"groups",
"[",
"0",
"]",
"->",
"items",
")",
";",
"}"
] |
Explore venues.
@param Explore $options The explore options.
@return Venue[]
|
[
"Explore",
"venues",
"."
] |
ce5e7c308f87d5ccc28ab8d27a9cb51bd106d969
|
https://github.com/ben-gibson/foursquare-venue-client/blob/ce5e7c308f87d5ccc28ab8d27a9cb51bd106d969/src/Client.php#L112-L127
|
train
|
ben-gibson/foursquare-venue-client
|
src/Client.php
|
Client.parseResponse
|
private function parseResponse(ResponseInterface $response)
{
if ($response->getStatusCode() >= 400 && $response->getStatusCode() < 500) {
throw new ClientErrorException($response);
}
if ($response->getStatusCode() >= 500 && $response->getStatusCode() < 600) {
throw new ServerErrorException($response);
}
$response->getBody()->rewind();
$result = json_decode($response->getBody()->getContents());
if ($result === null) {
throw InvalidResponseException::failedToDecodeResponse($response, json_last_error_msg());
}
return $result;
}
|
php
|
private function parseResponse(ResponseInterface $response)
{
if ($response->getStatusCode() >= 400 && $response->getStatusCode() < 500) {
throw new ClientErrorException($response);
}
if ($response->getStatusCode() >= 500 && $response->getStatusCode() < 600) {
throw new ServerErrorException($response);
}
$response->getBody()->rewind();
$result = json_decode($response->getBody()->getContents());
if ($result === null) {
throw InvalidResponseException::failedToDecodeResponse($response, json_last_error_msg());
}
return $result;
}
|
[
"private",
"function",
"parseResponse",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
">=",
"400",
"&&",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"<",
"500",
")",
"{",
"throw",
"new",
"ClientErrorException",
"(",
"$",
"response",
")",
";",
"}",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
">=",
"500",
"&&",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"<",
"600",
")",
"{",
"throw",
"new",
"ServerErrorException",
"(",
"$",
"response",
")",
";",
"}",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"rewind",
"(",
")",
";",
"$",
"result",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
")",
";",
"if",
"(",
"$",
"result",
"===",
"null",
")",
"{",
"throw",
"InvalidResponseException",
"::",
"failedToDecodeResponse",
"(",
"$",
"response",
",",
"json_last_error_msg",
"(",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Parse a response.
@param ResponseInterface $response The response to parse.
@throws ClientErrorException Thrown when a 4xx response status is returned.
@throws ServerErrorException Thrown when a 5xx response status is returned.
@throws InvalidResponseException Thrown when an invalid response body is encountered.
@return mixed
|
[
"Parse",
"a",
"response",
"."
] |
ce5e7c308f87d5ccc28ab8d27a9cb51bd106d969
|
https://github.com/ben-gibson/foursquare-venue-client/blob/ce5e7c308f87d5ccc28ab8d27a9cb51bd106d969/src/Client.php#L164-L183
|
train
|
ben-gibson/foursquare-venue-client
|
src/Client.php
|
Client.getUrl
|
private function getUrl($path, $parameters = [])
{
$url = sprintf(
'%s/v%d/%s?client_id=%s&client_secret=%s&v=%s%s',
$this->configuration->getBasePath(),
urlencode($this->configuration->getVersion()),
trim($path, '/'),
urlencode($this->configuration->getClientId()),
urlencode($this->configuration->getClientSecret()),
urlencode($this->configuration->getVersionedDate()),
$this->parseParameters($parameters)
);
return $url;
}
|
php
|
private function getUrl($path, $parameters = [])
{
$url = sprintf(
'%s/v%d/%s?client_id=%s&client_secret=%s&v=%s%s',
$this->configuration->getBasePath(),
urlencode($this->configuration->getVersion()),
trim($path, '/'),
urlencode($this->configuration->getClientId()),
urlencode($this->configuration->getClientSecret()),
urlencode($this->configuration->getVersionedDate()),
$this->parseParameters($parameters)
);
return $url;
}
|
[
"private",
"function",
"getUrl",
"(",
"$",
"path",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"url",
"=",
"sprintf",
"(",
"'%s/v%d/%s?client_id=%s&client_secret=%s&v=%s%s'",
",",
"$",
"this",
"->",
"configuration",
"->",
"getBasePath",
"(",
")",
",",
"urlencode",
"(",
"$",
"this",
"->",
"configuration",
"->",
"getVersion",
"(",
")",
")",
",",
"trim",
"(",
"$",
"path",
",",
"'/'",
")",
",",
"urlencode",
"(",
"$",
"this",
"->",
"configuration",
"->",
"getClientId",
"(",
")",
")",
",",
"urlencode",
"(",
"$",
"this",
"->",
"configuration",
"->",
"getClientSecret",
"(",
")",
")",
",",
"urlencode",
"(",
"$",
"this",
"->",
"configuration",
"->",
"getVersionedDate",
"(",
")",
")",
",",
"$",
"this",
"->",
"parseParameters",
"(",
"$",
"parameters",
")",
")",
";",
"return",
"$",
"url",
";",
"}"
] |
Get the API url for a given path.
@param string $path The path.
@param array $parameters The query parameters to include.
@return string
|
[
"Get",
"the",
"API",
"url",
"for",
"a",
"given",
"path",
"."
] |
ce5e7c308f87d5ccc28ab8d27a9cb51bd106d969
|
https://github.com/ben-gibson/foursquare-venue-client/blob/ce5e7c308f87d5ccc28ab8d27a9cb51bd106d969/src/Client.php#L193-L207
|
train
|
ben-gibson/foursquare-venue-client
|
src/Client.php
|
Client.parseParameters
|
private function parseParameters(array $parameters)
{
if (empty($parameters)) {
return '';
}
$parameters = implode('&', array_map(
function ($value, $key) {
return sprintf('%s=%s', $key, urlencode($value));
},
$parameters,
array_keys($parameters)
));
return "&{$parameters}";
}
|
php
|
private function parseParameters(array $parameters)
{
if (empty($parameters)) {
return '';
}
$parameters = implode('&', array_map(
function ($value, $key) {
return sprintf('%s=%s', $key, urlencode($value));
},
$parameters,
array_keys($parameters)
));
return "&{$parameters}";
}
|
[
"private",
"function",
"parseParameters",
"(",
"array",
"$",
"parameters",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"parameters",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"parameters",
"=",
"implode",
"(",
"'&'",
",",
"array_map",
"(",
"function",
"(",
"$",
"value",
",",
"$",
"key",
")",
"{",
"return",
"sprintf",
"(",
"'%s=%s'",
",",
"$",
"key",
",",
"urlencode",
"(",
"$",
"value",
")",
")",
";",
"}",
",",
"$",
"parameters",
",",
"array_keys",
"(",
"$",
"parameters",
")",
")",
")",
";",
"return",
"\"&{$parameters}\"",
";",
"}"
] |
Parse an array of parameters to their string representation.
@param array $parameters
@return string
|
[
"Parse",
"an",
"array",
"of",
"parameters",
"to",
"their",
"string",
"representation",
"."
] |
ce5e7c308f87d5ccc28ab8d27a9cb51bd106d969
|
https://github.com/ben-gibson/foursquare-venue-client/blob/ce5e7c308f87d5ccc28ab8d27a9cb51bd106d969/src/Client.php#L228-L243
|
train
|
bruno-barros/w.eloquent-framework
|
src/weloquent/Plugins/PluginsLoader.php
|
PluginsLoader.bootRequired
|
public static function bootRequired()
{
// on test do not load plugins
if(self::isUnableToRunPlugins())
{
return;
}
foreach (self::$required as $plugin)
{
require_once __DIR__ . DS . $plugin;
}
}
|
php
|
public static function bootRequired()
{
// on test do not load plugins
if(self::isUnableToRunPlugins())
{
return;
}
foreach (self::$required as $plugin)
{
require_once __DIR__ . DS . $plugin;
}
}
|
[
"public",
"static",
"function",
"bootRequired",
"(",
")",
"{",
"// on test do not load plugins",
"if",
"(",
"self",
"::",
"isUnableToRunPlugins",
"(",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"self",
"::",
"$",
"required",
"as",
"$",
"plugin",
")",
"{",
"require_once",
"__DIR__",
".",
"DS",
".",
"$",
"plugin",
";",
"}",
"}"
] |
Load required plugins
|
[
"Load",
"required",
"plugins"
] |
d252dcb1ba1b6b1cecf67877d7d6d3ba57ebedbd
|
https://github.com/bruno-barros/w.eloquent-framework/blob/d252dcb1ba1b6b1cecf67877d7d6d3ba57ebedbd/src/weloquent/Plugins/PluginsLoader.php#L46-L59
|
train
|
bruno-barros/w.eloquent-framework
|
src/weloquent/Plugins/PluginsLoader.php
|
PluginsLoader.loadFromPath
|
public static function loadFromPath($path)
{
// on test do not load plugins
if(self::isUnableToRunPlugins())
{
return;
}
if (!file_exists($path))
{
throw new InvalidArgumentException("The path [{$path}] doesn't exist to load plugins.");
}
$plugins = require $path;
foreach ($plugins as $plugin)
{
if (array_key_exists($plugin, self::$lookup))
{
$plugin = __DIR__ . DS . self::$lookup[$plugin];
}
if (file_exists($plugin))
{
require_once $plugin;
}
}
}
|
php
|
public static function loadFromPath($path)
{
// on test do not load plugins
if(self::isUnableToRunPlugins())
{
return;
}
if (!file_exists($path))
{
throw new InvalidArgumentException("The path [{$path}] doesn't exist to load plugins.");
}
$plugins = require $path;
foreach ($plugins as $plugin)
{
if (array_key_exists($plugin, self::$lookup))
{
$plugin = __DIR__ . DS . self::$lookup[$plugin];
}
if (file_exists($plugin))
{
require_once $plugin;
}
}
}
|
[
"public",
"static",
"function",
"loadFromPath",
"(",
"$",
"path",
")",
"{",
"// on test do not load plugins",
"if",
"(",
"self",
"::",
"isUnableToRunPlugins",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The path [{$path}] doesn't exist to load plugins.\"",
")",
";",
"}",
"$",
"plugins",
"=",
"require",
"$",
"path",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"plugin",
",",
"self",
"::",
"$",
"lookup",
")",
")",
"{",
"$",
"plugin",
"=",
"__DIR__",
".",
"DS",
".",
"self",
"::",
"$",
"lookup",
"[",
"$",
"plugin",
"]",
";",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"plugin",
")",
")",
"{",
"require_once",
"$",
"plugin",
";",
"}",
"}",
"}"
] |
Require plugins based on an array of paths
@param $path
|
[
"Require",
"plugins",
"based",
"on",
"an",
"array",
"of",
"paths"
] |
d252dcb1ba1b6b1cecf67877d7d6d3ba57ebedbd
|
https://github.com/bruno-barros/w.eloquent-framework/blob/d252dcb1ba1b6b1cecf67877d7d6d3ba57ebedbd/src/weloquent/Plugins/PluginsLoader.php#L66-L94
|
train
|
romeOz/rock-cache
|
src/Memcached.php
|
Memcached.setTags
|
protected function setTags($key, array $tags = [])
{
if (empty($tags)) {
return;
}
foreach ($this->prepareTags($tags) as $tag) {
if (($keys = $this->storage->get($tag)) !== false) {
$keys = $this->unserialize($keys);
if (in_array($key, $keys, true)) {
continue;
}
$keys[] = $key;
$this->setInternal($tag, $this->serialize($keys), 0);
continue;
}
$this->setInternal($tag, $this->serialize((array)$key), 0);
}
}
|
php
|
protected function setTags($key, array $tags = [])
{
if (empty($tags)) {
return;
}
foreach ($this->prepareTags($tags) as $tag) {
if (($keys = $this->storage->get($tag)) !== false) {
$keys = $this->unserialize($keys);
if (in_array($key, $keys, true)) {
continue;
}
$keys[] = $key;
$this->setInternal($tag, $this->serialize($keys), 0);
continue;
}
$this->setInternal($tag, $this->serialize((array)$key), 0);
}
}
|
[
"protected",
"function",
"setTags",
"(",
"$",
"key",
",",
"array",
"$",
"tags",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"tags",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"prepareTags",
"(",
"$",
"tags",
")",
"as",
"$",
"tag",
")",
"{",
"if",
"(",
"(",
"$",
"keys",
"=",
"$",
"this",
"->",
"storage",
"->",
"get",
"(",
"$",
"tag",
")",
")",
"!==",
"false",
")",
"{",
"$",
"keys",
"=",
"$",
"this",
"->",
"unserialize",
"(",
"$",
"keys",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"$",
"keys",
",",
"true",
")",
")",
"{",
"continue",
";",
"}",
"$",
"keys",
"[",
"]",
"=",
"$",
"key",
";",
"$",
"this",
"->",
"setInternal",
"(",
"$",
"tag",
",",
"$",
"this",
"->",
"serialize",
"(",
"$",
"keys",
")",
",",
"0",
")",
";",
"continue",
";",
"}",
"$",
"this",
"->",
"setInternal",
"(",
"$",
"tag",
",",
"$",
"this",
"->",
"serialize",
"(",
"(",
"array",
")",
"$",
"key",
")",
",",
"0",
")",
";",
"}",
"}"
] |
Sets a tags
@param string $key key of cache
@param array $tags list of tags
|
[
"Sets",
"a",
"tags"
] |
bbd146ee323e8cc1fb11dc1803215c3656e02c57
|
https://github.com/romeOz/rock-cache/blob/bbd146ee323e8cc1fb11dc1803215c3656e02c57/src/Memcached.php#L275-L293
|
train
|
3ev/wordpress-core
|
src/Tev/Term/Repository/TermRepository.php
|
TermRepository.getByTaxonomy
|
public function getByTaxonomy($taxonomy)
{
if (!($taxonomy instanceof Taxonomy)) {
$taxonomy = $this->taxonomyFactory->create($taxonomy);
}
return $this->convertTermsArray(get_terms($taxonomy->getName(), array(
'hide_empty' => false
)), $taxonomy);
}
|
php
|
public function getByTaxonomy($taxonomy)
{
if (!($taxonomy instanceof Taxonomy)) {
$taxonomy = $this->taxonomyFactory->create($taxonomy);
}
return $this->convertTermsArray(get_terms($taxonomy->getName(), array(
'hide_empty' => false
)), $taxonomy);
}
|
[
"public",
"function",
"getByTaxonomy",
"(",
"$",
"taxonomy",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"taxonomy",
"instanceof",
"Taxonomy",
")",
")",
"{",
"$",
"taxonomy",
"=",
"$",
"this",
"->",
"taxonomyFactory",
"->",
"create",
"(",
"$",
"taxonomy",
")",
";",
"}",
"return",
"$",
"this",
"->",
"convertTermsArray",
"(",
"get_terms",
"(",
"$",
"taxonomy",
"->",
"getName",
"(",
")",
",",
"array",
"(",
"'hide_empty'",
"=>",
"false",
")",
")",
",",
"$",
"taxonomy",
")",
";",
"}"
] |
Get all terms in the given taxonomy.
@param string|\Tev\Taxonomy\Model\Taxonomy $taxonomy Taxonomy object or name
@return \Tev\Term\Model\Term[]
|
[
"Get",
"all",
"terms",
"in",
"the",
"given",
"taxonomy",
"."
] |
da674fbec5bf3d5bd2a2141680a4c141113eb6b0
|
https://github.com/3ev/wordpress-core/blob/da674fbec5bf3d5bd2a2141680a4c141113eb6b0/src/Tev/Term/Repository/TermRepository.php#L51-L60
|
train
|
3ev/wordpress-core
|
src/Tev/Term/Repository/TermRepository.php
|
TermRepository.convertTermsArray
|
private function convertTermsArray($terms, Taxonomy $taxonomy)
{
$res = array();
foreach ($terms as $t) {
$res[] = $this->termFactory->create($t, $taxonomy);
}
return $res;
}
|
php
|
private function convertTermsArray($terms, Taxonomy $taxonomy)
{
$res = array();
foreach ($terms as $t) {
$res[] = $this->termFactory->create($t, $taxonomy);
}
return $res;
}
|
[
"private",
"function",
"convertTermsArray",
"(",
"$",
"terms",
",",
"Taxonomy",
"$",
"taxonomy",
")",
"{",
"$",
"res",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"terms",
"as",
"$",
"t",
")",
"{",
"$",
"res",
"[",
"]",
"=",
"$",
"this",
"->",
"termFactory",
"->",
"create",
"(",
"$",
"t",
",",
"$",
"taxonomy",
")",
";",
"}",
"return",
"$",
"res",
";",
"}"
] |
Convert an array of Wordpress term objects to array of Term objects.
@param \stdClass[] $terms Wordpress term objects
@param \Tev\Taxonomy\Model\Taxonomy $taxonomy Parent taxonomy
@return \Tev\Term\Model\Term[] Term objects
|
[
"Convert",
"an",
"array",
"of",
"Wordpress",
"term",
"objects",
"to",
"array",
"of",
"Term",
"objects",
"."
] |
da674fbec5bf3d5bd2a2141680a4c141113eb6b0
|
https://github.com/3ev/wordpress-core/blob/da674fbec5bf3d5bd2a2141680a4c141113eb6b0/src/Tev/Term/Repository/TermRepository.php#L69-L78
|
train
|
acacha/forge-publish
|
src/Console/Commands/Traits/ChecksSSHConnection.php
|
ChecksSSHConnection.checkSSHConnection
|
protected function checkSSHConnection($server = null, $ssh_config_file = null, $verbose = false)
{
$server = $server ? $server : $this->hostNameForConfigFile();
$ssh_config_file = $ssh_config_file ? $ssh_config_file : $this->sshConfigFile();
if ($verbose) {
$this->info("timeout 10 ssh -F $ssh_config_file -q " . $server . ' exit; echo $?');
}
$ret = exec("timeout 10 ssh -F $ssh_config_file -q " . $server . ' "exit"; echo $?');
if ($ret == 0) {
return true;
}
return false;
}
|
php
|
protected function checkSSHConnection($server = null, $ssh_config_file = null, $verbose = false)
{
$server = $server ? $server : $this->hostNameForConfigFile();
$ssh_config_file = $ssh_config_file ? $ssh_config_file : $this->sshConfigFile();
if ($verbose) {
$this->info("timeout 10 ssh -F $ssh_config_file -q " . $server . ' exit; echo $?');
}
$ret = exec("timeout 10 ssh -F $ssh_config_file -q " . $server . ' "exit"; echo $?');
if ($ret == 0) {
return true;
}
return false;
}
|
[
"protected",
"function",
"checkSSHConnection",
"(",
"$",
"server",
"=",
"null",
",",
"$",
"ssh_config_file",
"=",
"null",
",",
"$",
"verbose",
"=",
"false",
")",
"{",
"$",
"server",
"=",
"$",
"server",
"?",
"$",
"server",
":",
"$",
"this",
"->",
"hostNameForConfigFile",
"(",
")",
";",
"$",
"ssh_config_file",
"=",
"$",
"ssh_config_file",
"?",
"$",
"ssh_config_file",
":",
"$",
"this",
"->",
"sshConfigFile",
"(",
")",
";",
"if",
"(",
"$",
"verbose",
")",
"{",
"$",
"this",
"->",
"info",
"(",
"\"timeout 10 ssh -F $ssh_config_file -q \"",
".",
"$",
"server",
".",
"' exit; echo $?'",
")",
";",
"}",
"$",
"ret",
"=",
"exec",
"(",
"\"timeout 10 ssh -F $ssh_config_file -q \"",
".",
"$",
"server",
".",
"' \"exit\"; echo $?'",
")",
";",
"if",
"(",
"$",
"ret",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Check SSH connection.
@return bool
|
[
"Check",
"SSH",
"connection",
"."
] |
010779e3d2297c763b82dc3fbde992edffb3a6c6
|
https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/Traits/ChecksSSHConnection.php#L50-L63
|
train
|
acacha/forge-publish
|
src/Console/Commands/Traits/ChecksSSHConnection.php
|
ChecksSSHConnection.abortIfNoSSHConnection
|
protected function abortIfNoSSHConnection($server = null)
{
$server = $server ? $server : $this->hostNameForConfigFile();
if (!$this->checkSSHConnection($server)) {
$this->error("SSH connection to server $server doesn't works. Please run php artisan publish:init or publish:ssh");
die();
}
}
|
php
|
protected function abortIfNoSSHConnection($server = null)
{
$server = $server ? $server : $this->hostNameForConfigFile();
if (!$this->checkSSHConnection($server)) {
$this->error("SSH connection to server $server doesn't works. Please run php artisan publish:init or publish:ssh");
die();
}
}
|
[
"protected",
"function",
"abortIfNoSSHConnection",
"(",
"$",
"server",
"=",
"null",
")",
"{",
"$",
"server",
"=",
"$",
"server",
"?",
"$",
"server",
":",
"$",
"this",
"->",
"hostNameForConfigFile",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"checkSSHConnection",
"(",
"$",
"server",
")",
")",
"{",
"$",
"this",
"->",
"error",
"(",
"\"SSH connection to server $server doesn't works. Please run php artisan publish:init or publish:ssh\"",
")",
";",
"die",
"(",
")",
";",
"}",
"}"
] |
Abort if no SSH connection.
@return bool
|
[
"Abort",
"if",
"no",
"SSH",
"connection",
"."
] |
010779e3d2297c763b82dc3fbde992edffb3a6c6
|
https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/Traits/ChecksSSHConnection.php#L70-L77
|
train
|
schpill/thin
|
src/Load/Ini.php
|
Ini._processKey
|
protected function _processKey($config, $key, $value)
{
if (strpos($key, $this->_nestSeparator) !== false) {
$parts = explode($this->_nestSeparator, $key, 2);
if (strlen(Arrays::first($parts)) && strlen(Arrays::last($parts))) {
if (!isset($config[Arrays::first($parts)])) {
if (Arrays::first($parts) === '0' && !empty($config)) {
// convert the current values in $config into an array
$config = array(Arrays::first($parts) => $config);
} else {
$config[Arrays::first($parts)] = array();
}
} elseif (!Arrays::is($config[Arrays::first($parts)])) {
throw new Exception("Cannot create sub-key for '{Arrays::first($parts)}' as key already exists");
}
$config[Arrays::first($parts)] = $this->_processKey(
$config[Arrays::first($parts)],
Arrays::last($parts),
$value
);
} else {
throw new Exception("Invalid key '$key'");
}
} else {
$config[$key] = $value;
}
return $config;
}
|
php
|
protected function _processKey($config, $key, $value)
{
if (strpos($key, $this->_nestSeparator) !== false) {
$parts = explode($this->_nestSeparator, $key, 2);
if (strlen(Arrays::first($parts)) && strlen(Arrays::last($parts))) {
if (!isset($config[Arrays::first($parts)])) {
if (Arrays::first($parts) === '0' && !empty($config)) {
// convert the current values in $config into an array
$config = array(Arrays::first($parts) => $config);
} else {
$config[Arrays::first($parts)] = array();
}
} elseif (!Arrays::is($config[Arrays::first($parts)])) {
throw new Exception("Cannot create sub-key for '{Arrays::first($parts)}' as key already exists");
}
$config[Arrays::first($parts)] = $this->_processKey(
$config[Arrays::first($parts)],
Arrays::last($parts),
$value
);
} else {
throw new Exception("Invalid key '$key'");
}
} else {
$config[$key] = $value;
}
return $config;
}
|
[
"protected",
"function",
"_processKey",
"(",
"$",
"config",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"_nestSeparator",
")",
"!==",
"false",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"$",
"this",
"->",
"_nestSeparator",
",",
"$",
"key",
",",
"2",
")",
";",
"if",
"(",
"strlen",
"(",
"Arrays",
"::",
"first",
"(",
"$",
"parts",
")",
")",
"&&",
"strlen",
"(",
"Arrays",
"::",
"last",
"(",
"$",
"parts",
")",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"Arrays",
"::",
"first",
"(",
"$",
"parts",
")",
"]",
")",
")",
"{",
"if",
"(",
"Arrays",
"::",
"first",
"(",
"$",
"parts",
")",
"===",
"'0'",
"&&",
"!",
"empty",
"(",
"$",
"config",
")",
")",
"{",
"// convert the current values in $config into an array",
"$",
"config",
"=",
"array",
"(",
"Arrays",
"::",
"first",
"(",
"$",
"parts",
")",
"=>",
"$",
"config",
")",
";",
"}",
"else",
"{",
"$",
"config",
"[",
"Arrays",
"::",
"first",
"(",
"$",
"parts",
")",
"]",
"=",
"array",
"(",
")",
";",
"}",
"}",
"elseif",
"(",
"!",
"Arrays",
"::",
"is",
"(",
"$",
"config",
"[",
"Arrays",
"::",
"first",
"(",
"$",
"parts",
")",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Cannot create sub-key for '{Arrays::first($parts)}' as key already exists\"",
")",
";",
"}",
"$",
"config",
"[",
"Arrays",
"::",
"first",
"(",
"$",
"parts",
")",
"]",
"=",
"$",
"this",
"->",
"_processKey",
"(",
"$",
"config",
"[",
"Arrays",
"::",
"first",
"(",
"$",
"parts",
")",
"]",
",",
"Arrays",
"::",
"last",
"(",
"$",
"parts",
")",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"Invalid key '$key'\"",
")",
";",
"}",
"}",
"else",
"{",
"$",
"config",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"config",
";",
"}"
] |
Assign the key's value to the property list. Handles the
nest separator for sub-properties.
@param array $config
@param string $key
@param string $value
@throws Exception
@return array
|
[
"Assign",
"the",
"key",
"s",
"value",
"to",
"the",
"property",
"list",
".",
"Handles",
"the",
"nest",
"separator",
"for",
"sub",
"-",
"properties",
"."
] |
a9102d9d6f70e8b0f6be93153f70849f46489ee1
|
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Load/Ini.php#L253-L280
|
train
|
phonetworks/pho-compiler
|
src/Pho/Compiler/Inspector.php
|
Inspector.assertParity
|
public function assertParity(): void
{
$ignored_classes = [];
$object_exists = false;
$actor_exists = false;
$locator = new ClassFileLocator($this->folder);
foreach ($locator as $file) {
$filename = str_replace($this->folder . DIRECTORY_SEPARATOR, '', $file->getRealPath());
foreach ($file->getClasses() as $class) {
$reflector = new \ReflectionClass($class);
$parent = $reflector->getParentClass()->getName();
$class_name = $reflector->getShortName();
switch($parent) {
case "Pho\Framework\Object":
$object_exists = true;
try {
$this->checkEdgeDir($class_name);
}
catch(Exceptions\AbsentEdgeDirImparityException $e) {
throw $e;
}
break;
case "Pho\Framework\Actor":
$actor_exists = true;
try {
$this->checkEdgeDir($class_name);
}
catch(Exceptions\AbsentEdgeDirImparityException $e) {
throw $e;
}
break;
case "Pho\Framework\Frame":
try {
$this->checkEdgeDir($class_name);
}
catch(Exceptions\AbsentEdgeDirImparityException $e) {
throw $e;
}
break;
default:
$ignored_classes[] = [
"filename" => $filename,
"classname" => $class_name
];
break;
}
}
}
if(!$object_exists) {
throw new Exceptions\MissingObjectImparityException($this->folder);
}
if(!$actor_exists) {
throw new Exceptions\MissingActorImparityException($this->folder);
}
}
|
php
|
public function assertParity(): void
{
$ignored_classes = [];
$object_exists = false;
$actor_exists = false;
$locator = new ClassFileLocator($this->folder);
foreach ($locator as $file) {
$filename = str_replace($this->folder . DIRECTORY_SEPARATOR, '', $file->getRealPath());
foreach ($file->getClasses() as $class) {
$reflector = new \ReflectionClass($class);
$parent = $reflector->getParentClass()->getName();
$class_name = $reflector->getShortName();
switch($parent) {
case "Pho\Framework\Object":
$object_exists = true;
try {
$this->checkEdgeDir($class_name);
}
catch(Exceptions\AbsentEdgeDirImparityException $e) {
throw $e;
}
break;
case "Pho\Framework\Actor":
$actor_exists = true;
try {
$this->checkEdgeDir($class_name);
}
catch(Exceptions\AbsentEdgeDirImparityException $e) {
throw $e;
}
break;
case "Pho\Framework\Frame":
try {
$this->checkEdgeDir($class_name);
}
catch(Exceptions\AbsentEdgeDirImparityException $e) {
throw $e;
}
break;
default:
$ignored_classes[] = [
"filename" => $filename,
"classname" => $class_name
];
break;
}
}
}
if(!$object_exists) {
throw new Exceptions\MissingObjectImparityException($this->folder);
}
if(!$actor_exists) {
throw new Exceptions\MissingActorImparityException($this->folder);
}
}
|
[
"public",
"function",
"assertParity",
"(",
")",
":",
"void",
"{",
"$",
"ignored_classes",
"=",
"[",
"]",
";",
"$",
"object_exists",
"=",
"false",
";",
"$",
"actor_exists",
"=",
"false",
";",
"$",
"locator",
"=",
"new",
"ClassFileLocator",
"(",
"$",
"this",
"->",
"folder",
")",
";",
"foreach",
"(",
"$",
"locator",
"as",
"$",
"file",
")",
"{",
"$",
"filename",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"folder",
".",
"DIRECTORY_SEPARATOR",
",",
"''",
",",
"$",
"file",
"->",
"getRealPath",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"file",
"->",
"getClasses",
"(",
")",
"as",
"$",
"class",
")",
"{",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"$",
"parent",
"=",
"$",
"reflector",
"->",
"getParentClass",
"(",
")",
"->",
"getName",
"(",
")",
";",
"$",
"class_name",
"=",
"$",
"reflector",
"->",
"getShortName",
"(",
")",
";",
"switch",
"(",
"$",
"parent",
")",
"{",
"case",
"\"Pho\\Framework\\Object\"",
":",
"$",
"object_exists",
"=",
"true",
";",
"try",
"{",
"$",
"this",
"->",
"checkEdgeDir",
"(",
"$",
"class_name",
")",
";",
"}",
"catch",
"(",
"Exceptions",
"\\",
"AbsentEdgeDirImparityException",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"break",
";",
"case",
"\"Pho\\Framework\\Actor\"",
":",
"$",
"actor_exists",
"=",
"true",
";",
"try",
"{",
"$",
"this",
"->",
"checkEdgeDir",
"(",
"$",
"class_name",
")",
";",
"}",
"catch",
"(",
"Exceptions",
"\\",
"AbsentEdgeDirImparityException",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"break",
";",
"case",
"\"Pho\\Framework\\Frame\"",
":",
"try",
"{",
"$",
"this",
"->",
"checkEdgeDir",
"(",
"$",
"class_name",
")",
";",
"}",
"catch",
"(",
"Exceptions",
"\\",
"AbsentEdgeDirImparityException",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"break",
";",
"default",
":",
"$",
"ignored_classes",
"[",
"]",
"=",
"[",
"\"filename\"",
"=>",
"$",
"filename",
",",
"\"classname\"",
"=>",
"$",
"class_name",
"]",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"$",
"object_exists",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"MissingObjectImparityException",
"(",
"$",
"this",
"->",
"folder",
")",
";",
"}",
"if",
"(",
"!",
"$",
"actor_exists",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"MissingActorImparityException",
"(",
"$",
"this",
"->",
"folder",
")",
";",
"}",
"}"
] |
Validates the compiled schema directory.
@return void
@throws Exceptions\MissingObjectImparityException if there is no object node found.
@throws Exceptions\MissingActorImparityException if there is no actor node found.
@throws Exceptions\AbsentEdgeDirImparityException if the node does not have a directory for its edges.
|
[
"Validates",
"the",
"compiled",
"schema",
"directory",
"."
] |
9131c3ac55d163069aaf6808b7339345151c7280
|
https://github.com/phonetworks/pho-compiler/blob/9131c3ac55d163069aaf6808b7339345151c7280/src/Pho/Compiler/Inspector.php#L63-L117
|
train
|
phonetworks/pho-compiler
|
src/Pho/Compiler/Inspector.php
|
Inspector.checkEdgeDir
|
protected function checkEdgeDir(string $node_name): void
{
$dirname = $this->folder.DIRECTORY_SEPARATOR.$node_name."Out";
if(!file_exists($dirname)) {
throw new Exceptions\AbsentEdgeDirImparityException($dirname, $node_name);
}
}
|
php
|
protected function checkEdgeDir(string $node_name): void
{
$dirname = $this->folder.DIRECTORY_SEPARATOR.$node_name."Out";
if(!file_exists($dirname)) {
throw new Exceptions\AbsentEdgeDirImparityException($dirname, $node_name);
}
}
|
[
"protected",
"function",
"checkEdgeDir",
"(",
"string",
"$",
"node_name",
")",
":",
"void",
"{",
"$",
"dirname",
"=",
"$",
"this",
"->",
"folder",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"node_name",
".",
"\"Out\"",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"dirname",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"AbsentEdgeDirImparityException",
"(",
"$",
"dirname",
",",
"$",
"node_name",
")",
";",
"}",
"}"
] |
Checks if the node has a directory for its edges.
@param string $node_name The name of the node.
@return void
@throws Exceptions\AbsentEdgeDirImparityException if the node does not have a directory for its edges.
|
[
"Checks",
"if",
"the",
"node",
"has",
"a",
"directory",
"for",
"its",
"edges",
"."
] |
9131c3ac55d163069aaf6808b7339345151c7280
|
https://github.com/phonetworks/pho-compiler/blob/9131c3ac55d163069aaf6808b7339345151c7280/src/Pho/Compiler/Inspector.php#L128-L134
|
train
|
interactivesolutions/honeycomb-scripts
|
src/app/commands/service/HCServiceTranslations.php
|
HCServiceTranslations.optimize
|
public function optimize (stdClass $data)
{
$data->translationFilePrefix = $this->stringWithUnderscore ($data->serviceURL);
$data->translationFilePrefix = $this->stringWithUnderscore ($data->translationFilePrefix);
$data->translationsLocation = $this->getTranslationPrefix ($data) . $data->translationFilePrefix;
return $data;
}
|
php
|
public function optimize (stdClass $data)
{
$data->translationFilePrefix = $this->stringWithUnderscore ($data->serviceURL);
$data->translationFilePrefix = $this->stringWithUnderscore ($data->translationFilePrefix);
$data->translationsLocation = $this->getTranslationPrefix ($data) . $data->translationFilePrefix;
return $data;
}
|
[
"public",
"function",
"optimize",
"(",
"stdClass",
"$",
"data",
")",
"{",
"$",
"data",
"->",
"translationFilePrefix",
"=",
"$",
"this",
"->",
"stringWithUnderscore",
"(",
"$",
"data",
"->",
"serviceURL",
")",
";",
"$",
"data",
"->",
"translationFilePrefix",
"=",
"$",
"this",
"->",
"stringWithUnderscore",
"(",
"$",
"data",
"->",
"translationFilePrefix",
")",
";",
"$",
"data",
"->",
"translationsLocation",
"=",
"$",
"this",
"->",
"getTranslationPrefix",
"(",
"$",
"data",
")",
".",
"$",
"data",
"->",
"translationFilePrefix",
";",
"return",
"$",
"data",
";",
"}"
] |
Optimizing Translations data
@param stdClass $data
@return stdClass
|
[
"Optimizing",
"Translations",
"data"
] |
be2428ded5219dc612ecc51f43aa4dedff3d034d
|
https://github.com/interactivesolutions/honeycomb-scripts/blob/be2428ded5219dc612ecc51f43aa4dedff3d034d/src/app/commands/service/HCServiceTranslations.php#L21-L29
|
train
|
interactivesolutions/honeycomb-scripts
|
src/app/commands/service/HCServiceTranslations.php
|
HCServiceTranslations.getServiceProviderNameSpace
|
private function getServiceProviderNameSpace (stdClass $item)
{
return json_decode (file_get_contents ($item->rootDirectory . 'app/' . HCNewService::CONFIG_PATH))->general->serviceProviderNameSpace;
}
|
php
|
private function getServiceProviderNameSpace (stdClass $item)
{
return json_decode (file_get_contents ($item->rootDirectory . 'app/' . HCNewService::CONFIG_PATH))->general->serviceProviderNameSpace;
}
|
[
"private",
"function",
"getServiceProviderNameSpace",
"(",
"stdClass",
"$",
"item",
")",
"{",
"return",
"json_decode",
"(",
"file_get_contents",
"(",
"$",
"item",
"->",
"rootDirectory",
".",
"'app/'",
".",
"HCNewService",
"::",
"CONFIG_PATH",
")",
")",
"->",
"general",
"->",
"serviceProviderNameSpace",
";",
"}"
] |
Getting service provider namespace
@param $item
@return mixed
|
[
"Getting",
"service",
"provider",
"namespace"
] |
be2428ded5219dc612ecc51f43aa4dedff3d034d
|
https://github.com/interactivesolutions/honeycomb-scripts/blob/be2428ded5219dc612ecc51f43aa4dedff3d034d/src/app/commands/service/HCServiceTranslations.php#L52-L55
|
train
|
interactivesolutions/honeycomb-scripts
|
src/app/commands/service/HCServiceTranslations.php
|
HCServiceTranslations.generate
|
public function generate (stdClass $service)
{
$this->createFileFromTemplate ([
"destination" => $service->rootDirectory . 'resources/lang/en/' . $service->translationFilePrefix . '.php',
"templateDestination" => __DIR__ . '/../templates/service/translations.hctpl',
"content" => [
"translations" => $this->gatherTranslations ($service),
],
]);
return $service->rootDirectory . 'resources/lang/en/' . $service->translationFilePrefix . '.php';
}
|
php
|
public function generate (stdClass $service)
{
$this->createFileFromTemplate ([
"destination" => $service->rootDirectory . 'resources/lang/en/' . $service->translationFilePrefix . '.php',
"templateDestination" => __DIR__ . '/../templates/service/translations.hctpl',
"content" => [
"translations" => $this->gatherTranslations ($service),
],
]);
return $service->rootDirectory . 'resources/lang/en/' . $service->translationFilePrefix . '.php';
}
|
[
"public",
"function",
"generate",
"(",
"stdClass",
"$",
"service",
")",
"{",
"$",
"this",
"->",
"createFileFromTemplate",
"(",
"[",
"\"destination\"",
"=>",
"$",
"service",
"->",
"rootDirectory",
".",
"'resources/lang/en/'",
".",
"$",
"service",
"->",
"translationFilePrefix",
".",
"'.php'",
",",
"\"templateDestination\"",
"=>",
"__DIR__",
".",
"'/../templates/service/translations.hctpl'",
",",
"\"content\"",
"=>",
"[",
"\"translations\"",
"=>",
"$",
"this",
"->",
"gatherTranslations",
"(",
"$",
"service",
")",
",",
"]",
",",
"]",
")",
";",
"return",
"$",
"service",
"->",
"rootDirectory",
".",
"'resources/lang/en/'",
".",
"$",
"service",
"->",
"translationFilePrefix",
".",
"'.php'",
";",
"}"
] |
Creating translation file
@param $service
@return string
|
[
"Creating",
"translation",
"file"
] |
be2428ded5219dc612ecc51f43aa4dedff3d034d
|
https://github.com/interactivesolutions/honeycomb-scripts/blob/be2428ded5219dc612ecc51f43aa4dedff3d034d/src/app/commands/service/HCServiceTranslations.php#L63-L74
|
train
|
interactivesolutions/honeycomb-scripts
|
src/app/commands/service/HCServiceTranslations.php
|
HCServiceTranslations.gatherTranslations
|
private function gatherTranslations (stdClass $service)
{
$output = '';
$tpl = file_get_contents (__DIR__ . '/../templates/shared/array.element.hctpl');
$line = str_replace ('{key}', 'page_title', $tpl);
$line = str_replace ('{value}', $service->serviceName, $line);
$output .= $line;
$output .= $this->gatherTranslationsFromModel ($service->mainModel, $tpl, array_merge ($this->getAutoFill (), ['id']));
if (isset($service->mainModel->multiLanguage))
$output .= $this->gatherTranslationsFromModel ($service->mainModel->multiLanguage, $tpl, array_merge ($this->getAutoFill (), ['id', 'language_code', 'record_id']));
return $output;
}
|
php
|
private function gatherTranslations (stdClass $service)
{
$output = '';
$tpl = file_get_contents (__DIR__ . '/../templates/shared/array.element.hctpl');
$line = str_replace ('{key}', 'page_title', $tpl);
$line = str_replace ('{value}', $service->serviceName, $line);
$output .= $line;
$output .= $this->gatherTranslationsFromModel ($service->mainModel, $tpl, array_merge ($this->getAutoFill (), ['id']));
if (isset($service->mainModel->multiLanguage))
$output .= $this->gatherTranslationsFromModel ($service->mainModel->multiLanguage, $tpl, array_merge ($this->getAutoFill (), ['id', 'language_code', 'record_id']));
return $output;
}
|
[
"private",
"function",
"gatherTranslations",
"(",
"stdClass",
"$",
"service",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"tpl",
"=",
"file_get_contents",
"(",
"__DIR__",
".",
"'/../templates/shared/array.element.hctpl'",
")",
";",
"$",
"line",
"=",
"str_replace",
"(",
"'{key}'",
",",
"'page_title'",
",",
"$",
"tpl",
")",
";",
"$",
"line",
"=",
"str_replace",
"(",
"'{value}'",
",",
"$",
"service",
"->",
"serviceName",
",",
"$",
"line",
")",
";",
"$",
"output",
".=",
"$",
"line",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"gatherTranslationsFromModel",
"(",
"$",
"service",
"->",
"mainModel",
",",
"$",
"tpl",
",",
"array_merge",
"(",
"$",
"this",
"->",
"getAutoFill",
"(",
")",
",",
"[",
"'id'",
"]",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"service",
"->",
"mainModel",
"->",
"multiLanguage",
")",
")",
"$",
"output",
".=",
"$",
"this",
"->",
"gatherTranslationsFromModel",
"(",
"$",
"service",
"->",
"mainModel",
"->",
"multiLanguage",
",",
"$",
"tpl",
",",
"array_merge",
"(",
"$",
"this",
"->",
"getAutoFill",
"(",
")",
",",
"[",
"'id'",
",",
"'language_code'",
",",
"'record_id'",
"]",
")",
")",
";",
"return",
"$",
"output",
";",
"}"
] |
Gathering available translations
@param $service
@return string
|
[
"Gathering",
"available",
"translations"
] |
be2428ded5219dc612ecc51f43aa4dedff3d034d
|
https://github.com/interactivesolutions/honeycomb-scripts/blob/be2428ded5219dc612ecc51f43aa4dedff3d034d/src/app/commands/service/HCServiceTranslations.php#L82-L96
|
train
|
interactivesolutions/honeycomb-scripts
|
src/app/commands/service/HCServiceTranslations.php
|
HCServiceTranslations.gatherTranslationsFromModel
|
private function gatherTranslationsFromModel (stdClass $model, string $tpl, array $skip)
{
$output = '';
if (array_key_exists ('columns', $model) && !empty($model->columns))
foreach ($model->columns as $column) {
if (in_array ($column->Field, $skip))
continue;
$line = str_replace ('{key}', $column->Field, $tpl);
$line = str_replace ('{value}', str_replace ("_", " ", ucfirst ($column->Field)), $line);
$output .= $line;
}
return $output;
}
|
php
|
private function gatherTranslationsFromModel (stdClass $model, string $tpl, array $skip)
{
$output = '';
if (array_key_exists ('columns', $model) && !empty($model->columns))
foreach ($model->columns as $column) {
if (in_array ($column->Field, $skip))
continue;
$line = str_replace ('{key}', $column->Field, $tpl);
$line = str_replace ('{value}', str_replace ("_", " ", ucfirst ($column->Field)), $line);
$output .= $line;
}
return $output;
}
|
[
"private",
"function",
"gatherTranslationsFromModel",
"(",
"stdClass",
"$",
"model",
",",
"string",
"$",
"tpl",
",",
"array",
"$",
"skip",
")",
"{",
"$",
"output",
"=",
"''",
";",
"if",
"(",
"array_key_exists",
"(",
"'columns'",
",",
"$",
"model",
")",
"&&",
"!",
"empty",
"(",
"$",
"model",
"->",
"columns",
")",
")",
"foreach",
"(",
"$",
"model",
"->",
"columns",
"as",
"$",
"column",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"column",
"->",
"Field",
",",
"$",
"skip",
")",
")",
"continue",
";",
"$",
"line",
"=",
"str_replace",
"(",
"'{key}'",
",",
"$",
"column",
"->",
"Field",
",",
"$",
"tpl",
")",
";",
"$",
"line",
"=",
"str_replace",
"(",
"'{value}'",
",",
"str_replace",
"(",
"\"_\"",
",",
"\" \"",
",",
"ucfirst",
"(",
"$",
"column",
"->",
"Field",
")",
")",
",",
"$",
"line",
")",
";",
"$",
"output",
".=",
"$",
"line",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Gathering fields from specific model
@param stdClass $model
@param string $tpl
@param array $skip
@return string
|
[
"Gathering",
"fields",
"from",
"specific",
"model"
] |
be2428ded5219dc612ecc51f43aa4dedff3d034d
|
https://github.com/interactivesolutions/honeycomb-scripts/blob/be2428ded5219dc612ecc51f43aa4dedff3d034d/src/app/commands/service/HCServiceTranslations.php#L106-L122
|
train
|
juliangut/doctrine-manager-builder
|
src/RelationalBuilder.php
|
RelationalBuilder.getQueryCacheDriver
|
public function getQueryCacheDriver()
{
if (!$this->queryCacheDriver instanceof CacheProvider) {
$this->queryCacheDriver = $this->getCacheDriver(
(string) $this->getOption('query_cache_namespace'),
$this->getOption('query_cache_driver')
);
}
return $this->queryCacheDriver;
}
|
php
|
public function getQueryCacheDriver()
{
if (!$this->queryCacheDriver instanceof CacheProvider) {
$this->queryCacheDriver = $this->getCacheDriver(
(string) $this->getOption('query_cache_namespace'),
$this->getOption('query_cache_driver')
);
}
return $this->queryCacheDriver;
}
|
[
"public",
"function",
"getQueryCacheDriver",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"queryCacheDriver",
"instanceof",
"CacheProvider",
")",
"{",
"$",
"this",
"->",
"queryCacheDriver",
"=",
"$",
"this",
"->",
"getCacheDriver",
"(",
"(",
"string",
")",
"$",
"this",
"->",
"getOption",
"(",
"'query_cache_namespace'",
")",
",",
"$",
"this",
"->",
"getOption",
"(",
"'query_cache_driver'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"queryCacheDriver",
";",
"}"
] |
Retrieve query cache driver.
@throws \InvalidArgumentException
@return CacheProvider
|
[
"Retrieve",
"query",
"cache",
"driver",
"."
] |
9c63bc689e4084f06be4d119f2c56f6040453d0e
|
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/RelationalBuilder.php#L289-L299
|
train
|
juliangut/doctrine-manager-builder
|
src/RelationalBuilder.php
|
RelationalBuilder.getResultCacheDriver
|
public function getResultCacheDriver()
{
if (!$this->resultCacheDriver instanceof CacheProvider) {
$this->resultCacheDriver = $this->getCacheDriver(
(string) $this->getOption('result_cache_namespace'),
$this->getOption('result_cache_driver')
);
}
return $this->resultCacheDriver;
}
|
php
|
public function getResultCacheDriver()
{
if (!$this->resultCacheDriver instanceof CacheProvider) {
$this->resultCacheDriver = $this->getCacheDriver(
(string) $this->getOption('result_cache_namespace'),
$this->getOption('result_cache_driver')
);
}
return $this->resultCacheDriver;
}
|
[
"public",
"function",
"getResultCacheDriver",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"resultCacheDriver",
"instanceof",
"CacheProvider",
")",
"{",
"$",
"this",
"->",
"resultCacheDriver",
"=",
"$",
"this",
"->",
"getCacheDriver",
"(",
"(",
"string",
")",
"$",
"this",
"->",
"getOption",
"(",
"'result_cache_namespace'",
")",
",",
"$",
"this",
"->",
"getOption",
"(",
"'result_cache_driver'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"resultCacheDriver",
";",
"}"
] |
Retrieve result cache driver.
@throws \InvalidArgumentException
@return CacheProvider
|
[
"Retrieve",
"result",
"cache",
"driver",
"."
] |
9c63bc689e4084f06be4d119f2c56f6040453d0e
|
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/RelationalBuilder.php#L318-L328
|
train
|
juliangut/doctrine-manager-builder
|
src/RelationalBuilder.php
|
RelationalBuilder.getHydratorCacheDriver
|
public function getHydratorCacheDriver()
{
if (!$this->hydratorCacheDriver instanceof CacheProvider) {
$this->hydratorCacheDriver = $this->getCacheDriver(
(string) $this->getOption('hydrator_cache_namespace'),
$this->getOption('hydrator_cache_driver')
);
}
return $this->hydratorCacheDriver;
}
|
php
|
public function getHydratorCacheDriver()
{
if (!$this->hydratorCacheDriver instanceof CacheProvider) {
$this->hydratorCacheDriver = $this->getCacheDriver(
(string) $this->getOption('hydrator_cache_namespace'),
$this->getOption('hydrator_cache_driver')
);
}
return $this->hydratorCacheDriver;
}
|
[
"public",
"function",
"getHydratorCacheDriver",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hydratorCacheDriver",
"instanceof",
"CacheProvider",
")",
"{",
"$",
"this",
"->",
"hydratorCacheDriver",
"=",
"$",
"this",
"->",
"getCacheDriver",
"(",
"(",
"string",
")",
"$",
"this",
"->",
"getOption",
"(",
"'hydrator_cache_namespace'",
")",
",",
"$",
"this",
"->",
"getOption",
"(",
"'hydrator_cache_driver'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"hydratorCacheDriver",
";",
"}"
] |
Retrieve hydrator cache driver.
@throws \InvalidArgumentException
@return CacheProvider
|
[
"Retrieve",
"hydrator",
"cache",
"driver",
"."
] |
9c63bc689e4084f06be4d119f2c56f6040453d0e
|
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/RelationalBuilder.php#L347-L357
|
train
|
juliangut/doctrine-manager-builder
|
src/RelationalBuilder.php
|
RelationalBuilder.getCacheDriver
|
protected function getCacheDriver($cacheNamespace, CacheProvider $cacheDriver = null)
{
if (!$cacheDriver instanceof CacheProvider) {
$cacheDriver = clone $this->getMetadataCacheDriver();
$cacheDriver->setNamespace($cacheNamespace);
}
if ($cacheDriver->getNamespace() === '') {
$cacheDriver->setNamespace($cacheNamespace);
}
return $cacheDriver;
}
|
php
|
protected function getCacheDriver($cacheNamespace, CacheProvider $cacheDriver = null)
{
if (!$cacheDriver instanceof CacheProvider) {
$cacheDriver = clone $this->getMetadataCacheDriver();
$cacheDriver->setNamespace($cacheNamespace);
}
if ($cacheDriver->getNamespace() === '') {
$cacheDriver->setNamespace($cacheNamespace);
}
return $cacheDriver;
}
|
[
"protected",
"function",
"getCacheDriver",
"(",
"$",
"cacheNamespace",
",",
"CacheProvider",
"$",
"cacheDriver",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"cacheDriver",
"instanceof",
"CacheProvider",
")",
"{",
"$",
"cacheDriver",
"=",
"clone",
"$",
"this",
"->",
"getMetadataCacheDriver",
"(",
")",
";",
"$",
"cacheDriver",
"->",
"setNamespace",
"(",
"$",
"cacheNamespace",
")",
";",
"}",
"if",
"(",
"$",
"cacheDriver",
"->",
"getNamespace",
"(",
")",
"===",
"''",
")",
"{",
"$",
"cacheDriver",
"->",
"setNamespace",
"(",
"$",
"cacheNamespace",
")",
";",
"}",
"return",
"$",
"cacheDriver",
";",
"}"
] |
Get cache driver.
@param string $cacheNamespace
@param CacheProvider|null $cacheDriver
@return CacheProvider
|
[
"Get",
"cache",
"driver",
"."
] |
9c63bc689e4084f06be4d119f2c56f6040453d0e
|
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/RelationalBuilder.php#L377-L389
|
train
|
juliangut/doctrine-manager-builder
|
src/RelationalBuilder.php
|
RelationalBuilder.getNamingStrategy
|
protected function getNamingStrategy()
{
if (!$this->namingStrategy instanceof NamingStrategy) {
$namingStrategy = $this->getOption('naming_strategy');
if (!$namingStrategy instanceof NamingStrategy) {
$namingStrategy = new UnderscoreNamingStrategy(CASE_LOWER);
}
$this->namingStrategy = $namingStrategy;
}
return $this->namingStrategy;
}
|
php
|
protected function getNamingStrategy()
{
if (!$this->namingStrategy instanceof NamingStrategy) {
$namingStrategy = $this->getOption('naming_strategy');
if (!$namingStrategy instanceof NamingStrategy) {
$namingStrategy = new UnderscoreNamingStrategy(CASE_LOWER);
}
$this->namingStrategy = $namingStrategy;
}
return $this->namingStrategy;
}
|
[
"protected",
"function",
"getNamingStrategy",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"namingStrategy",
"instanceof",
"NamingStrategy",
")",
"{",
"$",
"namingStrategy",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'naming_strategy'",
")",
";",
"if",
"(",
"!",
"$",
"namingStrategy",
"instanceof",
"NamingStrategy",
")",
"{",
"$",
"namingStrategy",
"=",
"new",
"UnderscoreNamingStrategy",
"(",
"CASE_LOWER",
")",
";",
"}",
"$",
"this",
"->",
"namingStrategy",
"=",
"$",
"namingStrategy",
";",
"}",
"return",
"$",
"this",
"->",
"namingStrategy",
";",
"}"
] |
Retrieve naming strategy.
@return NamingStrategy
|
[
"Retrieve",
"naming",
"strategy",
"."
] |
9c63bc689e4084f06be4d119f2c56f6040453d0e
|
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/RelationalBuilder.php#L396-L409
|
train
|
juliangut/doctrine-manager-builder
|
src/RelationalBuilder.php
|
RelationalBuilder.getQuoteStrategy
|
protected function getQuoteStrategy()
{
if (!$this->quoteStrategy instanceof QuoteStrategy) {
$quoteStrategy = $this->getOption('quote_strategy');
if (!$quoteStrategy instanceof QuoteStrategy) {
$quoteStrategy = new DefaultQuoteStrategy;
}
$this->quoteStrategy = $quoteStrategy;
}
return $this->quoteStrategy;
}
|
php
|
protected function getQuoteStrategy()
{
if (!$this->quoteStrategy instanceof QuoteStrategy) {
$quoteStrategy = $this->getOption('quote_strategy');
if (!$quoteStrategy instanceof QuoteStrategy) {
$quoteStrategy = new DefaultQuoteStrategy;
}
$this->quoteStrategy = $quoteStrategy;
}
return $this->quoteStrategy;
}
|
[
"protected",
"function",
"getQuoteStrategy",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"quoteStrategy",
"instanceof",
"QuoteStrategy",
")",
"{",
"$",
"quoteStrategy",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'quote_strategy'",
")",
";",
"if",
"(",
"!",
"$",
"quoteStrategy",
"instanceof",
"QuoteStrategy",
")",
"{",
"$",
"quoteStrategy",
"=",
"new",
"DefaultQuoteStrategy",
";",
"}",
"$",
"this",
"->",
"quoteStrategy",
"=",
"$",
"quoteStrategy",
";",
"}",
"return",
"$",
"this",
"->",
"quoteStrategy",
";",
"}"
] |
Retrieve quote strategy.
@throws \InvalidArgumentException
@return QuoteStrategy
|
[
"Retrieve",
"quote",
"strategy",
"."
] |
9c63bc689e4084f06be4d119f2c56f6040453d0e
|
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/RelationalBuilder.php#L418-L431
|
train
|
juliangut/doctrine-manager-builder
|
src/RelationalBuilder.php
|
RelationalBuilder.getSecondLevelCacheConfiguration
|
protected function getSecondLevelCacheConfiguration()
{
if (!$this->secondCacheConfig instanceof CacheConfiguration) {
$secondCacheConfig = $this->getOption('second_level_cache_configuration');
if ($secondCacheConfig instanceof CacheConfiguration) {
$this->secondCacheConfig = $secondCacheConfig;
}
}
return $this->secondCacheConfig;
}
|
php
|
protected function getSecondLevelCacheConfiguration()
{
if (!$this->secondCacheConfig instanceof CacheConfiguration) {
$secondCacheConfig = $this->getOption('second_level_cache_configuration');
if ($secondCacheConfig instanceof CacheConfiguration) {
$this->secondCacheConfig = $secondCacheConfig;
}
}
return $this->secondCacheConfig;
}
|
[
"protected",
"function",
"getSecondLevelCacheConfiguration",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"secondCacheConfig",
"instanceof",
"CacheConfiguration",
")",
"{",
"$",
"secondCacheConfig",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'second_level_cache_configuration'",
")",
";",
"if",
"(",
"$",
"secondCacheConfig",
"instanceof",
"CacheConfiguration",
")",
"{",
"$",
"this",
"->",
"secondCacheConfig",
"=",
"$",
"secondCacheConfig",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"secondCacheConfig",
";",
"}"
] |
Retrieve second level cache configuration.
@return CacheConfiguration|null
|
[
"Retrieve",
"second",
"level",
"cache",
"configuration",
"."
] |
9c63bc689e4084f06be4d119f2c56f6040453d0e
|
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/RelationalBuilder.php#L438-L449
|
train
|
juliangut/doctrine-manager-builder
|
src/RelationalBuilder.php
|
RelationalBuilder.getSQLLogger
|
protected function getSQLLogger()
{
if (!$this->SQLLogger instanceof SQLLogger) {
$sqlLogger = $this->getOption('sql_logger');
if ($sqlLogger instanceof SQLLogger) {
$this->SQLLogger = $sqlLogger;
}
}
return $this->SQLLogger;
}
|
php
|
protected function getSQLLogger()
{
if (!$this->SQLLogger instanceof SQLLogger) {
$sqlLogger = $this->getOption('sql_logger');
if ($sqlLogger instanceof SQLLogger) {
$this->SQLLogger = $sqlLogger;
}
}
return $this->SQLLogger;
}
|
[
"protected",
"function",
"getSQLLogger",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"SQLLogger",
"instanceof",
"SQLLogger",
")",
"{",
"$",
"sqlLogger",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'sql_logger'",
")",
";",
"if",
"(",
"$",
"sqlLogger",
"instanceof",
"SQLLogger",
")",
"{",
"$",
"this",
"->",
"SQLLogger",
"=",
"$",
"sqlLogger",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"SQLLogger",
";",
"}"
] |
Retrieve SQL logger.
@return SQLLogger|null
|
[
"Retrieve",
"SQL",
"logger",
"."
] |
9c63bc689e4084f06be4d119f2c56f6040453d0e
|
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/RelationalBuilder.php#L456-L467
|
train
|
juliangut/doctrine-manager-builder
|
src/RelationalBuilder.php
|
RelationalBuilder.getCustomStringFunctions
|
protected function getCustomStringFunctions()
{
$functions = (array) $this->getOption('custom_string_functions');
return array_filter(
$functions,
function ($name) {
return is_string($name);
},
ARRAY_FILTER_USE_KEY
);
}
|
php
|
protected function getCustomStringFunctions()
{
$functions = (array) $this->getOption('custom_string_functions');
return array_filter(
$functions,
function ($name) {
return is_string($name);
},
ARRAY_FILTER_USE_KEY
);
}
|
[
"protected",
"function",
"getCustomStringFunctions",
"(",
")",
"{",
"$",
"functions",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"getOption",
"(",
"'custom_string_functions'",
")",
";",
"return",
"array_filter",
"(",
"$",
"functions",
",",
"function",
"(",
"$",
"name",
")",
"{",
"return",
"is_string",
"(",
"$",
"name",
")",
";",
"}",
",",
"ARRAY_FILTER_USE_KEY",
")",
";",
"}"
] |
Retrieve custom DQL string functions.
@return array
|
[
"Retrieve",
"custom",
"DQL",
"string",
"functions",
"."
] |
9c63bc689e4084f06be4d119f2c56f6040453d0e
|
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/RelationalBuilder.php#L474-L485
|
train
|
juliangut/doctrine-manager-builder
|
src/RelationalBuilder.php
|
RelationalBuilder.getCustomNumericFunctions
|
protected function getCustomNumericFunctions()
{
$functions = (array) $this->getOption('custom_numeric_functions');
return array_filter(
$functions,
function ($name) {
return is_string($name);
},
ARRAY_FILTER_USE_KEY
);
}
|
php
|
protected function getCustomNumericFunctions()
{
$functions = (array) $this->getOption('custom_numeric_functions');
return array_filter(
$functions,
function ($name) {
return is_string($name);
},
ARRAY_FILTER_USE_KEY
);
}
|
[
"protected",
"function",
"getCustomNumericFunctions",
"(",
")",
"{",
"$",
"functions",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"getOption",
"(",
"'custom_numeric_functions'",
")",
";",
"return",
"array_filter",
"(",
"$",
"functions",
",",
"function",
"(",
"$",
"name",
")",
"{",
"return",
"is_string",
"(",
"$",
"name",
")",
";",
"}",
",",
"ARRAY_FILTER_USE_KEY",
")",
";",
"}"
] |
Retrieve custom DQL numeric functions.
@return array
|
[
"Retrieve",
"custom",
"DQL",
"numeric",
"functions",
"."
] |
9c63bc689e4084f06be4d119f2c56f6040453d0e
|
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/RelationalBuilder.php#L492-L503
|
train
|
juliangut/doctrine-manager-builder
|
src/RelationalBuilder.php
|
RelationalBuilder.getCustomDateTimeFunctions
|
protected function getCustomDateTimeFunctions()
{
$functions = (array) $this->getOption('custom_datetime_functions');
return array_filter(
$functions,
function ($name) {
return is_string($name);
},
ARRAY_FILTER_USE_KEY
);
}
|
php
|
protected function getCustomDateTimeFunctions()
{
$functions = (array) $this->getOption('custom_datetime_functions');
return array_filter(
$functions,
function ($name) {
return is_string($name);
},
ARRAY_FILTER_USE_KEY
);
}
|
[
"protected",
"function",
"getCustomDateTimeFunctions",
"(",
")",
"{",
"$",
"functions",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"getOption",
"(",
"'custom_datetime_functions'",
")",
";",
"return",
"array_filter",
"(",
"$",
"functions",
",",
"function",
"(",
"$",
"name",
")",
"{",
"return",
"is_string",
"(",
"$",
"name",
")",
";",
"}",
",",
"ARRAY_FILTER_USE_KEY",
")",
";",
"}"
] |
Retrieve custom DQL date time functions.
@return array
|
[
"Retrieve",
"custom",
"DQL",
"date",
"time",
"functions",
"."
] |
9c63bc689e4084f06be4d119f2c56f6040453d0e
|
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/RelationalBuilder.php#L510-L521
|
train
|
juliangut/doctrine-manager-builder
|
src/RelationalBuilder.php
|
RelationalBuilder.getCustomTypes
|
protected function getCustomTypes()
{
$types = (array) $this->getOption('custom_types');
return array_filter(
$types,
function ($name) {
return is_string($name);
},
ARRAY_FILTER_USE_KEY
);
}
|
php
|
protected function getCustomTypes()
{
$types = (array) $this->getOption('custom_types');
return array_filter(
$types,
function ($name) {
return is_string($name);
},
ARRAY_FILTER_USE_KEY
);
}
|
[
"protected",
"function",
"getCustomTypes",
"(",
")",
"{",
"$",
"types",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"getOption",
"(",
"'custom_types'",
")",
";",
"return",
"array_filter",
"(",
"$",
"types",
",",
"function",
"(",
"$",
"name",
")",
"{",
"return",
"is_string",
"(",
"$",
"name",
")",
";",
"}",
",",
"ARRAY_FILTER_USE_KEY",
")",
";",
"}"
] |
Retrieve custom DBAL types.
@return array
|
[
"Retrieve",
"custom",
"DBAL",
"types",
"."
] |
9c63bc689e4084f06be4d119f2c56f6040453d0e
|
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/RelationalBuilder.php#L528-L539
|
train
|
juliangut/doctrine-manager-builder
|
src/RelationalBuilder.php
|
RelationalBuilder.getCustomMappingTypes
|
protected function getCustomMappingTypes()
{
$mappingTypes = (array) $this->getOption('custom_mapping_types');
return array_filter(
$mappingTypes,
function ($name) {
return is_string($name);
},
ARRAY_FILTER_USE_KEY
);
}
|
php
|
protected function getCustomMappingTypes()
{
$mappingTypes = (array) $this->getOption('custom_mapping_types');
return array_filter(
$mappingTypes,
function ($name) {
return is_string($name);
},
ARRAY_FILTER_USE_KEY
);
}
|
[
"protected",
"function",
"getCustomMappingTypes",
"(",
")",
"{",
"$",
"mappingTypes",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"getOption",
"(",
"'custom_mapping_types'",
")",
";",
"return",
"array_filter",
"(",
"$",
"mappingTypes",
",",
"function",
"(",
"$",
"name",
")",
"{",
"return",
"is_string",
"(",
"$",
"name",
")",
";",
"}",
",",
"ARRAY_FILTER_USE_KEY",
")",
";",
"}"
] |
Retrieve custom DBAL mapping types.
@return array
|
[
"Retrieve",
"custom",
"DBAL",
"mapping",
"types",
"."
] |
9c63bc689e4084f06be4d119f2c56f6040453d0e
|
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/RelationalBuilder.php#L546-L557
|
train
|
juliangut/doctrine-manager-builder
|
src/RelationalBuilder.php
|
RelationalBuilder.getCustomFilters
|
protected function getCustomFilters()
{
$filters = (array) $this->getOption('custom_filters');
return array_filter(
$filters,
function ($name) {
return is_string($name);
},
ARRAY_FILTER_USE_KEY
);
}
|
php
|
protected function getCustomFilters()
{
$filters = (array) $this->getOption('custom_filters');
return array_filter(
$filters,
function ($name) {
return is_string($name);
},
ARRAY_FILTER_USE_KEY
);
}
|
[
"protected",
"function",
"getCustomFilters",
"(",
")",
"{",
"$",
"filters",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"getOption",
"(",
"'custom_filters'",
")",
";",
"return",
"array_filter",
"(",
"$",
"filters",
",",
"function",
"(",
"$",
"name",
")",
"{",
"return",
"is_string",
"(",
"$",
"name",
")",
";",
"}",
",",
"ARRAY_FILTER_USE_KEY",
")",
";",
"}"
] |
Get custom registered filters.
@return array
|
[
"Get",
"custom",
"registered",
"filters",
"."
] |
9c63bc689e4084f06be4d119f2c56f6040453d0e
|
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/RelationalBuilder.php#L564-L575
|
train
|
juliangut/doctrine-manager-builder
|
src/RelationalBuilder.php
|
RelationalBuilder.getConsoleHelperSet
|
protected function getConsoleHelperSet()
{
/* @var EntityManager $entityManager */
$entityManager = $this->getManager();
return new HelperSet([
'db' => new ConnectionHelper($entityManager->getConnection()),
'em' => new EntityManagerHelper($entityManager),
]);
}
|
php
|
protected function getConsoleHelperSet()
{
/* @var EntityManager $entityManager */
$entityManager = $this->getManager();
return new HelperSet([
'db' => new ConnectionHelper($entityManager->getConnection()),
'em' => new EntityManagerHelper($entityManager),
]);
}
|
[
"protected",
"function",
"getConsoleHelperSet",
"(",
")",
"{",
"/* @var EntityManager $entityManager */",
"$",
"entityManager",
"=",
"$",
"this",
"->",
"getManager",
"(",
")",
";",
"return",
"new",
"HelperSet",
"(",
"[",
"'db'",
"=>",
"new",
"ConnectionHelper",
"(",
"$",
"entityManager",
"->",
"getConnection",
"(",
")",
")",
",",
"'em'",
"=>",
"new",
"EntityManagerHelper",
"(",
"$",
"entityManager",
")",
",",
"]",
")",
";",
"}"
] |
Get console helper set.
@return \Symfony\Component\Console\Helper\HelperSet
|
[
"Get",
"console",
"helper",
"set",
"."
] |
9c63bc689e4084f06be4d119f2c56f6040453d0e
|
https://github.com/juliangut/doctrine-manager-builder/blob/9c63bc689e4084f06be4d119f2c56f6040453d0e/src/RelationalBuilder.php#L651-L660
|
train
|
Phauthentic/password-hashers
|
src/AbstractPasswordHasher.php
|
AbstractPasswordHasher.setSalt
|
public function setSalt(string $salt, string $position = self::SALT_AFTER): self
{
$this->checkSaltPositionArgument($position);
$this->salt = $salt;
$this->saltPosition = $position;
return $this;
}
|
php
|
public function setSalt(string $salt, string $position = self::SALT_AFTER): self
{
$this->checkSaltPositionArgument($position);
$this->salt = $salt;
$this->saltPosition = $position;
return $this;
}
|
[
"public",
"function",
"setSalt",
"(",
"string",
"$",
"salt",
",",
"string",
"$",
"position",
"=",
"self",
"::",
"SALT_AFTER",
")",
":",
"self",
"{",
"$",
"this",
"->",
"checkSaltPositionArgument",
"(",
"$",
"position",
")",
";",
"$",
"this",
"->",
"salt",
"=",
"$",
"salt",
";",
"$",
"this",
"->",
"saltPosition",
"=",
"$",
"position",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the salt if any was used
@return $this
|
[
"Sets",
"the",
"salt",
"if",
"any",
"was",
"used"
] |
c0679d51c941d8808ae143a20e63daab2d4388ec
|
https://github.com/Phauthentic/password-hashers/blob/c0679d51c941d8808ae143a20e63daab2d4388ec/src/AbstractPasswordHasher.php#L46-L53
|
train
|
Phauthentic/password-hashers
|
src/AbstractPasswordHasher.php
|
AbstractPasswordHasher.checkSaltPositionArgument
|
protected function checkSaltPositionArgument($position): void
{
if (!in_array($position, [self::SALT_BEFORE, self::SALT_AFTER])) {
throw new InvalidArgumentException(sprintf(
'`%s` is an invalud argument, it has to be `` or ``',
$position,
self::SALT_BEFORE,
self::SALT_AFTER
));
}
}
|
php
|
protected function checkSaltPositionArgument($position): void
{
if (!in_array($position, [self::SALT_BEFORE, self::SALT_AFTER])) {
throw new InvalidArgumentException(sprintf(
'`%s` is an invalud argument, it has to be `` or ``',
$position,
self::SALT_BEFORE,
self::SALT_AFTER
));
}
}
|
[
"protected",
"function",
"checkSaltPositionArgument",
"(",
"$",
"position",
")",
":",
"void",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"position",
",",
"[",
"self",
"::",
"SALT_BEFORE",
",",
"self",
"::",
"SALT_AFTER",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'`%s` is an invalud argument, it has to be `` or ``'",
",",
"$",
"position",
",",
"self",
"::",
"SALT_BEFORE",
",",
"self",
"::",
"SALT_AFTER",
")",
")",
";",
"}",
"}"
] |
Checks the salt position argument
@return void
|
[
"Checks",
"the",
"salt",
"position",
"argument"
] |
c0679d51c941d8808ae143a20e63daab2d4388ec
|
https://github.com/Phauthentic/password-hashers/blob/c0679d51c941d8808ae143a20e63daab2d4388ec/src/AbstractPasswordHasher.php#L60-L70
|
train
|
PhoxPHP/Glider
|
src/Platform/Pdo/PdoProvider.php
|
PdoProvider.queryBuilder
|
public function queryBuilder(ConnectionInterface $connection, String $connectionId=null) : QueryBuilderProvider
{
return new PdoQueryBuilder($connection, $connectionId);
}
|
php
|
public function queryBuilder(ConnectionInterface $connection, String $connectionId=null) : QueryBuilderProvider
{
return new PdoQueryBuilder($connection, $connectionId);
}
|
[
"public",
"function",
"queryBuilder",
"(",
"ConnectionInterface",
"$",
"connection",
",",
"String",
"$",
"connectionId",
"=",
"null",
")",
":",
"QueryBuilderProvider",
"{",
"return",
"new",
"PdoQueryBuilder",
"(",
"$",
"connection",
",",
"$",
"connectionId",
")",
";",
"}"
] |
We're using pdo query builder.
{@inheritDoc}
|
[
"We",
"re",
"using",
"pdo",
"query",
"builder",
"."
] |
17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042
|
https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Platform/Pdo/PdoProvider.php#L99-L102
|
train
|
gplcart/file_manager
|
handlers/validators/Copy.php
|
Copy.validateDestinationNameCopy
|
protected function validateDestinationNameCopy()
{
$destination = $this->getSubmitted('destination');
if ($destination !== '' && preg_match('/^[\w-]+[\w-\/]*[\w-]+$|^[\w-]$/', $destination) !== 1) {
$this->setErrorInvalid('destination', $this->translation->text('Destination'));
}
}
|
php
|
protected function validateDestinationNameCopy()
{
$destination = $this->getSubmitted('destination');
if ($destination !== '' && preg_match('/^[\w-]+[\w-\/]*[\w-]+$|^[\w-]$/', $destination) !== 1) {
$this->setErrorInvalid('destination', $this->translation->text('Destination'));
}
}
|
[
"protected",
"function",
"validateDestinationNameCopy",
"(",
")",
"{",
"$",
"destination",
"=",
"$",
"this",
"->",
"getSubmitted",
"(",
"'destination'",
")",
";",
"if",
"(",
"$",
"destination",
"!==",
"''",
"&&",
"preg_match",
"(",
"'/^[\\w-]+[\\w-\\/]*[\\w-]+$|^[\\w-]$/'",
",",
"$",
"destination",
")",
"!==",
"1",
")",
"{",
"$",
"this",
"->",
"setErrorInvalid",
"(",
"'destination'",
",",
"$",
"this",
"->",
"translation",
"->",
"text",
"(",
"'Destination'",
")",
")",
";",
"}",
"}"
] |
Validates a directory name
|
[
"Validates",
"a",
"directory",
"name"
] |
45424e93eafea75d31af6410ac9cf110f08e500a
|
https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/handlers/validators/Copy.php#L59-L66
|
train
|
gplcart/file_manager
|
handlers/validators/Copy.php
|
Copy.validateDestinationDirectoryCopy
|
protected function validateDestinationDirectoryCopy()
{
if ($this->isError()) {
return null;
}
$initial_path = $this->scanner->getInitialPath(true);
$directory = gplcart_path_normalize("$initial_path/" . $this->getSubmitted('destination'));
if (!file_exists($directory) && !mkdir($directory, 0777, true)) {
$this->setError('destination', $this->translation->text('Destination does not exist'));
return false;
}
if (!is_dir($directory)) {
$this->setError('destination', $this->translation->text('Destination is not a directory'));
return false;
}
if (!is_writable($directory)) {
$this->setError('destination', $this->translation->text('Directory is not writable'));
return false;
}
$this->setSubmitted('directory', $directory);
return true;
}
|
php
|
protected function validateDestinationDirectoryCopy()
{
if ($this->isError()) {
return null;
}
$initial_path = $this->scanner->getInitialPath(true);
$directory = gplcart_path_normalize("$initial_path/" . $this->getSubmitted('destination'));
if (!file_exists($directory) && !mkdir($directory, 0777, true)) {
$this->setError('destination', $this->translation->text('Destination does not exist'));
return false;
}
if (!is_dir($directory)) {
$this->setError('destination', $this->translation->text('Destination is not a directory'));
return false;
}
if (!is_writable($directory)) {
$this->setError('destination', $this->translation->text('Directory is not writable'));
return false;
}
$this->setSubmitted('directory', $directory);
return true;
}
|
[
"protected",
"function",
"validateDestinationDirectoryCopy",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isError",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"initial_path",
"=",
"$",
"this",
"->",
"scanner",
"->",
"getInitialPath",
"(",
"true",
")",
";",
"$",
"directory",
"=",
"gplcart_path_normalize",
"(",
"\"$initial_path/\"",
".",
"$",
"this",
"->",
"getSubmitted",
"(",
"'destination'",
")",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"directory",
")",
"&&",
"!",
"mkdir",
"(",
"$",
"directory",
",",
"0777",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"'destination'",
",",
"$",
"this",
"->",
"translation",
"->",
"text",
"(",
"'Destination does not exist'",
")",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"directory",
")",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"'destination'",
",",
"$",
"this",
"->",
"translation",
"->",
"text",
"(",
"'Destination is not a directory'",
")",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"is_writable",
"(",
"$",
"directory",
")",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"'destination'",
",",
"$",
"this",
"->",
"translation",
"->",
"text",
"(",
"'Directory is not writable'",
")",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"setSubmitted",
"(",
"'directory'",
",",
"$",
"directory",
")",
";",
"return",
"true",
";",
"}"
] |
Validates a destination directory
@return bool
|
[
"Validates",
"a",
"destination",
"directory"
] |
45424e93eafea75d31af6410ac9cf110f08e500a
|
https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/handlers/validators/Copy.php#L72-L98
|
train
|
gplcart/file_manager
|
handlers/validators/Copy.php
|
Copy.validateDestinationExistanceCopy
|
protected function validateDestinationExistanceCopy()
{
if ($this->isError()) {
return null;
}
$destinations = array();
$directory = $this->getSubmitted('directory');
$error = null;
foreach ((array) $this->getSubmitted('files') as $index => $file) {
/* @var $file \SplFileInfo */
if ($file->isDir() && gplcart_path_normalize($file->getRealPath()) === $directory) {
$error = $this->translation->text('Destination already exists');
continue;
}
$destination = "$directory/" . $file->getBasename();
if (file_exists($destination)) {
$error = $this->translation->text('Destination already exists');
continue;
}
$destinations[$index] = $destination;
}
if (isset($error)) {
$this->setError('destination', $error);
} else {
$this->setSubmitted('destinations', $destinations);
}
return true;
}
|
php
|
protected function validateDestinationExistanceCopy()
{
if ($this->isError()) {
return null;
}
$destinations = array();
$directory = $this->getSubmitted('directory');
$error = null;
foreach ((array) $this->getSubmitted('files') as $index => $file) {
/* @var $file \SplFileInfo */
if ($file->isDir() && gplcart_path_normalize($file->getRealPath()) === $directory) {
$error = $this->translation->text('Destination already exists');
continue;
}
$destination = "$directory/" . $file->getBasename();
if (file_exists($destination)) {
$error = $this->translation->text('Destination already exists');
continue;
}
$destinations[$index] = $destination;
}
if (isset($error)) {
$this->setError('destination', $error);
} else {
$this->setSubmitted('destinations', $destinations);
}
return true;
}
|
[
"protected",
"function",
"validateDestinationExistanceCopy",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isError",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"destinations",
"=",
"array",
"(",
")",
";",
"$",
"directory",
"=",
"$",
"this",
"->",
"getSubmitted",
"(",
"'directory'",
")",
";",
"$",
"error",
"=",
"null",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"getSubmitted",
"(",
"'files'",
")",
"as",
"$",
"index",
"=>",
"$",
"file",
")",
"{",
"/* @var $file \\SplFileInfo */",
"if",
"(",
"$",
"file",
"->",
"isDir",
"(",
")",
"&&",
"gplcart_path_normalize",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
")",
"===",
"$",
"directory",
")",
"{",
"$",
"error",
"=",
"$",
"this",
"->",
"translation",
"->",
"text",
"(",
"'Destination already exists'",
")",
";",
"continue",
";",
"}",
"$",
"destination",
"=",
"\"$directory/\"",
".",
"$",
"file",
"->",
"getBasename",
"(",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"destination",
")",
")",
"{",
"$",
"error",
"=",
"$",
"this",
"->",
"translation",
"->",
"text",
"(",
"'Destination already exists'",
")",
";",
"continue",
";",
"}",
"$",
"destinations",
"[",
"$",
"index",
"]",
"=",
"$",
"destination",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"error",
")",
")",
"{",
"$",
"this",
"->",
"setError",
"(",
"'destination'",
",",
"$",
"error",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setSubmitted",
"(",
"'destinations'",
",",
"$",
"destinations",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Validates file destinations
@return boolean
|
[
"Validates",
"file",
"destinations"
] |
45424e93eafea75d31af6410ac9cf110f08e500a
|
https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/handlers/validators/Copy.php#L104-L139
|
train
|
hal-platform/hal-core
|
src/Repository/ApplicationRepository.php
|
ApplicationRepository.getGroupedApplications
|
public function getGroupedApplications()
{
$organizations = $this->getEntityManager()
->getRepository(Organization::class)
->findAll();
$applications = $this->findAll();
usort($applications, $this->applicationSorter());
usort($organizations, $this->organizationSorter());
$grouped = [];
foreach ($organizations as $org) {
$grouped[$org->id()] = [];
}
foreach ($applications as $app) {
$orgID = $app->organization() ? $app->organization()->id() : 'none';
$grouped[$orgID][] = $app;
}
return $grouped;
}
|
php
|
public function getGroupedApplications()
{
$organizations = $this->getEntityManager()
->getRepository(Organization::class)
->findAll();
$applications = $this->findAll();
usort($applications, $this->applicationSorter());
usort($organizations, $this->organizationSorter());
$grouped = [];
foreach ($organizations as $org) {
$grouped[$org->id()] = [];
}
foreach ($applications as $app) {
$orgID = $app->organization() ? $app->organization()->id() : 'none';
$grouped[$orgID][] = $app;
}
return $grouped;
}
|
[
"public",
"function",
"getGroupedApplications",
"(",
")",
"{",
"$",
"organizations",
"=",
"$",
"this",
"->",
"getEntityManager",
"(",
")",
"->",
"getRepository",
"(",
"Organization",
"::",
"class",
")",
"->",
"findAll",
"(",
")",
";",
"$",
"applications",
"=",
"$",
"this",
"->",
"findAll",
"(",
")",
";",
"usort",
"(",
"$",
"applications",
",",
"$",
"this",
"->",
"applicationSorter",
"(",
")",
")",
";",
"usort",
"(",
"$",
"organizations",
",",
"$",
"this",
"->",
"organizationSorter",
"(",
")",
")",
";",
"$",
"grouped",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"organizations",
"as",
"$",
"org",
")",
"{",
"$",
"grouped",
"[",
"$",
"org",
"->",
"id",
"(",
")",
"]",
"=",
"[",
"]",
";",
"}",
"foreach",
"(",
"$",
"applications",
"as",
"$",
"app",
")",
"{",
"$",
"orgID",
"=",
"$",
"app",
"->",
"organization",
"(",
")",
"?",
"$",
"app",
"->",
"organization",
"(",
")",
"->",
"id",
"(",
")",
":",
"'none'",
";",
"$",
"grouped",
"[",
"$",
"orgID",
"]",
"[",
"]",
"=",
"$",
"app",
";",
"}",
"return",
"$",
"grouped",
";",
"}"
] |
Get all applications sorted into organizations.
@return array
|
[
"Get",
"all",
"applications",
"sorted",
"into",
"organizations",
"."
] |
30d456f8392fc873301ad4217d2ae90436c67090
|
https://github.com/hal-platform/hal-core/blob/30d456f8392fc873301ad4217d2ae90436c67090/src/Repository/ApplicationRepository.php#L33-L55
|
train
|
rujiali/acquia-site-factory-cli
|
src/AppBundle/Connector/ConnectorThemes.php
|
ConnectorThemes.sendNotification
|
public function sendNotification($scope, $event, $nid = null, $theme = null, $timestamp = null, $uid = null)
{
if ($this->connector->getURL() === null) {
return 'Cannot find site URL from configuration.';
}
$url = $this->connector->getURL().self::VERSION.'/notification';
$params = [
'scope' => $scope,
'event' => $event,
'nid' => $nid,
'theme' => $theme,
'timestamp' => $timestamp,
'uid' => $uid,
];
$response = $this->connector->connecting($url, $params, 'POST');
if (isset($response->notification)) {
return $response->message;
}
return $response;
}
|
php
|
public function sendNotification($scope, $event, $nid = null, $theme = null, $timestamp = null, $uid = null)
{
if ($this->connector->getURL() === null) {
return 'Cannot find site URL from configuration.';
}
$url = $this->connector->getURL().self::VERSION.'/notification';
$params = [
'scope' => $scope,
'event' => $event,
'nid' => $nid,
'theme' => $theme,
'timestamp' => $timestamp,
'uid' => $uid,
];
$response = $this->connector->connecting($url, $params, 'POST');
if (isset($response->notification)) {
return $response->message;
}
return $response;
}
|
[
"public",
"function",
"sendNotification",
"(",
"$",
"scope",
",",
"$",
"event",
",",
"$",
"nid",
"=",
"null",
",",
"$",
"theme",
"=",
"null",
",",
"$",
"timestamp",
"=",
"null",
",",
"$",
"uid",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"connector",
"->",
"getURL",
"(",
")",
"===",
"null",
")",
"{",
"return",
"'Cannot find site URL from configuration.'",
";",
"}",
"$",
"url",
"=",
"$",
"this",
"->",
"connector",
"->",
"getURL",
"(",
")",
".",
"self",
"::",
"VERSION",
".",
"'/notification'",
";",
"$",
"params",
"=",
"[",
"'scope'",
"=>",
"$",
"scope",
",",
"'event'",
"=>",
"$",
"event",
",",
"'nid'",
"=>",
"$",
"nid",
",",
"'theme'",
"=>",
"$",
"theme",
",",
"'timestamp'",
"=>",
"$",
"timestamp",
",",
"'uid'",
"=>",
"$",
"uid",
",",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"connector",
"->",
"connecting",
"(",
"$",
"url",
",",
"$",
"params",
",",
"'POST'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"response",
"->",
"notification",
")",
")",
"{",
"return",
"$",
"response",
"->",
"message",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
Send theme notification.
@param string $scope The scope.
@param string $event The event.
@param null $nid The node ID of the related entity (site or group).
@param null $theme The system name of the theme.
@param null $timestamp A Unix timestamp of when the event occurred.
@param null $uid The user id owning the notification and who should get notified if an error occurs during processing.
@return mixed|string
|
[
"Send",
"theme",
"notification",
"."
] |
c9dbb9dfd71408adff0ea26db94678a61c584df6
|
https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorThemes.php#L40-L60
|
train
|
rujiali/acquia-site-factory-cli
|
src/AppBundle/Connector/ConnectorThemes.php
|
ConnectorThemes.processModification
|
public function processModification($siteGroupId = null)
{
if ($this->connector->getURL() === null) {
return 'Cannot find site URL from configuration.';
}
$url = $this->connector->getURL().self::VERSION.'/process';
$params = [
'sitegroup_id' => $siteGroupId,
];
$response = $this->connector->connecting($url, $params, 'POST');
if (isset($response->sitegroups)) {
return $response->message;
}
return $response;
}
|
php
|
public function processModification($siteGroupId = null)
{
if ($this->connector->getURL() === null) {
return 'Cannot find site URL from configuration.';
}
$url = $this->connector->getURL().self::VERSION.'/process';
$params = [
'sitegroup_id' => $siteGroupId,
];
$response = $this->connector->connecting($url, $params, 'POST');
if (isset($response->sitegroups)) {
return $response->message;
}
return $response;
}
|
[
"public",
"function",
"processModification",
"(",
"$",
"siteGroupId",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"connector",
"->",
"getURL",
"(",
")",
"===",
"null",
")",
"{",
"return",
"'Cannot find site URL from configuration.'",
";",
"}",
"$",
"url",
"=",
"$",
"this",
"->",
"connector",
"->",
"getURL",
"(",
")",
".",
"self",
"::",
"VERSION",
".",
"'/process'",
";",
"$",
"params",
"=",
"[",
"'sitegroup_id'",
"=>",
"$",
"siteGroupId",
",",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"connector",
"->",
"connecting",
"(",
"$",
"url",
",",
"$",
"params",
",",
"'POST'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"response",
"->",
"sitegroups",
")",
")",
"{",
"return",
"$",
"response",
"->",
"message",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
Process theme modification.
@param string $siteGroupId Site group ID.
@return mixed|string
|
[
"Process",
"theme",
"modification",
"."
] |
c9dbb9dfd71408adff0ea26db94678a61c584df6
|
https://github.com/rujiali/acquia-site-factory-cli/blob/c9dbb9dfd71408adff0ea26db94678a61c584df6/src/AppBundle/Connector/ConnectorThemes.php#L69-L84
|
train
|
matryoshka-model/matryoshka
|
library/ResultSet/ArrayObjectResultSet.php
|
ArrayObjectResultSet.setObjectPrototype
|
public function setObjectPrototype($objectPrototype)
{
if (!is_object($objectPrototype)
|| (!$objectPrototype instanceof ArrayObject && !method_exists($objectPrototype, 'exchangeArray'))
) {
throw new Exception\InvalidArgumentException(sprintf(
'Object must be of type %s, or at least implement %s',
'ArrayObject',
'exchangeArray'
));
}
$this->arrayObjectPrototype = $objectPrototype;
return $this;
}
|
php
|
public function setObjectPrototype($objectPrototype)
{
if (!is_object($objectPrototype)
|| (!$objectPrototype instanceof ArrayObject && !method_exists($objectPrototype, 'exchangeArray'))
) {
throw new Exception\InvalidArgumentException(sprintf(
'Object must be of type %s, or at least implement %s',
'ArrayObject',
'exchangeArray'
));
}
$this->arrayObjectPrototype = $objectPrototype;
return $this;
}
|
[
"public",
"function",
"setObjectPrototype",
"(",
"$",
"objectPrototype",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"objectPrototype",
")",
"||",
"(",
"!",
"$",
"objectPrototype",
"instanceof",
"ArrayObject",
"&&",
"!",
"method_exists",
"(",
"$",
"objectPrototype",
",",
"'exchangeArray'",
")",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Object must be of type %s, or at least implement %s'",
",",
"'ArrayObject'",
",",
"'exchangeArray'",
")",
")",
";",
"}",
"$",
"this",
"->",
"arrayObjectPrototype",
"=",
"$",
"objectPrototype",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the item object prototype
@param object $objectPrototype
@throws Exception\InvalidArgumentException
@return ResultSetInterface
|
[
"Set",
"the",
"item",
"object",
"prototype"
] |
51792df00d9897f556d5a3c53193eed0974ff09d
|
https://github.com/matryoshka-model/matryoshka/blob/51792df00d9897f556d5a3c53193eed0974ff09d/library/ResultSet/ArrayObjectResultSet.php#L41-L55
|
train
|
martinvium/seine
|
src/Seine/Parser/DOM/DOMFactory.php
|
DOMFactory.getConfiguredWriter
|
public function getConfiguredWriter($fp, Configuration $config = null)
{
if(! $config) {
$config = $this->config;
}
$writerName = $config->getOption(Configuration::OPT_WRITER);
if(! $writerName) {
throw new \Exception('Writer must be defined in config for getConfiguredWriter()');
}
$writer = $this->getWriterByName($fp, $writerName);
$writer->setAutoCloseStream($config->getOption(Configuration::OPT_AUTO_CLOSE_STREAM, false));
$writer->setConfig($config);
return $writer;
}
|
php
|
public function getConfiguredWriter($fp, Configuration $config = null)
{
if(! $config) {
$config = $this->config;
}
$writerName = $config->getOption(Configuration::OPT_WRITER);
if(! $writerName) {
throw new \Exception('Writer must be defined in config for getConfiguredWriter()');
}
$writer = $this->getWriterByName($fp, $writerName);
$writer->setAutoCloseStream($config->getOption(Configuration::OPT_AUTO_CLOSE_STREAM, false));
$writer->setConfig($config);
return $writer;
}
|
[
"public",
"function",
"getConfiguredWriter",
"(",
"$",
"fp",
",",
"Configuration",
"$",
"config",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"config",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
";",
"}",
"$",
"writerName",
"=",
"$",
"config",
"->",
"getOption",
"(",
"Configuration",
"::",
"OPT_WRITER",
")",
";",
"if",
"(",
"!",
"$",
"writerName",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Writer must be defined in config for getConfiguredWriter()'",
")",
";",
"}",
"$",
"writer",
"=",
"$",
"this",
"->",
"getWriterByName",
"(",
"$",
"fp",
",",
"$",
"writerName",
")",
";",
"$",
"writer",
"->",
"setAutoCloseStream",
"(",
"$",
"config",
"->",
"getOption",
"(",
"Configuration",
"::",
"OPT_AUTO_CLOSE_STREAM",
",",
"false",
")",
")",
";",
"$",
"writer",
"->",
"setConfig",
"(",
"$",
"config",
")",
";",
"return",
"$",
"writer",
";",
"}"
] |
Get a writer configured using the default configuration or the one passed in.
@param stream $fp
@param Configuration $config
@return Writer
|
[
"Get",
"a",
"writer",
"configured",
"using",
"the",
"default",
"configuration",
"or",
"the",
"one",
"passed",
"in",
"."
] |
b361241c88bb73e81c66259f59193b175223c2eb
|
https://github.com/martinvium/seine/blob/b361241c88bb73e81c66259f59193b175223c2eb/src/Seine/Parser/DOM/DOMFactory.php#L142-L157
|
train
|
martinvium/seine
|
src/Seine/Parser/DOM/DOMFactory.php
|
DOMFactory.getWriterByName
|
public function getWriterByName($fp, $writerName)
{
$method = 'get' . $writerName;
if(method_exists($this->getWriterFactory(), $method)) {
return $this->getWriterFactory()->$method($fp);
} else {
throw new \InvalidArgumentException('writer not found: ' . $writerName);
}
}
|
php
|
public function getWriterByName($fp, $writerName)
{
$method = 'get' . $writerName;
if(method_exists($this->getWriterFactory(), $method)) {
return $this->getWriterFactory()->$method($fp);
} else {
throw new \InvalidArgumentException('writer not found: ' . $writerName);
}
}
|
[
"public",
"function",
"getWriterByName",
"(",
"$",
"fp",
",",
"$",
"writerName",
")",
"{",
"$",
"method",
"=",
"'get'",
".",
"$",
"writerName",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
"->",
"getWriterFactory",
"(",
")",
",",
"$",
"method",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getWriterFactory",
"(",
")",
"->",
"$",
"method",
"(",
"$",
"fp",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'writer not found: '",
".",
"$",
"writerName",
")",
";",
"}",
"}"
] |
Get a writer by it's name. The name is looked up in the writer factory prefixed with "get".
@example $writer = $factory->getWriterByName($fp, 'OfficeOpenXML2003StreamWriter');
@param stream $fp
@param string $writerName
@return Writer
|
[
"Get",
"a",
"writer",
"by",
"it",
"s",
"name",
".",
"The",
"name",
"is",
"looked",
"up",
"in",
"the",
"writer",
"factory",
"prefixed",
"with",
"get",
"."
] |
b361241c88bb73e81c66259f59193b175223c2eb
|
https://github.com/martinvium/seine/blob/b361241c88bb73e81c66259f59193b175223c2eb/src/Seine/Parser/DOM/DOMFactory.php#L167-L175
|
train
|
Synapse-Cmf/synapse-cmf
|
src/Synapse/Admin/Bundle/Controller/ImageAdminController.php
|
ImageAdminController.editAction
|
public function editAction(Image $image, Request $request)
{
$form = $this->container->get('form.factory')->createNamed(
'image',
ImageType::class,
$image,
array(
'action' => $this->container->get('router')->generate(
'synapse_admin_image_edition',
array('id' => $image->getId())
),
'method' => 'POST',
'csrf_protection' => false,
)
);
if ($request->request->has('image')) {
$form->handleRequest($request);
if ($form->isValid()) {
return $this->redirect(
$this->container->get('router')->generate(
'synapse_admin_image_edition',
array('id' => $image->getId())
)
);
}
}
return $this->render('SynapseAdminBundle:Image:edit.html.twig', array(
'image' => $image,
'theme' => $request->attributes->get(
'synapse_theme',
$this->container->get('synapse')
->enableDefaultTheme()
->getCurrentTheme()
),
'form' => $form->createView(),
));
}
|
php
|
public function editAction(Image $image, Request $request)
{
$form = $this->container->get('form.factory')->createNamed(
'image',
ImageType::class,
$image,
array(
'action' => $this->container->get('router')->generate(
'synapse_admin_image_edition',
array('id' => $image->getId())
),
'method' => 'POST',
'csrf_protection' => false,
)
);
if ($request->request->has('image')) {
$form->handleRequest($request);
if ($form->isValid()) {
return $this->redirect(
$this->container->get('router')->generate(
'synapse_admin_image_edition',
array('id' => $image->getId())
)
);
}
}
return $this->render('SynapseAdminBundle:Image:edit.html.twig', array(
'image' => $image,
'theme' => $request->attributes->get(
'synapse_theme',
$this->container->get('synapse')
->enableDefaultTheme()
->getCurrentTheme()
),
'form' => $form->createView(),
));
}
|
[
"public",
"function",
"editAction",
"(",
"Image",
"$",
"image",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'form.factory'",
")",
"->",
"createNamed",
"(",
"'image'",
",",
"ImageType",
"::",
"class",
",",
"$",
"image",
",",
"array",
"(",
"'action'",
"=>",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'router'",
")",
"->",
"generate",
"(",
"'synapse_admin_image_edition'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"image",
"->",
"getId",
"(",
")",
")",
")",
",",
"'method'",
"=>",
"'POST'",
",",
"'csrf_protection'",
"=>",
"false",
",",
")",
")",
";",
"if",
"(",
"$",
"request",
"->",
"request",
"->",
"has",
"(",
"'image'",
")",
")",
"{",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'router'",
")",
"->",
"generate",
"(",
"'synapse_admin_image_edition'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"image",
"->",
"getId",
"(",
")",
")",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'SynapseAdminBundle:Image:edit.html.twig'",
",",
"array",
"(",
"'image'",
"=>",
"$",
"image",
",",
"'theme'",
"=>",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'synapse_theme'",
",",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'synapse'",
")",
"->",
"enableDefaultTheme",
"(",
")",
"->",
"getCurrentTheme",
"(",
")",
")",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
")",
";",
"}"
] |
Image edition action.
@param Request $request
@return Response
|
[
"Image",
"edition",
"action",
"."
] |
d8122a4150a83d5607289724425cf35c56a5e880
|
https://github.com/Synapse-Cmf/synapse-cmf/blob/d8122a4150a83d5607289724425cf35c56a5e880/src/Synapse/Admin/Bundle/Controller/ImageAdminController.php#L55-L92
|
train
|
Synapse-Cmf/synapse-cmf
|
src/Synapse/Admin/Bundle/Controller/ImageAdminController.php
|
ImageAdminController.xhrFormatAction
|
public function xhrFormatAction(Image $image, $formatName, Request $request)
{
// retrieve format value object
if (!$format = $this->container->get('synapse.image_format.loader')
->retrieveOne(array('name' => $formatName))
) {
return new JsonResponse(
array(
'error' => 400,
'error_message' => sprintf('No format found with name "%s".', $formatName),
),
400
);
}
// form handle
$form = $this->container->get('form.factory')->createNamed(
'',
FormatType::class,
$image,
array(
'format' => $format,
'method' => 'POST',
'csrf_protection' => false,
)
);
$form->handleRequest($request);
if (!$form->isValid()) {
return new JsonResponse(
array(
'error' => 400,
'error_message' => 'Invalid format data.',
),
400
);
}
// formatted image data
return new JsonResponse(
$form->getData()
->getFormattedImage($formatName)
->normalize(),
201
);
}
|
php
|
public function xhrFormatAction(Image $image, $formatName, Request $request)
{
// retrieve format value object
if (!$format = $this->container->get('synapse.image_format.loader')
->retrieveOne(array('name' => $formatName))
) {
return new JsonResponse(
array(
'error' => 400,
'error_message' => sprintf('No format found with name "%s".', $formatName),
),
400
);
}
// form handle
$form = $this->container->get('form.factory')->createNamed(
'',
FormatType::class,
$image,
array(
'format' => $format,
'method' => 'POST',
'csrf_protection' => false,
)
);
$form->handleRequest($request);
if (!$form->isValid()) {
return new JsonResponse(
array(
'error' => 400,
'error_message' => 'Invalid format data.',
),
400
);
}
// formatted image data
return new JsonResponse(
$form->getData()
->getFormattedImage($formatName)
->normalize(),
201
);
}
|
[
"public",
"function",
"xhrFormatAction",
"(",
"Image",
"$",
"image",
",",
"$",
"formatName",
",",
"Request",
"$",
"request",
")",
"{",
"// retrieve format value object",
"if",
"(",
"!",
"$",
"format",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'synapse.image_format.loader'",
")",
"->",
"retrieveOne",
"(",
"array",
"(",
"'name'",
"=>",
"$",
"formatName",
")",
")",
")",
"{",
"return",
"new",
"JsonResponse",
"(",
"array",
"(",
"'error'",
"=>",
"400",
",",
"'error_message'",
"=>",
"sprintf",
"(",
"'No format found with name \"%s\".'",
",",
"$",
"formatName",
")",
",",
")",
",",
"400",
")",
";",
"}",
"// form handle",
"$",
"form",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'form.factory'",
")",
"->",
"createNamed",
"(",
"''",
",",
"FormatType",
"::",
"class",
",",
"$",
"image",
",",
"array",
"(",
"'format'",
"=>",
"$",
"format",
",",
"'method'",
"=>",
"'POST'",
",",
"'csrf_protection'",
"=>",
"false",
",",
")",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
"new",
"JsonResponse",
"(",
"array",
"(",
"'error'",
"=>",
"400",
",",
"'error_message'",
"=>",
"'Invalid format data.'",
",",
")",
",",
"400",
")",
";",
"}",
"// formatted image data",
"return",
"new",
"JsonResponse",
"(",
"$",
"form",
"->",
"getData",
"(",
")",
"->",
"getFormattedImage",
"(",
"$",
"formatName",
")",
"->",
"normalize",
"(",
")",
",",
"201",
")",
";",
"}"
] |
Image formating action through XmlHttpRequest.
@param Image $image
@param string $formatName
@param Request $request
@return JsonResponse
|
[
"Image",
"formating",
"action",
"through",
"XmlHttpRequest",
"."
] |
d8122a4150a83d5607289724425cf35c56a5e880
|
https://github.com/Synapse-Cmf/synapse-cmf/blob/d8122a4150a83d5607289724425cf35c56a5e880/src/Synapse/Admin/Bundle/Controller/ImageAdminController.php#L103-L147
|
train
|
symfony2admingenerator/FormBundle
|
Twig/Extension/FormExtension.php
|
FormExtension.renderJavascript
|
public function renderJavascript(FormView $view, $prototype = false)
{
$block = $prototype ? 'js_prototype' : 'js';
return $this->renderer->searchAndRenderBlock($view, $block);
}
|
php
|
public function renderJavascript(FormView $view, $prototype = false)
{
$block = $prototype ? 'js_prototype' : 'js';
return $this->renderer->searchAndRenderBlock($view, $block);
}
|
[
"public",
"function",
"renderJavascript",
"(",
"FormView",
"$",
"view",
",",
"$",
"prototype",
"=",
"false",
")",
"{",
"$",
"block",
"=",
"$",
"prototype",
"?",
"'js_prototype'",
":",
"'js'",
";",
"return",
"$",
"this",
"->",
"renderer",
"->",
"searchAndRenderBlock",
"(",
"$",
"view",
",",
"$",
"block",
")",
";",
"}"
] |
Render Function Form Javascript
@param FormView $view
@param bool $prototype
@return string
|
[
"Render",
"Function",
"Form",
"Javascript"
] |
0f0dbf8f0aecc3332daa959771af611f00b35359
|
https://github.com/symfony2admingenerator/FormBundle/blob/0f0dbf8f0aecc3332daa959771af611f00b35359/Twig/Extension/FormExtension.php#L57-L62
|
train
|
Laralum/Tickets
|
src/Controllers/MessageController.php
|
MessageController.confirmDestroy
|
public function confirmDestroy(Message $message)
{
$this->authorize('delete', $message);
return view('laralum::pages.confirmation', [
'method' => 'DELETE',
'message' => __('laralum_tickets::general.sure_del_message', ['id' => $message->id]),
'action' => route('laralum::tickets.messages.destroy', ['message' => $message->id]),
]);
}
|
php
|
public function confirmDestroy(Message $message)
{
$this->authorize('delete', $message);
return view('laralum::pages.confirmation', [
'method' => 'DELETE',
'message' => __('laralum_tickets::general.sure_del_message', ['id' => $message->id]),
'action' => route('laralum::tickets.messages.destroy', ['message' => $message->id]),
]);
}
|
[
"public",
"function",
"confirmDestroy",
"(",
"Message",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'delete'",
",",
"$",
"message",
")",
";",
"return",
"view",
"(",
"'laralum::pages.confirmation'",
",",
"[",
"'method'",
"=>",
"'DELETE'",
",",
"'message'",
"=>",
"__",
"(",
"'laralum_tickets::general.sure_del_message'",
",",
"[",
"'id'",
"=>",
"$",
"message",
"->",
"id",
"]",
")",
",",
"'action'",
"=>",
"route",
"(",
"'laralum::tickets.messages.destroy'",
",",
"[",
"'message'",
"=>",
"$",
"message",
"->",
"id",
"]",
")",
",",
"]",
")",
";",
"}"
] |
View for cofirm delete message.
@param \Laralum\Tickets\Models\Message $message
@return \Illuminate\Http\Response
|
[
"View",
"for",
"cofirm",
"delete",
"message",
"."
] |
834b04e28cc3be285fc0eac1a673f6370079e6d2
|
https://github.com/Laralum/Tickets/blob/834b04e28cc3be285fc0eac1a673f6370079e6d2/src/Controllers/MessageController.php#L98-L107
|
train
|
IftekherSunny/Planet-Framework
|
src/Sun/Container/Container.php
|
Container.make
|
public function make($key, $params = [])
{
if($this->aliasExist($key)) {
return $this->make($this->aliases[$key], $params);
}
if(is_callable($key)) {
return call_user_func_array($key, $this->resolveCallback($key, $params));
}
return $this->resolveClass($key, $params);
}
|
php
|
public function make($key, $params = [])
{
if($this->aliasExist($key)) {
return $this->make($this->aliases[$key], $params);
}
if(is_callable($key)) {
return call_user_func_array($key, $this->resolveCallback($key, $params));
}
return $this->resolveClass($key, $params);
}
|
[
"public",
"function",
"make",
"(",
"$",
"key",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"aliasExist",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"make",
"(",
"$",
"this",
"->",
"aliases",
"[",
"$",
"key",
"]",
",",
"$",
"params",
")",
";",
"}",
"if",
"(",
"is_callable",
"(",
"$",
"key",
")",
")",
"{",
"return",
"call_user_func_array",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"resolveCallback",
"(",
"$",
"key",
",",
"$",
"params",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"resolveClass",
"(",
"$",
"key",
",",
"$",
"params",
")",
";",
"}"
] |
Resolved dependencies for a key.
@param string $key
@param array $params
@return object
@throws Exception
|
[
"Resolved",
"dependencies",
"for",
"a",
"key",
"."
] |
530e772fb97695c1c4e1af73f81675f189474d9f
|
https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Container/Container.php#L38-L49
|
train
|
IftekherSunny/Planet-Framework
|
src/Sun/Container/Container.php
|
Container.need
|
public function need($key)
{
if(!isset($this->resolved[$key])) {
return $this->make($key);
}
return $this->resolved[$key];
}
|
php
|
public function need($key)
{
if(!isset($this->resolved[$key])) {
return $this->make($key);
}
return $this->resolved[$key];
}
|
[
"public",
"function",
"need",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"resolved",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"make",
"(",
"$",
"key",
")",
";",
"}",
"return",
"$",
"this",
"->",
"resolved",
"[",
"$",
"key",
"]",
";",
"}"
] |
Get the resolved type for a key that already resolved by the container.
If the key does not resolve, at first resolved it,
then returns the resolved type.
@param string $key
@return mixed
|
[
"Get",
"the",
"resolved",
"type",
"for",
"a",
"key",
"that",
"already",
"resolved",
"by",
"the",
"container",
".",
"If",
"the",
"key",
"does",
"not",
"resolve",
"at",
"first",
"resolved",
"it",
"then",
"returns",
"the",
"resolved",
"type",
"."
] |
530e772fb97695c1c4e1af73f81675f189474d9f
|
https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Container/Container.php#L60-L67
|
train
|
IftekherSunny/Planet-Framework
|
src/Sun/Container/Container.php
|
Container.bind
|
public function bind($key, $value)
{
if(is_callable($value)) {
$this->aliases[$key] = $value;
} elseif(is_object($value)) {
$this->resolved[$key] = $value;
} else {
if(class_exists($value)) $this->aliases[$key] = $value;
else throw new Exception("Class [ $value ] does not exist.");
}
}
|
php
|
public function bind($key, $value)
{
if(is_callable($value)) {
$this->aliases[$key] = $value;
} elseif(is_object($value)) {
$this->resolved[$key] = $value;
} else {
if(class_exists($value)) $this->aliases[$key] = $value;
else throw new Exception("Class [ $value ] does not exist.");
}
}
|
[
"public",
"function",
"bind",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"aliases",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"resolved",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"if",
"(",
"class_exists",
"(",
"$",
"value",
")",
")",
"$",
"this",
"->",
"aliases",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"else",
"throw",
"new",
"Exception",
"(",
"\"Class [ $value ] does not exist.\"",
")",
";",
"}",
"}"
] |
Bind a value for a key.
@param string $key
@param string|callback|object $value
@throws Exception
|
[
"Bind",
"a",
"value",
"for",
"a",
"key",
"."
] |
530e772fb97695c1c4e1af73f81675f189474d9f
|
https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Container/Container.php#L77-L87
|
train
|
IftekherSunny/Planet-Framework
|
src/Sun/Container/Container.php
|
Container.resolveCallback
|
public function resolveCallback(Closure $callback, $params = [])
{
$reflectionParameter = new ReflectionFunction($callback);
$dependencies = $reflectionParameter->getParameters();
return $this->getDependencies($dependencies, $params);
}
|
php
|
public function resolveCallback(Closure $callback, $params = [])
{
$reflectionParameter = new ReflectionFunction($callback);
$dependencies = $reflectionParameter->getParameters();
return $this->getDependencies($dependencies, $params);
}
|
[
"public",
"function",
"resolveCallback",
"(",
"Closure",
"$",
"callback",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"reflectionParameter",
"=",
"new",
"ReflectionFunction",
"(",
"$",
"callback",
")",
";",
"$",
"dependencies",
"=",
"$",
"reflectionParameter",
"->",
"getParameters",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getDependencies",
"(",
"$",
"dependencies",
",",
"$",
"params",
")",
";",
"}"
] |
Resolve dependencies for a callback.
@param Closure $callback
@param array $params
@return array
@throws Exception
|
[
"Resolve",
"dependencies",
"for",
"a",
"callback",
"."
] |
530e772fb97695c1c4e1af73f81675f189474d9f
|
https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Container/Container.php#L99-L106
|
train
|
IftekherSunny/Planet-Framework
|
src/Sun/Container/Container.php
|
Container.resolveMethod
|
public function resolveMethod($class, $method, $params = [], $isRoute = false)
{
$reflectionMethod = new ReflectionMethod($class, $method);
$dependencies = $reflectionMethod->getParameters();
return $this->getDependencies($dependencies, $params, $isRoute);
}
|
php
|
public function resolveMethod($class, $method, $params = [], $isRoute = false)
{
$reflectionMethod = new ReflectionMethod($class, $method);
$dependencies = $reflectionMethod->getParameters();
return $this->getDependencies($dependencies, $params, $isRoute);
}
|
[
"public",
"function",
"resolveMethod",
"(",
"$",
"class",
",",
"$",
"method",
",",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"isRoute",
"=",
"false",
")",
"{",
"$",
"reflectionMethod",
"=",
"new",
"ReflectionMethod",
"(",
"$",
"class",
",",
"$",
"method",
")",
";",
"$",
"dependencies",
"=",
"$",
"reflectionMethod",
"->",
"getParameters",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getDependencies",
"(",
"$",
"dependencies",
",",
"$",
"params",
",",
"$",
"isRoute",
")",
";",
"}"
] |
Resolve dependencies for a method.
@param string $class
@param string $method
@param array $params
@param bool $isRoute
@return array
|
[
"Resolve",
"dependencies",
"for",
"a",
"method",
"."
] |
530e772fb97695c1c4e1af73f81675f189474d9f
|
https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Container/Container.php#L118-L125
|
train
|
IftekherSunny/Planet-Framework
|
src/Sun/Container/Container.php
|
Container.resolveClass
|
public function resolveClass($name, $params = [])
{
$reflectionClass = new ReflectionClass($name);
if (!$reflectionClass->isInstantiable()) {
throw new Exception("The [ {$name} ] is not instantiable.");
}
$constructor = $reflectionClass->getConstructor();
if (!is_null($constructor)) {
$dependencies = $constructor->getParameters();
$resolving = $this->getDependencies($dependencies, $params);
$instance = $reflectionClass->newInstanceArgs($resolving);
return $this->resolved[$name] = $this->getInstanceWithAppProperty($instance);
}
$instance = new $name;
return $this->resolved[$name] = $this->getInstanceWithAppProperty($instance);
}
|
php
|
public function resolveClass($name, $params = [])
{
$reflectionClass = new ReflectionClass($name);
if (!$reflectionClass->isInstantiable()) {
throw new Exception("The [ {$name} ] is not instantiable.");
}
$constructor = $reflectionClass->getConstructor();
if (!is_null($constructor)) {
$dependencies = $constructor->getParameters();
$resolving = $this->getDependencies($dependencies, $params);
$instance = $reflectionClass->newInstanceArgs($resolving);
return $this->resolved[$name] = $this->getInstanceWithAppProperty($instance);
}
$instance = new $name;
return $this->resolved[$name] = $this->getInstanceWithAppProperty($instance);
}
|
[
"public",
"function",
"resolveClass",
"(",
"$",
"name",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"reflectionClass",
"=",
"new",
"ReflectionClass",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"$",
"reflectionClass",
"->",
"isInstantiable",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"The [ {$name} ] is not instantiable.\"",
")",
";",
"}",
"$",
"constructor",
"=",
"$",
"reflectionClass",
"->",
"getConstructor",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"constructor",
")",
")",
"{",
"$",
"dependencies",
"=",
"$",
"constructor",
"->",
"getParameters",
"(",
")",
";",
"$",
"resolving",
"=",
"$",
"this",
"->",
"getDependencies",
"(",
"$",
"dependencies",
",",
"$",
"params",
")",
";",
"$",
"instance",
"=",
"$",
"reflectionClass",
"->",
"newInstanceArgs",
"(",
"$",
"resolving",
")",
";",
"return",
"$",
"this",
"->",
"resolved",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"getInstanceWithAppProperty",
"(",
"$",
"instance",
")",
";",
"}",
"$",
"instance",
"=",
"new",
"$",
"name",
";",
"return",
"$",
"this",
"->",
"resolved",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"getInstanceWithAppProperty",
"(",
"$",
"instance",
")",
";",
"}"
] |
Resolve dependencies for a class.
@param string $name
@param array $params
@return object
@throws Exception
|
[
"Resolve",
"dependencies",
"for",
"a",
"class",
"."
] |
530e772fb97695c1c4e1af73f81675f189474d9f
|
https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Container/Container.php#L136-L159
|
train
|
IftekherSunny/Planet-Framework
|
src/Sun/Container/Container.php
|
Container.getDependencies
|
protected function getDependencies($dependencies, $params = [], $isRoute = false)
{
$resolving = [];
foreach ($dependencies as $dependency) {
if ($dependency->isDefaultValueAvailable()) {
$resolving = $this->getDependencyDefaultValue($dependency, $params, $resolving, $isRoute);
} elseif(isset($params[$dependency->name])) {
$resolving[] = $params[$dependency->name];
} else {
if ($dependency->getClass() === null) {
throw new Exception("The [ $" . "{$dependency->name} ] is not instantiable.");
}
$className = $dependency->getClass()->name;
if (!isset($this->resolved[$className])) {
$this->resolved[$className] = $this->make($className);
$resolving[] = $this->resolved[$className];
} else {
$resolving[] = $this->resolved[$className];
}
}
}
return $resolving;
}
|
php
|
protected function getDependencies($dependencies, $params = [], $isRoute = false)
{
$resolving = [];
foreach ($dependencies as $dependency) {
if ($dependency->isDefaultValueAvailable()) {
$resolving = $this->getDependencyDefaultValue($dependency, $params, $resolving, $isRoute);
} elseif(isset($params[$dependency->name])) {
$resolving[] = $params[$dependency->name];
} else {
if ($dependency->getClass() === null) {
throw new Exception("The [ $" . "{$dependency->name} ] is not instantiable.");
}
$className = $dependency->getClass()->name;
if (!isset($this->resolved[$className])) {
$this->resolved[$className] = $this->make($className);
$resolving[] = $this->resolved[$className];
} else {
$resolving[] = $this->resolved[$className];
}
}
}
return $resolving;
}
|
[
"protected",
"function",
"getDependencies",
"(",
"$",
"dependencies",
",",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"isRoute",
"=",
"false",
")",
"{",
"$",
"resolving",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"dependencies",
"as",
"$",
"dependency",
")",
"{",
"if",
"(",
"$",
"dependency",
"->",
"isDefaultValueAvailable",
"(",
")",
")",
"{",
"$",
"resolving",
"=",
"$",
"this",
"->",
"getDependencyDefaultValue",
"(",
"$",
"dependency",
",",
"$",
"params",
",",
"$",
"resolving",
",",
"$",
"isRoute",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"params",
"[",
"$",
"dependency",
"->",
"name",
"]",
")",
")",
"{",
"$",
"resolving",
"[",
"]",
"=",
"$",
"params",
"[",
"$",
"dependency",
"->",
"name",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"dependency",
"->",
"getClass",
"(",
")",
"===",
"null",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"The [ $\"",
".",
"\"{$dependency->name} ] is not instantiable.\"",
")",
";",
"}",
"$",
"className",
"=",
"$",
"dependency",
"->",
"getClass",
"(",
")",
"->",
"name",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"resolved",
"[",
"$",
"className",
"]",
")",
")",
"{",
"$",
"this",
"->",
"resolved",
"[",
"$",
"className",
"]",
"=",
"$",
"this",
"->",
"make",
"(",
"$",
"className",
")",
";",
"$",
"resolving",
"[",
"]",
"=",
"$",
"this",
"->",
"resolved",
"[",
"$",
"className",
"]",
";",
"}",
"else",
"{",
"$",
"resolving",
"[",
"]",
"=",
"$",
"this",
"->",
"resolved",
"[",
"$",
"className",
"]",
";",
"}",
"}",
"}",
"return",
"$",
"resolving",
";",
"}"
] |
Get all required dependencies.
@param string $dependencies
@param array $params
@param bool $isRoute
@return array
@throws Exception
|
[
"Get",
"all",
"required",
"dependencies",
"."
] |
530e772fb97695c1c4e1af73f81675f189474d9f
|
https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Container/Container.php#L171-L197
|
train
|
IftekherSunny/Planet-Framework
|
src/Sun/Container/Container.php
|
Container.has
|
public function has($key)
{
if(array_key_exists($key, $this->aliases) || array_key_exists($key, $this->resolved)) {
return true;
} else {
return false;
}
}
|
php
|
public function has($key)
{
if(array_key_exists($key, $this->aliases) || array_key_exists($key, $this->resolved)) {
return true;
} else {
return false;
}
}
|
[
"public",
"function",
"has",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"aliases",
")",
"||",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"resolved",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Check a key is already exists.
@param string $key
@return bool
|
[
"Check",
"a",
"key",
"is",
"already",
"exists",
"."
] |
530e772fb97695c1c4e1af73f81675f189474d9f
|
https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Container/Container.php#L206-L213
|
train
|
IftekherSunny/Planet-Framework
|
src/Sun/Container/Container.php
|
Container.getDependencyDefaultValue
|
protected function getDependencyDefaultValue($dependency, $params, $resolving, $isRoute)
{
if ($isRoute) {
if(isset($params[$dependency->name])) {
$resolving[] = $params[$dependency->name];
} else {
$resolving[] = $dependency->getDefaultValue();
}
return $resolving;
} else {
$resolving[] = $dependency->getDefaultValue();
return $resolving;
}
}
|
php
|
protected function getDependencyDefaultValue($dependency, $params, $resolving, $isRoute)
{
if ($isRoute) {
if(isset($params[$dependency->name])) {
$resolving[] = $params[$dependency->name];
} else {
$resolving[] = $dependency->getDefaultValue();
}
return $resolving;
} else {
$resolving[] = $dependency->getDefaultValue();
return $resolving;
}
}
|
[
"protected",
"function",
"getDependencyDefaultValue",
"(",
"$",
"dependency",
",",
"$",
"params",
",",
"$",
"resolving",
",",
"$",
"isRoute",
")",
"{",
"if",
"(",
"$",
"isRoute",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"$",
"dependency",
"->",
"name",
"]",
")",
")",
"{",
"$",
"resolving",
"[",
"]",
"=",
"$",
"params",
"[",
"$",
"dependency",
"->",
"name",
"]",
";",
"}",
"else",
"{",
"$",
"resolving",
"[",
"]",
"=",
"$",
"dependency",
"->",
"getDefaultValue",
"(",
")",
";",
"}",
"return",
"$",
"resolving",
";",
"}",
"else",
"{",
"$",
"resolving",
"[",
"]",
"=",
"$",
"dependency",
"->",
"getDefaultValue",
"(",
")",
";",
"return",
"$",
"resolving",
";",
"}",
"}"
] |
Get dependency default value.
@param $dependency
@param $params
@param $resolving
@param $isRoute
@return array
|
[
"Get",
"dependency",
"default",
"value",
"."
] |
530e772fb97695c1c4e1af73f81675f189474d9f
|
https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Container/Container.php#L309-L324
|
train
|
schpill/thin
|
src/Html/Cell.php
|
Cell.cell
|
public function cell($value, array $attributes = null)
{
$cell = new self;
$cell->setValue($value);
if (null !== $attributes) {
$cell->setAttributes($attributes);
}
return $cell;
}
|
php
|
public function cell($value, array $attributes = null)
{
$cell = new self;
$cell->setValue($value);
if (null !== $attributes) {
$cell->setAttributes($attributes);
}
return $cell;
}
|
[
"public",
"function",
"cell",
"(",
"$",
"value",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"$",
"cell",
"=",
"new",
"self",
";",
"$",
"cell",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"attributes",
")",
"{",
"$",
"cell",
"->",
"setAttributes",
"(",
"$",
"attributes",
")",
";",
"}",
"return",
"$",
"cell",
";",
"}"
] |
Generates a new table cell
@param string $value
@param array $attributes
@return FTV_Html_Cell
|
[
"Generates",
"a",
"new",
"table",
"cell"
] |
a9102d9d6f70e8b0f6be93153f70849f46489ee1
|
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Cell.php#L77-L87
|
train
|
Dhii/map
|
src/IteratorAwareTrait.php
|
IteratorAwareTrait._getIterator
|
protected function _getIterator()
{
if (is_null($this->iterator)) {
$this->iterator = $this->_resolveIterator($this->_getDataStore());
}
return $this->iterator;
}
|
php
|
protected function _getIterator()
{
if (is_null($this->iterator)) {
$this->iterator = $this->_resolveIterator($this->_getDataStore());
}
return $this->iterator;
}
|
[
"protected",
"function",
"_getIterator",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"iterator",
")",
")",
"{",
"$",
"this",
"->",
"iterator",
"=",
"$",
"this",
"->",
"_resolveIterator",
"(",
"$",
"this",
"->",
"_getDataStore",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"iterator",
";",
"}"
] |
Retrieves the iterator of this instance's data store.
@since [*next-version*]
@return Iterator The iterator.
|
[
"Retrieves",
"the",
"iterator",
"of",
"this",
"instance",
"s",
"data",
"store",
"."
] |
9ec82af42b7cb33d3b0b70d753e8a2bc7451cedf
|
https://github.com/Dhii/map/blob/9ec82af42b7cb33d3b0b70d753e8a2bc7451cedf/src/IteratorAwareTrait.php#L35-L42
|
train
|
lechimp-p/flightcontrol
|
src/FDirectory.php
|
FDirectory.fmap
|
public function fmap(\Closure $trans) {
return $this->flightcontrol()->newFDirectory($this, function() use ($trans) {
return array_map($trans, $this->fcontents());
});
}
|
php
|
public function fmap(\Closure $trans) {
return $this->flightcontrol()->newFDirectory($this, function() use ($trans) {
return array_map($trans, $this->fcontents());
});
}
|
[
"public",
"function",
"fmap",
"(",
"\\",
"Closure",
"$",
"trans",
")",
"{",
"return",
"$",
"this",
"->",
"flightcontrol",
"(",
")",
"->",
"newFDirectory",
"(",
"$",
"this",
",",
"function",
"(",
")",
"use",
"(",
"$",
"trans",
")",
"{",
"return",
"array_map",
"(",
"$",
"trans",
",",
"$",
"this",
"->",
"fcontents",
"(",
")",
")",
";",
"}",
")",
";",
"}"
] |
As this is as functor, we could map over it.
Turns an FDirectory a to an FDirectory b by using the provided $trans
function.
@param \Closure $trans a -> b
@return FDirectory
|
[
"As",
"this",
"is",
"as",
"functor",
"we",
"could",
"map",
"over",
"it",
"."
] |
be7698183b44787f1b3d4a16d739655388e569ae
|
https://github.com/lechimp-p/flightcontrol/blob/be7698183b44787f1b3d4a16d739655388e569ae/src/FDirectory.php#L76-L80
|
train
|
lechimp-p/flightcontrol
|
src/FDirectory.php
|
FDirectory.fold
|
public function fold($start_value, $iteration) {
return $this->outer_fmap(function($contents) use ($start_value, $iteration) {
$value = $start_value;
foreach($contents as $content) {
$value = $iteration($value, $content);
}
return $value;
});
}
|
php
|
public function fold($start_value, $iteration) {
return $this->outer_fmap(function($contents) use ($start_value, $iteration) {
$value = $start_value;
foreach($contents as $content) {
$value = $iteration($value, $content);
}
return $value;
});
}
|
[
"public",
"function",
"fold",
"(",
"$",
"start_value",
",",
"$",
"iteration",
")",
"{",
"return",
"$",
"this",
"->",
"outer_fmap",
"(",
"function",
"(",
"$",
"contents",
")",
"use",
"(",
"$",
"start_value",
",",
"$",
"iteration",
")",
"{",
"$",
"value",
"=",
"$",
"start_value",
";",
"foreach",
"(",
"$",
"contents",
"as",
"$",
"content",
")",
"{",
"$",
"value",
"=",
"$",
"iteration",
"(",
"$",
"value",
",",
"$",
"content",
")",
";",
"}",
"return",
"$",
"value",
";",
"}",
")",
";",
"}"
] |
Define the function to be iterated with and close this level
of iteration.
@param \Closure $iteration a -> File|Directory -> a
@return Iterator|a
|
[
"Define",
"the",
"function",
"to",
"be",
"iterated",
"with",
"and",
"close",
"this",
"level",
"of",
"iteration",
"."
] |
be7698183b44787f1b3d4a16d739655388e569ae
|
https://github.com/lechimp-p/flightcontrol/blob/be7698183b44787f1b3d4a16d739655388e569ae/src/FDirectory.php#L103-L111
|
train
|
lechimp-p/flightcontrol
|
src/FDirectory.php
|
FDirectory.fcontents
|
public function fcontents() {
if ($this->contents === null) {
$cl = $this->contents_lazy;
$this->contents = $cl();
}
return $this->contents;
}
|
php
|
public function fcontents() {
if ($this->contents === null) {
$cl = $this->contents_lazy;
$this->contents = $cl();
}
return $this->contents;
}
|
[
"public",
"function",
"fcontents",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"contents",
"===",
"null",
")",
"{",
"$",
"cl",
"=",
"$",
"this",
"->",
"contents_lazy",
";",
"$",
"this",
"->",
"contents",
"=",
"$",
"cl",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"contents",
";",
"}"
] |
The contents of this directory.
It should really return type any[], as we do want to return an array
from things of the same type (but depend on the construction of this
object).
@return mixed[] for an FDirectory a
|
[
"The",
"contents",
"of",
"this",
"directory",
"."
] |
be7698183b44787f1b3d4a16d739655388e569ae
|
https://github.com/lechimp-p/flightcontrol/blob/be7698183b44787f1b3d4a16d739655388e569ae/src/FDirectory.php#L135-L141
|
train
|
smalldb/libSmalldb
|
class/Auth/CookieAuth.php
|
CookieAuth.checkSession
|
public function checkSession()
{
// Get session token
$session_token = isset($_COOKIE[$this->cookie_name]) ? $_COOKIE[$this->cookie_name]
: (isset($_SERVER['HTTP_AUTH_TOKEN']) ? $_SERVER['HTTP_AUTH_TOKEN'] : null);
// Get reference to session state machine
if ($session_token) {
// Get session machine ref
$session_id = (array) $this->session_machine_ref_prefix;
$session_id[] = $session_token;
$this->session_machine = $this->smalldb->ref($session_id);
// Check session
if ($this->session_machine->state == '') {
// Invalid token
$this->session_machine = $this->smalldb->ref($this->session_machine_null_ref);
} else {
// TODO: Validate token, not only session existence, and check whether session is in valid state (invoke a transition to check).
// TODO: Session should tell how long it will last so the cookie should have the same duration.
// Token is good - refresh cookie
setcookie($this->cookie_name, $session_token, time() + $this->cookie_ttl, '/', null, !empty($_SERVER['HTTPS']), true);
}
} else {
// No token
$this->session_machine = $this->smalldb->ref($this->session_machine_null_ref);
}
// Update token on state change
$t = $this;
$this->session_machine->afterTransition()->addListener(function($ref, $transition_name, $arguments, $return_value, $returns) use ($t) {
if (!$ref->state) {
// Remove cookie when session is terminated
setcookie($t->cookie_name, null, time() + $t->cookie_ttl, '/', null, !empty($_SERVER['HTTPS']), true);
if (isset($_SESSION)) {
// Kill PHP session if in use
session_regenerate_id(true);
}
} else {
// Update cookie on state change
setcookie($t->cookie_name, $ref->id, time() + $t->cookie_ttl, '/', null, !empty($_SERVER['HTTPS']), true);
}
});
// Everything else is up to the state machine
}
|
php
|
public function checkSession()
{
// Get session token
$session_token = isset($_COOKIE[$this->cookie_name]) ? $_COOKIE[$this->cookie_name]
: (isset($_SERVER['HTTP_AUTH_TOKEN']) ? $_SERVER['HTTP_AUTH_TOKEN'] : null);
// Get reference to session state machine
if ($session_token) {
// Get session machine ref
$session_id = (array) $this->session_machine_ref_prefix;
$session_id[] = $session_token;
$this->session_machine = $this->smalldb->ref($session_id);
// Check session
if ($this->session_machine->state == '') {
// Invalid token
$this->session_machine = $this->smalldb->ref($this->session_machine_null_ref);
} else {
// TODO: Validate token, not only session existence, and check whether session is in valid state (invoke a transition to check).
// TODO: Session should tell how long it will last so the cookie should have the same duration.
// Token is good - refresh cookie
setcookie($this->cookie_name, $session_token, time() + $this->cookie_ttl, '/', null, !empty($_SERVER['HTTPS']), true);
}
} else {
// No token
$this->session_machine = $this->smalldb->ref($this->session_machine_null_ref);
}
// Update token on state change
$t = $this;
$this->session_machine->afterTransition()->addListener(function($ref, $transition_name, $arguments, $return_value, $returns) use ($t) {
if (!$ref->state) {
// Remove cookie when session is terminated
setcookie($t->cookie_name, null, time() + $t->cookie_ttl, '/', null, !empty($_SERVER['HTTPS']), true);
if (isset($_SESSION)) {
// Kill PHP session if in use
session_regenerate_id(true);
}
} else {
// Update cookie on state change
setcookie($t->cookie_name, $ref->id, time() + $t->cookie_ttl, '/', null, !empty($_SERVER['HTTPS']), true);
}
});
// Everything else is up to the state machine
}
|
[
"public",
"function",
"checkSession",
"(",
")",
"{",
"// Get session token",
"$",
"session_token",
"=",
"isset",
"(",
"$",
"_COOKIE",
"[",
"$",
"this",
"->",
"cookie_name",
"]",
")",
"?",
"$",
"_COOKIE",
"[",
"$",
"this",
"->",
"cookie_name",
"]",
":",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_AUTH_TOKEN'",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"'HTTP_AUTH_TOKEN'",
"]",
":",
"null",
")",
";",
"// Get reference to session state machine",
"if",
"(",
"$",
"session_token",
")",
"{",
"// Get session machine ref",
"$",
"session_id",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"session_machine_ref_prefix",
";",
"$",
"session_id",
"[",
"]",
"=",
"$",
"session_token",
";",
"$",
"this",
"->",
"session_machine",
"=",
"$",
"this",
"->",
"smalldb",
"->",
"ref",
"(",
"$",
"session_id",
")",
";",
"// Check session",
"if",
"(",
"$",
"this",
"->",
"session_machine",
"->",
"state",
"==",
"''",
")",
"{",
"// Invalid token",
"$",
"this",
"->",
"session_machine",
"=",
"$",
"this",
"->",
"smalldb",
"->",
"ref",
"(",
"$",
"this",
"->",
"session_machine_null_ref",
")",
";",
"}",
"else",
"{",
"// TODO: Validate token, not only session existence, and check whether session is in valid state (invoke a transition to check).",
"// TODO: Session should tell how long it will last so the cookie should have the same duration.",
"// Token is good - refresh cookie",
"setcookie",
"(",
"$",
"this",
"->",
"cookie_name",
",",
"$",
"session_token",
",",
"time",
"(",
")",
"+",
"$",
"this",
"->",
"cookie_ttl",
",",
"'/'",
",",
"null",
",",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
")",
",",
"true",
")",
";",
"}",
"}",
"else",
"{",
"// No token",
"$",
"this",
"->",
"session_machine",
"=",
"$",
"this",
"->",
"smalldb",
"->",
"ref",
"(",
"$",
"this",
"->",
"session_machine_null_ref",
")",
";",
"}",
"// Update token on state change",
"$",
"t",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"session_machine",
"->",
"afterTransition",
"(",
")",
"->",
"addListener",
"(",
"function",
"(",
"$",
"ref",
",",
"$",
"transition_name",
",",
"$",
"arguments",
",",
"$",
"return_value",
",",
"$",
"returns",
")",
"use",
"(",
"$",
"t",
")",
"{",
"if",
"(",
"!",
"$",
"ref",
"->",
"state",
")",
"{",
"// Remove cookie when session is terminated",
"setcookie",
"(",
"$",
"t",
"->",
"cookie_name",
",",
"null",
",",
"time",
"(",
")",
"+",
"$",
"t",
"->",
"cookie_ttl",
",",
"'/'",
",",
"null",
",",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
")",
",",
"true",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"_SESSION",
")",
")",
"{",
"// Kill PHP session if in use",
"session_regenerate_id",
"(",
"true",
")",
";",
"}",
"}",
"else",
"{",
"// Update cookie on state change",
"setcookie",
"(",
"$",
"t",
"->",
"cookie_name",
",",
"$",
"ref",
"->",
"id",
",",
"time",
"(",
")",
"+",
"$",
"t",
"->",
"cookie_ttl",
",",
"'/'",
",",
"null",
",",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'HTTPS'",
"]",
")",
",",
"true",
")",
";",
"}",
"}",
")",
";",
"// Everything else is up to the state machine",
"}"
] |
Check session - read & update cookies, setup session state machine and register callbacks.
This must be called before using any state machines. No transitions
are invoked at this point, only the session state machine reference
is created.
|
[
"Check",
"session",
"-",
"read",
"&",
"update",
"cookies",
"setup",
"session",
"state",
"machine",
"and",
"register",
"callbacks",
"."
] |
b94d22af5014e8060d0530fc7043768cdc57b01a
|
https://github.com/smalldb/libSmalldb/blob/b94d22af5014e8060d0530fc7043768cdc57b01a/class/Auth/CookieAuth.php#L98-L145
|
train
|
payapi/payapi-sdk-php
|
src/payapi/plugin/plugin.boc.php
|
plugin.consumerId
|
public function consumerId()
{
if (isset($this->session->data['customer_id']) === true) {
return $this->session->data['customer_id'];
}
return null;
}
|
php
|
public function consumerId()
{
if (isset($this->session->data['customer_id']) === true) {
return $this->session->data['customer_id'];
}
return null;
}
|
[
"public",
"function",
"consumerId",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"session",
"->",
"data",
"[",
"'customer_id'",
"]",
")",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"session",
"->",
"data",
"[",
"'customer_id'",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
-> NEW
|
[
"-",
">",
"NEW"
] |
6a675749c88742b261178d7977f2436d540132b4
|
https://github.com/payapi/payapi-sdk-php/blob/6a675749c88742b261178d7977f2436d540132b4/src/payapi/plugin/plugin.boc.php#L134-L140
|
train
|
acacha/forge-publish
|
src/Console/Commands/PublishDomain.php
|
PublishDomain.defaultDomain
|
protected function defaultDomain()
{
if ($suffix = $this->parser->getDomainSuffix()) {
return strtolower(camel_case(basename(getcwd()))) . '.' . $suffix;
}
return '';
}
|
php
|
protected function defaultDomain()
{
if ($suffix = $this->parser->getDomainSuffix()) {
return strtolower(camel_case(basename(getcwd()))) . '.' . $suffix;
}
return '';
}
|
[
"protected",
"function",
"defaultDomain",
"(",
")",
"{",
"if",
"(",
"$",
"suffix",
"=",
"$",
"this",
"->",
"parser",
"->",
"getDomainSuffix",
"(",
")",
")",
"{",
"return",
"strtolower",
"(",
"camel_case",
"(",
"basename",
"(",
"getcwd",
"(",
")",
")",
")",
")",
".",
"'.'",
".",
"$",
"suffix",
";",
"}",
"return",
"''",
";",
"}"
] |
Default domain.
@return string
|
[
"Default",
"domain",
"."
] |
010779e3d2297c763b82dc3fbde992edffb3a6c6
|
https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/PublishDomain.php#L89-L95
|
train
|
jails/li3_tree
|
extensions/data/behavior/Tree.php
|
Tree._init
|
public function _init() {
parent::_init();
if (!$model = $this->_model) {
throw new ConfigException("`'model'` option needs to be defined.");
}
$behavior = $this;
$model::applyFilter('save', function($self, $params, $chain) use ($behavior) {
if ($behavior->invokeMethod('_beforeSave', [$params])) {
return $chain->next($self, $params, $chain);
}
});
$model::applyFilter('delete', function($self, $params, $chain) use ($behavior) {
if ($behavior->invokeMethod('_beforeDelete', [$params])) {
return $chain->next($self, $params, $chain);
}
});
}
|
php
|
public function _init() {
parent::_init();
if (!$model = $this->_model) {
throw new ConfigException("`'model'` option needs to be defined.");
}
$behavior = $this;
$model::applyFilter('save', function($self, $params, $chain) use ($behavior) {
if ($behavior->invokeMethod('_beforeSave', [$params])) {
return $chain->next($self, $params, $chain);
}
});
$model::applyFilter('delete', function($self, $params, $chain) use ($behavior) {
if ($behavior->invokeMethod('_beforeDelete', [$params])) {
return $chain->next($self, $params, $chain);
}
});
}
|
[
"public",
"function",
"_init",
"(",
")",
"{",
"parent",
"::",
"_init",
"(",
")",
";",
"if",
"(",
"!",
"$",
"model",
"=",
"$",
"this",
"->",
"_model",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"\"`'model'` option needs to be defined.\"",
")",
";",
"}",
"$",
"behavior",
"=",
"$",
"this",
";",
"$",
"model",
"::",
"applyFilter",
"(",
"'save'",
",",
"function",
"(",
"$",
"self",
",",
"$",
"params",
",",
"$",
"chain",
")",
"use",
"(",
"$",
"behavior",
")",
"{",
"if",
"(",
"$",
"behavior",
"->",
"invokeMethod",
"(",
"'_beforeSave'",
",",
"[",
"$",
"params",
"]",
")",
")",
"{",
"return",
"$",
"chain",
"->",
"next",
"(",
"$",
"self",
",",
"$",
"params",
",",
"$",
"chain",
")",
";",
"}",
"}",
")",
";",
"$",
"model",
"::",
"applyFilter",
"(",
"'delete'",
",",
"function",
"(",
"$",
"self",
",",
"$",
"params",
",",
"$",
"chain",
")",
"use",
"(",
"$",
"behavior",
")",
"{",
"if",
"(",
"$",
"behavior",
"->",
"invokeMethod",
"(",
"'_beforeDelete'",
",",
"[",
"$",
"params",
"]",
")",
")",
"{",
"return",
"$",
"chain",
"->",
"next",
"(",
"$",
"self",
",",
"$",
"params",
",",
"$",
"chain",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Initializer function called by the constructor unless the constructor `'init'` flag is set
to `false`.
@see lithium\core\Object
@throws ConfigException
|
[
"Initializer",
"function",
"called",
"by",
"the",
"constructor",
"unless",
"the",
"constructor",
"init",
"flag",
"is",
"set",
"to",
"false",
"."
] |
43fdbe9c621f1f712131c6a338bb5421da67fc17
|
https://github.com/jails/li3_tree/blob/43fdbe9c621f1f712131c6a338bb5421da67fc17/extensions/data/behavior/Tree.php#L45-L62
|
train
|
jails/li3_tree
|
extensions/data/behavior/Tree.php
|
Tree._scope
|
protected function _scope($entity) {
$scope = [];
foreach ($this->_config['scope'] as $key => $value) {
if (is_numeric($key)) {
if (isset($entity, $value)) {
$scope[$value] = $entity->$value;
} else {
$message = "The `{$value}` scope in not present in the entity.";
throw new UnexpectedValueException($message);
}
} else {
$scope[$key] = $value;
}
}
return $scope;
}
|
php
|
protected function _scope($entity) {
$scope = [];
foreach ($this->_config['scope'] as $key => $value) {
if (is_numeric($key)) {
if (isset($entity, $value)) {
$scope[$value] = $entity->$value;
} else {
$message = "The `{$value}` scope in not present in the entity.";
throw new UnexpectedValueException($message);
}
} else {
$scope[$key] = $value;
}
}
return $scope;
}
|
[
"protected",
"function",
"_scope",
"(",
"$",
"entity",
")",
"{",
"$",
"scope",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_config",
"[",
"'scope'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"key",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"entity",
",",
"$",
"value",
")",
")",
"{",
"$",
"scope",
"[",
"$",
"value",
"]",
"=",
"$",
"entity",
"->",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"message",
"=",
"\"The `{$value}` scope in not present in the entity.\"",
";",
"throw",
"new",
"UnexpectedValueException",
"(",
"$",
"message",
")",
";",
"}",
"}",
"else",
"{",
"$",
"scope",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"scope",
";",
"}"
] |
Setting a scope to an entity node.
@param object $entity
@return array The scope values
@throws UnexpectedValueException
|
[
"Setting",
"a",
"scope",
"to",
"an",
"entity",
"node",
"."
] |
43fdbe9c621f1f712131c6a338bb5421da67fc17
|
https://github.com/jails/li3_tree/blob/43fdbe9c621f1f712131c6a338bb5421da67fc17/extensions/data/behavior/Tree.php#L71-L86
|
train
|
jails/li3_tree
|
extensions/data/behavior/Tree.php
|
Tree._insertParent
|
protected function _insertParent($entity) {
extract($this->_config);
$parent = $this->_getById($entity->$parent);
if ($parent) {
$r = $parent->$right;
$this->_update($r, '+', 2, $this->_scope($entity));
$entity->set([
$left => $r,
$right => $r + 1
]);
}
}
|
php
|
protected function _insertParent($entity) {
extract($this->_config);
$parent = $this->_getById($entity->$parent);
if ($parent) {
$r = $parent->$right;
$this->_update($r, '+', 2, $this->_scope($entity));
$entity->set([
$left => $r,
$right => $r + 1
]);
}
}
|
[
"protected",
"function",
"_insertParent",
"(",
"$",
"entity",
")",
"{",
"extract",
"(",
"$",
"this",
"->",
"_config",
")",
";",
"$",
"parent",
"=",
"$",
"this",
"->",
"_getById",
"(",
"$",
"entity",
"->",
"$",
"parent",
")",
";",
"if",
"(",
"$",
"parent",
")",
"{",
"$",
"r",
"=",
"$",
"parent",
"->",
"$",
"right",
";",
"$",
"this",
"->",
"_update",
"(",
"$",
"r",
",",
"'+'",
",",
"2",
",",
"$",
"this",
"->",
"_scope",
"(",
"$",
"entity",
")",
")",
";",
"$",
"entity",
"->",
"set",
"(",
"[",
"$",
"left",
"=>",
"$",
"r",
",",
"$",
"right",
"=>",
"$",
"r",
"+",
"1",
"]",
")",
";",
"}",
"}"
] |
Insert a parent
inserts a node at given last position of parent set in $entity
@param object $entity
|
[
"Insert",
"a",
"parent"
] |
43fdbe9c621f1f712131c6a338bb5421da67fc17
|
https://github.com/jails/li3_tree/blob/43fdbe9c621f1f712131c6a338bb5421da67fc17/extensions/data/behavior/Tree.php#L244-L255
|
train
|
jails/li3_tree
|
extensions/data/behavior/Tree.php
|
Tree._deleteFromTree
|
protected function _deleteFromTree($entity) {
extract($this->_config);
$span = 1;
if ($entity->$right - $entity->$left !== 1) {
$span = $entity->$right - $entity->$left;
$model::remove([$parent => $entity->data($model::key())]);
}
$this->_update($entity->$right, '-', $span + 1, $this->_scope($entity));
return true;
}
|
php
|
protected function _deleteFromTree($entity) {
extract($this->_config);
$span = 1;
if ($entity->$right - $entity->$left !== 1) {
$span = $entity->$right - $entity->$left;
$model::remove([$parent => $entity->data($model::key())]);
}
$this->_update($entity->$right, '-', $span + 1, $this->_scope($entity));
return true;
}
|
[
"protected",
"function",
"_deleteFromTree",
"(",
"$",
"entity",
")",
"{",
"extract",
"(",
"$",
"this",
"->",
"_config",
")",
";",
"$",
"span",
"=",
"1",
";",
"if",
"(",
"$",
"entity",
"->",
"$",
"right",
"-",
"$",
"entity",
"->",
"$",
"left",
"!==",
"1",
")",
"{",
"$",
"span",
"=",
"$",
"entity",
"->",
"$",
"right",
"-",
"$",
"entity",
"->",
"$",
"left",
";",
"$",
"model",
"::",
"remove",
"(",
"[",
"$",
"parent",
"=>",
"$",
"entity",
"->",
"data",
"(",
"$",
"model",
"::",
"key",
"(",
")",
")",
"]",
")",
";",
"}",
"$",
"this",
"->",
"_update",
"(",
"$",
"entity",
"->",
"$",
"right",
",",
"'-'",
",",
"$",
"span",
"+",
"1",
",",
"$",
"this",
"->",
"_scope",
"(",
"$",
"entity",
")",
")",
";",
"return",
"true",
";",
"}"
] |
Delete from tree
deletes a node (and its children) from the tree
@param object $entity updated tree element
|
[
"Delete",
"from",
"tree"
] |
43fdbe9c621f1f712131c6a338bb5421da67fc17
|
https://github.com/jails/li3_tree/blob/43fdbe9c621f1f712131c6a338bb5421da67fc17/extensions/data/behavior/Tree.php#L342-L352
|
train
|
jails/li3_tree
|
extensions/data/behavior/Tree.php
|
Tree._update
|
protected function _update($rght, $dir = '+', $span = 2, $scp = []) {
extract($this->_config);
$model::update([$right => (object) ($right . $dir . $span)], [
$right => ['>=' => $rght]
] + $scp);
$model::update([$left => (object) ($left . $dir . $span)], [
$left => ['>' => $rght]
] + $scp);
}
|
php
|
protected function _update($rght, $dir = '+', $span = 2, $scp = []) {
extract($this->_config);
$model::update([$right => (object) ($right . $dir . $span)], [
$right => ['>=' => $rght]
] + $scp);
$model::update([$left => (object) ($left . $dir . $span)], [
$left => ['>' => $rght]
] + $scp);
}
|
[
"protected",
"function",
"_update",
"(",
"$",
"rght",
",",
"$",
"dir",
"=",
"'+'",
",",
"$",
"span",
"=",
"2",
",",
"$",
"scp",
"=",
"[",
"]",
")",
"{",
"extract",
"(",
"$",
"this",
"->",
"_config",
")",
";",
"$",
"model",
"::",
"update",
"(",
"[",
"$",
"right",
"=>",
"(",
"object",
")",
"(",
"$",
"right",
".",
"$",
"dir",
".",
"$",
"span",
")",
"]",
",",
"[",
"$",
"right",
"=>",
"[",
"'>='",
"=>",
"$",
"rght",
"]",
"]",
"+",
"$",
"scp",
")",
";",
"$",
"model",
"::",
"update",
"(",
"[",
"$",
"left",
"=>",
"(",
"object",
")",
"(",
"$",
"left",
".",
"$",
"dir",
".",
"$",
"span",
")",
"]",
",",
"[",
"$",
"left",
"=>",
"[",
"'>'",
"=>",
"$",
"rght",
"]",
"]",
"+",
"$",
"scp",
")",
";",
"}"
] |
Update node indices
Updates the Indices in greater than $rght with given value.
@param integer $rght the right index border to start indexing
@param string $dir Direction +/- (defaults to +)
@param integer $span value to be added/subtracted (defaults to 2)
@param array $scp The scope to apply updates on
|
[
"Update",
"node",
"indices"
] |
43fdbe9c621f1f712131c6a338bb5421da67fc17
|
https://github.com/jails/li3_tree/blob/43fdbe9c621f1f712131c6a338bb5421da67fc17/extensions/data/behavior/Tree.php#L376-L386
|
train
|
jails/li3_tree
|
extensions/data/behavior/Tree.php
|
Tree._updateBetween
|
protected function _updateBetween($range, $dir = '+', $span = 2, $scp = [], $data = []) {
extract($this->_config);
$model::update([$right => (object) ($right . $dir . $span)], [
$right => [
'>=' => $range['floor'],
'<=' => $range['ceiling']
]] + $scp);
$model::update([$left => (object) ($left . $dir . $span)] + $data, [
$left => [
'>=' => $range['floor'],
'<=' => $range['ceiling']
]] + $scp);
}
|
php
|
protected function _updateBetween($range, $dir = '+', $span = 2, $scp = [], $data = []) {
extract($this->_config);
$model::update([$right => (object) ($right . $dir . $span)], [
$right => [
'>=' => $range['floor'],
'<=' => $range['ceiling']
]] + $scp);
$model::update([$left => (object) ($left . $dir . $span)] + $data, [
$left => [
'>=' => $range['floor'],
'<=' => $range['ceiling']
]] + $scp);
}
|
[
"protected",
"function",
"_updateBetween",
"(",
"$",
"range",
",",
"$",
"dir",
"=",
"'+'",
",",
"$",
"span",
"=",
"2",
",",
"$",
"scp",
"=",
"[",
"]",
",",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"extract",
"(",
"$",
"this",
"->",
"_config",
")",
";",
"$",
"model",
"::",
"update",
"(",
"[",
"$",
"right",
"=>",
"(",
"object",
")",
"(",
"$",
"right",
".",
"$",
"dir",
".",
"$",
"span",
")",
"]",
",",
"[",
"$",
"right",
"=>",
"[",
"'>='",
"=>",
"$",
"range",
"[",
"'floor'",
"]",
",",
"'<='",
"=>",
"$",
"range",
"[",
"'ceiling'",
"]",
"]",
"]",
"+",
"$",
"scp",
")",
";",
"$",
"model",
"::",
"update",
"(",
"[",
"$",
"left",
"=>",
"(",
"object",
")",
"(",
"$",
"left",
".",
"$",
"dir",
".",
"$",
"span",
")",
"]",
"+",
"$",
"data",
",",
"[",
"$",
"left",
"=>",
"[",
"'>='",
"=>",
"$",
"range",
"[",
"'floor'",
"]",
",",
"'<='",
"=>",
"$",
"range",
"[",
"'ceiling'",
"]",
"]",
"]",
"+",
"$",
"scp",
")",
";",
"}"
] |
Update node indices between
Updates the Indices in given range with given value.
@param array $range the range to be updated
@param string $dir Direction +/- (defaults to +)
@param integer $span Value to be added/subtracted (defaults to 2)
@param array $scp The scope to apply updates on
@param array $data Additionnal scope datas (optionnal)
|
[
"Update",
"node",
"indices",
"between"
] |
43fdbe9c621f1f712131c6a338bb5421da67fc17
|
https://github.com/jails/li3_tree/blob/43fdbe9c621f1f712131c6a338bb5421da67fc17/extensions/data/behavior/Tree.php#L399-L413
|
train
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.