id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
223,400
|
lexik/LexikWorkflowBundle
|
Flow/Node.php
|
Node.addNextStateOr
|
public function addNextStateOr($name, $type, array $targets)
{
$this->nextStates[$name] = new NextStateOr($name, $type, $targets);
}
|
php
|
public function addNextStateOr($name, $type, array $targets)
{
$this->nextStates[$name] = new NextStateOr($name, $type, $targets);
}
|
[
"public",
"function",
"addNextStateOr",
"(",
"$",
"name",
",",
"$",
"type",
",",
"array",
"$",
"targets",
")",
"{",
"$",
"this",
"->",
"nextStates",
"[",
"$",
"name",
"]",
"=",
"new",
"NextStateOr",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"targets",
")",
";",
"}"
] |
Add a next state OR
@param string $name
@param string $type
@param array $targets
|
[
"Add",
"a",
"next",
"state",
"OR"
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/Flow/Node.php#L99-L102
|
223,401
|
silverstripe/silverstripe-ldap
|
src/Model/LDAPGateway.php
|
LDAPGateway.search
|
protected function search($filter, $baseDn = null, $scope = Ldap::SEARCH_SCOPE_SUB, $attributes = [], $sort = '')
{
$records = $this->ldap->search($filter, $baseDn, $scope, $attributes, $sort);
return $this->processSearchResults($records);
}
|
php
|
protected function search($filter, $baseDn = null, $scope = Ldap::SEARCH_SCOPE_SUB, $attributes = [], $sort = '')
{
$records = $this->ldap->search($filter, $baseDn, $scope, $attributes, $sort);
return $this->processSearchResults($records);
}
|
[
"protected",
"function",
"search",
"(",
"$",
"filter",
",",
"$",
"baseDn",
"=",
"null",
",",
"$",
"scope",
"=",
"Ldap",
"::",
"SEARCH_SCOPE_SUB",
",",
"$",
"attributes",
"=",
"[",
"]",
",",
"$",
"sort",
"=",
"''",
")",
"{",
"$",
"records",
"=",
"$",
"this",
"->",
"ldap",
"->",
"search",
"(",
"$",
"filter",
",",
"$",
"baseDn",
",",
"$",
"scope",
",",
"$",
"attributes",
",",
"$",
"sort",
")",
";",
"return",
"$",
"this",
"->",
"processSearchResults",
"(",
"$",
"records",
")",
";",
"}"
] |
Query the LDAP directory with the given filter.
@param string $filter The string to filter by, e.g. (objectClass=user)
@param null|string $baseDn The DN to search from. Default is the baseDn option in the connection if not given
@param int $scope The scope to perform the search. Zend_Ldap::SEARCH_SCOPE_ONE, Zend_LDAP::SEARCH_SCOPE_BASE.
Default is Zend_Ldap::SEARCH_SCOPE_SUB
@param array $attributes Restrict to specific AD attributes. An empty array will return all attributes
@param string $sort Sort results by this attribute if given
@return array
|
[
"Query",
"the",
"LDAP",
"directory",
"with",
"the",
"given",
"filter",
"."
] |
e8e6de4de9d61ad383086bc2fb2a793809cb755e
|
https://github.com/silverstripe/silverstripe-ldap/blob/e8e6de4de9d61ad383086bc2fb2a793809cb755e/src/Model/LDAPGateway.php#L80-L84
|
223,402
|
silverstripe/silverstripe-ldap
|
src/Model/LDAPGateway.php
|
LDAPGateway.getUserByDN
|
public function getUserByDN($dn, $baseDn = null, $scope = Ldap::SEARCH_SCOPE_SUB, $attributes = [])
{
return $this->search(
sprintf('(&(objectClass=user)(distinguishedname=%s))', $dn),
$baseDn,
$scope,
$attributes
);
}
|
php
|
public function getUserByDN($dn, $baseDn = null, $scope = Ldap::SEARCH_SCOPE_SUB, $attributes = [])
{
return $this->search(
sprintf('(&(objectClass=user)(distinguishedname=%s))', $dn),
$baseDn,
$scope,
$attributes
);
}
|
[
"public",
"function",
"getUserByDN",
"(",
"$",
"dn",
",",
"$",
"baseDn",
"=",
"null",
",",
"$",
"scope",
"=",
"Ldap",
"::",
"SEARCH_SCOPE_SUB",
",",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"search",
"(",
"sprintf",
"(",
"'(&(objectClass=user)(distinguishedname=%s))'",
",",
"$",
"dn",
")",
",",
"$",
"baseDn",
",",
"$",
"scope",
",",
"$",
"attributes",
")",
";",
"}"
] |
Return a particular LDAP user by DN value.
@param string $dn
@param null|string $baseDn The DN to search from. Default is the baseDn option in the connection if not given
@param int $scope The scope to perform the search. Zend_Ldap::SEARCH_SCOPE_ONE, Zend_LDAP::SEARCH_SCOPE_BASE.
Default is Zend_Ldap::SEARCH_SCOPE_SUB
@param array $attributes Restrict to specific AD attributes. An empty array will return all attributes
@return array
|
[
"Return",
"a",
"particular",
"LDAP",
"user",
"by",
"DN",
"value",
"."
] |
e8e6de4de9d61ad383086bc2fb2a793809cb755e
|
https://github.com/silverstripe/silverstripe-ldap/blob/e8e6de4de9d61ad383086bc2fb2a793809cb755e/src/Model/LDAPGateway.php#L295-L303
|
223,403
|
silverstripe/silverstripe-ldap
|
src/Model/LDAPGateway.php
|
LDAPGateway.getUserByEmail
|
public function getUserByEmail($email, $baseDn = null, $scope = Ldap::SEARCH_SCOPE_SUB, $attributes = [])
{
return $this->search(
sprintf('(&(objectClass=user)(mail=%s))', AbstractFilter::escapeValue($email)),
$baseDn,
$scope,
$attributes
);
}
|
php
|
public function getUserByEmail($email, $baseDn = null, $scope = Ldap::SEARCH_SCOPE_SUB, $attributes = [])
{
return $this->search(
sprintf('(&(objectClass=user)(mail=%s))', AbstractFilter::escapeValue($email)),
$baseDn,
$scope,
$attributes
);
}
|
[
"public",
"function",
"getUserByEmail",
"(",
"$",
"email",
",",
"$",
"baseDn",
"=",
"null",
",",
"$",
"scope",
"=",
"Ldap",
"::",
"SEARCH_SCOPE_SUB",
",",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"search",
"(",
"sprintf",
"(",
"'(&(objectClass=user)(mail=%s))'",
",",
"AbstractFilter",
"::",
"escapeValue",
"(",
"$",
"email",
")",
")",
",",
"$",
"baseDn",
",",
"$",
"scope",
",",
"$",
"attributes",
")",
";",
"}"
] |
Return a particular LDAP user by mail value.
@param string $email
@return array
|
[
"Return",
"a",
"particular",
"LDAP",
"user",
"by",
"mail",
"value",
"."
] |
e8e6de4de9d61ad383086bc2fb2a793809cb755e
|
https://github.com/silverstripe/silverstripe-ldap/blob/e8e6de4de9d61ad383086bc2fb2a793809cb755e/src/Model/LDAPGateway.php#L311-L319
|
223,404
|
silverstripe/silverstripe-ldap
|
src/Model/LDAPGateway.php
|
LDAPGateway.getUserByUsername
|
public function getUserByUsername($username, $baseDn = null, $scope = Ldap::SEARCH_SCOPE_SUB, $attributes = [])
{
$options = $this->config()->options;
$option = isset($options['accountCanonicalForm']) ? $options['accountCanonicalForm'] : null;
// will translate the username to username@foo.bar, username or foo\user depending on the
// $options['accountCanonicalForm']
$username = $this->ldap->getCanonicalAccountName($username, $option);
switch ($option) {
case Ldap::ACCTNAME_FORM_USERNAME: // traditional style usernames, e.g. alice
$filter = sprintf('(&(objectClass=user)(samaccountname=%s))', AbstractFilter::escapeValue($username));
break;
case Ldap::ACCTNAME_FORM_BACKSLASH: // backslash style usernames, e.g. FOO\alice
// @todo Not supported yet!
throw new Exception('Backslash style not supported in LDAPGateway::getUserByUsername()!');
break;
case Ldap::ACCTNAME_FORM_PRINCIPAL: // principal style usernames, e.g. alice@foo.com
$filter = sprintf(
'(&(objectClass=user)(userprincipalname=%s))',
AbstractFilter::escapeValue($username)
);
break;
case Ldap::ACCTNAME_FORM_DN: // distinguished name, e.g. CN=someone,DC=example,DC=co,DC=nz
// @todo Not supported yet!
throw new Exception('DN style not supported in LDAPGateway::getUserByUsername()!');
break;
default: // default to principal style
$filter = sprintf(
'(&(objectClass=user)(userprincipalname=%s))',
AbstractFilter::escapeValue($username)
);
break;
}
return $this->search($filter, $baseDn, $scope, $attributes);
}
|
php
|
public function getUserByUsername($username, $baseDn = null, $scope = Ldap::SEARCH_SCOPE_SUB, $attributes = [])
{
$options = $this->config()->options;
$option = isset($options['accountCanonicalForm']) ? $options['accountCanonicalForm'] : null;
// will translate the username to username@foo.bar, username or foo\user depending on the
// $options['accountCanonicalForm']
$username = $this->ldap->getCanonicalAccountName($username, $option);
switch ($option) {
case Ldap::ACCTNAME_FORM_USERNAME: // traditional style usernames, e.g. alice
$filter = sprintf('(&(objectClass=user)(samaccountname=%s))', AbstractFilter::escapeValue($username));
break;
case Ldap::ACCTNAME_FORM_BACKSLASH: // backslash style usernames, e.g. FOO\alice
// @todo Not supported yet!
throw new Exception('Backslash style not supported in LDAPGateway::getUserByUsername()!');
break;
case Ldap::ACCTNAME_FORM_PRINCIPAL: // principal style usernames, e.g. alice@foo.com
$filter = sprintf(
'(&(objectClass=user)(userprincipalname=%s))',
AbstractFilter::escapeValue($username)
);
break;
case Ldap::ACCTNAME_FORM_DN: // distinguished name, e.g. CN=someone,DC=example,DC=co,DC=nz
// @todo Not supported yet!
throw new Exception('DN style not supported in LDAPGateway::getUserByUsername()!');
break;
default: // default to principal style
$filter = sprintf(
'(&(objectClass=user)(userprincipalname=%s))',
AbstractFilter::escapeValue($username)
);
break;
}
return $this->search($filter, $baseDn, $scope, $attributes);
}
|
[
"public",
"function",
"getUserByUsername",
"(",
"$",
"username",
",",
"$",
"baseDn",
"=",
"null",
",",
"$",
"scope",
"=",
"Ldap",
"::",
"SEARCH_SCOPE_SUB",
",",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"options",
";",
"$",
"option",
"=",
"isset",
"(",
"$",
"options",
"[",
"'accountCanonicalForm'",
"]",
")",
"?",
"$",
"options",
"[",
"'accountCanonicalForm'",
"]",
":",
"null",
";",
"// will translate the username to username@foo.bar, username or foo\\user depending on the",
"// $options['accountCanonicalForm']",
"$",
"username",
"=",
"$",
"this",
"->",
"ldap",
"->",
"getCanonicalAccountName",
"(",
"$",
"username",
",",
"$",
"option",
")",
";",
"switch",
"(",
"$",
"option",
")",
"{",
"case",
"Ldap",
"::",
"ACCTNAME_FORM_USERNAME",
":",
"// traditional style usernames, e.g. alice",
"$",
"filter",
"=",
"sprintf",
"(",
"'(&(objectClass=user)(samaccountname=%s))'",
",",
"AbstractFilter",
"::",
"escapeValue",
"(",
"$",
"username",
")",
")",
";",
"break",
";",
"case",
"Ldap",
"::",
"ACCTNAME_FORM_BACKSLASH",
":",
"// backslash style usernames, e.g. FOO\\alice",
"// @todo Not supported yet!",
"throw",
"new",
"Exception",
"(",
"'Backslash style not supported in LDAPGateway::getUserByUsername()!'",
")",
";",
"break",
";",
"case",
"Ldap",
"::",
"ACCTNAME_FORM_PRINCIPAL",
":",
"// principal style usernames, e.g. alice@foo.com",
"$",
"filter",
"=",
"sprintf",
"(",
"'(&(objectClass=user)(userprincipalname=%s))'",
",",
"AbstractFilter",
"::",
"escapeValue",
"(",
"$",
"username",
")",
")",
";",
"break",
";",
"case",
"Ldap",
"::",
"ACCTNAME_FORM_DN",
":",
"// distinguished name, e.g. CN=someone,DC=example,DC=co,DC=nz",
"// @todo Not supported yet!",
"throw",
"new",
"Exception",
"(",
"'DN style not supported in LDAPGateway::getUserByUsername()!'",
")",
";",
"break",
";",
"default",
":",
"// default to principal style",
"$",
"filter",
"=",
"sprintf",
"(",
"'(&(objectClass=user)(userprincipalname=%s))'",
",",
"AbstractFilter",
"::",
"escapeValue",
"(",
"$",
"username",
")",
")",
";",
"break",
";",
"}",
"return",
"$",
"this",
"->",
"search",
"(",
"$",
"filter",
",",
"$",
"baseDn",
",",
"$",
"scope",
",",
"$",
"attributes",
")",
";",
"}"
] |
Get a specific user's data from LDAP
@param string $username
@param null|string $baseDn The DN to search from. Default is the baseDn option in the connection if not given
@param int $scope The scope to perform the search. Zend_Ldap::SEARCH_SCOPE_ONE, Zend_LDAP::SEARCH_SCOPE_BASE.
Default is Zend_Ldap::SEARCH_SCOPE_SUB
@param array $attributes Restrict to specific AD attributes. An empty array will return all attributes
@return array
@throws Exception
|
[
"Get",
"a",
"specific",
"user",
"s",
"data",
"from",
"LDAP"
] |
e8e6de4de9d61ad383086bc2fb2a793809cb755e
|
https://github.com/silverstripe/silverstripe-ldap/blob/e8e6de4de9d61ad383086bc2fb2a793809cb755e/src/Model/LDAPGateway.php#L332-L367
|
223,405
|
silverstripe/silverstripe-ldap
|
src/Model/LDAPGateway.php
|
LDAPGateway.getCanonicalUsername
|
public function getCanonicalUsername($data)
{
$options = $this->config()->options;
$option = isset($options['accountCanonicalForm']) ? $options['accountCanonicalForm'] : null;
switch ($option) {
case Ldap::ACCTNAME_FORM_USERNAME: // traditional style usernames, e.g. alice
if (empty($data['samaccountname'])) {
throw new \Exception('Could not extract canonical username: samaccountname field missing');
}
return $data['samaccountname'];
case Ldap::ACCTNAME_FORM_BACKSLASH: // backslash style usernames, e.g. FOO\alice
// @todo Not supported yet!
throw new Exception('Backslash style not supported in LDAPGateway::getUsernameByEmail()!');
case Ldap::ACCTNAME_FORM_PRINCIPAL: // principal style usernames, e.g. alice@foo.com
if (empty($data['userprincipalname'])) {
throw new Exception('Could not extract canonical username: userprincipalname field missing');
}
return $data['userprincipalname'];
default: // default to principal style
if (empty($data['userprincipalname'])) {
throw new Exception('Could not extract canonical username: userprincipalname field missing');
}
return $data['userprincipalname'];
}
}
|
php
|
public function getCanonicalUsername($data)
{
$options = $this->config()->options;
$option = isset($options['accountCanonicalForm']) ? $options['accountCanonicalForm'] : null;
switch ($option) {
case Ldap::ACCTNAME_FORM_USERNAME: // traditional style usernames, e.g. alice
if (empty($data['samaccountname'])) {
throw new \Exception('Could not extract canonical username: samaccountname field missing');
}
return $data['samaccountname'];
case Ldap::ACCTNAME_FORM_BACKSLASH: // backslash style usernames, e.g. FOO\alice
// @todo Not supported yet!
throw new Exception('Backslash style not supported in LDAPGateway::getUsernameByEmail()!');
case Ldap::ACCTNAME_FORM_PRINCIPAL: // principal style usernames, e.g. alice@foo.com
if (empty($data['userprincipalname'])) {
throw new Exception('Could not extract canonical username: userprincipalname field missing');
}
return $data['userprincipalname'];
default: // default to principal style
if (empty($data['userprincipalname'])) {
throw new Exception('Could not extract canonical username: userprincipalname field missing');
}
return $data['userprincipalname'];
}
}
|
[
"public",
"function",
"getCanonicalUsername",
"(",
"$",
"data",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"options",
";",
"$",
"option",
"=",
"isset",
"(",
"$",
"options",
"[",
"'accountCanonicalForm'",
"]",
")",
"?",
"$",
"options",
"[",
"'accountCanonicalForm'",
"]",
":",
"null",
";",
"switch",
"(",
"$",
"option",
")",
"{",
"case",
"Ldap",
"::",
"ACCTNAME_FORM_USERNAME",
":",
"// traditional style usernames, e.g. alice",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'samaccountname'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Could not extract canonical username: samaccountname field missing'",
")",
";",
"}",
"return",
"$",
"data",
"[",
"'samaccountname'",
"]",
";",
"case",
"Ldap",
"::",
"ACCTNAME_FORM_BACKSLASH",
":",
"// backslash style usernames, e.g. FOO\\alice",
"// @todo Not supported yet!",
"throw",
"new",
"Exception",
"(",
"'Backslash style not supported in LDAPGateway::getUsernameByEmail()!'",
")",
";",
"case",
"Ldap",
"::",
"ACCTNAME_FORM_PRINCIPAL",
":",
"// principal style usernames, e.g. alice@foo.com",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'userprincipalname'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Could not extract canonical username: userprincipalname field missing'",
")",
";",
"}",
"return",
"$",
"data",
"[",
"'userprincipalname'",
"]",
";",
"default",
":",
"// default to principal style",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'userprincipalname'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Could not extract canonical username: userprincipalname field missing'",
")",
";",
"}",
"return",
"$",
"data",
"[",
"'userprincipalname'",
"]",
";",
"}",
"}"
] |
Get a canonical username from the record based on the connection settings.
@param array $data
@return string
@throws Exception
|
[
"Get",
"a",
"canonical",
"username",
"from",
"the",
"record",
"based",
"on",
"the",
"connection",
"settings",
"."
] |
e8e6de4de9d61ad383086bc2fb2a793809cb755e
|
https://github.com/silverstripe/silverstripe-ldap/blob/e8e6de4de9d61ad383086bc2fb2a793809cb755e/src/Model/LDAPGateway.php#L376-L400
|
223,406
|
wirecard/checkout-client-library
|
library/WirecardCEE/Stdlib/Validate/Fingerprint.php
|
WirecardCEE_Stdlib_Validate_Fingerprint.setHashAlgorithm
|
public function setHashAlgorithm($hashAlgorithm)
{
$this->hashAlgorithm = (string) $hashAlgorithm;
WirecardCEE_Stdlib_Fingerprint::setHashAlgorithm($hashAlgorithm);
return $this;
}
|
php
|
public function setHashAlgorithm($hashAlgorithm)
{
$this->hashAlgorithm = (string) $hashAlgorithm;
WirecardCEE_Stdlib_Fingerprint::setHashAlgorithm($hashAlgorithm);
return $this;
}
|
[
"public",
"function",
"setHashAlgorithm",
"(",
"$",
"hashAlgorithm",
")",
"{",
"$",
"this",
"->",
"hashAlgorithm",
"=",
"(",
"string",
")",
"$",
"hashAlgorithm",
";",
"WirecardCEE_Stdlib_Fingerprint",
"::",
"setHashAlgorithm",
"(",
"$",
"hashAlgorithm",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Hash algorithm setter
@param string $hashAlgorithm
@return WirecardCEE_Stdlib_Validate_Fingerprint
|
[
"Hash",
"algorithm",
"setter"
] |
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
|
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/Stdlib/Validate/Fingerprint.php#L223-L229
|
223,407
|
wirecard/checkout-client-library
|
library/WirecardCEE/Stdlib/Validate/Fingerprint.php
|
WirecardCEE_Stdlib_Validate_Fingerprint.addMandatoryField
|
public function addMandatoryField($mandatoryField)
{
if (!in_array((string) $mandatoryField, $this->_mandatoryFields)) {
$this->_mandatoryFields[] = (string) $mandatoryField;
}
return $this;
}
|
php
|
public function addMandatoryField($mandatoryField)
{
if (!in_array((string) $mandatoryField, $this->_mandatoryFields)) {
$this->_mandatoryFields[] = (string) $mandatoryField;
}
return $this;
}
|
[
"public",
"function",
"addMandatoryField",
"(",
"$",
"mandatoryField",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"(",
"string",
")",
"$",
"mandatoryField",
",",
"$",
"this",
"->",
"_mandatoryFields",
")",
")",
"{",
"$",
"this",
"->",
"_mandatoryFields",
"[",
"]",
"=",
"(",
"string",
")",
"$",
"mandatoryField",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add madatory field
@param string $mandatoryField
@return WirecardCEE_Stdlib_Validate_Fingerprint
|
[
"Add",
"madatory",
"field"
] |
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
|
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/Stdlib/Validate/Fingerprint.php#L252-L259
|
223,408
|
wirecard/checkout-client-library
|
library/WirecardCEE/Stdlib/Validate/Fingerprint.php
|
WirecardCEE_Stdlib_Validate_Fingerprint.isValid
|
public function isValid($value, $context = null)
{
$context = array_change_key_case($context, CASE_LOWER);
switch ($this->hashAlgorithm) {
case WirecardCEE_Stdlib_Fingerprint::HASH_ALGORITHM_HMAC_SHA512:
case WirecardCEE_Stdlib_Fingerprint::HASH_ALGORITHM_SHA512:
$stringLength = 128;
break;
case WirecardCEE_Stdlib_Fingerprint::HASH_ALGORITHM_MD5:
$stringLength = 32;
break;
default:
throw new WirecardCEE_Stdlib_Exception_UnexpectedValueException(sprintf("Used hash algorithm '%s' is not supported. MD5, SHA512, or HMAC_SHA512 are currently supported.",
$this->hashAlgorithm));
break;
}
if (strlen($value) != $stringLength) {
return false;
}
if ($this->fingerprintOrderType == self::TYPE_FIXED) {
$fingerprintOrder = $this->fingerprintOrder;
} else {
if (array_key_exists($this->fingerprintOrderField, $context)) {
$fingerprintOrder = new WirecardCEE_Stdlib_FingerprintOrder(strtolower($context[$this->fingerprintOrderField]));
} else {
$this->_error(self::FINGERPRINTORDER_MISSING);
return false;
}
}
$fingerprintOrder->setOrder(array_map('strtolower', $this->fingerprintOrder->__toArray()));
if (!in_array('secret', $fingerprintOrder->__toArray())) {
throw new WirecardCEE_Stdlib_Exception_UnexpectedValueException();
}
$fingerprintFields = Array();
foreach ($fingerprintOrder as $fingerprintFieldKey) {
if ($fingerprintFieldKey == 'secret') {
$fingerprintFields[$fingerprintFieldKey] = $this->secret;
} else {
$fingerprintFields[$fingerprintFieldKey] = isset( $context[$fingerprintFieldKey] ) ? $context[$fingerprintFieldKey] : '';
}
}
if (!WirecardCEE_Stdlib_Fingerprint::compare($fingerprintFields, $fingerprintOrder, $value)) {
$this->_error(self::INVALID);
return false;
}
return true;
}
|
php
|
public function isValid($value, $context = null)
{
$context = array_change_key_case($context, CASE_LOWER);
switch ($this->hashAlgorithm) {
case WirecardCEE_Stdlib_Fingerprint::HASH_ALGORITHM_HMAC_SHA512:
case WirecardCEE_Stdlib_Fingerprint::HASH_ALGORITHM_SHA512:
$stringLength = 128;
break;
case WirecardCEE_Stdlib_Fingerprint::HASH_ALGORITHM_MD5:
$stringLength = 32;
break;
default:
throw new WirecardCEE_Stdlib_Exception_UnexpectedValueException(sprintf("Used hash algorithm '%s' is not supported. MD5, SHA512, or HMAC_SHA512 are currently supported.",
$this->hashAlgorithm));
break;
}
if (strlen($value) != $stringLength) {
return false;
}
if ($this->fingerprintOrderType == self::TYPE_FIXED) {
$fingerprintOrder = $this->fingerprintOrder;
} else {
if (array_key_exists($this->fingerprintOrderField, $context)) {
$fingerprintOrder = new WirecardCEE_Stdlib_FingerprintOrder(strtolower($context[$this->fingerprintOrderField]));
} else {
$this->_error(self::FINGERPRINTORDER_MISSING);
return false;
}
}
$fingerprintOrder->setOrder(array_map('strtolower', $this->fingerprintOrder->__toArray()));
if (!in_array('secret', $fingerprintOrder->__toArray())) {
throw new WirecardCEE_Stdlib_Exception_UnexpectedValueException();
}
$fingerprintFields = Array();
foreach ($fingerprintOrder as $fingerprintFieldKey) {
if ($fingerprintFieldKey == 'secret') {
$fingerprintFields[$fingerprintFieldKey] = $this->secret;
} else {
$fingerprintFields[$fingerprintFieldKey] = isset( $context[$fingerprintFieldKey] ) ? $context[$fingerprintFieldKey] : '';
}
}
if (!WirecardCEE_Stdlib_Fingerprint::compare($fingerprintFields, $fingerprintOrder, $value)) {
$this->_error(self::INVALID);
return false;
}
return true;
}
|
[
"public",
"function",
"isValid",
"(",
"$",
"value",
",",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"context",
"=",
"array_change_key_case",
"(",
"$",
"context",
",",
"CASE_LOWER",
")",
";",
"switch",
"(",
"$",
"this",
"->",
"hashAlgorithm",
")",
"{",
"case",
"WirecardCEE_Stdlib_Fingerprint",
"::",
"HASH_ALGORITHM_HMAC_SHA512",
":",
"case",
"WirecardCEE_Stdlib_Fingerprint",
"::",
"HASH_ALGORITHM_SHA512",
":",
"$",
"stringLength",
"=",
"128",
";",
"break",
";",
"case",
"WirecardCEE_Stdlib_Fingerprint",
"::",
"HASH_ALGORITHM_MD5",
":",
"$",
"stringLength",
"=",
"32",
";",
"break",
";",
"default",
":",
"throw",
"new",
"WirecardCEE_Stdlib_Exception_UnexpectedValueException",
"(",
"sprintf",
"(",
"\"Used hash algorithm '%s' is not supported. MD5, SHA512, or HMAC_SHA512 are currently supported.\"",
",",
"$",
"this",
"->",
"hashAlgorithm",
")",
")",
";",
"break",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"value",
")",
"!=",
"$",
"stringLength",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"fingerprintOrderType",
"==",
"self",
"::",
"TYPE_FIXED",
")",
"{",
"$",
"fingerprintOrder",
"=",
"$",
"this",
"->",
"fingerprintOrder",
";",
"}",
"else",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"this",
"->",
"fingerprintOrderField",
",",
"$",
"context",
")",
")",
"{",
"$",
"fingerprintOrder",
"=",
"new",
"WirecardCEE_Stdlib_FingerprintOrder",
"(",
"strtolower",
"(",
"$",
"context",
"[",
"$",
"this",
"->",
"fingerprintOrderField",
"]",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_error",
"(",
"self",
"::",
"FINGERPRINTORDER_MISSING",
")",
";",
"return",
"false",
";",
"}",
"}",
"$",
"fingerprintOrder",
"->",
"setOrder",
"(",
"array_map",
"(",
"'strtolower'",
",",
"$",
"this",
"->",
"fingerprintOrder",
"->",
"__toArray",
"(",
")",
")",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"'secret'",
",",
"$",
"fingerprintOrder",
"->",
"__toArray",
"(",
")",
")",
")",
"{",
"throw",
"new",
"WirecardCEE_Stdlib_Exception_UnexpectedValueException",
"(",
")",
";",
"}",
"$",
"fingerprintFields",
"=",
"Array",
"(",
")",
";",
"foreach",
"(",
"$",
"fingerprintOrder",
"as",
"$",
"fingerprintFieldKey",
")",
"{",
"if",
"(",
"$",
"fingerprintFieldKey",
"==",
"'secret'",
")",
"{",
"$",
"fingerprintFields",
"[",
"$",
"fingerprintFieldKey",
"]",
"=",
"$",
"this",
"->",
"secret",
";",
"}",
"else",
"{",
"$",
"fingerprintFields",
"[",
"$",
"fingerprintFieldKey",
"]",
"=",
"isset",
"(",
"$",
"context",
"[",
"$",
"fingerprintFieldKey",
"]",
")",
"?",
"$",
"context",
"[",
"$",
"fingerprintFieldKey",
"]",
":",
"''",
";",
"}",
"}",
"if",
"(",
"!",
"WirecardCEE_Stdlib_Fingerprint",
"::",
"compare",
"(",
"$",
"fingerprintFields",
",",
"$",
"fingerprintOrder",
",",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"_error",
"(",
"self",
"::",
"INVALID",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Is validator check valid?
@see WirecardCEE_Stdlib_Validate_Interface::isValid()
|
[
"Is",
"validator",
"check",
"valid?"
] |
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
|
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/Stdlib/Validate/Fingerprint.php#L280-L335
|
223,409
|
leonelquinteros/php-toml
|
src/Toml.php
|
Toml.parseFile
|
public static function parseFile($path)
{
if(!is_file($path))
{
throw new Exception('Invalid file path');
}
$toml = file_get_contents($path);
// Remove BOM if present
$toml = preg_replace('/^' . pack('H*','EFBBBF') . '/', '', $toml);
return self::parse($toml);
}
|
php
|
public static function parseFile($path)
{
if(!is_file($path))
{
throw new Exception('Invalid file path');
}
$toml = file_get_contents($path);
// Remove BOM if present
$toml = preg_replace('/^' . pack('H*','EFBBBF') . '/', '', $toml);
return self::parse($toml);
}
|
[
"public",
"static",
"function",
"parseFile",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid file path'",
")",
";",
"}",
"$",
"toml",
"=",
"file_get_contents",
"(",
"$",
"path",
")",
";",
"// Remove BOM if present",
"$",
"toml",
"=",
"preg_replace",
"(",
"'/^'",
".",
"pack",
"(",
"'H*'",
",",
"'EFBBBF'",
")",
".",
"'/'",
",",
"''",
",",
"$",
"toml",
")",
";",
"return",
"self",
"::",
"parse",
"(",
"$",
"toml",
")",
";",
"}"
] |
Reads string from specified file path and parses it as TOML.
@param (string) File path
@return (array) Toml::parse() result
|
[
"Reads",
"string",
"from",
"specified",
"file",
"path",
"and",
"parses",
"it",
"as",
"TOML",
"."
] |
33e0157ff38626d39f0fe71d642301a320a12fc3
|
https://github.com/leonelquinteros/php-toml/blob/33e0157ff38626d39f0fe71d642301a320a12fc3/src/Toml.php#L51-L64
|
223,410
|
leonelquinteros/php-toml
|
src/Toml.php
|
Toml.parseTableName
|
private static function parseTableName($name)
{
// Init buffer
$buffer = '';
$strOpen = false;
$names = array();
$strLen = strlen($name);
for($i = 0; $i < $strLen; $i++)
{
if($name[$i] == '"')
{
// Toggle strings
if( !$strOpen || ($strOpen && $name[$i - 1] != "\\") )
{
$strOpen = !$strOpen;
}
}
elseif($name[$i] == '.' && !$strOpen)
{
// Save and cleanup buffer. Continue.
$names[] = $buffer;
$buffer = '';
continue;
}
// Store char
$buffer .= $name[$i];
}
// Save last buffer
if($buffer != '') {
$names[] = $buffer;
}
return $names;
}
|
php
|
private static function parseTableName($name)
{
// Init buffer
$buffer = '';
$strOpen = false;
$names = array();
$strLen = strlen($name);
for($i = 0; $i < $strLen; $i++)
{
if($name[$i] == '"')
{
// Toggle strings
if( !$strOpen || ($strOpen && $name[$i - 1] != "\\") )
{
$strOpen = !$strOpen;
}
}
elseif($name[$i] == '.' && !$strOpen)
{
// Save and cleanup buffer. Continue.
$names[] = $buffer;
$buffer = '';
continue;
}
// Store char
$buffer .= $name[$i];
}
// Save last buffer
if($buffer != '') {
$names[] = $buffer;
}
return $names;
}
|
[
"private",
"static",
"function",
"parseTableName",
"(",
"$",
"name",
")",
"{",
"// Init buffer",
"$",
"buffer",
"=",
"''",
";",
"$",
"strOpen",
"=",
"false",
";",
"$",
"names",
"=",
"array",
"(",
")",
";",
"$",
"strLen",
"=",
"strlen",
"(",
"$",
"name",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"strLen",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"name",
"[",
"$",
"i",
"]",
"==",
"'\"'",
")",
"{",
"// Toggle strings",
"if",
"(",
"!",
"$",
"strOpen",
"||",
"(",
"$",
"strOpen",
"&&",
"$",
"name",
"[",
"$",
"i",
"-",
"1",
"]",
"!=",
"\"\\\\\"",
")",
")",
"{",
"$",
"strOpen",
"=",
"!",
"$",
"strOpen",
";",
"}",
"}",
"elseif",
"(",
"$",
"name",
"[",
"$",
"i",
"]",
"==",
"'.'",
"&&",
"!",
"$",
"strOpen",
")",
"{",
"// Save and cleanup buffer. Continue.",
"$",
"names",
"[",
"]",
"=",
"$",
"buffer",
";",
"$",
"buffer",
"=",
"''",
";",
"continue",
";",
"}",
"// Store char",
"$",
"buffer",
".=",
"$",
"name",
"[",
"$",
"i",
"]",
";",
"}",
"// Save last buffer",
"if",
"(",
"$",
"buffer",
"!=",
"''",
")",
"{",
"$",
"names",
"[",
"]",
"=",
"$",
"buffer",
";",
"}",
"return",
"$",
"names",
";",
"}"
] |
Parses TOML table names and returns the hierarchy array of table names.
@param (string) $name
@return (array) Table names
|
[
"Parses",
"TOML",
"table",
"names",
"and",
"returns",
"the",
"hierarchy",
"array",
"of",
"table",
"names",
"."
] |
33e0157ff38626d39f0fe71d642301a320a12fc3
|
https://github.com/leonelquinteros/php-toml/blob/33e0157ff38626d39f0fe71d642301a320a12fc3/src/Toml.php#L464-L500
|
223,411
|
leonelquinteros/php-toml
|
src/Toml.php
|
Toml.parseValue
|
private static function parseValue($val)
{
$parsedVal = null;
// Cleanup
$val = trim($val);
if($val === '')
{
throw new Exception('Empty value not allowed');
}
// Boolean
if($val == 'true' || $val == 'false')
{
$parsedVal = ($val == 'true');
}
// Literal multi-line string
elseif(substr($val, 0, 3) == "'''" && substr($val, -3) == "'''")
{
$parsedVal = substr($val, 3, -3);
// Trim first newline on multi-line string definition
if($parsedVal[0] == "\n")
{
$parsedVal = substr($parsedVal, 1);
}
}
// Literal string
elseif($val[0] == "'" && substr($val, -1) == "'")
{
// No newlines allowed
if(strpos($val, "\n") !== false)
{
throw new Exception('New lines not allowed on single line string literals.');
}
$parsedVal = substr($val, 1, -1);
}
// Multi-line string
elseif(substr($val, 0, 3) == '"""' && substr($val, -3) == '"""')
{
$parsedVal = substr($val, 3, -3);
// Trim first newline on multi-line string definition
if($parsedVal[0] == "\n")
{
$parsedVal = substr($parsedVal, 1);
}
// Use json_decode to finally parse the string.
$parsedVal = json_decode('"' . str_replace("\n", '\n', $parsedVal) . '"');
}
// String
elseif($val[0] == '"' && substr($val, -1) == '"')
{
// TOML's specification says it's the same as for JSON format... so
$parsedVal = json_decode($val);
}
// Numbers
elseif(is_numeric(str_replace('_', '', $val)))
{
$val = str_replace('_', '', $val);
$intVal = filter_var($val, FILTER_VALIDATE_INT);
if($intVal !== false)
{
$parsedVal = $intVal;
}
else
{
$parsedVal = (float) $val;
}
}
// Datetime. Parsed to UNIX time value.
elseif(self::isISODate($val))
{
$parsedVal = new DateTime($val);
}
// Single line array (normalized)
elseif($val[0] == '[' && substr($val, -1) == ']')
{
$parsedVal = self::parseArray($val);
}
// Inline table (normalized)
elseif($val[0] == '{' && substr($val, -1) == '}')
{
$parsedVal = self::parseInlineTable($val);
}
else
{
throw new Exception('Unknown value type: ' . $val);
}
return $parsedVal;
}
|
php
|
private static function parseValue($val)
{
$parsedVal = null;
// Cleanup
$val = trim($val);
if($val === '')
{
throw new Exception('Empty value not allowed');
}
// Boolean
if($val == 'true' || $val == 'false')
{
$parsedVal = ($val == 'true');
}
// Literal multi-line string
elseif(substr($val, 0, 3) == "'''" && substr($val, -3) == "'''")
{
$parsedVal = substr($val, 3, -3);
// Trim first newline on multi-line string definition
if($parsedVal[0] == "\n")
{
$parsedVal = substr($parsedVal, 1);
}
}
// Literal string
elseif($val[0] == "'" && substr($val, -1) == "'")
{
// No newlines allowed
if(strpos($val, "\n") !== false)
{
throw new Exception('New lines not allowed on single line string literals.');
}
$parsedVal = substr($val, 1, -1);
}
// Multi-line string
elseif(substr($val, 0, 3) == '"""' && substr($val, -3) == '"""')
{
$parsedVal = substr($val, 3, -3);
// Trim first newline on multi-line string definition
if($parsedVal[0] == "\n")
{
$parsedVal = substr($parsedVal, 1);
}
// Use json_decode to finally parse the string.
$parsedVal = json_decode('"' . str_replace("\n", '\n', $parsedVal) . '"');
}
// String
elseif($val[0] == '"' && substr($val, -1) == '"')
{
// TOML's specification says it's the same as for JSON format... so
$parsedVal = json_decode($val);
}
// Numbers
elseif(is_numeric(str_replace('_', '', $val)))
{
$val = str_replace('_', '', $val);
$intVal = filter_var($val, FILTER_VALIDATE_INT);
if($intVal !== false)
{
$parsedVal = $intVal;
}
else
{
$parsedVal = (float) $val;
}
}
// Datetime. Parsed to UNIX time value.
elseif(self::isISODate($val))
{
$parsedVal = new DateTime($val);
}
// Single line array (normalized)
elseif($val[0] == '[' && substr($val, -1) == ']')
{
$parsedVal = self::parseArray($val);
}
// Inline table (normalized)
elseif($val[0] == '{' && substr($val, -1) == '}')
{
$parsedVal = self::parseInlineTable($val);
}
else
{
throw new Exception('Unknown value type: ' . $val);
}
return $parsedVal;
}
|
[
"private",
"static",
"function",
"parseValue",
"(",
"$",
"val",
")",
"{",
"$",
"parsedVal",
"=",
"null",
";",
"// Cleanup",
"$",
"val",
"=",
"trim",
"(",
"$",
"val",
")",
";",
"if",
"(",
"$",
"val",
"===",
"''",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Empty value not allowed'",
")",
";",
"}",
"// Boolean",
"if",
"(",
"$",
"val",
"==",
"'true'",
"||",
"$",
"val",
"==",
"'false'",
")",
"{",
"$",
"parsedVal",
"=",
"(",
"$",
"val",
"==",
"'true'",
")",
";",
"}",
"// Literal multi-line string",
"elseif",
"(",
"substr",
"(",
"$",
"val",
",",
"0",
",",
"3",
")",
"==",
"\"'''\"",
"&&",
"substr",
"(",
"$",
"val",
",",
"-",
"3",
")",
"==",
"\"'''\"",
")",
"{",
"$",
"parsedVal",
"=",
"substr",
"(",
"$",
"val",
",",
"3",
",",
"-",
"3",
")",
";",
"// Trim first newline on multi-line string definition",
"if",
"(",
"$",
"parsedVal",
"[",
"0",
"]",
"==",
"\"\\n\"",
")",
"{",
"$",
"parsedVal",
"=",
"substr",
"(",
"$",
"parsedVal",
",",
"1",
")",
";",
"}",
"}",
"// Literal string",
"elseif",
"(",
"$",
"val",
"[",
"0",
"]",
"==",
"\"'\"",
"&&",
"substr",
"(",
"$",
"val",
",",
"-",
"1",
")",
"==",
"\"'\"",
")",
"{",
"// No newlines allowed",
"if",
"(",
"strpos",
"(",
"$",
"val",
",",
"\"\\n\"",
")",
"!==",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'New lines not allowed on single line string literals.'",
")",
";",
"}",
"$",
"parsedVal",
"=",
"substr",
"(",
"$",
"val",
",",
"1",
",",
"-",
"1",
")",
";",
"}",
"// Multi-line string",
"elseif",
"(",
"substr",
"(",
"$",
"val",
",",
"0",
",",
"3",
")",
"==",
"'\"\"\"'",
"&&",
"substr",
"(",
"$",
"val",
",",
"-",
"3",
")",
"==",
"'\"\"\"'",
")",
"{",
"$",
"parsedVal",
"=",
"substr",
"(",
"$",
"val",
",",
"3",
",",
"-",
"3",
")",
";",
"// Trim first newline on multi-line string definition",
"if",
"(",
"$",
"parsedVal",
"[",
"0",
"]",
"==",
"\"\\n\"",
")",
"{",
"$",
"parsedVal",
"=",
"substr",
"(",
"$",
"parsedVal",
",",
"1",
")",
";",
"}",
"// Use json_decode to finally parse the string.",
"$",
"parsedVal",
"=",
"json_decode",
"(",
"'\"'",
".",
"str_replace",
"(",
"\"\\n\"",
",",
"'\\n'",
",",
"$",
"parsedVal",
")",
".",
"'\"'",
")",
";",
"}",
"// String",
"elseif",
"(",
"$",
"val",
"[",
"0",
"]",
"==",
"'\"'",
"&&",
"substr",
"(",
"$",
"val",
",",
"-",
"1",
")",
"==",
"'\"'",
")",
"{",
"// TOML's specification says it's the same as for JSON format... so",
"$",
"parsedVal",
"=",
"json_decode",
"(",
"$",
"val",
")",
";",
"}",
"// Numbers",
"elseif",
"(",
"is_numeric",
"(",
"str_replace",
"(",
"'_'",
",",
"''",
",",
"$",
"val",
")",
")",
")",
"{",
"$",
"val",
"=",
"str_replace",
"(",
"'_'",
",",
"''",
",",
"$",
"val",
")",
";",
"$",
"intVal",
"=",
"filter_var",
"(",
"$",
"val",
",",
"FILTER_VALIDATE_INT",
")",
";",
"if",
"(",
"$",
"intVal",
"!==",
"false",
")",
"{",
"$",
"parsedVal",
"=",
"$",
"intVal",
";",
"}",
"else",
"{",
"$",
"parsedVal",
"=",
"(",
"float",
")",
"$",
"val",
";",
"}",
"}",
"// Datetime. Parsed to UNIX time value.",
"elseif",
"(",
"self",
"::",
"isISODate",
"(",
"$",
"val",
")",
")",
"{",
"$",
"parsedVal",
"=",
"new",
"DateTime",
"(",
"$",
"val",
")",
";",
"}",
"// Single line array (normalized)",
"elseif",
"(",
"$",
"val",
"[",
"0",
"]",
"==",
"'['",
"&&",
"substr",
"(",
"$",
"val",
",",
"-",
"1",
")",
"==",
"']'",
")",
"{",
"$",
"parsedVal",
"=",
"self",
"::",
"parseArray",
"(",
"$",
"val",
")",
";",
"}",
"// Inline table (normalized)",
"elseif",
"(",
"$",
"val",
"[",
"0",
"]",
"==",
"'{'",
"&&",
"substr",
"(",
"$",
"val",
",",
"-",
"1",
")",
"==",
"'}'",
")",
"{",
"$",
"parsedVal",
"=",
"self",
"::",
"parseInlineTable",
"(",
"$",
"val",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"'Unknown value type: '",
".",
"$",
"val",
")",
";",
"}",
"return",
"$",
"parsedVal",
";",
"}"
] |
Parses TOML value and returns it to be assigned on the hashed array
@param (string) $val
@return (mixed) Parsed value.
|
[
"Parses",
"TOML",
"value",
"and",
"returns",
"it",
"to",
"be",
"assigned",
"on",
"the",
"hashed",
"array"
] |
33e0157ff38626d39f0fe71d642301a320a12fc3
|
https://github.com/leonelquinteros/php-toml/blob/33e0157ff38626d39f0fe71d642301a320a12fc3/src/Toml.php#L509-L604
|
223,412
|
leonelquinteros/php-toml
|
src/Toml.php
|
Toml.parseInlineTable
|
private static function parseInlineTable($val)
{
// Check valid inline table
if($val[0] == '{' && substr($val, -1) == '}')
{
$val = substr($val, 1, -1);
}
else
{
throw new Exception('Invalid inline table definition: ' . $val);
}
$result = new stdClass();
$openString = false;
$openLString = false;
$buffer = '';
$strLen = strlen($val);
for($i = 0; $i < $strLen; $i++)
{
// Handle strings
if($val[$i] == '"' && $val[$i - 1] != "\\")
{
$openString = !$openString;
}
elseif($val[$i] == "'") {
$openLString = !$openLString;
}
if( $val[$i] == ',' && !$openString && !$openLString )
{
// Parse buffer
$kv = explode('=', $buffer, 2);
$result->{trim($kv[0])} = self::parseValue( trim($kv[1]) );
// Clear buffer
$buffer = '';
}
else
{
$buffer .= $val[$i];
}
}
// Parse last buffer
$kv = explode('=', $buffer, 2);
$result->{trim($kv[0])} = self::parseValue( trim($kv[1]) );
return $result;
}
|
php
|
private static function parseInlineTable($val)
{
// Check valid inline table
if($val[0] == '{' && substr($val, -1) == '}')
{
$val = substr($val, 1, -1);
}
else
{
throw new Exception('Invalid inline table definition: ' . $val);
}
$result = new stdClass();
$openString = false;
$openLString = false;
$buffer = '';
$strLen = strlen($val);
for($i = 0; $i < $strLen; $i++)
{
// Handle strings
if($val[$i] == '"' && $val[$i - 1] != "\\")
{
$openString = !$openString;
}
elseif($val[$i] == "'") {
$openLString = !$openLString;
}
if( $val[$i] == ',' && !$openString && !$openLString )
{
// Parse buffer
$kv = explode('=', $buffer, 2);
$result->{trim($kv[0])} = self::parseValue( trim($kv[1]) );
// Clear buffer
$buffer = '';
}
else
{
$buffer .= $val[$i];
}
}
// Parse last buffer
$kv = explode('=', $buffer, 2);
$result->{trim($kv[0])} = self::parseValue( trim($kv[1]) );
return $result;
}
|
[
"private",
"static",
"function",
"parseInlineTable",
"(",
"$",
"val",
")",
"{",
"// Check valid inline table",
"if",
"(",
"$",
"val",
"[",
"0",
"]",
"==",
"'{'",
"&&",
"substr",
"(",
"$",
"val",
",",
"-",
"1",
")",
"==",
"'}'",
")",
"{",
"$",
"val",
"=",
"substr",
"(",
"$",
"val",
",",
"1",
",",
"-",
"1",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid inline table definition: '",
".",
"$",
"val",
")",
";",
"}",
"$",
"result",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"openString",
"=",
"false",
";",
"$",
"openLString",
"=",
"false",
";",
"$",
"buffer",
"=",
"''",
";",
"$",
"strLen",
"=",
"strlen",
"(",
"$",
"val",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"strLen",
";",
"$",
"i",
"++",
")",
"{",
"// Handle strings",
"if",
"(",
"$",
"val",
"[",
"$",
"i",
"]",
"==",
"'\"'",
"&&",
"$",
"val",
"[",
"$",
"i",
"-",
"1",
"]",
"!=",
"\"\\\\\"",
")",
"{",
"$",
"openString",
"=",
"!",
"$",
"openString",
";",
"}",
"elseif",
"(",
"$",
"val",
"[",
"$",
"i",
"]",
"==",
"\"'\"",
")",
"{",
"$",
"openLString",
"=",
"!",
"$",
"openLString",
";",
"}",
"if",
"(",
"$",
"val",
"[",
"$",
"i",
"]",
"==",
"','",
"&&",
"!",
"$",
"openString",
"&&",
"!",
"$",
"openLString",
")",
"{",
"// Parse buffer",
"$",
"kv",
"=",
"explode",
"(",
"'='",
",",
"$",
"buffer",
",",
"2",
")",
";",
"$",
"result",
"->",
"{",
"trim",
"(",
"$",
"kv",
"[",
"0",
"]",
")",
"}",
"=",
"self",
"::",
"parseValue",
"(",
"trim",
"(",
"$",
"kv",
"[",
"1",
"]",
")",
")",
";",
"// Clear buffer",
"$",
"buffer",
"=",
"''",
";",
"}",
"else",
"{",
"$",
"buffer",
".=",
"$",
"val",
"[",
"$",
"i",
"]",
";",
"}",
"}",
"// Parse last buffer",
"$",
"kv",
"=",
"explode",
"(",
"'='",
",",
"$",
"buffer",
",",
"2",
")",
";",
"$",
"result",
"->",
"{",
"trim",
"(",
"$",
"kv",
"[",
"0",
"]",
")",
"}",
"=",
"self",
"::",
"parseValue",
"(",
"trim",
"(",
"$",
"kv",
"[",
"1",
"]",
")",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Parse inline tables into common table array
|
[
"Parse",
"inline",
"tables",
"into",
"common",
"table",
"array"
] |
33e0157ff38626d39f0fe71d642301a320a12fc3
|
https://github.com/leonelquinteros/php-toml/blob/33e0157ff38626d39f0fe71d642301a320a12fc3/src/Toml.php#L686-L735
|
223,413
|
leonelquinteros/php-toml
|
src/Toml.php
|
Toml.parseKeyValue
|
private static function parseKeyValue($key, $val, & $pointer)
{
// Flags
$openQuote = false;
$openDoubleQuote = false;
// Buffer
$buff = '';
// Parse
for($i = 0; $i < strlen($key); $i++) {
// Handle quoting
if($key[$i] == '"') {
if(!$openQuote) {
if($openDoubleQuote) {
$openDoubleQuote = false;
} else {
$openDoubleQuote = true;
}
continue;
}
}
if($key[$i] == "'") {
if(!$openDoubleQuote) {
if($openQuote) {
$openQuote = false;
} else {
$openQuote = true;
}
continue;
}
}
// Handle dotted keys
if($key[$i] == "." && !$openQuote && !$openDoubleQuote) {
if(is_array($pointer)) {
if(!isset($pointer[$buff])) {
$pointer[$buff] = new stdClass();
}
$pointer = & $pointer[$buff];
} else {
if(!isset($pointer->{$buff})) {
$pointer->{$buff} = new stdClass();
}
$pointer = & $pointer->{$buff};
}
// Cleanup buffer
$buff = '';
continue;
}
$buff .= $key[$i];
}
if(is_array($pointer)) {
$pointer[$buff] = self::parseValue( $val );
} else {
$pointer->{$buff} = self::parseValue( $val );
}
return $buff;
}
|
php
|
private static function parseKeyValue($key, $val, & $pointer)
{
// Flags
$openQuote = false;
$openDoubleQuote = false;
// Buffer
$buff = '';
// Parse
for($i = 0; $i < strlen($key); $i++) {
// Handle quoting
if($key[$i] == '"') {
if(!$openQuote) {
if($openDoubleQuote) {
$openDoubleQuote = false;
} else {
$openDoubleQuote = true;
}
continue;
}
}
if($key[$i] == "'") {
if(!$openDoubleQuote) {
if($openQuote) {
$openQuote = false;
} else {
$openQuote = true;
}
continue;
}
}
// Handle dotted keys
if($key[$i] == "." && !$openQuote && !$openDoubleQuote) {
if(is_array($pointer)) {
if(!isset($pointer[$buff])) {
$pointer[$buff] = new stdClass();
}
$pointer = & $pointer[$buff];
} else {
if(!isset($pointer->{$buff})) {
$pointer->{$buff} = new stdClass();
}
$pointer = & $pointer->{$buff};
}
// Cleanup buffer
$buff = '';
continue;
}
$buff .= $key[$i];
}
if(is_array($pointer)) {
$pointer[$buff] = self::parseValue( $val );
} else {
$pointer->{$buff} = self::parseValue( $val );
}
return $buff;
}
|
[
"private",
"static",
"function",
"parseKeyValue",
"(",
"$",
"key",
",",
"$",
"val",
",",
"&",
"$",
"pointer",
")",
"{",
"// Flags",
"$",
"openQuote",
"=",
"false",
";",
"$",
"openDoubleQuote",
"=",
"false",
";",
"// Buffer",
"$",
"buff",
"=",
"''",
";",
"// Parse",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
"key",
")",
";",
"$",
"i",
"++",
")",
"{",
"// Handle quoting",
"if",
"(",
"$",
"key",
"[",
"$",
"i",
"]",
"==",
"'\"'",
")",
"{",
"if",
"(",
"!",
"$",
"openQuote",
")",
"{",
"if",
"(",
"$",
"openDoubleQuote",
")",
"{",
"$",
"openDoubleQuote",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"openDoubleQuote",
"=",
"true",
";",
"}",
"continue",
";",
"}",
"}",
"if",
"(",
"$",
"key",
"[",
"$",
"i",
"]",
"==",
"\"'\"",
")",
"{",
"if",
"(",
"!",
"$",
"openDoubleQuote",
")",
"{",
"if",
"(",
"$",
"openQuote",
")",
"{",
"$",
"openQuote",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"openQuote",
"=",
"true",
";",
"}",
"continue",
";",
"}",
"}",
"// Handle dotted keys",
"if",
"(",
"$",
"key",
"[",
"$",
"i",
"]",
"==",
"\".\"",
"&&",
"!",
"$",
"openQuote",
"&&",
"!",
"$",
"openDoubleQuote",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"pointer",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"pointer",
"[",
"$",
"buff",
"]",
")",
")",
"{",
"$",
"pointer",
"[",
"$",
"buff",
"]",
"=",
"new",
"stdClass",
"(",
")",
";",
"}",
"$",
"pointer",
"=",
"&",
"$",
"pointer",
"[",
"$",
"buff",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"pointer",
"->",
"{",
"$",
"buff",
"}",
")",
")",
"{",
"$",
"pointer",
"->",
"{",
"$",
"buff",
"}",
"=",
"new",
"stdClass",
"(",
")",
";",
"}",
"$",
"pointer",
"=",
"&",
"$",
"pointer",
"->",
"{",
"$",
"buff",
"}",
";",
"}",
"// Cleanup buffer",
"$",
"buff",
"=",
"''",
";",
"continue",
";",
"}",
"$",
"buff",
".=",
"$",
"key",
"[",
"$",
"i",
"]",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"pointer",
")",
")",
"{",
"$",
"pointer",
"[",
"$",
"buff",
"]",
"=",
"self",
"::",
"parseValue",
"(",
"$",
"val",
")",
";",
"}",
"else",
"{",
"$",
"pointer",
"->",
"{",
"$",
"buff",
"}",
"=",
"self",
"::",
"parseValue",
"(",
"$",
"val",
")",
";",
"}",
"return",
"$",
"buff",
";",
"}"
] |
Function that takes a key expression and the current pointer to position in the right hierarchy.
Then it sets the corresponding value on that position.
@param (string) $key
@param (&) $pointer
|
[
"Function",
"that",
"takes",
"a",
"key",
"expression",
"and",
"the",
"current",
"pointer",
"to",
"position",
"in",
"the",
"right",
"hierarchy",
".",
"Then",
"it",
"sets",
"the",
"corresponding",
"value",
"on",
"that",
"position",
"."
] |
33e0157ff38626d39f0fe71d642301a320a12fc3
|
https://github.com/leonelquinteros/php-toml/blob/33e0157ff38626d39f0fe71d642301a320a12fc3/src/Toml.php#L744-L806
|
223,414
|
leonelquinteros/php-toml
|
src/Toml.php
|
Toml.checkDataType
|
private static function checkDataType($array)
{
if(count($array) <= 1)
{
return true;
}
$last = count($array) - 1;
$type = self::getCustomDataType($array[$last]);
if ($type != self::getCustomDataType($array[0]))
{
return false;
}
else
{
return true;
}
}
|
php
|
private static function checkDataType($array)
{
if(count($array) <= 1)
{
return true;
}
$last = count($array) - 1;
$type = self::getCustomDataType($array[$last]);
if ($type != self::getCustomDataType($array[0]))
{
return false;
}
else
{
return true;
}
}
|
[
"private",
"static",
"function",
"checkDataType",
"(",
"$",
"array",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"array",
")",
"<=",
"1",
")",
"{",
"return",
"true",
";",
"}",
"$",
"last",
"=",
"count",
"(",
"$",
"array",
")",
"-",
"1",
";",
"$",
"type",
"=",
"self",
"::",
"getCustomDataType",
"(",
"$",
"array",
"[",
"$",
"last",
"]",
")",
";",
"if",
"(",
"$",
"type",
"!=",
"self",
"::",
"getCustomDataType",
"(",
"$",
"array",
"[",
"0",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] |
Function that checks the data type of the first and last elements of an array,
and returns false if they don't match
@param (array) $array
@return boolean
|
[
"Function",
"that",
"checks",
"the",
"data",
"type",
"of",
"the",
"first",
"and",
"last",
"elements",
"of",
"an",
"array",
"and",
"returns",
"false",
"if",
"they",
"don",
"t",
"match"
] |
33e0157ff38626d39f0fe71d642301a320a12fc3
|
https://github.com/leonelquinteros/php-toml/blob/33e0157ff38626d39f0fe71d642301a320a12fc3/src/Toml.php#L816-L835
|
223,415
|
leonelquinteros/php-toml
|
src/Toml.php
|
Toml.isISODate
|
public static function isISODate($val)
{
if(!is_string($val)) {
return false;
}
// Use DateTime support to check for valid dates.
try
{
$date = new DateTime($val);
}
catch(Exception $e)
{
return false;
}
return true;
}
|
php
|
public static function isISODate($val)
{
if(!is_string($val)) {
return false;
}
// Use DateTime support to check for valid dates.
try
{
$date = new DateTime($val);
}
catch(Exception $e)
{
return false;
}
return true;
}
|
[
"public",
"static",
"function",
"isISODate",
"(",
"$",
"val",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"val",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Use DateTime support to check for valid dates.",
"try",
"{",
"$",
"date",
"=",
"new",
"DateTime",
"(",
"$",
"val",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Return whether the given value is a valid ISODate
@param (string) $val
@return boolean
|
[
"Return",
"whether",
"the",
"given",
"value",
"is",
"a",
"valid",
"ISODate"
] |
33e0157ff38626d39f0fe71d642301a320a12fc3
|
https://github.com/leonelquinteros/php-toml/blob/33e0157ff38626d39f0fe71d642301a320a12fc3/src/Toml.php#L863-L880
|
223,416
|
digiaonline/lumen-fractal
|
src/FractalService.php
|
FractalService.makeBuilder
|
protected function makeBuilder(
$resourceClass,
$data,
TransformerAbstract $transformer = null,
$resourceKey = null
) {
$fractal = $this->makeFractal();
$builder = new FractalBuilder($fractal, $resourceClass, $data);
if ($transformer !== null) {
$builder->setTransformer($transformer);
}
if ($resourceKey !== null) {
$builder->setResourceKey($resourceKey);
}
return $builder;
}
|
php
|
protected function makeBuilder(
$resourceClass,
$data,
TransformerAbstract $transformer = null,
$resourceKey = null
) {
$fractal = $this->makeFractal();
$builder = new FractalBuilder($fractal, $resourceClass, $data);
if ($transformer !== null) {
$builder->setTransformer($transformer);
}
if ($resourceKey !== null) {
$builder->setResourceKey($resourceKey);
}
return $builder;
}
|
[
"protected",
"function",
"makeBuilder",
"(",
"$",
"resourceClass",
",",
"$",
"data",
",",
"TransformerAbstract",
"$",
"transformer",
"=",
"null",
",",
"$",
"resourceKey",
"=",
"null",
")",
"{",
"$",
"fractal",
"=",
"$",
"this",
"->",
"makeFractal",
"(",
")",
";",
"$",
"builder",
"=",
"new",
"FractalBuilder",
"(",
"$",
"fractal",
",",
"$",
"resourceClass",
",",
"$",
"data",
")",
";",
"if",
"(",
"$",
"transformer",
"!==",
"null",
")",
"{",
"$",
"builder",
"->",
"setTransformer",
"(",
"$",
"transformer",
")",
";",
"}",
"if",
"(",
"$",
"resourceKey",
"!==",
"null",
")",
"{",
"$",
"builder",
"->",
"setResourceKey",
"(",
"$",
"resourceKey",
")",
";",
"}",
"return",
"$",
"builder",
";",
"}"
] |
Creates a builder for serializing data.
@param array $resourceClass
@param mixed $data
@param TransformerAbstract|null $transformer
@param string|null $resourceKey
@return FractalBuilder
|
[
"Creates",
"a",
"builder",
"for",
"serializing",
"data",
"."
] |
f2e70aff2d8ae55e072b062ed4ded45d0635069f
|
https://github.com/digiaonline/lumen-fractal/blob/f2e70aff2d8ae55e072b062ed4ded45d0635069f/src/FractalService.php#L75-L93
|
223,417
|
Payum/PayumModule
|
src/Payum/PayumModule/Module/AbstractModuleNoTraits.php
|
AbstractModuleNoTraits.getAutoloaderConfig
|
public function getAutoloaderConfig()
{
$autoloaderArray = array();
// If this module has a defined classmap, add a classmap autoloader.
$classmapPath = $this->getDir() . '/' . $this->relativeModuleDir . 'autoload_classmap.php';
if (file_exists($classmapPath)) {
$autoloaderArray['Zend\Loader\ClassMapAutoloader'] = array(
$classmapPath
);
}
// Fallback to a PSR-0 autoloader.
$autoloaderArray['Zend\Loader\StandardAutoloader'] = array(
'namespaces' => array(
$this->getNamespace() =>
$this->getDir() . '/' . $this->relativeModuleDir . 'src/' . $this->getNamespace(),
),
);
return $autoloaderArray;
}
|
php
|
public function getAutoloaderConfig()
{
$autoloaderArray = array();
// If this module has a defined classmap, add a classmap autoloader.
$classmapPath = $this->getDir() . '/' . $this->relativeModuleDir . 'autoload_classmap.php';
if (file_exists($classmapPath)) {
$autoloaderArray['Zend\Loader\ClassMapAutoloader'] = array(
$classmapPath
);
}
// Fallback to a PSR-0 autoloader.
$autoloaderArray['Zend\Loader\StandardAutoloader'] = array(
'namespaces' => array(
$this->getNamespace() =>
$this->getDir() . '/' . $this->relativeModuleDir . 'src/' . $this->getNamespace(),
),
);
return $autoloaderArray;
}
|
[
"public",
"function",
"getAutoloaderConfig",
"(",
")",
"{",
"$",
"autoloaderArray",
"=",
"array",
"(",
")",
";",
"// If this module has a defined classmap, add a classmap autoloader.",
"$",
"classmapPath",
"=",
"$",
"this",
"->",
"getDir",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"relativeModuleDir",
".",
"'autoload_classmap.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"classmapPath",
")",
")",
"{",
"$",
"autoloaderArray",
"[",
"'Zend\\Loader\\ClassMapAutoloader'",
"]",
"=",
"array",
"(",
"$",
"classmapPath",
")",
";",
"}",
"// Fallback to a PSR-0 autoloader.",
"$",
"autoloaderArray",
"[",
"'Zend\\Loader\\StandardAutoloader'",
"]",
"=",
"array",
"(",
"'namespaces'",
"=>",
"array",
"(",
"$",
"this",
"->",
"getNamespace",
"(",
")",
"=>",
"$",
"this",
"->",
"getDir",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"relativeModuleDir",
".",
"'src/'",
".",
"$",
"this",
"->",
"getNamespace",
"(",
")",
",",
")",
",",
")",
";",
"return",
"$",
"autoloaderArray",
";",
"}"
] |
Return an array to configure a default autoloader instance.
@return array
|
[
"Return",
"an",
"array",
"to",
"configure",
"a",
"default",
"autoloader",
"instance",
"."
] |
ecac0586b4573edd686aa899b05021b6995ee355
|
https://github.com/Payum/PayumModule/blob/ecac0586b4573edd686aa899b05021b6995ee355/src/Payum/PayumModule/Module/AbstractModuleNoTraits.php#L51-L72
|
223,418
|
silverstripe/silverstripe-ldap
|
src/Tasks/LDAPMemberSyncOneTask.php
|
LDAPMemberSyncOneTask.run
|
public function run($request)
{
$email = $request->getVar('email');
if (!$email) {
echo 'You must supply an email parameter to this method.', PHP_EOL;
exit;
}
$user = $this->ldapService->getUserByEmail($email);
if (!$user) {
echo sprintf('No user found in LDAP for email %s', $email), PHP_EOL;
exit;
}
$member = $this->findOrCreateMember($user);
// If member exists already, we're updating - otherwise we're creating
if ($member->exists()) {
$this->log(sprintf(
'Updating existing Member %s: "%s" (ID: %s, SAM Account Name: %s)',
$user['objectguid'],
$member->getName(),
$member->ID,
$user['samaccountname']
));
} else {
$this->log(sprintf(
'Creating new Member %s: "%s" (SAM Account Name: %s)',
$user['objectguid'],
$user['cn'],
$user['samaccountname']
));
}
$this->log('User data returned from LDAP follows:');
$this->log(var_export($user));
try {
$this->ldapService->updateMemberFromLDAP($member, $user);
$this->log('Done!');
} catch (Exception $e) {
$this->log($e->getMessage());
}
}
|
php
|
public function run($request)
{
$email = $request->getVar('email');
if (!$email) {
echo 'You must supply an email parameter to this method.', PHP_EOL;
exit;
}
$user = $this->ldapService->getUserByEmail($email);
if (!$user) {
echo sprintf('No user found in LDAP for email %s', $email), PHP_EOL;
exit;
}
$member = $this->findOrCreateMember($user);
// If member exists already, we're updating - otherwise we're creating
if ($member->exists()) {
$this->log(sprintf(
'Updating existing Member %s: "%s" (ID: %s, SAM Account Name: %s)',
$user['objectguid'],
$member->getName(),
$member->ID,
$user['samaccountname']
));
} else {
$this->log(sprintf(
'Creating new Member %s: "%s" (SAM Account Name: %s)',
$user['objectguid'],
$user['cn'],
$user['samaccountname']
));
}
$this->log('User data returned from LDAP follows:');
$this->log(var_export($user));
try {
$this->ldapService->updateMemberFromLDAP($member, $user);
$this->log('Done!');
} catch (Exception $e) {
$this->log($e->getMessage());
}
}
|
[
"public",
"function",
"run",
"(",
"$",
"request",
")",
"{",
"$",
"email",
"=",
"$",
"request",
"->",
"getVar",
"(",
"'email'",
")",
";",
"if",
"(",
"!",
"$",
"email",
")",
"{",
"echo",
"'You must supply an email parameter to this method.'",
",",
"PHP_EOL",
";",
"exit",
";",
"}",
"$",
"user",
"=",
"$",
"this",
"->",
"ldapService",
"->",
"getUserByEmail",
"(",
"$",
"email",
")",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"echo",
"sprintf",
"(",
"'No user found in LDAP for email %s'",
",",
"$",
"email",
")",
",",
"PHP_EOL",
";",
"exit",
";",
"}",
"$",
"member",
"=",
"$",
"this",
"->",
"findOrCreateMember",
"(",
"$",
"user",
")",
";",
"// If member exists already, we're updating - otherwise we're creating",
"if",
"(",
"$",
"member",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Updating existing Member %s: \"%s\" (ID: %s, SAM Account Name: %s)'",
",",
"$",
"user",
"[",
"'objectguid'",
"]",
",",
"$",
"member",
"->",
"getName",
"(",
")",
",",
"$",
"member",
"->",
"ID",
",",
"$",
"user",
"[",
"'samaccountname'",
"]",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"log",
"(",
"sprintf",
"(",
"'Creating new Member %s: \"%s\" (SAM Account Name: %s)'",
",",
"$",
"user",
"[",
"'objectguid'",
"]",
",",
"$",
"user",
"[",
"'cn'",
"]",
",",
"$",
"user",
"[",
"'samaccountname'",
"]",
")",
")",
";",
"}",
"$",
"this",
"->",
"log",
"(",
"'User data returned from LDAP follows:'",
")",
";",
"$",
"this",
"->",
"log",
"(",
"var_export",
"(",
"$",
"user",
")",
")",
";",
"try",
"{",
"$",
"this",
"->",
"ldapService",
"->",
"updateMemberFromLDAP",
"(",
"$",
"member",
",",
"$",
"user",
")",
";",
"$",
"this",
"->",
"log",
"(",
"'Done!'",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Syncs a single user based on the email address passed in the URL
@param HTTPRequest $request
|
[
"Syncs",
"a",
"single",
"user",
"based",
"on",
"the",
"email",
"address",
"passed",
"in",
"the",
"URL"
] |
e8e6de4de9d61ad383086bc2fb2a793809cb755e
|
https://github.com/silverstripe/silverstripe-ldap/blob/e8e6de4de9d61ad383086bc2fb2a793809cb755e/src/Tasks/LDAPMemberSyncOneTask.php#L50-L95
|
223,419
|
lexik/LexikWorkflowBundle
|
Handler/ProcessHandler.php
|
ProcessHandler.getProcessStep
|
protected function getProcessStep($stepName)
{
$step = $this->process->getStep($stepName);
if (! ($step instanceof Step)) {
throw new WorkflowException(sprintf('Can\'t find step named "%s" in process "%s".', $stepName, $this->process->getName()));
}
return $step;
}
|
php
|
protected function getProcessStep($stepName)
{
$step = $this->process->getStep($stepName);
if (! ($step instanceof Step)) {
throw new WorkflowException(sprintf('Can\'t find step named "%s" in process "%s".', $stepName, $this->process->getName()));
}
return $step;
}
|
[
"protected",
"function",
"getProcessStep",
"(",
"$",
"stepName",
")",
"{",
"$",
"step",
"=",
"$",
"this",
"->",
"process",
"->",
"getStep",
"(",
"$",
"stepName",
")",
";",
"if",
"(",
"!",
"(",
"$",
"step",
"instanceof",
"Step",
")",
")",
"{",
"throw",
"new",
"WorkflowException",
"(",
"sprintf",
"(",
"'Can\\'t find step named \"%s\" in process \"%s\".'",
",",
"$",
"stepName",
",",
"$",
"this",
"->",
"process",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"step",
";",
"}"
] |
Returns a step by its name.
@param string $stepName
@return Step
@throws WorkflowException
|
[
"Returns",
"a",
"step",
"by",
"its",
"name",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/Handler/ProcessHandler.php#L213-L222
|
223,420
|
lexik/LexikWorkflowBundle
|
Handler/ProcessHandler.php
|
ProcessHandler.checkCredentials
|
protected function checkCredentials(ModelInterface $model, Step $step)
{
$roles = $step->getRoles();
if (!empty($roles) && !$this->authorizationChecker->isGranted($roles, $model->getWorkflowObject())) {
throw new AccessDeniedException($step->getName());
}
}
|
php
|
protected function checkCredentials(ModelInterface $model, Step $step)
{
$roles = $step->getRoles();
if (!empty($roles) && !$this->authorizationChecker->isGranted($roles, $model->getWorkflowObject())) {
throw new AccessDeniedException($step->getName());
}
}
|
[
"protected",
"function",
"checkCredentials",
"(",
"ModelInterface",
"$",
"model",
",",
"Step",
"$",
"step",
")",
"{",
"$",
"roles",
"=",
"$",
"step",
"->",
"getRoles",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"roles",
")",
"&&",
"!",
"$",
"this",
"->",
"authorizationChecker",
"->",
"isGranted",
"(",
"$",
"roles",
",",
"$",
"model",
"->",
"getWorkflowObject",
"(",
")",
")",
")",
"{",
"throw",
"new",
"AccessDeniedException",
"(",
"$",
"step",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}"
] |
Check if the user is allowed to reach the step.
@param ModelInterface $model
@param Step $step
@throws AccessDeniedException
|
[
"Check",
"if",
"the",
"user",
"is",
"allowed",
"to",
"reach",
"the",
"step",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/Handler/ProcessHandler.php#L231-L238
|
223,421
|
wirecard/checkout-client-library
|
library/WirecardCEE/QPay/ReturnFactory.php
|
WirecardCEE_QPay_ReturnFactory._getSuccessInstance
|
protected static function _getSuccessInstance($return, $secret)
{
if (!array_key_exists('paymentType', $return)) {
throw new WirecardCEE_QPay_Exception_InvalidResponseException('Invalid response from QPAY. Paymenttype is missing.');
}
switch (strtoupper($return['paymentType'])) {
case WirecardCEE_Stdlib_PaymentTypeAbstract::CCARD:
case WirecardCEE_Stdlib_PaymentTypeAbstract::CCARD_MOTO:
case WirecardCEE_Stdlib_PaymentTypeAbstract::MAESTRO:
return new WirecardCEE_QPay_Return_Success_CreditCard($return, $secret);
break;
case WirecardCEE_Stdlib_PaymentTypeAbstract::PAYPAL:
return new WirecardCEE_QPay_Return_Success_PayPal($return, $secret);
break;
case WirecardCEE_Stdlib_PaymentTypeAbstract::SOFORTUEBERWEISUNG:
return new WirecardCEE_QPay_Return_Success_Sofortueberweisung($return, $secret);
break;
case WirecardCEE_Stdlib_PaymentTypeAbstract::IDL:
return new WirecardCEE_QPay_Return_Success_Ideal($return, $secret);
break;
default:
return new WirecardCEE_QPay_Return_Success($return, $secret);
break;
}
}
|
php
|
protected static function _getSuccessInstance($return, $secret)
{
if (!array_key_exists('paymentType', $return)) {
throw new WirecardCEE_QPay_Exception_InvalidResponseException('Invalid response from QPAY. Paymenttype is missing.');
}
switch (strtoupper($return['paymentType'])) {
case WirecardCEE_Stdlib_PaymentTypeAbstract::CCARD:
case WirecardCEE_Stdlib_PaymentTypeAbstract::CCARD_MOTO:
case WirecardCEE_Stdlib_PaymentTypeAbstract::MAESTRO:
return new WirecardCEE_QPay_Return_Success_CreditCard($return, $secret);
break;
case WirecardCEE_Stdlib_PaymentTypeAbstract::PAYPAL:
return new WirecardCEE_QPay_Return_Success_PayPal($return, $secret);
break;
case WirecardCEE_Stdlib_PaymentTypeAbstract::SOFORTUEBERWEISUNG:
return new WirecardCEE_QPay_Return_Success_Sofortueberweisung($return, $secret);
break;
case WirecardCEE_Stdlib_PaymentTypeAbstract::IDL:
return new WirecardCEE_QPay_Return_Success_Ideal($return, $secret);
break;
default:
return new WirecardCEE_QPay_Return_Success($return, $secret);
break;
}
}
|
[
"protected",
"static",
"function",
"_getSuccessInstance",
"(",
"$",
"return",
",",
"$",
"secret",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'paymentType'",
",",
"$",
"return",
")",
")",
"{",
"throw",
"new",
"WirecardCEE_QPay_Exception_InvalidResponseException",
"(",
"'Invalid response from QPAY. Paymenttype is missing.'",
")",
";",
"}",
"switch",
"(",
"strtoupper",
"(",
"$",
"return",
"[",
"'paymentType'",
"]",
")",
")",
"{",
"case",
"WirecardCEE_Stdlib_PaymentTypeAbstract",
"::",
"CCARD",
":",
"case",
"WirecardCEE_Stdlib_PaymentTypeAbstract",
"::",
"CCARD_MOTO",
":",
"case",
"WirecardCEE_Stdlib_PaymentTypeAbstract",
"::",
"MAESTRO",
":",
"return",
"new",
"WirecardCEE_QPay_Return_Success_CreditCard",
"(",
"$",
"return",
",",
"$",
"secret",
")",
";",
"break",
";",
"case",
"WirecardCEE_Stdlib_PaymentTypeAbstract",
"::",
"PAYPAL",
":",
"return",
"new",
"WirecardCEE_QPay_Return_Success_PayPal",
"(",
"$",
"return",
",",
"$",
"secret",
")",
";",
"break",
";",
"case",
"WirecardCEE_Stdlib_PaymentTypeAbstract",
"::",
"SOFORTUEBERWEISUNG",
":",
"return",
"new",
"WirecardCEE_QPay_Return_Success_Sofortueberweisung",
"(",
"$",
"return",
",",
"$",
"secret",
")",
";",
"break",
";",
"case",
"WirecardCEE_Stdlib_PaymentTypeAbstract",
"::",
"IDL",
":",
"return",
"new",
"WirecardCEE_QPay_Return_Success_Ideal",
"(",
"$",
"return",
",",
"$",
"secret",
")",
";",
"break",
";",
"default",
":",
"return",
"new",
"WirecardCEE_QPay_Return_Success",
"(",
"$",
"return",
",",
"$",
"secret",
")",
";",
"break",
";",
"}",
"}"
] |
getter for the correct qpay success return instance
@param string[] $return
@param string $secret
@return WirecardCEE_QPay_Return_Success|WirecardCEE_QPay_Return_Success_CreditCard|WirecardCEE_QPay_Return_Success_Ideal|WirecardCEE_QPay_Return_Success_PayPal|WirecardCEE_QPay_Return_Success_Sofortueberweisung
@throws WirecardCEE_QPay_Exception_InvalidResponseException
|
[
"getter",
"for",
"the",
"correct",
"qpay",
"success",
"return",
"instance"
] |
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
|
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/QPay/ReturnFactory.php#L112-L137
|
223,422
|
lexik/LexikWorkflowBundle
|
Twig/Extension/WorkflowExtension.php
|
WorkflowExtension.getStepLabel
|
public function getStepLabel(ModelState $state)
{
$step = $this->aggregator
->getProcess($state->getProcessName())
->getStep($state->getStepName());
return $step instanceof Step ? $step->getLabel() : '';
}
|
php
|
public function getStepLabel(ModelState $state)
{
$step = $this->aggregator
->getProcess($state->getProcessName())
->getStep($state->getStepName());
return $step instanceof Step ? $step->getLabel() : '';
}
|
[
"public",
"function",
"getStepLabel",
"(",
"ModelState",
"$",
"state",
")",
"{",
"$",
"step",
"=",
"$",
"this",
"->",
"aggregator",
"->",
"getProcess",
"(",
"$",
"state",
"->",
"getProcessName",
"(",
")",
")",
"->",
"getStep",
"(",
"$",
"state",
"->",
"getStepName",
"(",
")",
")",
";",
"return",
"$",
"step",
"instanceof",
"Step",
"?",
"$",
"step",
"->",
"getLabel",
"(",
")",
":",
"''",
";",
"}"
] |
Return the state's step label.
@param ModelState $state
@return string
|
[
"Return",
"the",
"state",
"s",
"step",
"label",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/Twig/Extension/WorkflowExtension.php#L52-L59
|
223,423
|
lexik/LexikWorkflowBundle
|
Twig/Extension/WorkflowExtension.php
|
WorkflowExtension.getStateMessage
|
public function getStateMessage(ModelState $state)
{
$message = '';
if ($state->getSuccessful()) {
$data = $state->getData();
$message = isset($data['success_message']) ? $data['success_message'] : '';
} else {
$message = implode("\n", $state->getErrors());
}
return $message;
}
|
php
|
public function getStateMessage(ModelState $state)
{
$message = '';
if ($state->getSuccessful()) {
$data = $state->getData();
$message = isset($data['success_message']) ? $data['success_message'] : '';
} else {
$message = implode("\n", $state->getErrors());
}
return $message;
}
|
[
"public",
"function",
"getStateMessage",
"(",
"ModelState",
"$",
"state",
")",
"{",
"$",
"message",
"=",
"''",
";",
"if",
"(",
"$",
"state",
"->",
"getSuccessful",
"(",
")",
")",
"{",
"$",
"data",
"=",
"$",
"state",
"->",
"getData",
"(",
")",
";",
"$",
"message",
"=",
"isset",
"(",
"$",
"data",
"[",
"'success_message'",
"]",
")",
"?",
"$",
"data",
"[",
"'success_message'",
"]",
":",
"''",
";",
"}",
"else",
"{",
"$",
"message",
"=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"state",
"->",
"getErrors",
"(",
")",
")",
";",
"}",
"return",
"$",
"message",
";",
"}"
] |
Returns the state message.
@param ModelState $state
@return string
|
[
"Returns",
"the",
"state",
"message",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/Twig/Extension/WorkflowExtension.php#L67-L80
|
223,424
|
wirecard/checkout-client-library
|
library/WirecardCEE/QPay/ToolkitClient.php
|
WirecardCEE_QPay_ToolkitClient.getOrderDetails
|
public function getOrderDetails($iOrderNumber)
{
$this->_requestData[self::COMMAND] = self::$COMMAND_GET_ORDER_DETAILS;
$this->_setField(self::ORDER_NUMBER, $iOrderNumber);
$this->_fingerprintOrder->setOrder(Array(
self::CUSTOMER_ID,
self::SHOP_ID,
self::TOOLKIT_PASSWORD,
self::SECRET,
self::COMMAND,
self::LANGUAGE,
self::ORDER_NUMBER
));
return new WirecardCEE_QPay_Response_Toolkit_GetOrderDetails($this->_send());
}
|
php
|
public function getOrderDetails($iOrderNumber)
{
$this->_requestData[self::COMMAND] = self::$COMMAND_GET_ORDER_DETAILS;
$this->_setField(self::ORDER_NUMBER, $iOrderNumber);
$this->_fingerprintOrder->setOrder(Array(
self::CUSTOMER_ID,
self::SHOP_ID,
self::TOOLKIT_PASSWORD,
self::SECRET,
self::COMMAND,
self::LANGUAGE,
self::ORDER_NUMBER
));
return new WirecardCEE_QPay_Response_Toolkit_GetOrderDetails($this->_send());
}
|
[
"public",
"function",
"getOrderDetails",
"(",
"$",
"iOrderNumber",
")",
"{",
"$",
"this",
"->",
"_requestData",
"[",
"self",
"::",
"COMMAND",
"]",
"=",
"self",
"::",
"$",
"COMMAND_GET_ORDER_DETAILS",
";",
"$",
"this",
"->",
"_setField",
"(",
"self",
"::",
"ORDER_NUMBER",
",",
"$",
"iOrderNumber",
")",
";",
"$",
"this",
"->",
"_fingerprintOrder",
"->",
"setOrder",
"(",
"Array",
"(",
"self",
"::",
"CUSTOMER_ID",
",",
"self",
"::",
"SHOP_ID",
",",
"self",
"::",
"TOOLKIT_PASSWORD",
",",
"self",
"::",
"SECRET",
",",
"self",
"::",
"COMMAND",
",",
"self",
"::",
"LANGUAGE",
",",
"self",
"::",
"ORDER_NUMBER",
")",
")",
";",
"return",
"new",
"WirecardCEE_QPay_Response_Toolkit_GetOrderDetails",
"(",
"$",
"this",
"->",
"_send",
"(",
")",
")",
";",
"}"
] |
Returns order details
@param int|string $iOrderNumber
@throws WirecardCEE_Stdlib_Client_Exception_InvalidResponseException
@return WirecardCEE_QPay_Response_Toolkit_GetOrderDetails
|
[
"Returns",
"order",
"details"
] |
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
|
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/QPay/ToolkitClient.php#L417-L433
|
223,425
|
haridarshan/instagram-php
|
src/InstagramRequest.php
|
InstagramRequest.execute
|
protected function execute()
{
$authMethod = '?access_token=' . $this->params['access_token'];
$endpoint = Constants::API_VERSION . $this->path . (('GET' === $this->method) ? '?' . http_build_query($this->params) : $authMethod);
$endpoint .= (strstr($endpoint, '?') ? '&' : '?') . 'sig=' . static::generateSignature($this->instagram->getApp(), $this->path, $this->params);
$request = HelperFactory::getInstance()->request($this->instagram->getHttpClient(), $endpoint, $this->params, $this->method);
if ($request === null) {
throw new InstagramResponseException('400 Bad Request: instanceof InstagramResponse cannot be null', 400);
}
$this->response = new InstagramResponse($request);
$this->xRateLimitRemaining = $this->response->getHeader('X-Ratelimit-Remaining');
}
|
php
|
protected function execute()
{
$authMethod = '?access_token=' . $this->params['access_token'];
$endpoint = Constants::API_VERSION . $this->path . (('GET' === $this->method) ? '?' . http_build_query($this->params) : $authMethod);
$endpoint .= (strstr($endpoint, '?') ? '&' : '?') . 'sig=' . static::generateSignature($this->instagram->getApp(), $this->path, $this->params);
$request = HelperFactory::getInstance()->request($this->instagram->getHttpClient(), $endpoint, $this->params, $this->method);
if ($request === null) {
throw new InstagramResponseException('400 Bad Request: instanceof InstagramResponse cannot be null', 400);
}
$this->response = new InstagramResponse($request);
$this->xRateLimitRemaining = $this->response->getHeader('X-Ratelimit-Remaining');
}
|
[
"protected",
"function",
"execute",
"(",
")",
"{",
"$",
"authMethod",
"=",
"'?access_token='",
".",
"$",
"this",
"->",
"params",
"[",
"'access_token'",
"]",
";",
"$",
"endpoint",
"=",
"Constants",
"::",
"API_VERSION",
".",
"$",
"this",
"->",
"path",
".",
"(",
"(",
"'GET'",
"===",
"$",
"this",
"->",
"method",
")",
"?",
"'?'",
".",
"http_build_query",
"(",
"$",
"this",
"->",
"params",
")",
":",
"$",
"authMethod",
")",
";",
"$",
"endpoint",
".=",
"(",
"strstr",
"(",
"$",
"endpoint",
",",
"'?'",
")",
"?",
"'&'",
":",
"'?'",
")",
".",
"'sig='",
".",
"static",
"::",
"generateSignature",
"(",
"$",
"this",
"->",
"instagram",
"->",
"getApp",
"(",
")",
",",
"$",
"this",
"->",
"path",
",",
"$",
"this",
"->",
"params",
")",
";",
"$",
"request",
"=",
"HelperFactory",
"::",
"getInstance",
"(",
")",
"->",
"request",
"(",
"$",
"this",
"->",
"instagram",
"->",
"getHttpClient",
"(",
")",
",",
"$",
"endpoint",
",",
"$",
"this",
"->",
"params",
",",
"$",
"this",
"->",
"method",
")",
";",
"if",
"(",
"$",
"request",
"===",
"null",
")",
"{",
"throw",
"new",
"InstagramResponseException",
"(",
"'400 Bad Request: instanceof InstagramResponse cannot be null'",
",",
"400",
")",
";",
"}",
"$",
"this",
"->",
"response",
"=",
"new",
"InstagramResponse",
"(",
"$",
"request",
")",
";",
"$",
"this",
"->",
"xRateLimitRemaining",
"=",
"$",
"this",
"->",
"response",
"->",
"getHeader",
"(",
"'X-Ratelimit-Remaining'",
")",
";",
"}"
] |
Execute the Instagram Request
@param void
@throws InstagramResponseException
@return InstagramResponse
|
[
"Execute",
"the",
"Instagram",
"Request"
] |
5f21e622eaffcbb9b30f12ebdf0064a91ff1caff
|
https://github.com/haridarshan/instagram-php/blob/5f21e622eaffcbb9b30f12ebdf0064a91ff1caff/src/InstagramRequest.php#L100-L113
|
223,426
|
haridarshan/instagram-php
|
src/InstagramRequest.php
|
InstagramRequest.generateSignature
|
public static function generateSignature(InstagramApp $app, $endpoint, $params)
{
$signature = $endpoint;
ksort($params);
foreach ($params as $key => $value) {
$signature .= "|$key=$value";
}
return hash_hmac('sha256', $signature, $app->getSecret(), false);
}
|
php
|
public static function generateSignature(InstagramApp $app, $endpoint, $params)
{
$signature = $endpoint;
ksort($params);
foreach ($params as $key => $value) {
$signature .= "|$key=$value";
}
return hash_hmac('sha256', $signature, $app->getSecret(), false);
}
|
[
"public",
"static",
"function",
"generateSignature",
"(",
"InstagramApp",
"$",
"app",
",",
"$",
"endpoint",
",",
"$",
"params",
")",
"{",
"$",
"signature",
"=",
"$",
"endpoint",
";",
"ksort",
"(",
"$",
"params",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"signature",
".=",
"\"|$key=$value\"",
";",
"}",
"return",
"hash_hmac",
"(",
"'sha256'",
",",
"$",
"signature",
",",
"$",
"app",
"->",
"getSecret",
"(",
")",
",",
"false",
")",
";",
"}"
] |
Secure API Request by using endpoint, paramters and API secret
@see https://www.instagram.com/developer/secure-api-requests/
@param InstagramApp $app
@param string $endpoint
@param array $params
@return string (Signature)
|
[
"Secure",
"API",
"Request",
"by",
"using",
"endpoint",
"paramters",
"and",
"API",
"secret"
] |
5f21e622eaffcbb9b30f12ebdf0064a91ff1caff
|
https://github.com/haridarshan/instagram-php/blob/5f21e622eaffcbb9b30f12ebdf0064a91ff1caff/src/InstagramRequest.php#L170-L179
|
223,427
|
wirecard/checkout-client-library
|
library/WirecardCEE/Stdlib/ReturnFactoryAbstract.php
|
WirecardCEE_Stdlib_ReturnFactoryAbstract.generateConfirmResponseString
|
public static function generateConfirmResponseString($messages = null, $inCommentTag = false)
{
$template = '<QPAY-CONFIRMATION-RESPONSE result="%status%" %message%/>';
if (empty( $messages )) {
$returnValue = str_replace('%status%', 'OK', $template);
$returnValue = str_replace('%message%', '', $returnValue);
} else {
$returnValue = str_replace('%status%', 'NOK', $template);
$returnValue = str_replace('%message%', 'message="' . strval($messages) . '" ', $returnValue);
}
if ($inCommentTag) {
$returnValue = '<!--' . $returnValue . '-->';
}
return $returnValue;
}
|
php
|
public static function generateConfirmResponseString($messages = null, $inCommentTag = false)
{
$template = '<QPAY-CONFIRMATION-RESPONSE result="%status%" %message%/>';
if (empty( $messages )) {
$returnValue = str_replace('%status%', 'OK', $template);
$returnValue = str_replace('%message%', '', $returnValue);
} else {
$returnValue = str_replace('%status%', 'NOK', $template);
$returnValue = str_replace('%message%', 'message="' . strval($messages) . '" ', $returnValue);
}
if ($inCommentTag) {
$returnValue = '<!--' . $returnValue . '-->';
}
return $returnValue;
}
|
[
"public",
"static",
"function",
"generateConfirmResponseString",
"(",
"$",
"messages",
"=",
"null",
",",
"$",
"inCommentTag",
"=",
"false",
")",
"{",
"$",
"template",
"=",
"'<QPAY-CONFIRMATION-RESPONSE result=\"%status%\" %message%/>'",
";",
"if",
"(",
"empty",
"(",
"$",
"messages",
")",
")",
"{",
"$",
"returnValue",
"=",
"str_replace",
"(",
"'%status%'",
",",
"'OK'",
",",
"$",
"template",
")",
";",
"$",
"returnValue",
"=",
"str_replace",
"(",
"'%message%'",
",",
"''",
",",
"$",
"returnValue",
")",
";",
"}",
"else",
"{",
"$",
"returnValue",
"=",
"str_replace",
"(",
"'%status%'",
",",
"'NOK'",
",",
"$",
"template",
")",
";",
"$",
"returnValue",
"=",
"str_replace",
"(",
"'%message%'",
",",
"'message=\"'",
".",
"strval",
"(",
"$",
"messages",
")",
".",
"'\" '",
",",
"$",
"returnValue",
")",
";",
"}",
"if",
"(",
"$",
"inCommentTag",
")",
"{",
"$",
"returnValue",
"=",
"'<!--'",
".",
"$",
"returnValue",
".",
"'-->'",
";",
"}",
"return",
"$",
"returnValue",
";",
"}"
] |
generator for qpay confirm response strings.
the response-string must be returned to QPAY in confirmation process.
@param string $messages
@param bool $inCommentTag
@return string
|
[
"generator",
"for",
"qpay",
"confirm",
"response",
"strings",
".",
"the",
"response",
"-",
"string",
"must",
"be",
"returned",
"to",
"QPAY",
"in",
"confirmation",
"process",
"."
] |
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
|
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/Stdlib/ReturnFactoryAbstract.php#L83-L98
|
223,428
|
wirecard/checkout-client-library
|
library/WirecardCEE/QMore/Return/Failure.php
|
WirecardCEE_QMore_Return_Failure.getErrors
|
public function getErrors()
{
if (empty( $this->_errors )) {
$errorList = Array();
foreach ($this->__get(self::$ERROR) as $error) {
$errorCode = $error[self::$ERROR_ERROR_CODE];
$message = $error[self::$ERROR_MESSAGE];
$consumerMessage = $error[self::$ERROR_CONSUMER_MESSAGE];
$paySysMessage = $error[self::$ERROR_PAY_SYS_MESSAGE];
$errorObject = new WirecardCEE_QMore_Error($errorCode, $message);
$errorObject->setPaySysMessage($paySysMessage);
$errorObject->setConsumerMessage($consumerMessage);
array_push($errorList, $errorObject);
}
$this->_errors = $errorList;
}
return $this->_errors;
}
|
php
|
public function getErrors()
{
if (empty( $this->_errors )) {
$errorList = Array();
foreach ($this->__get(self::$ERROR) as $error) {
$errorCode = $error[self::$ERROR_ERROR_CODE];
$message = $error[self::$ERROR_MESSAGE];
$consumerMessage = $error[self::$ERROR_CONSUMER_MESSAGE];
$paySysMessage = $error[self::$ERROR_PAY_SYS_MESSAGE];
$errorObject = new WirecardCEE_QMore_Error($errorCode, $message);
$errorObject->setPaySysMessage($paySysMessage);
$errorObject->setConsumerMessage($consumerMessage);
array_push($errorList, $errorObject);
}
$this->_errors = $errorList;
}
return $this->_errors;
}
|
[
"public",
"function",
"getErrors",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_errors",
")",
")",
"{",
"$",
"errorList",
"=",
"Array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"__get",
"(",
"self",
"::",
"$",
"ERROR",
")",
"as",
"$",
"error",
")",
"{",
"$",
"errorCode",
"=",
"$",
"error",
"[",
"self",
"::",
"$",
"ERROR_ERROR_CODE",
"]",
";",
"$",
"message",
"=",
"$",
"error",
"[",
"self",
"::",
"$",
"ERROR_MESSAGE",
"]",
";",
"$",
"consumerMessage",
"=",
"$",
"error",
"[",
"self",
"::",
"$",
"ERROR_CONSUMER_MESSAGE",
"]",
";",
"$",
"paySysMessage",
"=",
"$",
"error",
"[",
"self",
"::",
"$",
"ERROR_PAY_SYS_MESSAGE",
"]",
";",
"$",
"errorObject",
"=",
"new",
"WirecardCEE_QMore_Error",
"(",
"$",
"errorCode",
",",
"$",
"message",
")",
";",
"$",
"errorObject",
"->",
"setPaySysMessage",
"(",
"$",
"paySysMessage",
")",
";",
"$",
"errorObject",
"->",
"setConsumerMessage",
"(",
"$",
"consumerMessage",
")",
";",
"array_push",
"(",
"$",
"errorList",
",",
"$",
"errorObject",
")",
";",
"}",
"$",
"this",
"->",
"_errors",
"=",
"$",
"errorList",
";",
"}",
"return",
"$",
"this",
"->",
"_errors",
";",
"}"
] |
Returns all the errors
return Array
|
[
"Returns",
"all",
"the",
"errors",
"return",
"Array"
] |
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
|
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/QMore/Return/Failure.php#L57-L79
|
223,429
|
EtonDigital/EDBlogBundle
|
Security/Authorization/Voter/AdminVoter.php
|
AdminVoter.supportsClass
|
public function supportsClass($class)
{
if($class)
{
$classNameArray = explode('\\', $class);
$className = $classNameArray[ count($classNameArray)-1 ];
if( in_array($className, array('User', 'AdminVoter')) )
{
return true;
}
}
return false;
}
|
php
|
public function supportsClass($class)
{
if($class)
{
$classNameArray = explode('\\', $class);
$className = $classNameArray[ count($classNameArray)-1 ];
if( in_array($className, array('User', 'AdminVoter')) )
{
return true;
}
}
return false;
}
|
[
"public",
"function",
"supportsClass",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"class",
")",
"{",
"$",
"classNameArray",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"class",
")",
";",
"$",
"className",
"=",
"$",
"classNameArray",
"[",
"count",
"(",
"$",
"classNameArray",
")",
"-",
"1",
"]",
";",
"if",
"(",
"in_array",
"(",
"$",
"className",
",",
"array",
"(",
"'User'",
",",
"'AdminVoter'",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Checks if the voter supports the given class.
@param string $class A class name
@return bool true if this Voter can process the class
|
[
"Checks",
"if",
"the",
"voter",
"supports",
"the",
"given",
"class",
"."
] |
bce97b1991b6201733aa7459712c840d92a96ccc
|
https://github.com/EtonDigital/EDBlogBundle/blob/bce97b1991b6201733aa7459712c840d92a96ccc/Security/Authorization/Voter/AdminVoter.php#L43-L57
|
223,430
|
silverstripe/silverstripe-ldap
|
src/Extensions/LDAPMemberExtension.php
|
LDAPMemberExtension.writeWithoutSync
|
public function writeWithoutSync()
{
$this->owner->LDAPMemberExtension_NoSync = true;
try {
$this->owner->write();
} finally {
$this->owner->LDAPMemberExtension_NoSync = false;
}
}
|
php
|
public function writeWithoutSync()
{
$this->owner->LDAPMemberExtension_NoSync = true;
try {
$this->owner->write();
} finally {
$this->owner->LDAPMemberExtension_NoSync = false;
}
}
|
[
"public",
"function",
"writeWithoutSync",
"(",
")",
"{",
"$",
"this",
"->",
"owner",
"->",
"LDAPMemberExtension_NoSync",
"=",
"true",
";",
"try",
"{",
"$",
"this",
"->",
"owner",
"->",
"write",
"(",
")",
";",
"}",
"finally",
"{",
"$",
"this",
"->",
"owner",
"->",
"LDAPMemberExtension_NoSync",
"=",
"false",
";",
"}",
"}"
] |
Write DataObject without triggering this extension's hooks.
@throws Exception
|
[
"Write",
"DataObject",
"without",
"triggering",
"this",
"extension",
"s",
"hooks",
"."
] |
e8e6de4de9d61ad383086bc2fb2a793809cb755e
|
https://github.com/silverstripe/silverstripe-ldap/blob/e8e6de4de9d61ad383086bc2fb2a793809cb755e/src/Extensions/LDAPMemberExtension.php#L265-L273
|
223,431
|
silverstripe/silverstripe-ldap
|
src/Extensions/LDAPMemberExtension.php
|
LDAPMemberExtension.sync
|
public function sync()
{
$service = Injector::inst()->get(LDAPService::class);
if (!$service->enabled() ||
!$this->owner->GUID
) {
return;
}
$service->updateLDAPFromMember($this->owner);
$service->updateLDAPGroupsForMember($this->owner);
}
|
php
|
public function sync()
{
$service = Injector::inst()->get(LDAPService::class);
if (!$service->enabled() ||
!$this->owner->GUID
) {
return;
}
$service->updateLDAPFromMember($this->owner);
$service->updateLDAPGroupsForMember($this->owner);
}
|
[
"public",
"function",
"sync",
"(",
")",
"{",
"$",
"service",
"=",
"Injector",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"LDAPService",
"::",
"class",
")",
";",
"if",
"(",
"!",
"$",
"service",
"->",
"enabled",
"(",
")",
"||",
"!",
"$",
"this",
"->",
"owner",
"->",
"GUID",
")",
"{",
"return",
";",
"}",
"$",
"service",
"->",
"updateLDAPFromMember",
"(",
"$",
"this",
"->",
"owner",
")",
";",
"$",
"service",
"->",
"updateLDAPGroupsForMember",
"(",
"$",
"this",
"->",
"owner",
")",
";",
"}"
] |
Update the local data with LDAP, and ensure local membership is also set in
LDAP too. This writes into LDAP, provided that feature is enabled.
|
[
"Update",
"the",
"local",
"data",
"with",
"LDAP",
"and",
"ensure",
"local",
"membership",
"is",
"also",
"set",
"in",
"LDAP",
"too",
".",
"This",
"writes",
"into",
"LDAP",
"provided",
"that",
"feature",
"is",
"enabled",
"."
] |
e8e6de4de9d61ad383086bc2fb2a793809cb755e
|
https://github.com/silverstripe/silverstripe-ldap/blob/e8e6de4de9d61ad383086bc2fb2a793809cb755e/src/Extensions/LDAPMemberExtension.php#L279-L289
|
223,432
|
silverstripe/silverstripe-ldap
|
src/Extensions/LDAPMemberExtension.php
|
LDAPMemberExtension.onBeforeChangePassword
|
public function onBeforeChangePassword($newPassword, $validation)
{
// Don't do anything if there's already a validation failure
if (!$validation->isValid()) {
return;
}
Injector::inst()->get(LDAPService::class)
->setPassword($this->owner, $newPassword);
}
|
php
|
public function onBeforeChangePassword($newPassword, $validation)
{
// Don't do anything if there's already a validation failure
if (!$validation->isValid()) {
return;
}
Injector::inst()->get(LDAPService::class)
->setPassword($this->owner, $newPassword);
}
|
[
"public",
"function",
"onBeforeChangePassword",
"(",
"$",
"newPassword",
",",
"$",
"validation",
")",
"{",
"// Don't do anything if there's already a validation failure",
"if",
"(",
"!",
"$",
"validation",
"->",
"isValid",
"(",
")",
")",
"{",
"return",
";",
"}",
"Injector",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"LDAPService",
"::",
"class",
")",
"->",
"setPassword",
"(",
"$",
"this",
"->",
"owner",
",",
"$",
"newPassword",
")",
";",
"}"
] |
Synchronise password changes to AD when they happen in SilverStripe
@param string $newPassword
@param ValidationResult $validation
|
[
"Synchronise",
"password",
"changes",
"to",
"AD",
"when",
"they",
"happen",
"in",
"SilverStripe"
] |
e8e6de4de9d61ad383086bc2fb2a793809cb755e
|
https://github.com/silverstripe/silverstripe-ldap/blob/e8e6de4de9d61ad383086bc2fb2a793809cb755e/src/Extensions/LDAPMemberExtension.php#L326-L335
|
223,433
|
appstract/laravel-tracer
|
src/Tracer.php
|
Tracer.trace
|
public function trace()
{
foreach ($this->files as $file) {
($this->debug === true) ? $this->addTrace($file) : $this->removeTrace($file);
}
}
|
php
|
public function trace()
{
foreach ($this->files as $file) {
($this->debug === true) ? $this->addTrace($file) : $this->removeTrace($file);
}
}
|
[
"public",
"function",
"trace",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"files",
"as",
"$",
"file",
")",
"{",
"(",
"$",
"this",
"->",
"debug",
"===",
"true",
")",
"?",
"$",
"this",
"->",
"addTrace",
"(",
"$",
"file",
")",
":",
"$",
"this",
"->",
"removeTrace",
"(",
"$",
"file",
")",
";",
"}",
"}"
] |
Start the tracer.
@return [type] [description]
|
[
"Start",
"the",
"tracer",
"."
] |
64b6cb334ddea3bc4c8527d66b6e2050223f39fd
|
https://github.com/appstract/laravel-tracer/blob/64b6cb334ddea3bc4c8527d66b6e2050223f39fd/src/Tracer.php#L41-L46
|
223,434
|
appstract/laravel-tracer
|
src/Tracer.php
|
Tracer.addTrace
|
public function addTrace($file)
{
// If the file does not contain the trace, add it.
if (strpos(File::get($file), $this->realPath) === false && $this->debug == true) {
File::prepend($file, $this->realPath);
File::append($file, '</span>');
}
}
|
php
|
public function addTrace($file)
{
// If the file does not contain the trace, add it.
if (strpos(File::get($file), $this->realPath) === false && $this->debug == true) {
File::prepend($file, $this->realPath);
File::append($file, '</span>');
}
}
|
[
"public",
"function",
"addTrace",
"(",
"$",
"file",
")",
"{",
"// If the file does not contain the trace, add it.",
"if",
"(",
"strpos",
"(",
"File",
"::",
"get",
"(",
"$",
"file",
")",
",",
"$",
"this",
"->",
"realPath",
")",
"===",
"false",
"&&",
"$",
"this",
"->",
"debug",
"==",
"true",
")",
"{",
"File",
"::",
"prepend",
"(",
"$",
"file",
",",
"$",
"this",
"->",
"realPath",
")",
";",
"File",
"::",
"append",
"(",
"$",
"file",
",",
"'</span>'",
")",
";",
"}",
"}"
] |
Add the trace to the view.
@param [type] $file [description]
|
[
"Add",
"the",
"trace",
"to",
"the",
"view",
"."
] |
64b6cb334ddea3bc4c8527d66b6e2050223f39fd
|
https://github.com/appstract/laravel-tracer/blob/64b6cb334ddea3bc4c8527d66b6e2050223f39fd/src/Tracer.php#L52-L59
|
223,435
|
appstract/laravel-tracer
|
src/Tracer.php
|
Tracer.removeTrace
|
public function removeTrace($file)
{
// If the file does contain the trace, remove it.
if (strpos(File::get($file), $this->realPath) !== false) {
$content = str_replace($this->realPath, '', File::get($file));
File::put($file, $content);
}
}
|
php
|
public function removeTrace($file)
{
// If the file does contain the trace, remove it.
if (strpos(File::get($file), $this->realPath) !== false) {
$content = str_replace($this->realPath, '', File::get($file));
File::put($file, $content);
}
}
|
[
"public",
"function",
"removeTrace",
"(",
"$",
"file",
")",
"{",
"// If the file does contain the trace, remove it.",
"if",
"(",
"strpos",
"(",
"File",
"::",
"get",
"(",
"$",
"file",
")",
",",
"$",
"this",
"->",
"realPath",
")",
"!==",
"false",
")",
"{",
"$",
"content",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"realPath",
",",
"''",
",",
"File",
"::",
"get",
"(",
"$",
"file",
")",
")",
";",
"File",
"::",
"put",
"(",
"$",
"file",
",",
"$",
"content",
")",
";",
"}",
"}"
] |
Remove the trace from the view.
@param [type] $file [description]
@return [type] [description]
|
[
"Remove",
"the",
"trace",
"from",
"the",
"view",
"."
] |
64b6cb334ddea3bc4c8527d66b6e2050223f39fd
|
https://github.com/appstract/laravel-tracer/blob/64b6cb334ddea3bc4c8527d66b6e2050223f39fd/src/Tracer.php#L66-L73
|
223,436
|
EtonDigital/EDBlogBundle
|
Handler/ObjectGenerator.php
|
ObjectGenerator.generateArticleFromDraft
|
public function generateArticleFromDraft(ArticleInterface &$article, ArticleInterface $draft)
{
$this->loadArticle($article, $draft);
$article
->setStatus( Article::STATUS_PUBLISHED )
->setParent(null);
return $article;
}
|
php
|
public function generateArticleFromDraft(ArticleInterface &$article, ArticleInterface $draft)
{
$this->loadArticle($article, $draft);
$article
->setStatus( Article::STATUS_PUBLISHED )
->setParent(null);
return $article;
}
|
[
"public",
"function",
"generateArticleFromDraft",
"(",
"ArticleInterface",
"&",
"$",
"article",
",",
"ArticleInterface",
"$",
"draft",
")",
"{",
"$",
"this",
"->",
"loadArticle",
"(",
"$",
"article",
",",
"$",
"draft",
")",
";",
"$",
"article",
"->",
"setStatus",
"(",
"Article",
"::",
"STATUS_PUBLISHED",
")",
"->",
"setParent",
"(",
"null",
")",
";",
"return",
"$",
"article",
";",
"}"
] |
Will synchronize changes made on Draft to the master article and set it 'As Published'
@param ArticleInterface $article
@param ArticleInterface $draft
@return ArticleInterface
|
[
"Will",
"synchronize",
"changes",
"made",
"on",
"Draft",
"to",
"the",
"master",
"article",
"and",
"set",
"it",
"As",
"Published"
] |
bce97b1991b6201733aa7459712c840d92a96ccc
|
https://github.com/EtonDigital/EDBlogBundle/blob/bce97b1991b6201733aa7459712c840d92a96ccc/Handler/ObjectGenerator.php#L72-L82
|
223,437
|
lexik/LexikWorkflowBundle
|
DependencyInjection/LexikWorkflowExtension.php
|
LexikWorkflowExtension.buildProcesses
|
protected function buildProcesses($processes, $container, $processClass, $stepClass)
{
$processReferences = array();
foreach ($processes as $processName => $processConfig) {
if (!empty($processConfig['import'])) {
if (is_file($processConfig['import'])) {
$yaml = new Parser();
$config = $yaml->parse(file_get_contents($processConfig['import']));
$processConfig = array_merge($processConfig, $config[$processName]);
} else {
throw new \InvalidArgumentException(sprintf('Can\'t load process from file "%s"', $processConfig['import']));
}
}
$stepReferences = $this->buildSteps($processName, $processConfig['steps'], $container, $stepClass);
$definition = new Definition($processClass, array(
$processName,
$stepReferences,
$processConfig['start'],
$processConfig['end'],
));
$definition->setPublic(false)
->addTag('lexik_workflow.process', array('alias' => $processName));
$processReference = sprintf('lexik_workflow.process.%s', $processName);
$container->setDefinition($processReference, $definition);
$processReferences[$processName] = new Reference($processReference);
}
return $processReferences;
}
|
php
|
protected function buildProcesses($processes, $container, $processClass, $stepClass)
{
$processReferences = array();
foreach ($processes as $processName => $processConfig) {
if (!empty($processConfig['import'])) {
if (is_file($processConfig['import'])) {
$yaml = new Parser();
$config = $yaml->parse(file_get_contents($processConfig['import']));
$processConfig = array_merge($processConfig, $config[$processName]);
} else {
throw new \InvalidArgumentException(sprintf('Can\'t load process from file "%s"', $processConfig['import']));
}
}
$stepReferences = $this->buildSteps($processName, $processConfig['steps'], $container, $stepClass);
$definition = new Definition($processClass, array(
$processName,
$stepReferences,
$processConfig['start'],
$processConfig['end'],
));
$definition->setPublic(false)
->addTag('lexik_workflow.process', array('alias' => $processName));
$processReference = sprintf('lexik_workflow.process.%s', $processName);
$container->setDefinition($processReference, $definition);
$processReferences[$processName] = new Reference($processReference);
}
return $processReferences;
}
|
[
"protected",
"function",
"buildProcesses",
"(",
"$",
"processes",
",",
"$",
"container",
",",
"$",
"processClass",
",",
"$",
"stepClass",
")",
"{",
"$",
"processReferences",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"processes",
"as",
"$",
"processName",
"=>",
"$",
"processConfig",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"processConfig",
"[",
"'import'",
"]",
")",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"processConfig",
"[",
"'import'",
"]",
")",
")",
"{",
"$",
"yaml",
"=",
"new",
"Parser",
"(",
")",
";",
"$",
"config",
"=",
"$",
"yaml",
"->",
"parse",
"(",
"file_get_contents",
"(",
"$",
"processConfig",
"[",
"'import'",
"]",
")",
")",
";",
"$",
"processConfig",
"=",
"array_merge",
"(",
"$",
"processConfig",
",",
"$",
"config",
"[",
"$",
"processName",
"]",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Can\\'t load process from file \"%s\"'",
",",
"$",
"processConfig",
"[",
"'import'",
"]",
")",
")",
";",
"}",
"}",
"$",
"stepReferences",
"=",
"$",
"this",
"->",
"buildSteps",
"(",
"$",
"processName",
",",
"$",
"processConfig",
"[",
"'steps'",
"]",
",",
"$",
"container",
",",
"$",
"stepClass",
")",
";",
"$",
"definition",
"=",
"new",
"Definition",
"(",
"$",
"processClass",
",",
"array",
"(",
"$",
"processName",
",",
"$",
"stepReferences",
",",
"$",
"processConfig",
"[",
"'start'",
"]",
",",
"$",
"processConfig",
"[",
"'end'",
"]",
",",
")",
")",
";",
"$",
"definition",
"->",
"setPublic",
"(",
"false",
")",
"->",
"addTag",
"(",
"'lexik_workflow.process'",
",",
"array",
"(",
"'alias'",
"=>",
"$",
"processName",
")",
")",
";",
"$",
"processReference",
"=",
"sprintf",
"(",
"'lexik_workflow.process.%s'",
",",
"$",
"processName",
")",
";",
"$",
"container",
"->",
"setDefinition",
"(",
"$",
"processReference",
",",
"$",
"definition",
")",
";",
"$",
"processReferences",
"[",
"$",
"processName",
"]",
"=",
"new",
"Reference",
"(",
"$",
"processReference",
")",
";",
"}",
"return",
"$",
"processReferences",
";",
"}"
] |
Build process definitions from configuration.
@param array $processes
@param ContainerBuilder $container
@param string $processClass
@param string $stepClass
@return array
|
[
"Build",
"process",
"definitions",
"from",
"configuration",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/DependencyInjection/LexikWorkflowExtension.php#L77-L112
|
223,438
|
lexik/LexikWorkflowBundle
|
DependencyInjection/LexikWorkflowExtension.php
|
LexikWorkflowExtension.buildSteps
|
protected function buildSteps($processName, $steps, $container, $stepClass)
{
$stepReferences = array();
foreach ($steps as $stepName => $stepConfig) {
$definition = new Definition($stepClass, array(
$stepName,
$stepConfig['label'],
array(),
$stepConfig['model_status'],
$stepConfig['roles'],
$stepConfig['on_invalid'],
));
$this->addStepNextStates($definition, $stepConfig['next_states'], $processName);
$definition->setPublic(false)
->addTag(sprintf('lexik_workflow.process.%s.step', $processName), array('alias' => $stepName));
$stepReference = sprintf('lexik_workflow.process.%s.step.%s', $processName, $stepName);
$container->setDefinition($stepReference, $definition);
$stepReferences[$stepName] = new Reference($stepReference);
}
return $stepReferences;
}
|
php
|
protected function buildSteps($processName, $steps, $container, $stepClass)
{
$stepReferences = array();
foreach ($steps as $stepName => $stepConfig) {
$definition = new Definition($stepClass, array(
$stepName,
$stepConfig['label'],
array(),
$stepConfig['model_status'],
$stepConfig['roles'],
$stepConfig['on_invalid'],
));
$this->addStepNextStates($definition, $stepConfig['next_states'], $processName);
$definition->setPublic(false)
->addTag(sprintf('lexik_workflow.process.%s.step', $processName), array('alias' => $stepName));
$stepReference = sprintf('lexik_workflow.process.%s.step.%s', $processName, $stepName);
$container->setDefinition($stepReference, $definition);
$stepReferences[$stepName] = new Reference($stepReference);
}
return $stepReferences;
}
|
[
"protected",
"function",
"buildSteps",
"(",
"$",
"processName",
",",
"$",
"steps",
",",
"$",
"container",
",",
"$",
"stepClass",
")",
"{",
"$",
"stepReferences",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"steps",
"as",
"$",
"stepName",
"=>",
"$",
"stepConfig",
")",
"{",
"$",
"definition",
"=",
"new",
"Definition",
"(",
"$",
"stepClass",
",",
"array",
"(",
"$",
"stepName",
",",
"$",
"stepConfig",
"[",
"'label'",
"]",
",",
"array",
"(",
")",
",",
"$",
"stepConfig",
"[",
"'model_status'",
"]",
",",
"$",
"stepConfig",
"[",
"'roles'",
"]",
",",
"$",
"stepConfig",
"[",
"'on_invalid'",
"]",
",",
")",
")",
";",
"$",
"this",
"->",
"addStepNextStates",
"(",
"$",
"definition",
",",
"$",
"stepConfig",
"[",
"'next_states'",
"]",
",",
"$",
"processName",
")",
";",
"$",
"definition",
"->",
"setPublic",
"(",
"false",
")",
"->",
"addTag",
"(",
"sprintf",
"(",
"'lexik_workflow.process.%s.step'",
",",
"$",
"processName",
")",
",",
"array",
"(",
"'alias'",
"=>",
"$",
"stepName",
")",
")",
";",
"$",
"stepReference",
"=",
"sprintf",
"(",
"'lexik_workflow.process.%s.step.%s'",
",",
"$",
"processName",
",",
"$",
"stepName",
")",
";",
"$",
"container",
"->",
"setDefinition",
"(",
"$",
"stepReference",
",",
"$",
"definition",
")",
";",
"$",
"stepReferences",
"[",
"$",
"stepName",
"]",
"=",
"new",
"Reference",
"(",
"$",
"stepReference",
")",
";",
"}",
"return",
"$",
"stepReferences",
";",
"}"
] |
Build steps definitions from configuration.
@param string $processName
@param array $steps
@param ContainerBuilder $container
@param string $stepClass
@return array
|
[
"Build",
"steps",
"definitions",
"from",
"configuration",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/DependencyInjection/LexikWorkflowExtension.php#L124-L150
|
223,439
|
lexik/LexikWorkflowBundle
|
DependencyInjection/LexikWorkflowExtension.php
|
LexikWorkflowExtension.addStepNextStates
|
protected function addStepNextStates(Definition $step, $stepsNextStates, $processName)
{
foreach ($stepsNextStates as $stateName => $data) {
if (NextStateInterface::TYPE_STEP === $data['type']) {
$step->addMethodCall('addNextState', array(
$stateName,
$data['type'],
new Reference(sprintf('lexik_workflow.process.%s.step.%s', $processName, $data['target']))
));
} elseif (NextStateInterface::TYPE_STEP_OR === $data['type']) {
$targets = array();
foreach ($data['target'] as $stepName => $condition) {
$serviceId = null;
$method = null;
if (!empty($condition)) {
list($serviceId, $method) = explode(':', $condition);
}
$targets[] = array(
'target' => new Reference(sprintf('lexik_workflow.process.%s.step.%s', $processName, $stepName)),
'condition_object' => null !== $serviceId ? new Reference($serviceId) : null,
'condition_method' => $method,
);
}
$step->addMethodCall('addNextStateOr', array($stateName, $data['type'], $targets));
} elseif (NextStateInterface::TYPE_PROCESS === $data['type']) {
$step->addMethodCall('addNextState', array(
$stateName,
$data['type'],
new Reference(sprintf('lexik_workflow.process.%s', $data['target']))
));
} else {
throw new \InvalidArgumentException(sprintf('Unknown type "%s", please use "step" or "process"', $data['type']));
}
}
}
|
php
|
protected function addStepNextStates(Definition $step, $stepsNextStates, $processName)
{
foreach ($stepsNextStates as $stateName => $data) {
if (NextStateInterface::TYPE_STEP === $data['type']) {
$step->addMethodCall('addNextState', array(
$stateName,
$data['type'],
new Reference(sprintf('lexik_workflow.process.%s.step.%s', $processName, $data['target']))
));
} elseif (NextStateInterface::TYPE_STEP_OR === $data['type']) {
$targets = array();
foreach ($data['target'] as $stepName => $condition) {
$serviceId = null;
$method = null;
if (!empty($condition)) {
list($serviceId, $method) = explode(':', $condition);
}
$targets[] = array(
'target' => new Reference(sprintf('lexik_workflow.process.%s.step.%s', $processName, $stepName)),
'condition_object' => null !== $serviceId ? new Reference($serviceId) : null,
'condition_method' => $method,
);
}
$step->addMethodCall('addNextStateOr', array($stateName, $data['type'], $targets));
} elseif (NextStateInterface::TYPE_PROCESS === $data['type']) {
$step->addMethodCall('addNextState', array(
$stateName,
$data['type'],
new Reference(sprintf('lexik_workflow.process.%s', $data['target']))
));
} else {
throw new \InvalidArgumentException(sprintf('Unknown type "%s", please use "step" or "process"', $data['type']));
}
}
}
|
[
"protected",
"function",
"addStepNextStates",
"(",
"Definition",
"$",
"step",
",",
"$",
"stepsNextStates",
",",
"$",
"processName",
")",
"{",
"foreach",
"(",
"$",
"stepsNextStates",
"as",
"$",
"stateName",
"=>",
"$",
"data",
")",
"{",
"if",
"(",
"NextStateInterface",
"::",
"TYPE_STEP",
"===",
"$",
"data",
"[",
"'type'",
"]",
")",
"{",
"$",
"step",
"->",
"addMethodCall",
"(",
"'addNextState'",
",",
"array",
"(",
"$",
"stateName",
",",
"$",
"data",
"[",
"'type'",
"]",
",",
"new",
"Reference",
"(",
"sprintf",
"(",
"'lexik_workflow.process.%s.step.%s'",
",",
"$",
"processName",
",",
"$",
"data",
"[",
"'target'",
"]",
")",
")",
")",
")",
";",
"}",
"elseif",
"(",
"NextStateInterface",
"::",
"TYPE_STEP_OR",
"===",
"$",
"data",
"[",
"'type'",
"]",
")",
"{",
"$",
"targets",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"[",
"'target'",
"]",
"as",
"$",
"stepName",
"=>",
"$",
"condition",
")",
"{",
"$",
"serviceId",
"=",
"null",
";",
"$",
"method",
"=",
"null",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"condition",
")",
")",
"{",
"list",
"(",
"$",
"serviceId",
",",
"$",
"method",
")",
"=",
"explode",
"(",
"':'",
",",
"$",
"condition",
")",
";",
"}",
"$",
"targets",
"[",
"]",
"=",
"array",
"(",
"'target'",
"=>",
"new",
"Reference",
"(",
"sprintf",
"(",
"'lexik_workflow.process.%s.step.%s'",
",",
"$",
"processName",
",",
"$",
"stepName",
")",
")",
",",
"'condition_object'",
"=>",
"null",
"!==",
"$",
"serviceId",
"?",
"new",
"Reference",
"(",
"$",
"serviceId",
")",
":",
"null",
",",
"'condition_method'",
"=>",
"$",
"method",
",",
")",
";",
"}",
"$",
"step",
"->",
"addMethodCall",
"(",
"'addNextStateOr'",
",",
"array",
"(",
"$",
"stateName",
",",
"$",
"data",
"[",
"'type'",
"]",
",",
"$",
"targets",
")",
")",
";",
"}",
"elseif",
"(",
"NextStateInterface",
"::",
"TYPE_PROCESS",
"===",
"$",
"data",
"[",
"'type'",
"]",
")",
"{",
"$",
"step",
"->",
"addMethodCall",
"(",
"'addNextState'",
",",
"array",
"(",
"$",
"stateName",
",",
"$",
"data",
"[",
"'type'",
"]",
",",
"new",
"Reference",
"(",
"sprintf",
"(",
"'lexik_workflow.process.%s'",
",",
"$",
"data",
"[",
"'target'",
"]",
")",
")",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Unknown type \"%s\", please use \"step\" or \"process\"'",
",",
"$",
"data",
"[",
"'type'",
"]",
")",
")",
";",
"}",
"}",
"}"
] |
Add all next states to the step definition.
@param Definition $step
@param array $stepsNextStates
@param string $processName
@throws \InvalidArgumentException
|
[
"Add",
"all",
"next",
"states",
"to",
"the",
"step",
"definition",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/DependencyInjection/LexikWorkflowExtension.php#L160-L201
|
223,440
|
spanjeta/yii2-backup
|
helpers/MysqlBackup.php
|
MysqlBackup.createZipBackup
|
private function createZipBackup() {
if (class_exists ( \ZipArchive::class )) {
$zip = new \ZipArchive ();
$file_name = $this->file_name . '.zip';
if ($zip->open ( $file_name, \ZipArchive::CREATE ) === TRUE) {
$zip->addFile ( $this->file_name, basename ( $this->file_name ) );
$zip->close ();
@unlink ( $this->file_name );
$this->file_name = $file_name;
}
} else {
echo "ZipArchive missing class ";
}
}
|
php
|
private function createZipBackup() {
if (class_exists ( \ZipArchive::class )) {
$zip = new \ZipArchive ();
$file_name = $this->file_name . '.zip';
if ($zip->open ( $file_name, \ZipArchive::CREATE ) === TRUE) {
$zip->addFile ( $this->file_name, basename ( $this->file_name ) );
$zip->close ();
@unlink ( $this->file_name );
$this->file_name = $file_name;
}
} else {
echo "ZipArchive missing class ";
}
}
|
[
"private",
"function",
"createZipBackup",
"(",
")",
"{",
"if",
"(",
"class_exists",
"(",
"\\",
"ZipArchive",
"::",
"class",
")",
")",
"{",
"$",
"zip",
"=",
"new",
"\\",
"ZipArchive",
"(",
")",
";",
"$",
"file_name",
"=",
"$",
"this",
"->",
"file_name",
".",
"'.zip'",
";",
"if",
"(",
"$",
"zip",
"->",
"open",
"(",
"$",
"file_name",
",",
"\\",
"ZipArchive",
"::",
"CREATE",
")",
"===",
"TRUE",
")",
"{",
"$",
"zip",
"->",
"addFile",
"(",
"$",
"this",
"->",
"file_name",
",",
"basename",
"(",
"$",
"this",
"->",
"file_name",
")",
")",
";",
"$",
"zip",
"->",
"close",
"(",
")",
";",
"@",
"unlink",
"(",
"$",
"this",
"->",
"file_name",
")",
";",
"$",
"this",
"->",
"file_name",
"=",
"$",
"file_name",
";",
"}",
"}",
"else",
"{",
"echo",
"\"ZipArchive missing class \"",
";",
"}",
"}"
] |
Charge method to backup and create a zip with this
|
[
"Charge",
"method",
"to",
"backup",
"and",
"create",
"a",
"zip",
"with",
"this"
] |
cead8b178f86192c875cfbede54fec6a6ba9ef5b
|
https://github.com/spanjeta/yii2-backup/blob/cead8b178f86192c875cfbede54fec6a6ba9ef5b/helpers/MysqlBackup.php#L165-L179
|
223,441
|
spanjeta/yii2-backup
|
helpers/MysqlBackup.php
|
MysqlBackup.zipDirectory
|
private function zipDirectory($zip, $alias, $directory) {
if ($handle = opendir ( $directory )) {
while ( ($file = readdir ( $handle )) !== false ) {
if (is_dir ( $directory . $file ) && $file != "." && $file != ".." && ! in_array ( $directory . $file . '/', $this->module->excludeDirectoryBackup ))
$this->zipDirectory ( $zip, $alias . $file . '/', $directory . $file . '/' );
if (is_file ( $directory . $file ) && ! in_array ( $directory . $file, $this->module->excludeFileBackup ))
$zip->addFile ( $directory . $file, $alias . $file );
}
closedir ( $handle );
}
}
|
php
|
private function zipDirectory($zip, $alias, $directory) {
if ($handle = opendir ( $directory )) {
while ( ($file = readdir ( $handle )) !== false ) {
if (is_dir ( $directory . $file ) && $file != "." && $file != ".." && ! in_array ( $directory . $file . '/', $this->module->excludeDirectoryBackup ))
$this->zipDirectory ( $zip, $alias . $file . '/', $directory . $file . '/' );
if (is_file ( $directory . $file ) && ! in_array ( $directory . $file, $this->module->excludeFileBackup ))
$zip->addFile ( $directory . $file, $alias . $file );
}
closedir ( $handle );
}
}
|
[
"private",
"function",
"zipDirectory",
"(",
"$",
"zip",
",",
"$",
"alias",
",",
"$",
"directory",
")",
"{",
"if",
"(",
"$",
"handle",
"=",
"opendir",
"(",
"$",
"directory",
")",
")",
"{",
"while",
"(",
"(",
"$",
"file",
"=",
"readdir",
"(",
"$",
"handle",
")",
")",
"!==",
"false",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"directory",
".",
"$",
"file",
")",
"&&",
"$",
"file",
"!=",
"\".\"",
"&&",
"$",
"file",
"!=",
"\"..\"",
"&&",
"!",
"in_array",
"(",
"$",
"directory",
".",
"$",
"file",
".",
"'/'",
",",
"$",
"this",
"->",
"module",
"->",
"excludeDirectoryBackup",
")",
")",
"$",
"this",
"->",
"zipDirectory",
"(",
"$",
"zip",
",",
"$",
"alias",
".",
"$",
"file",
".",
"'/'",
",",
"$",
"directory",
".",
"$",
"file",
".",
"'/'",
")",
";",
"if",
"(",
"is_file",
"(",
"$",
"directory",
".",
"$",
"file",
")",
"&&",
"!",
"in_array",
"(",
"$",
"directory",
".",
"$",
"file",
",",
"$",
"this",
"->",
"module",
"->",
"excludeFileBackup",
")",
")",
"$",
"zip",
"->",
"addFile",
"(",
"$",
"directory",
".",
"$",
"file",
",",
"$",
"alias",
".",
"$",
"file",
")",
";",
"}",
"closedir",
"(",
"$",
"handle",
")",
";",
"}",
"}"
] |
Method responsible for reading a directory and add them to the zip
@param ZipArchive $zip
@param string $alias
@param string $directory
|
[
"Method",
"responsible",
"for",
"reading",
"a",
"directory",
"and",
"add",
"them",
"to",
"the",
"zip"
] |
cead8b178f86192c875cfbede54fec6a6ba9ef5b
|
https://github.com/spanjeta/yii2-backup/blob/cead8b178f86192c875cfbede54fec6a6ba9ef5b/helpers/MysqlBackup.php#L188-L199
|
223,442
|
spanjeta/yii2-backup
|
helpers/MysqlBackup.php
|
MysqlBackup.unzip
|
public function unzip($sqlZipFile) {
if (file_exists ( $sqlZipFile )) {
$zip = new \ZipArchive ();
$result = $zip->open ( $sqlZipFile );
if ($result === true) {
$zip->extractTo ( dirname ( $sqlZipFile ) );
$zip->close ();
$sqlZipFile = str_replace ( ".zip", "", $sqlZipFile );
}
}
return $sqlZipFile;
}
|
php
|
public function unzip($sqlZipFile) {
if (file_exists ( $sqlZipFile )) {
$zip = new \ZipArchive ();
$result = $zip->open ( $sqlZipFile );
if ($result === true) {
$zip->extractTo ( dirname ( $sqlZipFile ) );
$zip->close ();
$sqlZipFile = str_replace ( ".zip", "", $sqlZipFile );
}
}
return $sqlZipFile;
}
|
[
"public",
"function",
"unzip",
"(",
"$",
"sqlZipFile",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"sqlZipFile",
")",
")",
"{",
"$",
"zip",
"=",
"new",
"\\",
"ZipArchive",
"(",
")",
";",
"$",
"result",
"=",
"$",
"zip",
"->",
"open",
"(",
"$",
"sqlZipFile",
")",
";",
"if",
"(",
"$",
"result",
"===",
"true",
")",
"{",
"$",
"zip",
"->",
"extractTo",
"(",
"dirname",
"(",
"$",
"sqlZipFile",
")",
")",
";",
"$",
"zip",
"->",
"close",
"(",
")",
";",
"$",
"sqlZipFile",
"=",
"str_replace",
"(",
"\".zip\"",
",",
"\"\"",
",",
"$",
"sqlZipFile",
")",
";",
"}",
"}",
"return",
"$",
"sqlZipFile",
";",
"}"
] |
Zip file execution
@param string $zipFile
Name of file zip
|
[
"Zip",
"file",
"execution"
] |
cead8b178f86192c875cfbede54fec6a6ba9ef5b
|
https://github.com/spanjeta/yii2-backup/blob/cead8b178f86192c875cfbede54fec6a6ba9ef5b/helpers/MysqlBackup.php#L206-L217
|
223,443
|
lexik/LexikWorkflowBundle
|
Model/ModelStorage.php
|
ModelStorage.findCurrentModelState
|
public function findCurrentModelState(ModelInterface $model, $processName, $stepName = null)
{
return $this->repository->findLatestModelState(
$model->getWorkflowIdentifier(),
$processName,
$stepName
);
}
|
php
|
public function findCurrentModelState(ModelInterface $model, $processName, $stepName = null)
{
return $this->repository->findLatestModelState(
$model->getWorkflowIdentifier(),
$processName,
$stepName
);
}
|
[
"public",
"function",
"findCurrentModelState",
"(",
"ModelInterface",
"$",
"model",
",",
"$",
"processName",
",",
"$",
"stepName",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"repository",
"->",
"findLatestModelState",
"(",
"$",
"model",
"->",
"getWorkflowIdentifier",
"(",
")",
",",
"$",
"processName",
",",
"$",
"stepName",
")",
";",
"}"
] |
Returns the current model state.
@param ModelInterface $model
@param string $processName
@param string $stepName
@return ModelState
|
[
"Returns",
"the",
"current",
"model",
"state",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/Model/ModelStorage.php#L43-L50
|
223,444
|
lexik/LexikWorkflowBundle
|
Model/ModelStorage.php
|
ModelStorage.findAllModelStates
|
public function findAllModelStates(ModelInterface $model, $processName, $successOnly = true)
{
return $this->repository->findModelStates(
$model->getWorkflowIdentifier(),
$processName,
$successOnly
);
}
|
php
|
public function findAllModelStates(ModelInterface $model, $processName, $successOnly = true)
{
return $this->repository->findModelStates(
$model->getWorkflowIdentifier(),
$processName,
$successOnly
);
}
|
[
"public",
"function",
"findAllModelStates",
"(",
"ModelInterface",
"$",
"model",
",",
"$",
"processName",
",",
"$",
"successOnly",
"=",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"repository",
"->",
"findModelStates",
"(",
"$",
"model",
"->",
"getWorkflowIdentifier",
"(",
")",
",",
"$",
"processName",
",",
"$",
"successOnly",
")",
";",
"}"
] |
Returns all model states.
@param ModelInterface $model
@param string $processName
@param bool $successOnly
@return mixed
|
[
"Returns",
"all",
"model",
"states",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/Model/ModelStorage.php#L61-L68
|
223,445
|
lexik/LexikWorkflowBundle
|
Model/ModelStorage.php
|
ModelStorage.newModelStateError
|
public function newModelStateError(ModelInterface $model, $processName, $stepName, ViolationList $violationList, $previous = null)
{
$modelState = $this->createModelState($model, $processName, $stepName, $previous);
$modelState->setSuccessful(false);
$modelState->setErrors($violationList->toArray());
$this->om->persist($modelState);
$this->om->flush($modelState);
return $modelState;
}
|
php
|
public function newModelStateError(ModelInterface $model, $processName, $stepName, ViolationList $violationList, $previous = null)
{
$modelState = $this->createModelState($model, $processName, $stepName, $previous);
$modelState->setSuccessful(false);
$modelState->setErrors($violationList->toArray());
$this->om->persist($modelState);
$this->om->flush($modelState);
return $modelState;
}
|
[
"public",
"function",
"newModelStateError",
"(",
"ModelInterface",
"$",
"model",
",",
"$",
"processName",
",",
"$",
"stepName",
",",
"ViolationList",
"$",
"violationList",
",",
"$",
"previous",
"=",
"null",
")",
"{",
"$",
"modelState",
"=",
"$",
"this",
"->",
"createModelState",
"(",
"$",
"model",
",",
"$",
"processName",
",",
"$",
"stepName",
",",
"$",
"previous",
")",
";",
"$",
"modelState",
"->",
"setSuccessful",
"(",
"false",
")",
";",
"$",
"modelState",
"->",
"setErrors",
"(",
"$",
"violationList",
"->",
"toArray",
"(",
")",
")",
";",
"$",
"this",
"->",
"om",
"->",
"persist",
"(",
"$",
"modelState",
")",
";",
"$",
"this",
"->",
"om",
"->",
"flush",
"(",
"$",
"modelState",
")",
";",
"return",
"$",
"modelState",
";",
"}"
] |
Create a new invalid model state.
@param ModelInterface $model
@param string $processName
@param string $stepName
@param ViolationList $violationList
@param null|ModelState $previous
@return ModelState
|
[
"Create",
"a",
"new",
"invalid",
"model",
"state",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/Model/ModelStorage.php#L81-L91
|
223,446
|
lexik/LexikWorkflowBundle
|
Model/ModelStorage.php
|
ModelStorage.deleteAllModelStates
|
public function deleteAllModelStates(ModelInterface $model, $processName = null)
{
return $this->repository->deleteModelStates(
$model->getWorkflowIdentifier(),
$processName
);
}
|
php
|
public function deleteAllModelStates(ModelInterface $model, $processName = null)
{
return $this->repository->deleteModelStates(
$model->getWorkflowIdentifier(),
$processName
);
}
|
[
"public",
"function",
"deleteAllModelStates",
"(",
"ModelInterface",
"$",
"model",
",",
"$",
"processName",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"repository",
"->",
"deleteModelStates",
"(",
"$",
"model",
"->",
"getWorkflowIdentifier",
"(",
")",
",",
"$",
"processName",
")",
";",
"}"
] |
Delete all model states.
@param ModelInterface $model
@param string $processName
|
[
"Delete",
"all",
"model",
"states",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/Model/ModelStorage.php#L99-L105
|
223,447
|
lexik/LexikWorkflowBundle
|
Model/ModelStorage.php
|
ModelStorage.newModelStateSuccess
|
public function newModelStateSuccess(ModelInterface $model, $processName, $stepName, $previous = null)
{
$modelState = $this->createModelState($model, $processName, $stepName, $previous);
$modelState->setSuccessful(true);
$this->om->persist($modelState);
$this->om->flush($modelState);
return $modelState;
}
|
php
|
public function newModelStateSuccess(ModelInterface $model, $processName, $stepName, $previous = null)
{
$modelState = $this->createModelState($model, $processName, $stepName, $previous);
$modelState->setSuccessful(true);
$this->om->persist($modelState);
$this->om->flush($modelState);
return $modelState;
}
|
[
"public",
"function",
"newModelStateSuccess",
"(",
"ModelInterface",
"$",
"model",
",",
"$",
"processName",
",",
"$",
"stepName",
",",
"$",
"previous",
"=",
"null",
")",
"{",
"$",
"modelState",
"=",
"$",
"this",
"->",
"createModelState",
"(",
"$",
"model",
",",
"$",
"processName",
",",
"$",
"stepName",
",",
"$",
"previous",
")",
";",
"$",
"modelState",
"->",
"setSuccessful",
"(",
"true",
")",
";",
"$",
"this",
"->",
"om",
"->",
"persist",
"(",
"$",
"modelState",
")",
";",
"$",
"this",
"->",
"om",
"->",
"flush",
"(",
"$",
"modelState",
")",
";",
"return",
"$",
"modelState",
";",
"}"
] |
Create a new successful model state.
@param ModelInterface $model
@param string $processName
@param string $stepName
@param ModelState $previous
@return \Lexik\Bundle\WorkflowBundle\Entity\ModelState
|
[
"Create",
"a",
"new",
"successful",
"model",
"state",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/Model/ModelStorage.php#L117-L126
|
223,448
|
lexik/LexikWorkflowBundle
|
Model/ModelStorage.php
|
ModelStorage.createModelState
|
protected function createModelState(ModelInterface $model, $processName, $stepName, $previous = null)
{
$modelState = new ModelState();
$modelState->setWorkflowIdentifier($model->getWorkflowIdentifier());
$modelState->setProcessName($processName);
$modelState->setStepName($stepName);
$modelState->setData($model->getWorkflowData());
if ($previous instanceof ModelState) {
$modelState->setPrevious($previous);
}
return $modelState;
}
|
php
|
protected function createModelState(ModelInterface $model, $processName, $stepName, $previous = null)
{
$modelState = new ModelState();
$modelState->setWorkflowIdentifier($model->getWorkflowIdentifier());
$modelState->setProcessName($processName);
$modelState->setStepName($stepName);
$modelState->setData($model->getWorkflowData());
if ($previous instanceof ModelState) {
$modelState->setPrevious($previous);
}
return $modelState;
}
|
[
"protected",
"function",
"createModelState",
"(",
"ModelInterface",
"$",
"model",
",",
"$",
"processName",
",",
"$",
"stepName",
",",
"$",
"previous",
"=",
"null",
")",
"{",
"$",
"modelState",
"=",
"new",
"ModelState",
"(",
")",
";",
"$",
"modelState",
"->",
"setWorkflowIdentifier",
"(",
"$",
"model",
"->",
"getWorkflowIdentifier",
"(",
")",
")",
";",
"$",
"modelState",
"->",
"setProcessName",
"(",
"$",
"processName",
")",
";",
"$",
"modelState",
"->",
"setStepName",
"(",
"$",
"stepName",
")",
";",
"$",
"modelState",
"->",
"setData",
"(",
"$",
"model",
"->",
"getWorkflowData",
"(",
")",
")",
";",
"if",
"(",
"$",
"previous",
"instanceof",
"ModelState",
")",
"{",
"$",
"modelState",
"->",
"setPrevious",
"(",
"$",
"previous",
")",
";",
"}",
"return",
"$",
"modelState",
";",
"}"
] |
Create a new model state.
@param ModelInterface $model
@param string $processName
@param string $stepName
@param ModelState $previous
@return \Lexik\Bundle\WorkflowBundle\Entity\ModelState
|
[
"Create",
"a",
"new",
"model",
"state",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/Model/ModelStorage.php#L149-L162
|
223,449
|
wirecard/checkout-client-library
|
library/WirecardCEE/Stdlib/Return/ReturnAbstract.php
|
WirecardCEE_Stdlib_Return_ReturnAbstract.addValidator
|
public function addValidator(WirecardCEE_Stdlib_Validate_ValidateAbstract $oValidator, $param)
{
$this->_validators[(string) $param][] = $oValidator;
return $this;
}
|
php
|
public function addValidator(WirecardCEE_Stdlib_Validate_ValidateAbstract $oValidator, $param)
{
$this->_validators[(string) $param][] = $oValidator;
return $this;
}
|
[
"public",
"function",
"addValidator",
"(",
"WirecardCEE_Stdlib_Validate_ValidateAbstract",
"$",
"oValidator",
",",
"$",
"param",
")",
"{",
"$",
"this",
"->",
"_validators",
"[",
"(",
"string",
")",
"$",
"param",
"]",
"[",
"]",
"=",
"$",
"oValidator",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds the validator
@param WirecardCEE_Stdlib_Validate_ValidateAbstract $oValidator
@param string $param
@return WirecardCEE_Stdlib_Return_ReturnAbstract
|
[
"Adds",
"the",
"validator"
] |
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
|
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/Stdlib/Return/ReturnAbstract.php#L121-L126
|
223,450
|
wirecard/checkout-client-library
|
library/WirecardCEE/Stdlib/Return/ReturnAbstract.php
|
WirecardCEE_Stdlib_Return_ReturnAbstract.getReturned
|
public function getReturned()
{
$ret = $this->_returnData;
// noone needs the responseFingerprintOrder and responseFingerprint in the shop.
if (array_key_exists('responseFingerprintOrder', $ret)) {
unset( $ret['responseFingerprintOrder'] );
}
if (array_key_exists('responseFingerprint', $ret)) {
unset( $ret['responseFingerprint'] );
}
return $ret;
}
|
php
|
public function getReturned()
{
$ret = $this->_returnData;
// noone needs the responseFingerprintOrder and responseFingerprint in the shop.
if (array_key_exists('responseFingerprintOrder', $ret)) {
unset( $ret['responseFingerprintOrder'] );
}
if (array_key_exists('responseFingerprint', $ret)) {
unset( $ret['responseFingerprint'] );
}
return $ret;
}
|
[
"public",
"function",
"getReturned",
"(",
")",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"_returnData",
";",
"// noone needs the responseFingerprintOrder and responseFingerprint in the shop.",
"if",
"(",
"array_key_exists",
"(",
"'responseFingerprintOrder'",
",",
"$",
"ret",
")",
")",
"{",
"unset",
"(",
"$",
"ret",
"[",
"'responseFingerprintOrder'",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'responseFingerprint'",
",",
"$",
"ret",
")",
")",
"{",
"unset",
"(",
"$",
"ret",
"[",
"'responseFingerprint'",
"]",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
getter for filtered return data.
@return string[]
|
[
"getter",
"for",
"filtered",
"return",
"data",
"."
] |
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
|
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/Stdlib/Return/ReturnAbstract.php#L157-L171
|
223,451
|
lexik/LexikWorkflowBundle
|
Model/ModelStateRepository.php
|
ModelStateRepository.findModelStates
|
public function findModelStates($workflowIdentifier, $processName, $successOnly)
{
$qb = $this->createQueryBuilder('ms')
->andWhere('ms.workflowIdentifier = :workflow_identifier')
->andWhere('ms.processName = :process')
->orderBy('ms.createdAt', 'ASC')
->setParameter('workflow_identifier', $workflowIdentifier)
->setParameter('process', $processName)
;
if ($successOnly) {
$qb->andWhere('ms.successful = :success')
->setParameter('success', true);
}
return $qb->getQuery()->getResult();
}
|
php
|
public function findModelStates($workflowIdentifier, $processName, $successOnly)
{
$qb = $this->createQueryBuilder('ms')
->andWhere('ms.workflowIdentifier = :workflow_identifier')
->andWhere('ms.processName = :process')
->orderBy('ms.createdAt', 'ASC')
->setParameter('workflow_identifier', $workflowIdentifier)
->setParameter('process', $processName)
;
if ($successOnly) {
$qb->andWhere('ms.successful = :success')
->setParameter('success', true);
}
return $qb->getQuery()->getResult();
}
|
[
"public",
"function",
"findModelStates",
"(",
"$",
"workflowIdentifier",
",",
"$",
"processName",
",",
"$",
"successOnly",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'ms'",
")",
"->",
"andWhere",
"(",
"'ms.workflowIdentifier = :workflow_identifier'",
")",
"->",
"andWhere",
"(",
"'ms.processName = :process'",
")",
"->",
"orderBy",
"(",
"'ms.createdAt'",
",",
"'ASC'",
")",
"->",
"setParameter",
"(",
"'workflow_identifier'",
",",
"$",
"workflowIdentifier",
")",
"->",
"setParameter",
"(",
"'process'",
",",
"$",
"processName",
")",
";",
"if",
"(",
"$",
"successOnly",
")",
"{",
"$",
"qb",
"->",
"andWhere",
"(",
"'ms.successful = :success'",
")",
"->",
"setParameter",
"(",
"'success'",
",",
"true",
")",
";",
"}",
"return",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"}"
] |
Returns all model states for the given workflow identifier.
@param string $workflowIdentifier
@param string $processName
@param boolean $successOnly
@return array
|
[
"Returns",
"all",
"model",
"states",
"for",
"the",
"given",
"workflow",
"identifier",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/Model/ModelStateRepository.php#L51-L67
|
223,452
|
wirecard/checkout-client-library
|
library/WirecardCEE/QPay/Response/Toolkit/Order.php
|
WirecardCEE_QPay_Response_Toolkit_Order.getOperationsAllowed
|
public function getOperationsAllowed()
{
if ($this->_getField(self::$OPERATIONS_ALLOWED) == '') {
return Array();
} else {
return explode(',', $this->_getField(self::$OPERATIONS_ALLOWED));
}
}
|
php
|
public function getOperationsAllowed()
{
if ($this->_getField(self::$OPERATIONS_ALLOWED) == '') {
return Array();
} else {
return explode(',', $this->_getField(self::$OPERATIONS_ALLOWED));
}
}
|
[
"public",
"function",
"getOperationsAllowed",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_getField",
"(",
"self",
"::",
"$",
"OPERATIONS_ALLOWED",
")",
"==",
"''",
")",
"{",
"return",
"Array",
"(",
")",
";",
"}",
"else",
"{",
"return",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"_getField",
"(",
"self",
"::",
"$",
"OPERATIONS_ALLOWED",
")",
")",
";",
"}",
"}"
] |
getter for allowed follow-up operations
@return string[]
|
[
"getter",
"for",
"allowed",
"follow",
"-",
"up",
"operations"
] |
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
|
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/QPay/Response/Toolkit/Order.php#L375-L382
|
223,453
|
wirecard/checkout-client-library
|
library/WirecardCEE/QMore/ReturnFactory.php
|
WirecardCEE_QMore_ReturnFactory._getInstance
|
protected static function _getInstance($return, $secret)
{
switch (strtoupper($return['paymentState'])) {
case parent::STATE_SUCCESS:
return self::_getSuccessInstance($return, $secret);
break;
case parent::STATE_CANCEL:
return new WirecardCEE_QMore_Return_Cancel($return);
break;
case parent::STATE_FAILURE:
return new WirecardCEE_QMore_Return_Failure($return);
break;
case parent::STATE_PENDING:
return new WirecardCEE_QMore_Return_Pending($return, $secret);
break;
default:
throw new WirecardCEE_QMore_Exception_InvalidResponseException('Invalid response from QMORE. Unexpected paymentState: ' . $return['paymentState']);
break;
}
}
|
php
|
protected static function _getInstance($return, $secret)
{
switch (strtoupper($return['paymentState'])) {
case parent::STATE_SUCCESS:
return self::_getSuccessInstance($return, $secret);
break;
case parent::STATE_CANCEL:
return new WirecardCEE_QMore_Return_Cancel($return);
break;
case parent::STATE_FAILURE:
return new WirecardCEE_QMore_Return_Failure($return);
break;
case parent::STATE_PENDING:
return new WirecardCEE_QMore_Return_Pending($return, $secret);
break;
default:
throw new WirecardCEE_QMore_Exception_InvalidResponseException('Invalid response from QMORE. Unexpected paymentState: ' . $return['paymentState']);
break;
}
}
|
[
"protected",
"static",
"function",
"_getInstance",
"(",
"$",
"return",
",",
"$",
"secret",
")",
"{",
"switch",
"(",
"strtoupper",
"(",
"$",
"return",
"[",
"'paymentState'",
"]",
")",
")",
"{",
"case",
"parent",
"::",
"STATE_SUCCESS",
":",
"return",
"self",
"::",
"_getSuccessInstance",
"(",
"$",
"return",
",",
"$",
"secret",
")",
";",
"break",
";",
"case",
"parent",
"::",
"STATE_CANCEL",
":",
"return",
"new",
"WirecardCEE_QMore_Return_Cancel",
"(",
"$",
"return",
")",
";",
"break",
";",
"case",
"parent",
"::",
"STATE_FAILURE",
":",
"return",
"new",
"WirecardCEE_QMore_Return_Failure",
"(",
"$",
"return",
")",
";",
"break",
";",
"case",
"parent",
"::",
"STATE_PENDING",
":",
"return",
"new",
"WirecardCEE_QMore_Return_Pending",
"(",
"$",
"return",
",",
"$",
"secret",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"WirecardCEE_QMore_Exception_InvalidResponseException",
"(",
"'Invalid response from QMORE. Unexpected paymentState: '",
".",
"$",
"return",
"[",
"'paymentState'",
"]",
")",
";",
"break",
";",
"}",
"}"
] |
Returns the "return" sintance object
@param array $return
@param string $secret
@throws WirecardCEE_QMore_Exception_InvalidResponseException
@return WirecardCEE_QMore_Return_Cancel|WirecardCEE_QMore_Return_Failure|WirecardCEE_QMore_Return_Pending|WirecardCEE_QMore_Return_Success
|
[
"Returns",
"the",
"return",
"sintance",
"object"
] |
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
|
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/QMore/ReturnFactory.php#L82-L101
|
223,454
|
wirecard/checkout-client-library
|
library/WirecardCEE/QMore/ReturnFactory.php
|
WirecardCEE_QMore_ReturnFactory._getSuccessInstance
|
protected static function _getSuccessInstance($return, $secret)
{
if (!array_key_exists('paymentType', $return)) {
throw new WirecardCEE_QMore_Exception_InvalidResponseException('Invalid response from QMORE. Paymenttype is missing.');
}
switch (strtoupper($return['paymentType'])) {
case WirecardCEE_Stdlib_PaymentTypeAbstract::CCARD:
case WirecardCEE_Stdlib_PaymentTypeAbstract::CCARD_MOTO:
case WirecardCEE_Stdlib_PaymentTypeAbstract::MAESTRO:
return new WirecardCEE_QMore_Return_Success_CreditCard($return, $secret);
break;
case WirecardCEE_Stdlib_PaymentTypeAbstract::PAYPAL:
return new WirecardCEE_QMore_Return_Success_PayPal($return, $secret);
break;
case WirecardCEE_Stdlib_PaymentTypeAbstract::SOFORTUEBERWEISUNG:
return new WirecardCEE_QMore_Return_Success_Sofortueberweisung($return, $secret);
break;
case WirecardCEE_Stdlib_PaymentTypeAbstract::IDL:
return new WirecardCEE_QMore_Return_Success_Ideal($return, $secret);
break;
case WirecardCEE_Stdlib_PaymentTypeAbstract::SEPADD:
return new WirecardCEE_QMore_Return_Success_SepaDD($return, $secret);
break;
default:
return new WirecardCEE_QMore_Return_Success($return, $secret);
break;
}
}
|
php
|
protected static function _getSuccessInstance($return, $secret)
{
if (!array_key_exists('paymentType', $return)) {
throw new WirecardCEE_QMore_Exception_InvalidResponseException('Invalid response from QMORE. Paymenttype is missing.');
}
switch (strtoupper($return['paymentType'])) {
case WirecardCEE_Stdlib_PaymentTypeAbstract::CCARD:
case WirecardCEE_Stdlib_PaymentTypeAbstract::CCARD_MOTO:
case WirecardCEE_Stdlib_PaymentTypeAbstract::MAESTRO:
return new WirecardCEE_QMore_Return_Success_CreditCard($return, $secret);
break;
case WirecardCEE_Stdlib_PaymentTypeAbstract::PAYPAL:
return new WirecardCEE_QMore_Return_Success_PayPal($return, $secret);
break;
case WirecardCEE_Stdlib_PaymentTypeAbstract::SOFORTUEBERWEISUNG:
return new WirecardCEE_QMore_Return_Success_Sofortueberweisung($return, $secret);
break;
case WirecardCEE_Stdlib_PaymentTypeAbstract::IDL:
return new WirecardCEE_QMore_Return_Success_Ideal($return, $secret);
break;
case WirecardCEE_Stdlib_PaymentTypeAbstract::SEPADD:
return new WirecardCEE_QMore_Return_Success_SepaDD($return, $secret);
break;
default:
return new WirecardCEE_QMore_Return_Success($return, $secret);
break;
}
}
|
[
"protected",
"static",
"function",
"_getSuccessInstance",
"(",
"$",
"return",
",",
"$",
"secret",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'paymentType'",
",",
"$",
"return",
")",
")",
"{",
"throw",
"new",
"WirecardCEE_QMore_Exception_InvalidResponseException",
"(",
"'Invalid response from QMORE. Paymenttype is missing.'",
")",
";",
"}",
"switch",
"(",
"strtoupper",
"(",
"$",
"return",
"[",
"'paymentType'",
"]",
")",
")",
"{",
"case",
"WirecardCEE_Stdlib_PaymentTypeAbstract",
"::",
"CCARD",
":",
"case",
"WirecardCEE_Stdlib_PaymentTypeAbstract",
"::",
"CCARD_MOTO",
":",
"case",
"WirecardCEE_Stdlib_PaymentTypeAbstract",
"::",
"MAESTRO",
":",
"return",
"new",
"WirecardCEE_QMore_Return_Success_CreditCard",
"(",
"$",
"return",
",",
"$",
"secret",
")",
";",
"break",
";",
"case",
"WirecardCEE_Stdlib_PaymentTypeAbstract",
"::",
"PAYPAL",
":",
"return",
"new",
"WirecardCEE_QMore_Return_Success_PayPal",
"(",
"$",
"return",
",",
"$",
"secret",
")",
";",
"break",
";",
"case",
"WirecardCEE_Stdlib_PaymentTypeAbstract",
"::",
"SOFORTUEBERWEISUNG",
":",
"return",
"new",
"WirecardCEE_QMore_Return_Success_Sofortueberweisung",
"(",
"$",
"return",
",",
"$",
"secret",
")",
";",
"break",
";",
"case",
"WirecardCEE_Stdlib_PaymentTypeAbstract",
"::",
"IDL",
":",
"return",
"new",
"WirecardCEE_QMore_Return_Success_Ideal",
"(",
"$",
"return",
",",
"$",
"secret",
")",
";",
"break",
";",
"case",
"WirecardCEE_Stdlib_PaymentTypeAbstract",
"::",
"SEPADD",
":",
"return",
"new",
"WirecardCEE_QMore_Return_Success_SepaDD",
"(",
"$",
"return",
",",
"$",
"secret",
")",
";",
"break",
";",
"default",
":",
"return",
"new",
"WirecardCEE_QMore_Return_Success",
"(",
"$",
"return",
",",
"$",
"secret",
")",
";",
"break",
";",
"}",
"}"
] |
getter for the correct QMORE success return instance
@param string[] $return
@param string $secret
@return WirecardCEE_QMore_Return_Success
@throws WirecardCEE_QMore_Exception_InvalidResponseException
|
[
"getter",
"for",
"the",
"correct",
"QMORE",
"success",
"return",
"instance"
] |
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
|
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/QMore/ReturnFactory.php#L112-L140
|
223,455
|
inpsyde/menu-cache
|
src/MenuCache.php
|
MenuCache.cache_menu
|
public function cache_menu( $menu, $args ) {
if ( $this->should_cache_menu( $args ) ) {
set_transient( $this->menu_key( $args ), $menu, $this->expiration() );
}
return $menu;
}
|
php
|
public function cache_menu( $menu, $args ) {
if ( $this->should_cache_menu( $args ) ) {
set_transient( $this->menu_key( $args ), $menu, $this->expiration() );
}
return $menu;
}
|
[
"public",
"function",
"cache_menu",
"(",
"$",
"menu",
",",
"$",
"args",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"should_cache_menu",
"(",
"$",
"args",
")",
")",
"{",
"set_transient",
"(",
"$",
"this",
"->",
"menu_key",
"(",
"$",
"args",
")",
",",
"$",
"menu",
",",
"$",
"this",
"->",
"expiration",
"(",
")",
")",
";",
"}",
"return",
"$",
"menu",
";",
"}"
] |
Stores the menu HTML in a transient.
@since 1.0.0
@wp-hook wp_nav_menu
@param string $menu Menu HTML.
@param object $args Menu args.
@return string Unfiltered menu HTML.
|
[
"Stores",
"the",
"menu",
"HTML",
"in",
"a",
"transient",
"."
] |
45ae3160484966cd642c4da0c66e275b1b23984b
|
https://github.com/inpsyde/menu-cache/blob/45ae3160484966cd642c4da0c66e275b1b23984b/src/MenuCache.php#L101-L108
|
223,456
|
inpsyde/menu-cache
|
src/MenuCache.php
|
MenuCache.get_menu
|
public function get_menu( $menu, $args ) {
if ( $this->should_cache_menu( $args ) ) {
$cached_menu = get_transient( $this->menu_key( $args ) );
if ( is_string( $cached_menu ) ) {
return $cached_menu;
}
}
return $menu;
}
|
php
|
public function get_menu( $menu, $args ) {
if ( $this->should_cache_menu( $args ) ) {
$cached_menu = get_transient( $this->menu_key( $args ) );
if ( is_string( $cached_menu ) ) {
return $cached_menu;
}
}
return $menu;
}
|
[
"public",
"function",
"get_menu",
"(",
"$",
"menu",
",",
"$",
"args",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"should_cache_menu",
"(",
"$",
"args",
")",
")",
"{",
"$",
"cached_menu",
"=",
"get_transient",
"(",
"$",
"this",
"->",
"menu_key",
"(",
"$",
"args",
")",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"cached_menu",
")",
")",
"{",
"return",
"$",
"cached_menu",
";",
"}",
"}",
"return",
"$",
"menu",
";",
"}"
] |
Returns a cached menu, if found.
@since 1.0.0
@wp-hook pre_wp_nav_menu
@param string|null $menu Menu HTML, or null.
@param object $args Menu args.
@return string|null Cached menu HTML, if found, or original value.
|
[
"Returns",
"a",
"cached",
"menu",
"if",
"found",
"."
] |
45ae3160484966cd642c4da0c66e275b1b23984b
|
https://github.com/inpsyde/menu-cache/blob/45ae3160484966cd642c4da0c66e275b1b23984b/src/MenuCache.php#L121-L131
|
223,457
|
inpsyde/menu-cache
|
src/MenuCache.php
|
MenuCache.expiration
|
private function expiration() {
if ( isset( $this->expiration ) ) {
return $this->expiration;
}
/**
* Filters the expiration.
*
* @since 1.0.0
*
* @param int $expiration Expiration in seconds.
*/
$this->expiration = (int) apply_filters( self::FILTER_EXPIRATION, 300 );
return $this->expiration;
}
|
php
|
private function expiration() {
if ( isset( $this->expiration ) ) {
return $this->expiration;
}
/**
* Filters the expiration.
*
* @since 1.0.0
*
* @param int $expiration Expiration in seconds.
*/
$this->expiration = (int) apply_filters( self::FILTER_EXPIRATION, 300 );
return $this->expiration;
}
|
[
"private",
"function",
"expiration",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"expiration",
")",
")",
"{",
"return",
"$",
"this",
"->",
"expiration",
";",
"}",
"/**\n\t\t * Filters the expiration.\n\t\t *\n\t\t * @since 1.0.0\n\t\t *\n\t\t * @param int $expiration Expiration in seconds.\n\t\t */",
"$",
"this",
"->",
"expiration",
"=",
"(",
"int",
")",
"apply_filters",
"(",
"self",
"::",
"FILTER_EXPIRATION",
",",
"300",
")",
";",
"return",
"$",
"this",
"->",
"expiration",
";",
"}"
] |
Returns the expiration.
@return int Expiration.
|
[
"Returns",
"the",
"expiration",
"."
] |
45ae3160484966cd642c4da0c66e275b1b23984b
|
https://github.com/inpsyde/menu-cache/blob/45ae3160484966cd642c4da0c66e275b1b23984b/src/MenuCache.php#L138-L154
|
223,458
|
inpsyde/menu-cache
|
src/MenuCache.php
|
MenuCache.should_cache_menu
|
private function should_cache_menu( $args ) {
$should_cache_menu = true;
if ( ! empty( $args->theme_location ) ) {
$theme_locations = $this->theme_locations();
if ( $theme_locations ) {
$should_cache_menu = in_array( $args->theme_location, $theme_locations, true );
}
}
/**
* Filters the caching condition of a single menu.
*
* @since 1.0.0
*
* @param bool $should_cache_menu Whether or not the menu should be cached.
* @param object $args Menu args.
*/
return (bool) apply_filters( self::FILTER_SHOULD_CACHE_MENU, $should_cache_menu, $args );
}
|
php
|
private function should_cache_menu( $args ) {
$should_cache_menu = true;
if ( ! empty( $args->theme_location ) ) {
$theme_locations = $this->theme_locations();
if ( $theme_locations ) {
$should_cache_menu = in_array( $args->theme_location, $theme_locations, true );
}
}
/**
* Filters the caching condition of a single menu.
*
* @since 1.0.0
*
* @param bool $should_cache_menu Whether or not the menu should be cached.
* @param object $args Menu args.
*/
return (bool) apply_filters( self::FILTER_SHOULD_CACHE_MENU, $should_cache_menu, $args );
}
|
[
"private",
"function",
"should_cache_menu",
"(",
"$",
"args",
")",
"{",
"$",
"should_cache_menu",
"=",
"true",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"args",
"->",
"theme_location",
")",
")",
"{",
"$",
"theme_locations",
"=",
"$",
"this",
"->",
"theme_locations",
"(",
")",
";",
"if",
"(",
"$",
"theme_locations",
")",
"{",
"$",
"should_cache_menu",
"=",
"in_array",
"(",
"$",
"args",
"->",
"theme_location",
",",
"$",
"theme_locations",
",",
"true",
")",
";",
"}",
"}",
"/**\n\t\t * Filters the caching condition of a single menu.\n\t\t *\n\t\t * @since 1.0.0\n\t\t *\n\t\t * @param bool $should_cache_menu Whether or not the menu should be cached.\n\t\t * @param object $args Menu args.\n\t\t */",
"return",
"(",
"bool",
")",
"apply_filters",
"(",
"self",
"::",
"FILTER_SHOULD_CACHE_MENU",
",",
"$",
"should_cache_menu",
",",
"$",
"args",
")",
";",
"}"
] |
Checks if a menu should be cached.
@param object $args Menu args.
@return bool Whether or not the menu should be cached.
|
[
"Checks",
"if",
"a",
"menu",
"should",
"be",
"cached",
"."
] |
45ae3160484966cd642c4da0c66e275b1b23984b
|
https://github.com/inpsyde/menu-cache/blob/45ae3160484966cd642c4da0c66e275b1b23984b/src/MenuCache.php#L191-L211
|
223,459
|
inpsyde/menu-cache
|
src/MenuCache.php
|
MenuCache.theme_locations
|
private function theme_locations() {
if ( isset( $this->theme_locations ) ) {
return $this->theme_locations;
}
/**
* Filters the theme locations.
*
* @since 1.0.0
*
* @param string|string[] $theme_locations One or more theme locations.
*/
$theme_locations = (array) apply_filters( self::FILTER_THEME_LOCATIONS, [] );
$this->theme_locations = array_map( 'strval', $theme_locations );
return $this->theme_locations;
}
|
php
|
private function theme_locations() {
if ( isset( $this->theme_locations ) ) {
return $this->theme_locations;
}
/**
* Filters the theme locations.
*
* @since 1.0.0
*
* @param string|string[] $theme_locations One or more theme locations.
*/
$theme_locations = (array) apply_filters( self::FILTER_THEME_LOCATIONS, [] );
$this->theme_locations = array_map( 'strval', $theme_locations );
return $this->theme_locations;
}
|
[
"private",
"function",
"theme_locations",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"theme_locations",
")",
")",
"{",
"return",
"$",
"this",
"->",
"theme_locations",
";",
"}",
"/**\n\t\t * Filters the theme locations.\n\t\t *\n\t\t * @since 1.0.0\n\t\t *\n\t\t * @param string|string[] $theme_locations One or more theme locations.\n\t\t */",
"$",
"theme_locations",
"=",
"(",
"array",
")",
"apply_filters",
"(",
"self",
"::",
"FILTER_THEME_LOCATIONS",
",",
"[",
"]",
")",
";",
"$",
"this",
"->",
"theme_locations",
"=",
"array_map",
"(",
"'strval'",
",",
"$",
"theme_locations",
")",
";",
"return",
"$",
"this",
"->",
"theme_locations",
";",
"}"
] |
Returns the theme locations.
@return string[] Theme locations.
|
[
"Returns",
"the",
"theme",
"locations",
"."
] |
45ae3160484966cd642c4da0c66e275b1b23984b
|
https://github.com/inpsyde/menu-cache/blob/45ae3160484966cd642c4da0c66e275b1b23984b/src/MenuCache.php#L218-L236
|
223,460
|
haridarshan/instagram-php
|
src/LoginUrl.php
|
LoginUrl.loginUrl
|
public function loginUrl()
{
$query = 'client_id=' . $this->app->getId() . '&redirect_uri=' . urlencode($this->callback) . '&response_type=code&state=' . $this->state;
$query .= isset($this->scopes) ? '&scope=' . urlencode(str_replace(',', ' ', implode(',', $this->scopes))) : '';
return sprintf('%s%s?%s', Constants::API_HOST, Constants::API_AUTH, $query);
}
|
php
|
public function loginUrl()
{
$query = 'client_id=' . $this->app->getId() . '&redirect_uri=' . urlencode($this->callback) . '&response_type=code&state=' . $this->state;
$query .= isset($this->scopes) ? '&scope=' . urlencode(str_replace(',', ' ', implode(',', $this->scopes))) : '';
return sprintf('%s%s?%s', Constants::API_HOST, Constants::API_AUTH, $query);
}
|
[
"public",
"function",
"loginUrl",
"(",
")",
"{",
"$",
"query",
"=",
"'client_id='",
".",
"$",
"this",
"->",
"app",
"->",
"getId",
"(",
")",
".",
"'&redirect_uri='",
".",
"urlencode",
"(",
"$",
"this",
"->",
"callback",
")",
".",
"'&response_type=code&state='",
".",
"$",
"this",
"->",
"state",
";",
"$",
"query",
".=",
"isset",
"(",
"$",
"this",
"->",
"scopes",
")",
"?",
"'&scope='",
".",
"urlencode",
"(",
"str_replace",
"(",
"','",
",",
"' '",
",",
"implode",
"(",
"','",
",",
"$",
"this",
"->",
"scopes",
")",
")",
")",
":",
"''",
";",
"return",
"sprintf",
"(",
"'%s%s?%s'",
",",
"Constants",
"::",
"API_HOST",
",",
"Constants",
"::",
"API_AUTH",
",",
"$",
"query",
")",
";",
"}"
] |
Creates login url
@return string
|
[
"Creates",
"login",
"url"
] |
5f21e622eaffcbb9b30f12ebdf0064a91ff1caff
|
https://github.com/haridarshan/instagram-php/blob/5f21e622eaffcbb9b30f12ebdf0064a91ff1caff/src/LoginUrl.php#L80-L86
|
223,461
|
EtonDigital/EDBlogBundle
|
Controller/Backend/FeedController.php
|
FeedController.feedAction
|
public function feedAction($type)
{
$articles = $this->get('app_repository_article')->getActiveArticles();
$feed = $this->get('eko_feed.feed.manager')->get('article');
$feed->addFromArray($articles);
return new Response($feed->render($type)); // or 'atom'
}
|
php
|
public function feedAction($type)
{
$articles = $this->get('app_repository_article')->getActiveArticles();
$feed = $this->get('eko_feed.feed.manager')->get('article');
$feed->addFromArray($articles);
return new Response($feed->render($type)); // or 'atom'
}
|
[
"public",
"function",
"feedAction",
"(",
"$",
"type",
")",
"{",
"$",
"articles",
"=",
"$",
"this",
"->",
"get",
"(",
"'app_repository_article'",
")",
"->",
"getActiveArticles",
"(",
")",
";",
"$",
"feed",
"=",
"$",
"this",
"->",
"get",
"(",
"'eko_feed.feed.manager'",
")",
"->",
"get",
"(",
"'article'",
")",
";",
"$",
"feed",
"->",
"addFromArray",
"(",
"$",
"articles",
")",
";",
"return",
"new",
"Response",
"(",
"$",
"feed",
"->",
"render",
"(",
"$",
"type",
")",
")",
";",
"// or 'atom'",
"}"
] |
Generate the article feed
|
[
"Generate",
"the",
"article",
"feed"
] |
bce97b1991b6201733aa7459712c840d92a96ccc
|
https://github.com/EtonDigital/EDBlogBundle/blob/bce97b1991b6201733aa7459712c840d92a96ccc/Controller/Backend/FeedController.php#L19-L27
|
223,462
|
lexik/LexikWorkflowBundle
|
Handler/ProcessAggregator.php
|
ProcessAggregator.getProcess
|
public function getProcess($name)
{
if (!isset($this->processes[$name])) {
throw new WorkflowException(sprintf('Unknown process "%s".', $name));
}
return $this->processes[$name];
}
|
php
|
public function getProcess($name)
{
if (!isset($this->processes[$name])) {
throw new WorkflowException(sprintf('Unknown process "%s".', $name));
}
return $this->processes[$name];
}
|
[
"public",
"function",
"getProcess",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"processes",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"WorkflowException",
"(",
"sprintf",
"(",
"'Unknown process \"%s\".'",
",",
"$",
"name",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"processes",
"[",
"$",
"name",
"]",
";",
"}"
] |
Returns a process by its name.
@param string $name
@return \Lexik\Bundle\WorkflowBundle\Flow\Process
@throws WorkflowException
|
[
"Returns",
"a",
"process",
"by",
"its",
"name",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/Handler/ProcessAggregator.php#L37-L44
|
223,463
|
EtonDigital/EDBlogBundle
|
Controller/Frontend/RedirectController.php
|
RedirectController.authenticateAction
|
public function authenticateAction(Request $request)
{
if(!$this->getUser())
{
//Get redirecting route
$referer = $request->headers->get('referer');
//Get section on the page to be redirected at
$pageSection = $request->get('section', false);
$this->get('session')->set('refererUrl', $referer);
if($pageSection)
{
$this->get('session')->set('refererUrlSection', $pageSection);
}
}
$user = $this->get('security.token_storage')->getToken()->getUser();
if (!is_object($user) || !$user instanceof UserInterface)
{
throw new AccessDeniedException('Please login first.');
}
$redirectURL = $this->get('session')->get('refererUrl', null);
$redirectURLSection = $this->get('session')->get('refererUrlSection', null);
if(!$redirectURL || $redirectURL == $this->generateUrl('ed_blog_redirect_authenticate', array(), true))
{
return $this->redirectToRoute("ed_blog_homepage_index");
}
else
{
if($redirectURLSection)
{
$redirectURL .= '#' . $redirectURLSection;
$this->get('session')->remove('refererUrlSection');
}
$this->get('session')->remove('refererUrl');
return $this->redirect($redirectURL) ;
}
}
|
php
|
public function authenticateAction(Request $request)
{
if(!$this->getUser())
{
//Get redirecting route
$referer = $request->headers->get('referer');
//Get section on the page to be redirected at
$pageSection = $request->get('section', false);
$this->get('session')->set('refererUrl', $referer);
if($pageSection)
{
$this->get('session')->set('refererUrlSection', $pageSection);
}
}
$user = $this->get('security.token_storage')->getToken()->getUser();
if (!is_object($user) || !$user instanceof UserInterface)
{
throw new AccessDeniedException('Please login first.');
}
$redirectURL = $this->get('session')->get('refererUrl', null);
$redirectURLSection = $this->get('session')->get('refererUrlSection', null);
if(!$redirectURL || $redirectURL == $this->generateUrl('ed_blog_redirect_authenticate', array(), true))
{
return $this->redirectToRoute("ed_blog_homepage_index");
}
else
{
if($redirectURLSection)
{
$redirectURL .= '#' . $redirectURLSection;
$this->get('session')->remove('refererUrlSection');
}
$this->get('session')->remove('refererUrl');
return $this->redirect($redirectURL) ;
}
}
|
[
"public",
"function",
"authenticateAction",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getUser",
"(",
")",
")",
"{",
"//Get redirecting route",
"$",
"referer",
"=",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"'referer'",
")",
";",
"//Get section on the page to be redirected at",
"$",
"pageSection",
"=",
"$",
"request",
"->",
"get",
"(",
"'section'",
",",
"false",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"set",
"(",
"'refererUrl'",
",",
"$",
"referer",
")",
";",
"if",
"(",
"$",
"pageSection",
")",
"{",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"set",
"(",
"'refererUrlSection'",
",",
"$",
"pageSection",
")",
";",
"}",
"}",
"$",
"user",
"=",
"$",
"this",
"->",
"get",
"(",
"'security.token_storage'",
")",
"->",
"getToken",
"(",
")",
"->",
"getUser",
"(",
")",
";",
"if",
"(",
"!",
"is_object",
"(",
"$",
"user",
")",
"||",
"!",
"$",
"user",
"instanceof",
"UserInterface",
")",
"{",
"throw",
"new",
"AccessDeniedException",
"(",
"'Please login first.'",
")",
";",
"}",
"$",
"redirectURL",
"=",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"get",
"(",
"'refererUrl'",
",",
"null",
")",
";",
"$",
"redirectURLSection",
"=",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"get",
"(",
"'refererUrlSection'",
",",
"null",
")",
";",
"if",
"(",
"!",
"$",
"redirectURL",
"||",
"$",
"redirectURL",
"==",
"$",
"this",
"->",
"generateUrl",
"(",
"'ed_blog_redirect_authenticate'",
",",
"array",
"(",
")",
",",
"true",
")",
")",
"{",
"return",
"$",
"this",
"->",
"redirectToRoute",
"(",
"\"ed_blog_homepage_index\"",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"redirectURLSection",
")",
"{",
"$",
"redirectURL",
".=",
"'#'",
".",
"$",
"redirectURLSection",
";",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"remove",
"(",
"'refererUrlSection'",
")",
";",
"}",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"remove",
"(",
"'refererUrl'",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"redirectURL",
")",
";",
"}",
"}"
] |
This action will ask for authorization and redirect user back to referer
@Route("/authenticate", name="ed_blog_redirect_authenticate")
|
[
"This",
"action",
"will",
"ask",
"for",
"authorization",
"and",
"redirect",
"user",
"back",
"to",
"referer"
] |
bce97b1991b6201733aa7459712c840d92a96ccc
|
https://github.com/EtonDigital/EDBlogBundle/blob/bce97b1991b6201733aa7459712c840d92a96ccc/Controller/Frontend/RedirectController.php#L26-L69
|
223,464
|
wirecard/checkout-client-library
|
library/WirecardCEE/Stdlib/Fingerprint.php
|
WirecardCEE_Stdlib_Fingerprint.generate
|
public static function generate(Array $aValues, WirecardCEE_Stdlib_FingerprintOrder $oFingerprintOrder)
{
if (self::$_HASH_ALGORITHM == self::HASH_ALGORITHM_HMAC_SHA512) {
$secret = isset( $aValues['secret'] ) && !empty( $aValues['secret'] ) ? $aValues['secret'] : '';
if (!strlen($secret)) {
throw new WirecardCEE_Stdlib_Exception_UnexpectedValueException();
}
$hash = hash_init(self::HASH_ALGORITHM_SHA512, HASH_HMAC, $secret);
} else {
$hash = hash_init(self::$_HASH_ALGORITHM);
}
foreach ($oFingerprintOrder as $key) {
$key = (string) $key;
if (array_key_exists($key, $aValues)) {
hash_update($hash, ( self::$_STRIP_SLASHES ) ? stripslashes($aValues[$key]) : $aValues[$key]);
} else {
throw new WirecardCEE_Stdlib_Exception_InvalidValueException('Value for key ' . strtoupper($key) . ' not found in values array.');
}
}
return hash_final($hash);
}
|
php
|
public static function generate(Array $aValues, WirecardCEE_Stdlib_FingerprintOrder $oFingerprintOrder)
{
if (self::$_HASH_ALGORITHM == self::HASH_ALGORITHM_HMAC_SHA512) {
$secret = isset( $aValues['secret'] ) && !empty( $aValues['secret'] ) ? $aValues['secret'] : '';
if (!strlen($secret)) {
throw new WirecardCEE_Stdlib_Exception_UnexpectedValueException();
}
$hash = hash_init(self::HASH_ALGORITHM_SHA512, HASH_HMAC, $secret);
} else {
$hash = hash_init(self::$_HASH_ALGORITHM);
}
foreach ($oFingerprintOrder as $key) {
$key = (string) $key;
if (array_key_exists($key, $aValues)) {
hash_update($hash, ( self::$_STRIP_SLASHES ) ? stripslashes($aValues[$key]) : $aValues[$key]);
} else {
throw new WirecardCEE_Stdlib_Exception_InvalidValueException('Value for key ' . strtoupper($key) . ' not found in values array.');
}
}
return hash_final($hash);
}
|
[
"public",
"static",
"function",
"generate",
"(",
"Array",
"$",
"aValues",
",",
"WirecardCEE_Stdlib_FingerprintOrder",
"$",
"oFingerprintOrder",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"_HASH_ALGORITHM",
"==",
"self",
"::",
"HASH_ALGORITHM_HMAC_SHA512",
")",
"{",
"$",
"secret",
"=",
"isset",
"(",
"$",
"aValues",
"[",
"'secret'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"aValues",
"[",
"'secret'",
"]",
")",
"?",
"$",
"aValues",
"[",
"'secret'",
"]",
":",
"''",
";",
"if",
"(",
"!",
"strlen",
"(",
"$",
"secret",
")",
")",
"{",
"throw",
"new",
"WirecardCEE_Stdlib_Exception_UnexpectedValueException",
"(",
")",
";",
"}",
"$",
"hash",
"=",
"hash_init",
"(",
"self",
"::",
"HASH_ALGORITHM_SHA512",
",",
"HASH_HMAC",
",",
"$",
"secret",
")",
";",
"}",
"else",
"{",
"$",
"hash",
"=",
"hash_init",
"(",
"self",
"::",
"$",
"_HASH_ALGORITHM",
")",
";",
"}",
"foreach",
"(",
"$",
"oFingerprintOrder",
"as",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"(",
"string",
")",
"$",
"key",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"aValues",
")",
")",
"{",
"hash_update",
"(",
"$",
"hash",
",",
"(",
"self",
"::",
"$",
"_STRIP_SLASHES",
")",
"?",
"stripslashes",
"(",
"$",
"aValues",
"[",
"$",
"key",
"]",
")",
":",
"$",
"aValues",
"[",
"$",
"key",
"]",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"WirecardCEE_Stdlib_Exception_InvalidValueException",
"(",
"'Value for key '",
".",
"strtoupper",
"(",
"$",
"key",
")",
".",
"' not found in values array.'",
")",
";",
"}",
"}",
"return",
"hash_final",
"(",
"$",
"hash",
")",
";",
"}"
] |
generates an Fingerprint-string
@param array $aValues
@param array $oFingerprintOrder
|
[
"generates",
"an",
"Fingerprint",
"-",
"string"
] |
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
|
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/Stdlib/Fingerprint.php#L102-L124
|
223,465
|
wirecard/checkout-client-library
|
library/WirecardCEE/Stdlib/ConsumerData/Address.php
|
WirecardCEE_Stdlib_ConsumerData_Address._setField
|
protected function _setField($name, $value)
{
// e.g. consumerBillingFirstname
$this->_addressData[self::$PREFIX . $this->_addressType . $name] = (string) $value;
}
|
php
|
protected function _setField($name, $value)
{
// e.g. consumerBillingFirstname
$this->_addressData[self::$PREFIX . $this->_addressType . $name] = (string) $value;
}
|
[
"protected",
"function",
"_setField",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"// e.g. consumerBillingFirstname",
"$",
"this",
"->",
"_addressData",
"[",
"self",
"::",
"$",
"PREFIX",
".",
"$",
"this",
"->",
"_addressType",
".",
"$",
"name",
"]",
"=",
"(",
"string",
")",
"$",
"value",
";",
"}"
] |
setter for an addressfield.
@param string $name
@param string $value
|
[
"setter",
"for",
"an",
"addressfield",
"."
] |
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
|
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/Stdlib/ConsumerData/Address.php#L317-L321
|
223,466
|
EtonDigital/EDBlogBundle
|
Converter/AbstractConverter.php
|
AbstractConverter.supports
|
public function supports(ParamConverter $configuration)
{
if (null === $configuration->getClass()) {
return false;
}
if(array_key_exists($configuration->getClass(), $this->targetEntitiesArray))
{
return true;
}
else
{
return false;
}
}
|
php
|
public function supports(ParamConverter $configuration)
{
if (null === $configuration->getClass()) {
return false;
}
if(array_key_exists($configuration->getClass(), $this->targetEntitiesArray))
{
return true;
}
else
{
return false;
}
}
|
[
"public",
"function",
"supports",
"(",
"ParamConverter",
"$",
"configuration",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"configuration",
"->",
"getClass",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"configuration",
"->",
"getClass",
"(",
")",
",",
"$",
"this",
"->",
"targetEntitiesArray",
")",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Checks if the object is supported.
@param ParamConverter $configuration Should be an instance of ParamConverter
@return bool True if the object is supported, else false
|
[
"Checks",
"if",
"the",
"object",
"is",
"supported",
"."
] |
bce97b1991b6201733aa7459712c840d92a96ccc
|
https://github.com/EtonDigital/EDBlogBundle/blob/bce97b1991b6201733aa7459712c840d92a96ccc/Converter/AbstractConverter.php#L79-L93
|
223,467
|
silverstripe/silverstripe-ldap
|
src/Authenticators/LDAPAuthenticator.php
|
LDAPAuthenticator.authenticate
|
public function authenticate(array $data, HTTPRequest $request, ValidationResult &$result = null)
{
$result = $result ?: ValidationResult::create();
/** @var LDAPService $service */
$service = Injector::inst()->get(LDAPService::class);
$login = trim($data['Login']);
if (Email::is_valid_address($login)) {
if (Config::inst()->get(self::class, 'allow_email_login') != 'yes') {
$result->addError(
_t(
__CLASS__ . '.PLEASEUSEUSERNAME',
'Please enter your username instead of your email to log in.'
)
);
return null;
}
$username = $service->getUsernameByEmail($login);
// No user found with this email.
if (!$username) {
if (Config::inst()->get(self::class, 'fallback_authenticator') === 'yes') {
if ($fallbackMember = $this->fallbackAuthenticate($data, $request)) {
{
return $fallbackMember;
}
}
}
$result->addError(_t(__CLASS__ . '.INVALIDCREDENTIALS', 'Invalid credentials'));
return null;
}
} else {
$username = $login;
}
$serviceAuthenticationResult = $service->authenticate($username, $data['Password']);
$success = $serviceAuthenticationResult['success'] === true;
if (!$success) {
/*
* Try the fallback method if admin or it failed for anything other than invalid credentials
* This is to avoid having an unhandled exception error thrown by PasswordEncryptor::create_for_algorithm()
*/
if (Config::inst()->get(self::class, 'fallback_authenticator') === 'yes') {
if (!in_array($serviceAuthenticationResult['code'], [Result::FAILURE_CREDENTIAL_INVALID])
|| $username === 'admin'
) {
if ($fallbackMember = $this->fallbackAuthenticate($data, $request)) {
return $fallbackMember;
}
}
}
$result->addError($serviceAuthenticationResult['message']);
return null;
}
$data = $service->getUserByUsername($serviceAuthenticationResult['identity']);
if (!$data) {
$result->addError(
_t(
__CLASS__ . '.PROBLEMFINDINGDATA',
'There was a problem retrieving your user data'
)
);
return null;
}
// LDAPMemberExtension::memberLoggedIn() will update any other AD attributes mapped to Member fields
$member = Member::get()->filter('GUID', $data['objectguid'])->limit(1)->first();
if (!($member && $member->exists())) {
$member = new Member();
$member->GUID = $data['objectguid'];
}
// Update the users from LDAP so we are sure that the email is correct.
// This will also write the Member record.
$service->updateMemberFromLDAP($member, $data);
$request->getSession()->clear('BackURL');
return $member;
}
|
php
|
public function authenticate(array $data, HTTPRequest $request, ValidationResult &$result = null)
{
$result = $result ?: ValidationResult::create();
/** @var LDAPService $service */
$service = Injector::inst()->get(LDAPService::class);
$login = trim($data['Login']);
if (Email::is_valid_address($login)) {
if (Config::inst()->get(self::class, 'allow_email_login') != 'yes') {
$result->addError(
_t(
__CLASS__ . '.PLEASEUSEUSERNAME',
'Please enter your username instead of your email to log in.'
)
);
return null;
}
$username = $service->getUsernameByEmail($login);
// No user found with this email.
if (!$username) {
if (Config::inst()->get(self::class, 'fallback_authenticator') === 'yes') {
if ($fallbackMember = $this->fallbackAuthenticate($data, $request)) {
{
return $fallbackMember;
}
}
}
$result->addError(_t(__CLASS__ . '.INVALIDCREDENTIALS', 'Invalid credentials'));
return null;
}
} else {
$username = $login;
}
$serviceAuthenticationResult = $service->authenticate($username, $data['Password']);
$success = $serviceAuthenticationResult['success'] === true;
if (!$success) {
/*
* Try the fallback method if admin or it failed for anything other than invalid credentials
* This is to avoid having an unhandled exception error thrown by PasswordEncryptor::create_for_algorithm()
*/
if (Config::inst()->get(self::class, 'fallback_authenticator') === 'yes') {
if (!in_array($serviceAuthenticationResult['code'], [Result::FAILURE_CREDENTIAL_INVALID])
|| $username === 'admin'
) {
if ($fallbackMember = $this->fallbackAuthenticate($data, $request)) {
return $fallbackMember;
}
}
}
$result->addError($serviceAuthenticationResult['message']);
return null;
}
$data = $service->getUserByUsername($serviceAuthenticationResult['identity']);
if (!$data) {
$result->addError(
_t(
__CLASS__ . '.PROBLEMFINDINGDATA',
'There was a problem retrieving your user data'
)
);
return null;
}
// LDAPMemberExtension::memberLoggedIn() will update any other AD attributes mapped to Member fields
$member = Member::get()->filter('GUID', $data['objectguid'])->limit(1)->first();
if (!($member && $member->exists())) {
$member = new Member();
$member->GUID = $data['objectguid'];
}
// Update the users from LDAP so we are sure that the email is correct.
// This will also write the Member record.
$service->updateMemberFromLDAP($member, $data);
$request->getSession()->clear('BackURL');
return $member;
}
|
[
"public",
"function",
"authenticate",
"(",
"array",
"$",
"data",
",",
"HTTPRequest",
"$",
"request",
",",
"ValidationResult",
"&",
"$",
"result",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"result",
"?",
":",
"ValidationResult",
"::",
"create",
"(",
")",
";",
"/** @var LDAPService $service */",
"$",
"service",
"=",
"Injector",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"LDAPService",
"::",
"class",
")",
";",
"$",
"login",
"=",
"trim",
"(",
"$",
"data",
"[",
"'Login'",
"]",
")",
";",
"if",
"(",
"Email",
"::",
"is_valid_address",
"(",
"$",
"login",
")",
")",
"{",
"if",
"(",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"self",
"::",
"class",
",",
"'allow_email_login'",
")",
"!=",
"'yes'",
")",
"{",
"$",
"result",
"->",
"addError",
"(",
"_t",
"(",
"__CLASS__",
".",
"'.PLEASEUSEUSERNAME'",
",",
"'Please enter your username instead of your email to log in.'",
")",
")",
";",
"return",
"null",
";",
"}",
"$",
"username",
"=",
"$",
"service",
"->",
"getUsernameByEmail",
"(",
"$",
"login",
")",
";",
"// No user found with this email.",
"if",
"(",
"!",
"$",
"username",
")",
"{",
"if",
"(",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"self",
"::",
"class",
",",
"'fallback_authenticator'",
")",
"===",
"'yes'",
")",
"{",
"if",
"(",
"$",
"fallbackMember",
"=",
"$",
"this",
"->",
"fallbackAuthenticate",
"(",
"$",
"data",
",",
"$",
"request",
")",
")",
"{",
"{",
"return",
"$",
"fallbackMember",
";",
"}",
"}",
"}",
"$",
"result",
"->",
"addError",
"(",
"_t",
"(",
"__CLASS__",
".",
"'.INVALIDCREDENTIALS'",
",",
"'Invalid credentials'",
")",
")",
";",
"return",
"null",
";",
"}",
"}",
"else",
"{",
"$",
"username",
"=",
"$",
"login",
";",
"}",
"$",
"serviceAuthenticationResult",
"=",
"$",
"service",
"->",
"authenticate",
"(",
"$",
"username",
",",
"$",
"data",
"[",
"'Password'",
"]",
")",
";",
"$",
"success",
"=",
"$",
"serviceAuthenticationResult",
"[",
"'success'",
"]",
"===",
"true",
";",
"if",
"(",
"!",
"$",
"success",
")",
"{",
"/*\n * Try the fallback method if admin or it failed for anything other than invalid credentials\n * This is to avoid having an unhandled exception error thrown by PasswordEncryptor::create_for_algorithm()\n */",
"if",
"(",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"self",
"::",
"class",
",",
"'fallback_authenticator'",
")",
"===",
"'yes'",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"serviceAuthenticationResult",
"[",
"'code'",
"]",
",",
"[",
"Result",
"::",
"FAILURE_CREDENTIAL_INVALID",
"]",
")",
"||",
"$",
"username",
"===",
"'admin'",
")",
"{",
"if",
"(",
"$",
"fallbackMember",
"=",
"$",
"this",
"->",
"fallbackAuthenticate",
"(",
"$",
"data",
",",
"$",
"request",
")",
")",
"{",
"return",
"$",
"fallbackMember",
";",
"}",
"}",
"}",
"$",
"result",
"->",
"addError",
"(",
"$",
"serviceAuthenticationResult",
"[",
"'message'",
"]",
")",
";",
"return",
"null",
";",
"}",
"$",
"data",
"=",
"$",
"service",
"->",
"getUserByUsername",
"(",
"$",
"serviceAuthenticationResult",
"[",
"'identity'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"data",
")",
"{",
"$",
"result",
"->",
"addError",
"(",
"_t",
"(",
"__CLASS__",
".",
"'.PROBLEMFINDINGDATA'",
",",
"'There was a problem retrieving your user data'",
")",
")",
";",
"return",
"null",
";",
"}",
"// LDAPMemberExtension::memberLoggedIn() will update any other AD attributes mapped to Member fields",
"$",
"member",
"=",
"Member",
"::",
"get",
"(",
")",
"->",
"filter",
"(",
"'GUID'",
",",
"$",
"data",
"[",
"'objectguid'",
"]",
")",
"->",
"limit",
"(",
"1",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"member",
"&&",
"$",
"member",
"->",
"exists",
"(",
")",
")",
")",
"{",
"$",
"member",
"=",
"new",
"Member",
"(",
")",
";",
"$",
"member",
"->",
"GUID",
"=",
"$",
"data",
"[",
"'objectguid'",
"]",
";",
"}",
"// Update the users from LDAP so we are sure that the email is correct.",
"// This will also write the Member record.",
"$",
"service",
"->",
"updateMemberFromLDAP",
"(",
"$",
"member",
",",
"$",
"data",
")",
";",
"$",
"request",
"->",
"getSession",
"(",
")",
"->",
"clear",
"(",
"'BackURL'",
")",
";",
"return",
"$",
"member",
";",
"}"
] |
Performs the login, but will also create and sync the Member record on-the-fly, if not found.
@param array $data
@param HTTPRequest $request
@param ValidationResult|null $result
@return null|Member
|
[
"Performs",
"the",
"login",
"but",
"will",
"also",
"create",
"and",
"sync",
"the",
"Member",
"record",
"on",
"-",
"the",
"-",
"fly",
"if",
"not",
"found",
"."
] |
e8e6de4de9d61ad383086bc2fb2a793809cb755e
|
https://github.com/silverstripe/silverstripe-ldap/blob/e8e6de4de9d61ad383086bc2fb2a793809cb755e/src/Authenticators/LDAPAuthenticator.php#L83-L165
|
223,468
|
silverstripe/silverstripe-ldap
|
src/Authenticators/LDAPAuthenticator.php
|
LDAPAuthenticator.fallbackAuthenticate
|
protected function fallbackAuthenticate($data, HTTPRequest $request)
{
// Set Email from Login
if (array_key_exists('Login', $data) && !array_key_exists('Email', $data)) {
$data['Email'] = $data['Login'];
}
$authenticatorClass = Config::inst()->get(self::class, 'fallback_authenticator_class');
if ($authenticator = Injector::inst()->get($authenticatorClass)) {
$result = call_user_func(
[
$authenticator,
'authenticate'
],
$data,
$request
);
return $result;
}
}
|
php
|
protected function fallbackAuthenticate($data, HTTPRequest $request)
{
// Set Email from Login
if (array_key_exists('Login', $data) && !array_key_exists('Email', $data)) {
$data['Email'] = $data['Login'];
}
$authenticatorClass = Config::inst()->get(self::class, 'fallback_authenticator_class');
if ($authenticator = Injector::inst()->get($authenticatorClass)) {
$result = call_user_func(
[
$authenticator,
'authenticate'
],
$data,
$request
);
return $result;
}
}
|
[
"protected",
"function",
"fallbackAuthenticate",
"(",
"$",
"data",
",",
"HTTPRequest",
"$",
"request",
")",
"{",
"// Set Email from Login",
"if",
"(",
"array_key_exists",
"(",
"'Login'",
",",
"$",
"data",
")",
"&&",
"!",
"array_key_exists",
"(",
"'Email'",
",",
"$",
"data",
")",
")",
"{",
"$",
"data",
"[",
"'Email'",
"]",
"=",
"$",
"data",
"[",
"'Login'",
"]",
";",
"}",
"$",
"authenticatorClass",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"self",
"::",
"class",
",",
"'fallback_authenticator_class'",
")",
";",
"if",
"(",
"$",
"authenticator",
"=",
"Injector",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"$",
"authenticatorClass",
")",
")",
"{",
"$",
"result",
"=",
"call_user_func",
"(",
"[",
"$",
"authenticator",
",",
"'authenticate'",
"]",
",",
"$",
"data",
",",
"$",
"request",
")",
";",
"return",
"$",
"result",
";",
"}",
"}"
] |
Try to authenticate using the fallback authenticator.
@param array $data
@param HTTPRequest $request
@return null|Member
|
[
"Try",
"to",
"authenticate",
"using",
"the",
"fallback",
"authenticator",
"."
] |
e8e6de4de9d61ad383086bc2fb2a793809cb755e
|
https://github.com/silverstripe/silverstripe-ldap/blob/e8e6de4de9d61ad383086bc2fb2a793809cb755e/src/Authenticators/LDAPAuthenticator.php#L174-L192
|
223,469
|
EtonDigital/EDBlogBundle
|
Hydrators/SettingsHydrator.php
|
SettingsHydrator.hydrateAllData
|
protected function hydrateAllData()
{
$result = array();
$data = $this->_stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($data as $row)
{
$keys = array_keys($row);
$result[ $row[ $keys[0] ] ] = $row[ $keys[1] ];
}
return $result;
}
|
php
|
protected function hydrateAllData()
{
$result = array();
$data = $this->_stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($data as $row)
{
$keys = array_keys($row);
$result[ $row[ $keys[0] ] ] = $row[ $keys[1] ];
}
return $result;
}
|
[
"protected",
"function",
"hydrateAllData",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"_stmt",
"->",
"fetchAll",
"(",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"row",
")",
"{",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"row",
")",
";",
"$",
"result",
"[",
"$",
"row",
"[",
"$",
"keys",
"[",
"0",
"]",
"]",
"]",
"=",
"$",
"row",
"[",
"$",
"keys",
"[",
"1",
"]",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Hydrates all rows from the current statement instance at once.
@return array
|
[
"Hydrates",
"all",
"rows",
"from",
"the",
"current",
"statement",
"instance",
"at",
"once",
"."
] |
bce97b1991b6201733aa7459712c840d92a96ccc
|
https://github.com/EtonDigital/EDBlogBundle/blob/bce97b1991b6201733aa7459712c840d92a96ccc/Hydrators/SettingsHydrator.php#L21-L34
|
223,470
|
lexik/LexikWorkflowBundle
|
Validation/ViolationList.php
|
ViolationList.toArray
|
public function toArray()
{
$data = array();
foreach ($this->violations as $violation) {
$data[] = $violation->getMessage();
}
return $data;
}
|
php
|
public function toArray()
{
$data = array();
foreach ($this->violations as $violation) {
$data[] = $violation->getMessage();
}
return $data;
}
|
[
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"violations",
"as",
"$",
"violation",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"$",
"violation",
"->",
"getMessage",
"(",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Cast violations to flat array.
@return array
|
[
"Cast",
"violations",
"to",
"flat",
"array",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/Validation/ViolationList.php#L102-L110
|
223,471
|
silverstripe/silverstripe-ldap
|
src/Services/LDAPService.php
|
LDAPService.getGroups
|
public function getGroups($cached = true, $attributes = [], $indexBy = 'dn')
{
$searchLocations = $this->config()->groups_search_locations ?: [null];
$cache = self::get_cache();
$cacheKey = 'groups' . md5(implode('', array_merge($searchLocations, $attributes)));
$results = $cache->has($cacheKey);
if (!$results || !$cached) {
$results = [];
foreach ($searchLocations as $searchLocation) {
$records = $this->getGateway()->getGroups($searchLocation, Ldap::SEARCH_SCOPE_SUB, $attributes);
if (!$records) {
continue;
}
foreach ($records as $record) {
$results[$record[$indexBy]] = $record;
}
}
$cache->set($cacheKey, $results);
}
if ($cached && $results === true) {
$results = $cache->get($cacheKey);
}
return $results;
}
|
php
|
public function getGroups($cached = true, $attributes = [], $indexBy = 'dn')
{
$searchLocations = $this->config()->groups_search_locations ?: [null];
$cache = self::get_cache();
$cacheKey = 'groups' . md5(implode('', array_merge($searchLocations, $attributes)));
$results = $cache->has($cacheKey);
if (!$results || !$cached) {
$results = [];
foreach ($searchLocations as $searchLocation) {
$records = $this->getGateway()->getGroups($searchLocation, Ldap::SEARCH_SCOPE_SUB, $attributes);
if (!$records) {
continue;
}
foreach ($records as $record) {
$results[$record[$indexBy]] = $record;
}
}
$cache->set($cacheKey, $results);
}
if ($cached && $results === true) {
$results = $cache->get($cacheKey);
}
return $results;
}
|
[
"public",
"function",
"getGroups",
"(",
"$",
"cached",
"=",
"true",
",",
"$",
"attributes",
"=",
"[",
"]",
",",
"$",
"indexBy",
"=",
"'dn'",
")",
"{",
"$",
"searchLocations",
"=",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"groups_search_locations",
"?",
":",
"[",
"null",
"]",
";",
"$",
"cache",
"=",
"self",
"::",
"get_cache",
"(",
")",
";",
"$",
"cacheKey",
"=",
"'groups'",
".",
"md5",
"(",
"implode",
"(",
"''",
",",
"array_merge",
"(",
"$",
"searchLocations",
",",
"$",
"attributes",
")",
")",
")",
";",
"$",
"results",
"=",
"$",
"cache",
"->",
"has",
"(",
"$",
"cacheKey",
")",
";",
"if",
"(",
"!",
"$",
"results",
"||",
"!",
"$",
"cached",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"searchLocations",
"as",
"$",
"searchLocation",
")",
"{",
"$",
"records",
"=",
"$",
"this",
"->",
"getGateway",
"(",
")",
"->",
"getGroups",
"(",
"$",
"searchLocation",
",",
"Ldap",
"::",
"SEARCH_SCOPE_SUB",
",",
"$",
"attributes",
")",
";",
"if",
"(",
"!",
"$",
"records",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"records",
"as",
"$",
"record",
")",
"{",
"$",
"results",
"[",
"$",
"record",
"[",
"$",
"indexBy",
"]",
"]",
"=",
"$",
"record",
";",
"}",
"}",
"$",
"cache",
"->",
"set",
"(",
"$",
"cacheKey",
",",
"$",
"results",
")",
";",
"}",
"if",
"(",
"$",
"cached",
"&&",
"$",
"results",
"===",
"true",
")",
"{",
"$",
"results",
"=",
"$",
"cache",
"->",
"get",
"(",
"$",
"cacheKey",
")",
";",
"}",
"return",
"$",
"results",
";",
"}"
] |
Return all AD groups in configured search locations, including all nested groups.
Uses groups_search_locations if defined, otherwise falls back to NULL, which tells LDAPGateway
to use the default baseDn defined in the connection.
@param boolean $cached Cache the results from AD, so that subsequent calls are faster. Enabled by default.
@param array $attributes List of specific AD attributes to return. Empty array means return everything.
@param string $indexBy Attribute to use as an index.
@return array
|
[
"Return",
"all",
"AD",
"groups",
"in",
"configured",
"search",
"locations",
"including",
"all",
"nested",
"groups",
".",
"Uses",
"groups_search_locations",
"if",
"defined",
"otherwise",
"falls",
"back",
"to",
"NULL",
"which",
"tells",
"LDAPGateway",
"to",
"use",
"the",
"default",
"baseDn",
"defined",
"in",
"the",
"connection",
"."
] |
e8e6de4de9d61ad383086bc2fb2a793809cb755e
|
https://github.com/silverstripe/silverstripe-ldap/blob/e8e6de4de9d61ad383086bc2fb2a793809cb755e/src/Services/LDAPService.php#L266-L294
|
223,472
|
silverstripe/silverstripe-ldap
|
src/Services/LDAPService.php
|
LDAPService.getGroupByGUID
|
public function getGroupByGUID($guid, $attributes = [])
{
$searchLocations = $this->config()->groups_search_locations ?: [null];
foreach ($searchLocations as $searchLocation) {
$records = $this->getGateway()->getGroupByGUID($guid, $searchLocation, Ldap::SEARCH_SCOPE_SUB, $attributes);
if ($records) {
return $records[0];
}
}
}
|
php
|
public function getGroupByGUID($guid, $attributes = [])
{
$searchLocations = $this->config()->groups_search_locations ?: [null];
foreach ($searchLocations as $searchLocation) {
$records = $this->getGateway()->getGroupByGUID($guid, $searchLocation, Ldap::SEARCH_SCOPE_SUB, $attributes);
if ($records) {
return $records[0];
}
}
}
|
[
"public",
"function",
"getGroupByGUID",
"(",
"$",
"guid",
",",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"searchLocations",
"=",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"groups_search_locations",
"?",
":",
"[",
"null",
"]",
";",
"foreach",
"(",
"$",
"searchLocations",
"as",
"$",
"searchLocation",
")",
"{",
"$",
"records",
"=",
"$",
"this",
"->",
"getGateway",
"(",
")",
"->",
"getGroupByGUID",
"(",
"$",
"guid",
",",
"$",
"searchLocation",
",",
"Ldap",
"::",
"SEARCH_SCOPE_SUB",
",",
"$",
"attributes",
")",
";",
"if",
"(",
"$",
"records",
")",
"{",
"return",
"$",
"records",
"[",
"0",
"]",
";",
"}",
"}",
"}"
] |
Get a particular AD group's data given a GUID.
@param string $guid
@param array $attributes List of specific AD attributes to return. Empty array means return everything.
@return array
|
[
"Get",
"a",
"particular",
"AD",
"group",
"s",
"data",
"given",
"a",
"GUID",
"."
] |
e8e6de4de9d61ad383086bc2fb2a793809cb755e
|
https://github.com/silverstripe/silverstripe-ldap/blob/e8e6de4de9d61ad383086bc2fb2a793809cb755e/src/Services/LDAPService.php#L330-L339
|
223,473
|
silverstripe/silverstripe-ldap
|
src/Services/LDAPService.php
|
LDAPService.getUsers
|
public function getUsers($attributes = [])
{
$searchLocations = $this->config()->users_search_locations ?: [null];
$results = [];
foreach ($searchLocations as $searchLocation) {
$records = $this->getGateway()->getUsersWithIterator($searchLocation, $attributes);
if (!$records) {
continue;
}
foreach ($records as $record) {
$results[$record['objectguid']] = $record;
}
}
return $results;
}
|
php
|
public function getUsers($attributes = [])
{
$searchLocations = $this->config()->users_search_locations ?: [null];
$results = [];
foreach ($searchLocations as $searchLocation) {
$records = $this->getGateway()->getUsersWithIterator($searchLocation, $attributes);
if (!$records) {
continue;
}
foreach ($records as $record) {
$results[$record['objectguid']] = $record;
}
}
return $results;
}
|
[
"public",
"function",
"getUsers",
"(",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"searchLocations",
"=",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"users_search_locations",
"?",
":",
"[",
"null",
"]",
";",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"searchLocations",
"as",
"$",
"searchLocation",
")",
"{",
"$",
"records",
"=",
"$",
"this",
"->",
"getGateway",
"(",
")",
"->",
"getUsersWithIterator",
"(",
"$",
"searchLocation",
",",
"$",
"attributes",
")",
";",
"if",
"(",
"!",
"$",
"records",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"records",
"as",
"$",
"record",
")",
"{",
"$",
"results",
"[",
"$",
"record",
"[",
"'objectguid'",
"]",
"]",
"=",
"$",
"record",
";",
"}",
"}",
"return",
"$",
"results",
";",
"}"
] |
Return all AD users in configured search locations, including all users in nested groups.
Uses users_search_locations if defined, otherwise falls back to NULL, which tells LDAPGateway
to use the default baseDn defined in the connection.
@param array $attributes List of specific AD attributes to return. Empty array means return everything.
@return array
|
[
"Return",
"all",
"AD",
"users",
"in",
"configured",
"search",
"locations",
"including",
"all",
"users",
"in",
"nested",
"groups",
".",
"Uses",
"users_search_locations",
"if",
"defined",
"otherwise",
"falls",
"back",
"to",
"NULL",
"which",
"tells",
"LDAPGateway",
"to",
"use",
"the",
"default",
"baseDn",
"defined",
"in",
"the",
"connection",
"."
] |
e8e6de4de9d61ad383086bc2fb2a793809cb755e
|
https://github.com/silverstripe/silverstripe-ldap/blob/e8e6de4de9d61ad383086bc2fb2a793809cb755e/src/Services/LDAPService.php#L367-L384
|
223,474
|
silverstripe/silverstripe-ldap
|
src/Services/LDAPService.php
|
LDAPService.updateMemberGroups
|
public function updateMemberGroups($data, Member $member)
{
if (isset($data['memberof'])) {
$ldapGroups = is_array($data['memberof']) ? $data['memberof'] : [$data['memberof']];
foreach ($ldapGroups as $groupDN) {
foreach (LDAPGroupMapping::get() as $mapping) {
if (!$mapping->DN) {
$this->getLogger()->debug(
sprintf(
'LDAPGroupMapping ID %s is missing DN field. Skipping',
$mapping->ID
)
);
continue;
}
// the user is a direct member of group with a mapping, add them to the SS group.
if ($mapping->DN == $groupDN) {
$group = $mapping->Group();
if ($group && $group->exists()) {
$group->Members()->add($member, [
'IsImportedFromLDAP' => '1'
]);
$mappedGroupIDs[] = $mapping->GroupID;
}
}
// the user *might* be a member of a nested group provided the scope of the mapping
// is to include the entire subtree. Check all those mappings and find the LDAP child groups
// to see if they are a member of one of those. If they are, add them to the SS group
if ($mapping->Scope == 'Subtree') {
$childGroups = $this->getNestedGroups($mapping->DN, ['dn']);
if (!$childGroups) {
continue;
}
foreach ($childGroups as $childGroupDN => $childGroupRecord) {
if ($childGroupDN == $groupDN) {
$group = $mapping->Group();
if ($group && $group->exists()) {
$group->Members()->add($member, [
'IsImportedFromLDAP' => '1'
]);
$mappedGroupIDs[] = $mapping->GroupID;
}
}
}
}
}
}
}
// Lookup the previous mappings and see if there is any mappings no longer present.
$unmappedGroups = $member->Groups()->alterDataQuery(function (DataQuery $query) {
// join with the Group_Members table because we only want those group members assigned by this module.
$query->leftJoin("Group_Members", '"Group_Members"."GroupID" = "Group"."ID"');
$query->where('"Group_Members"."IsImportedFromLDAP" = 1');
});
// Don't remove associations which have just been added and we know are already correct!
if (!empty($mappedGroupIDs)) {
$unmappedGroups = $unmappedGroups->filter("GroupID:NOT", $mappedGroupIDs);
}
// Remove the member from any previously mapped groups, where the mapping
// has since been removed in the LDAP data source
if ($unmappedGroups->count()) {
foreach ($unmappedGroups as $group) {
$group->Members()->remove($member);
}
}
}
|
php
|
public function updateMemberGroups($data, Member $member)
{
if (isset($data['memberof'])) {
$ldapGroups = is_array($data['memberof']) ? $data['memberof'] : [$data['memberof']];
foreach ($ldapGroups as $groupDN) {
foreach (LDAPGroupMapping::get() as $mapping) {
if (!$mapping->DN) {
$this->getLogger()->debug(
sprintf(
'LDAPGroupMapping ID %s is missing DN field. Skipping',
$mapping->ID
)
);
continue;
}
// the user is a direct member of group with a mapping, add them to the SS group.
if ($mapping->DN == $groupDN) {
$group = $mapping->Group();
if ($group && $group->exists()) {
$group->Members()->add($member, [
'IsImportedFromLDAP' => '1'
]);
$mappedGroupIDs[] = $mapping->GroupID;
}
}
// the user *might* be a member of a nested group provided the scope of the mapping
// is to include the entire subtree. Check all those mappings and find the LDAP child groups
// to see if they are a member of one of those. If they are, add them to the SS group
if ($mapping->Scope == 'Subtree') {
$childGroups = $this->getNestedGroups($mapping->DN, ['dn']);
if (!$childGroups) {
continue;
}
foreach ($childGroups as $childGroupDN => $childGroupRecord) {
if ($childGroupDN == $groupDN) {
$group = $mapping->Group();
if ($group && $group->exists()) {
$group->Members()->add($member, [
'IsImportedFromLDAP' => '1'
]);
$mappedGroupIDs[] = $mapping->GroupID;
}
}
}
}
}
}
}
// Lookup the previous mappings and see if there is any mappings no longer present.
$unmappedGroups = $member->Groups()->alterDataQuery(function (DataQuery $query) {
// join with the Group_Members table because we only want those group members assigned by this module.
$query->leftJoin("Group_Members", '"Group_Members"."GroupID" = "Group"."ID"');
$query->where('"Group_Members"."IsImportedFromLDAP" = 1');
});
// Don't remove associations which have just been added and we know are already correct!
if (!empty($mappedGroupIDs)) {
$unmappedGroups = $unmappedGroups->filter("GroupID:NOT", $mappedGroupIDs);
}
// Remove the member from any previously mapped groups, where the mapping
// has since been removed in the LDAP data source
if ($unmappedGroups->count()) {
foreach ($unmappedGroups as $group) {
$group->Members()->remove($member);
}
}
}
|
[
"public",
"function",
"updateMemberGroups",
"(",
"$",
"data",
",",
"Member",
"$",
"member",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'memberof'",
"]",
")",
")",
"{",
"$",
"ldapGroups",
"=",
"is_array",
"(",
"$",
"data",
"[",
"'memberof'",
"]",
")",
"?",
"$",
"data",
"[",
"'memberof'",
"]",
":",
"[",
"$",
"data",
"[",
"'memberof'",
"]",
"]",
";",
"foreach",
"(",
"$",
"ldapGroups",
"as",
"$",
"groupDN",
")",
"{",
"foreach",
"(",
"LDAPGroupMapping",
"::",
"get",
"(",
")",
"as",
"$",
"mapping",
")",
"{",
"if",
"(",
"!",
"$",
"mapping",
"->",
"DN",
")",
"{",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"debug",
"(",
"sprintf",
"(",
"'LDAPGroupMapping ID %s is missing DN field. Skipping'",
",",
"$",
"mapping",
"->",
"ID",
")",
")",
";",
"continue",
";",
"}",
"// the user is a direct member of group with a mapping, add them to the SS group.",
"if",
"(",
"$",
"mapping",
"->",
"DN",
"==",
"$",
"groupDN",
")",
"{",
"$",
"group",
"=",
"$",
"mapping",
"->",
"Group",
"(",
")",
";",
"if",
"(",
"$",
"group",
"&&",
"$",
"group",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"group",
"->",
"Members",
"(",
")",
"->",
"add",
"(",
"$",
"member",
",",
"[",
"'IsImportedFromLDAP'",
"=>",
"'1'",
"]",
")",
";",
"$",
"mappedGroupIDs",
"[",
"]",
"=",
"$",
"mapping",
"->",
"GroupID",
";",
"}",
"}",
"// the user *might* be a member of a nested group provided the scope of the mapping",
"// is to include the entire subtree. Check all those mappings and find the LDAP child groups",
"// to see if they are a member of one of those. If they are, add them to the SS group",
"if",
"(",
"$",
"mapping",
"->",
"Scope",
"==",
"'Subtree'",
")",
"{",
"$",
"childGroups",
"=",
"$",
"this",
"->",
"getNestedGroups",
"(",
"$",
"mapping",
"->",
"DN",
",",
"[",
"'dn'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"childGroups",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"childGroups",
"as",
"$",
"childGroupDN",
"=>",
"$",
"childGroupRecord",
")",
"{",
"if",
"(",
"$",
"childGroupDN",
"==",
"$",
"groupDN",
")",
"{",
"$",
"group",
"=",
"$",
"mapping",
"->",
"Group",
"(",
")",
";",
"if",
"(",
"$",
"group",
"&&",
"$",
"group",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"group",
"->",
"Members",
"(",
")",
"->",
"add",
"(",
"$",
"member",
",",
"[",
"'IsImportedFromLDAP'",
"=>",
"'1'",
"]",
")",
";",
"$",
"mappedGroupIDs",
"[",
"]",
"=",
"$",
"mapping",
"->",
"GroupID",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"}",
"// Lookup the previous mappings and see if there is any mappings no longer present.",
"$",
"unmappedGroups",
"=",
"$",
"member",
"->",
"Groups",
"(",
")",
"->",
"alterDataQuery",
"(",
"function",
"(",
"DataQuery",
"$",
"query",
")",
"{",
"// join with the Group_Members table because we only want those group members assigned by this module.",
"$",
"query",
"->",
"leftJoin",
"(",
"\"Group_Members\"",
",",
"'\"Group_Members\".\"GroupID\" = \"Group\".\"ID\"'",
")",
";",
"$",
"query",
"->",
"where",
"(",
"'\"Group_Members\".\"IsImportedFromLDAP\" = 1'",
")",
";",
"}",
")",
";",
"// Don't remove associations which have just been added and we know are already correct!",
"if",
"(",
"!",
"empty",
"(",
"$",
"mappedGroupIDs",
")",
")",
"{",
"$",
"unmappedGroups",
"=",
"$",
"unmappedGroups",
"->",
"filter",
"(",
"\"GroupID:NOT\"",
",",
"$",
"mappedGroupIDs",
")",
";",
"}",
"// Remove the member from any previously mapped groups, where the mapping",
"// has since been removed in the LDAP data source",
"if",
"(",
"$",
"unmappedGroups",
"->",
"count",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"unmappedGroups",
"as",
"$",
"group",
")",
"{",
"$",
"group",
"->",
"Members",
"(",
")",
"->",
"remove",
"(",
"$",
"member",
")",
";",
"}",
"}",
"}"
] |
Ensure the user is mapped to any applicable groups.
@param array $data
@param Member $member
|
[
"Ensure",
"the",
"user",
"is",
"mapped",
"to",
"any",
"applicable",
"groups",
"."
] |
e8e6de4de9d61ad383086bc2fb2a793809cb755e
|
https://github.com/silverstripe/silverstripe-ldap/blob/e8e6de4de9d61ad383086bc2fb2a793809cb755e/src/Services/LDAPService.php#L694-L765
|
223,475
|
silverstripe/silverstripe-ldap
|
src/Services/LDAPService.php
|
LDAPService.addLDAPUserToGroup
|
public function addLDAPUserToGroup($userDn, $groupDn)
{
$members = $this->getLDAPGroupMembers($groupDn);
// this user is already in the group, no need to do anything.
if (in_array($userDn, $members)) {
return;
}
$members[] = $userDn;
try {
$this->update($groupDn, ['member' => $members]);
} catch (Exception $e) {
throw new ValidationException('LDAP group membership add failure: ' . $e->getMessage());
}
}
|
php
|
public function addLDAPUserToGroup($userDn, $groupDn)
{
$members = $this->getLDAPGroupMembers($groupDn);
// this user is already in the group, no need to do anything.
if (in_array($userDn, $members)) {
return;
}
$members[] = $userDn;
try {
$this->update($groupDn, ['member' => $members]);
} catch (Exception $e) {
throw new ValidationException('LDAP group membership add failure: ' . $e->getMessage());
}
}
|
[
"public",
"function",
"addLDAPUserToGroup",
"(",
"$",
"userDn",
",",
"$",
"groupDn",
")",
"{",
"$",
"members",
"=",
"$",
"this",
"->",
"getLDAPGroupMembers",
"(",
"$",
"groupDn",
")",
";",
"// this user is already in the group, no need to do anything.",
"if",
"(",
"in_array",
"(",
"$",
"userDn",
",",
"$",
"members",
")",
")",
"{",
"return",
";",
"}",
"$",
"members",
"[",
"]",
"=",
"$",
"userDn",
";",
"try",
"{",
"$",
"this",
"->",
"update",
"(",
"$",
"groupDn",
",",
"[",
"'member'",
"=>",
"$",
"members",
"]",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"ValidationException",
"(",
"'LDAP group membership add failure: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] |
Add LDAP user by DN to LDAP group.
@param string $userDn
@param string $groupDn
@throws Exception
|
[
"Add",
"LDAP",
"user",
"by",
"DN",
"to",
"LDAP",
"group",
"."
] |
e8e6de4de9d61ad383086bc2fb2a793809cb755e
|
https://github.com/silverstripe/silverstripe-ldap/blob/e8e6de4de9d61ad383086bc2fb2a793809cb755e/src/Services/LDAPService.php#L1072-L1088
|
223,476
|
silverstripe/silverstripe-ldap
|
src/Services/LDAPService.php
|
LDAPService.setPassword
|
public function setPassword(Member $member, $password, $oldPassword = null)
{
$validationResult = ValidationResult::create();
$this->extend('onBeforeSetPassword', $member, $password, $validationResult);
if (!$member->GUID) {
$this->getLogger()->debug(sprintf('Cannot update Member ID %s, GUID not set', $member->ID));
$validationResult->addError(
_t(
'SilverStripe\\LDAP\\Authenticators\\LDAPAuthenticator.NOUSER',
'Your account hasn\'t been setup properly, please contact an administrator.'
)
);
return $validationResult;
}
$userData = $this->getUserByGUID($member->GUID);
if (empty($userData['distinguishedname'])) {
$validationResult->addError(
_t(
'SilverStripe\\LDAP\\Authenticators\\LDAPAuthenticator.NOUSER',
'Your account hasn\'t been setup properly, please contact an administrator.'
)
);
return $validationResult;
}
try {
if (!empty($oldPassword)) {
$this->getGateway()->changePassword($userData['distinguishedname'], $password, $oldPassword);
} elseif ($this->config()->password_history_workaround) {
$this->passwordHistoryWorkaround($userData['distinguishedname'], $password);
} else {
$this->getGateway()->resetPassword($userData['distinguishedname'], $password);
}
$this->extend('onAfterSetPassword', $member, $password, $validationResult);
} catch (Exception $e) {
$validationResult->addError($e->getMessage());
}
return $validationResult;
}
|
php
|
public function setPassword(Member $member, $password, $oldPassword = null)
{
$validationResult = ValidationResult::create();
$this->extend('onBeforeSetPassword', $member, $password, $validationResult);
if (!$member->GUID) {
$this->getLogger()->debug(sprintf('Cannot update Member ID %s, GUID not set', $member->ID));
$validationResult->addError(
_t(
'SilverStripe\\LDAP\\Authenticators\\LDAPAuthenticator.NOUSER',
'Your account hasn\'t been setup properly, please contact an administrator.'
)
);
return $validationResult;
}
$userData = $this->getUserByGUID($member->GUID);
if (empty($userData['distinguishedname'])) {
$validationResult->addError(
_t(
'SilverStripe\\LDAP\\Authenticators\\LDAPAuthenticator.NOUSER',
'Your account hasn\'t been setup properly, please contact an administrator.'
)
);
return $validationResult;
}
try {
if (!empty($oldPassword)) {
$this->getGateway()->changePassword($userData['distinguishedname'], $password, $oldPassword);
} elseif ($this->config()->password_history_workaround) {
$this->passwordHistoryWorkaround($userData['distinguishedname'], $password);
} else {
$this->getGateway()->resetPassword($userData['distinguishedname'], $password);
}
$this->extend('onAfterSetPassword', $member, $password, $validationResult);
} catch (Exception $e) {
$validationResult->addError($e->getMessage());
}
return $validationResult;
}
|
[
"public",
"function",
"setPassword",
"(",
"Member",
"$",
"member",
",",
"$",
"password",
",",
"$",
"oldPassword",
"=",
"null",
")",
"{",
"$",
"validationResult",
"=",
"ValidationResult",
"::",
"create",
"(",
")",
";",
"$",
"this",
"->",
"extend",
"(",
"'onBeforeSetPassword'",
",",
"$",
"member",
",",
"$",
"password",
",",
"$",
"validationResult",
")",
";",
"if",
"(",
"!",
"$",
"member",
"->",
"GUID",
")",
"{",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"debug",
"(",
"sprintf",
"(",
"'Cannot update Member ID %s, GUID not set'",
",",
"$",
"member",
"->",
"ID",
")",
")",
";",
"$",
"validationResult",
"->",
"addError",
"(",
"_t",
"(",
"'SilverStripe\\\\LDAP\\\\Authenticators\\\\LDAPAuthenticator.NOUSER'",
",",
"'Your account hasn\\'t been setup properly, please contact an administrator.'",
")",
")",
";",
"return",
"$",
"validationResult",
";",
"}",
"$",
"userData",
"=",
"$",
"this",
"->",
"getUserByGUID",
"(",
"$",
"member",
"->",
"GUID",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"userData",
"[",
"'distinguishedname'",
"]",
")",
")",
"{",
"$",
"validationResult",
"->",
"addError",
"(",
"_t",
"(",
"'SilverStripe\\\\LDAP\\\\Authenticators\\\\LDAPAuthenticator.NOUSER'",
",",
"'Your account hasn\\'t been setup properly, please contact an administrator.'",
")",
")",
";",
"return",
"$",
"validationResult",
";",
"}",
"try",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"oldPassword",
")",
")",
"{",
"$",
"this",
"->",
"getGateway",
"(",
")",
"->",
"changePassword",
"(",
"$",
"userData",
"[",
"'distinguishedname'",
"]",
",",
"$",
"password",
",",
"$",
"oldPassword",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"password_history_workaround",
")",
"{",
"$",
"this",
"->",
"passwordHistoryWorkaround",
"(",
"$",
"userData",
"[",
"'distinguishedname'",
"]",
",",
"$",
"password",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"getGateway",
"(",
")",
"->",
"resetPassword",
"(",
"$",
"userData",
"[",
"'distinguishedname'",
"]",
",",
"$",
"password",
")",
";",
"}",
"$",
"this",
"->",
"extend",
"(",
"'onAfterSetPassword'",
",",
"$",
"member",
",",
"$",
"password",
",",
"$",
"validationResult",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"validationResult",
"->",
"addError",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"validationResult",
";",
"}"
] |
Change a members password on the AD. Works with ActiveDirectory compatible services that saves the
password in the `unicodePwd` attribute.
@todo Use the Zend\Ldap\Attribute::setPassword functionality to create a password in
an abstract way, so it works on other LDAP directories, not just Active Directory.
Ensure that the LDAP bind:ed user can change passwords and that the connection is secure.
@param Member $member
@param string $password
@param string|null $oldPassword Supply old password to perform a password change (as opposed to password reset)
@return ValidationResult
|
[
"Change",
"a",
"members",
"password",
"on",
"the",
"AD",
".",
"Works",
"with",
"ActiveDirectory",
"compatible",
"services",
"that",
"saves",
"the",
"password",
"in",
"the",
"unicodePwd",
"attribute",
"."
] |
e8e6de4de9d61ad383086bc2fb2a793809cb755e
|
https://github.com/silverstripe/silverstripe-ldap/blob/e8e6de4de9d61ad383086bc2fb2a793809cb755e/src/Services/LDAPService.php#L1104-L1146
|
223,477
|
ConsoleTVs/Links
|
src/Builder/Link.php
|
Link.ajax
|
public function ajax($jquery = false)
{
$url = $this->link->shortered();
$code = $jquery ? "<script src='https://code.jquery.com/jquery-3.1.1.min.js' integrity='sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=' crossorigin='anonymous'></script>" : '';
$code .= '<script>';
$code .= "$.get('$url');";
$code .= '</script>';
return $code;
}
|
php
|
public function ajax($jquery = false)
{
$url = $this->link->shortered();
$code = $jquery ? "<script src='https://code.jquery.com/jquery-3.1.1.min.js' integrity='sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=' crossorigin='anonymous'></script>" : '';
$code .= '<script>';
$code .= "$.get('$url');";
$code .= '</script>';
return $code;
}
|
[
"public",
"function",
"ajax",
"(",
"$",
"jquery",
"=",
"false",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"link",
"->",
"shortered",
"(",
")",
";",
"$",
"code",
"=",
"$",
"jquery",
"?",
"\"<script src='https://code.jquery.com/jquery-3.1.1.min.js' integrity='sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=' crossorigin='anonymous'></script>\"",
":",
"''",
";",
"$",
"code",
".=",
"'<script>'",
";",
"$",
"code",
".=",
"\"$.get('$url');\"",
";",
"$",
"code",
".=",
"'</script>'",
";",
"return",
"$",
"code",
";",
"}"
] |
Returns the javascript code to send a and ajax request to the short url.
|
[
"Returns",
"the",
"javascript",
"code",
"to",
"send",
"a",
"and",
"ajax",
"request",
"to",
"the",
"short",
"url",
"."
] |
f9afe304137f8d7682eac9c46f8aa4c82f5e625c
|
https://github.com/ConsoleTVs/Links/blob/f9afe304137f8d7682eac9c46f8aa4c82f5e625c/src/Builder/Link.php#L63-L74
|
223,478
|
haridarshan/instagram-php
|
src/HelperFactory.php
|
HelperFactory.request
|
public function request(Client $client, $endpoint, $options, $method = 'GET')
{
try {
return $client->request($method, $endpoint, [
'form_params' => $options,
]);
} catch (ClientException $exception) {
static::throwException(static::extractOriginalExceptionMessage($exception), $exception);
}
}
|
php
|
public function request(Client $client, $endpoint, $options, $method = 'GET')
{
try {
return $client->request($method, $endpoint, [
'form_params' => $options,
]);
} catch (ClientException $exception) {
static::throwException(static::extractOriginalExceptionMessage($exception), $exception);
}
}
|
[
"public",
"function",
"request",
"(",
"Client",
"$",
"client",
",",
"$",
"endpoint",
",",
"$",
"options",
",",
"$",
"method",
"=",
"'GET'",
")",
"{",
"try",
"{",
"return",
"$",
"client",
"->",
"request",
"(",
"$",
"method",
",",
"$",
"endpoint",
",",
"[",
"'form_params'",
"=>",
"$",
"options",
",",
"]",
")",
";",
"}",
"catch",
"(",
"ClientException",
"$",
"exception",
")",
"{",
"static",
"::",
"throwException",
"(",
"static",
"::",
"extractOriginalExceptionMessage",
"(",
"$",
"exception",
")",
",",
"$",
"exception",
")",
";",
"}",
"}"
] |
Sends request to Instagram Api Endpoints
@param Client $client
@param string $endpoint
@param array|string $options
@param string $method
@throws InstagramOAuthException|InstagramException
@return Response
|
[
"Sends",
"request",
"to",
"Instagram",
"Api",
"Endpoints"
] |
5f21e622eaffcbb9b30f12ebdf0064a91ff1caff
|
https://github.com/haridarshan/instagram-php/blob/5f21e622eaffcbb9b30f12ebdf0064a91ff1caff/src/HelperFactory.php#L117-L126
|
223,479
|
haridarshan/instagram-php
|
src/HelperFactory.php
|
HelperFactory.createBody
|
protected static function createBody($options, $method)
{
return ('GET' !== $method) ? is_array($options) ? http_build_query($options) : ltrim($options, '&') : null;
}
|
php
|
protected static function createBody($options, $method)
{
return ('GET' !== $method) ? is_array($options) ? http_build_query($options) : ltrim($options, '&') : null;
}
|
[
"protected",
"static",
"function",
"createBody",
"(",
"$",
"options",
",",
"$",
"method",
")",
"{",
"return",
"(",
"'GET'",
"!==",
"$",
"method",
")",
"?",
"is_array",
"(",
"$",
"options",
")",
"?",
"http_build_query",
"(",
"$",
"options",
")",
":",
"ltrim",
"(",
"$",
"options",
",",
"'&'",
")",
":",
"null",
";",
"}"
] |
Create body for Guzzle client request
@param array|null|string $options
@param string $method GET|POST
@return string|mixed
|
[
"Create",
"body",
"for",
"Guzzle",
"client",
"request"
] |
5f21e622eaffcbb9b30f12ebdf0064a91ff1caff
|
https://github.com/haridarshan/instagram-php/blob/5f21e622eaffcbb9b30f12ebdf0064a91ff1caff/src/HelperFactory.php#L136-L139
|
223,480
|
haridarshan/instagram-php
|
src/HelperFactory.php
|
HelperFactory.throwException
|
protected static function throwException(\stdClass $object, ClientException $exMessage)
{
$exception = static::createExceptionMessage($object);
if (stripos($exception['error_type'], 'oauth') !== false) {
throw new InstagramOAuthException(
json_encode(['Type' => $exception['error_type'], 'Message' => $exception['error_message']]),
$exception['error_code'],
$exMessage
);
}
throw new InstagramException(
json_encode(['Type' => $exception['error_type'], 'Message' => $exception['error_message']]),
$exception['error_code'],
$exMessage
);
}
|
php
|
protected static function throwException(\stdClass $object, ClientException $exMessage)
{
$exception = static::createExceptionMessage($object);
if (stripos($exception['error_type'], 'oauth') !== false) {
throw new InstagramOAuthException(
json_encode(['Type' => $exception['error_type'], 'Message' => $exception['error_message']]),
$exception['error_code'],
$exMessage
);
}
throw new InstagramException(
json_encode(['Type' => $exception['error_type'], 'Message' => $exception['error_message']]),
$exception['error_code'],
$exMessage
);
}
|
[
"protected",
"static",
"function",
"throwException",
"(",
"\\",
"stdClass",
"$",
"object",
",",
"ClientException",
"$",
"exMessage",
")",
"{",
"$",
"exception",
"=",
"static",
"::",
"createExceptionMessage",
"(",
"$",
"object",
")",
";",
"if",
"(",
"stripos",
"(",
"$",
"exception",
"[",
"'error_type'",
"]",
",",
"'oauth'",
")",
"!==",
"false",
")",
"{",
"throw",
"new",
"InstagramOAuthException",
"(",
"json_encode",
"(",
"[",
"'Type'",
"=>",
"$",
"exception",
"[",
"'error_type'",
"]",
",",
"'Message'",
"=>",
"$",
"exception",
"[",
"'error_message'",
"]",
"]",
")",
",",
"$",
"exception",
"[",
"'error_code'",
"]",
",",
"$",
"exMessage",
")",
";",
"}",
"throw",
"new",
"InstagramException",
"(",
"json_encode",
"(",
"[",
"'Type'",
"=>",
"$",
"exception",
"[",
"'error_type'",
"]",
",",
"'Message'",
"=>",
"$",
"exception",
"[",
"'error_message'",
"]",
"]",
")",
",",
"$",
"exception",
"[",
"'error_code'",
"]",
",",
"$",
"exMessage",
")",
";",
"}"
] |
Throw required Exception
@param \stdClass $object
@param ClientException $exMessage
@throws InstagramOAuthException|InstagramException
|
[
"Throw",
"required",
"Exception"
] |
5f21e622eaffcbb9b30f12ebdf0064a91ff1caff
|
https://github.com/haridarshan/instagram-php/blob/5f21e622eaffcbb9b30f12ebdf0064a91ff1caff/src/HelperFactory.php#L174-L189
|
223,481
|
haridarshan/instagram-php
|
src/HelperFactory.php
|
HelperFactory.createExceptionMessage
|
protected static function createExceptionMessage(\stdClass $object)
{
$message = [];
$message['error_type'] = isset($object->meta) ? $object->meta->error_type : $object->error_type;
$message['error_message'] = isset($object->meta) ? $object->meta->error_message : $object->error_message;
$message['error_code'] = isset($object->meta) ? $object->meta->code : $object->code;
return $message;
}
|
php
|
protected static function createExceptionMessage(\stdClass $object)
{
$message = [];
$message['error_type'] = isset($object->meta) ? $object->meta->error_type : $object->error_type;
$message['error_message'] = isset($object->meta) ? $object->meta->error_message : $object->error_message;
$message['error_code'] = isset($object->meta) ? $object->meta->code : $object->code;
return $message;
}
|
[
"protected",
"static",
"function",
"createExceptionMessage",
"(",
"\\",
"stdClass",
"$",
"object",
")",
"{",
"$",
"message",
"=",
"[",
"]",
";",
"$",
"message",
"[",
"'error_type'",
"]",
"=",
"isset",
"(",
"$",
"object",
"->",
"meta",
")",
"?",
"$",
"object",
"->",
"meta",
"->",
"error_type",
":",
"$",
"object",
"->",
"error_type",
";",
"$",
"message",
"[",
"'error_message'",
"]",
"=",
"isset",
"(",
"$",
"object",
"->",
"meta",
")",
"?",
"$",
"object",
"->",
"meta",
"->",
"error_message",
":",
"$",
"object",
"->",
"error_message",
";",
"$",
"message",
"[",
"'error_code'",
"]",
"=",
"isset",
"(",
"$",
"object",
"->",
"meta",
")",
"?",
"$",
"object",
"->",
"meta",
"->",
"code",
":",
"$",
"object",
"->",
"code",
";",
"return",
"$",
"message",
";",
"}"
] |
Creates Exception Message
@param \stdClass $object
@return array
|
[
"Creates",
"Exception",
"Message"
] |
5f21e622eaffcbb9b30f12ebdf0064a91ff1caff
|
https://github.com/haridarshan/instagram-php/blob/5f21e622eaffcbb9b30f12ebdf0064a91ff1caff/src/HelperFactory.php#L198-L206
|
223,482
|
digiaonline/lumen-fractal
|
src/FractalBuilder.php
|
FractalBuilder.makeResource
|
protected function makeResource()
{
/** @var Item|Collection $resource */
$resource = new $this->resourceClass($this->data, $this->transformer, $this->resourceKey);
if (!empty($this->meta)) {
$resource->setMeta($this->meta);
}
if ($resource instanceof Collection && isset($this->paginator)) {
$resource->setPaginator($this->paginator);
}
return $resource;
}
|
php
|
protected function makeResource()
{
/** @var Item|Collection $resource */
$resource = new $this->resourceClass($this->data, $this->transformer, $this->resourceKey);
if (!empty($this->meta)) {
$resource->setMeta($this->meta);
}
if ($resource instanceof Collection && isset($this->paginator)) {
$resource->setPaginator($this->paginator);
}
return $resource;
}
|
[
"protected",
"function",
"makeResource",
"(",
")",
"{",
"/** @var Item|Collection $resource */",
"$",
"resource",
"=",
"new",
"$",
"this",
"->",
"resourceClass",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"this",
"->",
"transformer",
",",
"$",
"this",
"->",
"resourceKey",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"meta",
")",
")",
"{",
"$",
"resource",
"->",
"setMeta",
"(",
"$",
"this",
"->",
"meta",
")",
";",
"}",
"if",
"(",
"$",
"resource",
"instanceof",
"Collection",
"&&",
"isset",
"(",
"$",
"this",
"->",
"paginator",
")",
")",
"{",
"$",
"resource",
"->",
"setPaginator",
"(",
"$",
"this",
"->",
"paginator",
")",
";",
"}",
"return",
"$",
"resource",
";",
"}"
] |
Creates the resource for this builder.
@return ResourceAbstract
|
[
"Creates",
"the",
"resource",
"for",
"this",
"builder",
"."
] |
f2e70aff2d8ae55e072b062ed4ded45d0635069f
|
https://github.com/digiaonline/lumen-fractal/blob/f2e70aff2d8ae55e072b062ed4ded45d0635069f/src/FractalBuilder.php#L191-L205
|
223,483
|
digiaonline/lumen-fractal
|
src/FractalBuilder.php
|
FractalBuilder.makeScope
|
protected function makeScope()
{
$resource = $this->makeResource();
if (isset($this->serializer)) {
$this->fractal->setSerializer($this->serializer);
}
return $this->fractal->createData($resource);
}
|
php
|
protected function makeScope()
{
$resource = $this->makeResource();
if (isset($this->serializer)) {
$this->fractal->setSerializer($this->serializer);
}
return $this->fractal->createData($resource);
}
|
[
"protected",
"function",
"makeScope",
"(",
")",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"makeResource",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"serializer",
")",
")",
"{",
"$",
"this",
"->",
"fractal",
"->",
"setSerializer",
"(",
"$",
"this",
"->",
"serializer",
")",
";",
"}",
"return",
"$",
"this",
"->",
"fractal",
"->",
"createData",
"(",
"$",
"resource",
")",
";",
"}"
] |
Creates the scope for this builder.
@return Scope
|
[
"Creates",
"the",
"scope",
"for",
"this",
"builder",
"."
] |
f2e70aff2d8ae55e072b062ed4ded45d0635069f
|
https://github.com/digiaonline/lumen-fractal/blob/f2e70aff2d8ae55e072b062ed4ded45d0635069f/src/FractalBuilder.php#L213-L222
|
223,484
|
EtonDigital/EDBlogBundle
|
Controller/Backend/MediaController.php
|
MediaController.deleteAction
|
public function deleteAction(Request $request, Media $media)
{
$user = $this->getBlogUser();
$mediaLibrary = $this->container->get('sonata.media.manager.gallery')->findOneBy(array('name' => 'Media Library'));
$em = $this->getDoctrine()->getManager();
foreach($media->getGalleryHasMedias() as $hasMedia)
{
if($hasMedia->getGallery() == $mediaLibrary)
{
$em->remove($hasMedia);
}
}
$em->flush();
if($request->isXmlHttpRequest())
{
return new JsonResponse(array('success' => 'true'));
}
$this->get('session')->getFlashBag()->add('success', 'Photo removed successfully.');
return $this->redirectToRoute('ed_blog_admin_media_list');
}
|
php
|
public function deleteAction(Request $request, Media $media)
{
$user = $this->getBlogUser();
$mediaLibrary = $this->container->get('sonata.media.manager.gallery')->findOneBy(array('name' => 'Media Library'));
$em = $this->getDoctrine()->getManager();
foreach($media->getGalleryHasMedias() as $hasMedia)
{
if($hasMedia->getGallery() == $mediaLibrary)
{
$em->remove($hasMedia);
}
}
$em->flush();
if($request->isXmlHttpRequest())
{
return new JsonResponse(array('success' => 'true'));
}
$this->get('session')->getFlashBag()->add('success', 'Photo removed successfully.');
return $this->redirectToRoute('ed_blog_admin_media_list');
}
|
[
"public",
"function",
"deleteAction",
"(",
"Request",
"$",
"request",
",",
"Media",
"$",
"media",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getBlogUser",
"(",
")",
";",
"$",
"mediaLibrary",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'sonata.media.manager.gallery'",
")",
"->",
"findOneBy",
"(",
"array",
"(",
"'name'",
"=>",
"'Media Library'",
")",
")",
";",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"foreach",
"(",
"$",
"media",
"->",
"getGalleryHasMedias",
"(",
")",
"as",
"$",
"hasMedia",
")",
"{",
"if",
"(",
"$",
"hasMedia",
"->",
"getGallery",
"(",
")",
"==",
"$",
"mediaLibrary",
")",
"{",
"$",
"em",
"->",
"remove",
"(",
"$",
"hasMedia",
")",
";",
"}",
"}",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"if",
"(",
"$",
"request",
"->",
"isXmlHttpRequest",
"(",
")",
")",
"{",
"return",
"new",
"JsonResponse",
"(",
"array",
"(",
"'success'",
"=>",
"'true'",
")",
")",
";",
"}",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'success'",
",",
"'Photo removed successfully.'",
")",
";",
"return",
"$",
"this",
"->",
"redirectToRoute",
"(",
"'ed_blog_admin_media_list'",
")",
";",
"}"
] |
Will remove Media from MediaLibrary, but not from file system!
@Route("/media/delete/{id}", name="ed_blog_admin_media_delete")
@ParamConverter("media", class="ApplicationSonataMediaBundle:Media")
|
[
"Will",
"remove",
"Media",
"from",
"MediaLibrary",
"but",
"not",
"from",
"file",
"system!"
] |
bce97b1991b6201733aa7459712c840d92a96ccc
|
https://github.com/EtonDigital/EDBlogBundle/blob/bce97b1991b6201733aa7459712c840d92a96ccc/Controller/Backend/MediaController.php#L185-L208
|
223,485
|
haridarshan/instagram-php
|
src/InstagramResponse.php
|
InstagramResponse.setParams
|
private function setParams(Response $response)
{
$this->protocol = $response->getProtocolVersion();
$this->statusCode = (int) $response->getStatusCode();
$this->headers = $response->getHeaders();
$this->body = json_decode($response->getBody()->getContents());
$this->extractBodyParts();
}
|
php
|
private function setParams(Response $response)
{
$this->protocol = $response->getProtocolVersion();
$this->statusCode = (int) $response->getStatusCode();
$this->headers = $response->getHeaders();
$this->body = json_decode($response->getBody()->getContents());
$this->extractBodyParts();
}
|
[
"private",
"function",
"setParams",
"(",
"Response",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"protocol",
"=",
"$",
"response",
"->",
"getProtocolVersion",
"(",
")",
";",
"$",
"this",
"->",
"statusCode",
"=",
"(",
"int",
")",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
";",
"$",
"this",
"->",
"headers",
"=",
"$",
"response",
"->",
"getHeaders",
"(",
")",
";",
"$",
"this",
"->",
"body",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
")",
";",
"$",
"this",
"->",
"extractBodyParts",
"(",
")",
";",
"}"
] |
Set Values to the class members
@param Response $response
|
[
"Set",
"Values",
"to",
"the",
"class",
"members"
] |
5f21e622eaffcbb9b30f12ebdf0064a91ff1caff
|
https://github.com/haridarshan/instagram-php/blob/5f21e622eaffcbb9b30f12ebdf0064a91ff1caff/src/InstagramResponse.php#L79-L86
|
223,486
|
haridarshan/instagram-php
|
src/InstagramResponse.php
|
InstagramResponse.extractBodyParts
|
private function extractBodyParts()
{
if (isset($this->body->pagination)) {
$this->isPagination = true;
$this->pagination = $this->body->pagination;
}
if (isset($this->body->meta)) {
$this->isMetaData = true;
$this->metaData = $this->body->meta;
}
$this->data = $this->body->data;
}
|
php
|
private function extractBodyParts()
{
if (isset($this->body->pagination)) {
$this->isPagination = true;
$this->pagination = $this->body->pagination;
}
if (isset($this->body->meta)) {
$this->isMetaData = true;
$this->metaData = $this->body->meta;
}
$this->data = $this->body->data;
}
|
[
"private",
"function",
"extractBodyParts",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"body",
"->",
"pagination",
")",
")",
"{",
"$",
"this",
"->",
"isPagination",
"=",
"true",
";",
"$",
"this",
"->",
"pagination",
"=",
"$",
"this",
"->",
"body",
"->",
"pagination",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"body",
"->",
"meta",
")",
")",
"{",
"$",
"this",
"->",
"isMetaData",
"=",
"true",
";",
"$",
"this",
"->",
"metaData",
"=",
"$",
"this",
"->",
"body",
"->",
"meta",
";",
"}",
"$",
"this",
"->",
"data",
"=",
"$",
"this",
"->",
"body",
"->",
"data",
";",
"}"
] |
Extract Body Parts from the response
|
[
"Extract",
"Body",
"Parts",
"from",
"the",
"response"
] |
5f21e622eaffcbb9b30f12ebdf0064a91ff1caff
|
https://github.com/haridarshan/instagram-php/blob/5f21e622eaffcbb9b30f12ebdf0064a91ff1caff/src/InstagramResponse.php#L91-L104
|
223,487
|
lexik/LexikWorkflowBundle
|
DependencyInjection/Configuration.php
|
Configuration.createClassesNodeDefinition
|
private function createClassesNodeDefinition()
{
$classesNode = new ArrayNodeDefinition('classes');
$classesNode
->addDefaultsIfNotSet()
->children()
->scalarNode('process_handler')
->defaultValue('Lexik\Bundle\WorkflowBundle\Handler\ProcessHandler')
->end()
->scalarNode('process')
->defaultValue('Lexik\Bundle\WorkflowBundle\Flow\Process')
->end()
->scalarNode('step')
->defaultValue('Lexik\Bundle\WorkflowBundle\Flow\Step')
->end()
->end()
;
return $classesNode;
}
|
php
|
private function createClassesNodeDefinition()
{
$classesNode = new ArrayNodeDefinition('classes');
$classesNode
->addDefaultsIfNotSet()
->children()
->scalarNode('process_handler')
->defaultValue('Lexik\Bundle\WorkflowBundle\Handler\ProcessHandler')
->end()
->scalarNode('process')
->defaultValue('Lexik\Bundle\WorkflowBundle\Flow\Process')
->end()
->scalarNode('step')
->defaultValue('Lexik\Bundle\WorkflowBundle\Flow\Step')
->end()
->end()
;
return $classesNode;
}
|
[
"private",
"function",
"createClassesNodeDefinition",
"(",
")",
"{",
"$",
"classesNode",
"=",
"new",
"ArrayNodeDefinition",
"(",
"'classes'",
")",
";",
"$",
"classesNode",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'process_handler'",
")",
"->",
"defaultValue",
"(",
"'Lexik\\Bundle\\WorkflowBundle\\Handler\\ProcessHandler'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'process'",
")",
"->",
"defaultValue",
"(",
"'Lexik\\Bundle\\WorkflowBundle\\Flow\\Process'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'step'",
")",
"->",
"defaultValue",
"(",
"'Lexik\\Bundle\\WorkflowBundle\\Flow\\Step'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"classesNode",
";",
"}"
] |
Create a configuration node to customize classes used by the bundle.
@return ArrayNodeDefinition
|
[
"Create",
"a",
"configuration",
"node",
"to",
"customize",
"classes",
"used",
"by",
"the",
"bundle",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/DependencyInjection/Configuration.php#L40-L60
|
223,488
|
lexik/LexikWorkflowBundle
|
DependencyInjection/Configuration.php
|
Configuration.createProcessesNodeDefinition
|
private function createProcessesNodeDefinition()
{
$processesNode = new ArrayNodeDefinition('processes');
$processesNode
->useAttributeAsKey('name')
->prototype('array')
->validate()
->ifTrue(function ($value) {
return !empty($value['import']) && !empty($value['steps']);
})
->thenInvalid('You can\'t use "import" and "steps" keys at the same time.')
->end()
->children()
->scalarNode('import')
->defaultNull()
->end()
->scalarNode('start')
->defaultNull()
->end()
->arrayNode('end')
->defaultValue(array())
->prototype('scalar')->end()
->end()
->end()
->append($this->createStepsNodeDefinition())
->end()
;
return $processesNode;
}
|
php
|
private function createProcessesNodeDefinition()
{
$processesNode = new ArrayNodeDefinition('processes');
$processesNode
->useAttributeAsKey('name')
->prototype('array')
->validate()
->ifTrue(function ($value) {
return !empty($value['import']) && !empty($value['steps']);
})
->thenInvalid('You can\'t use "import" and "steps" keys at the same time.')
->end()
->children()
->scalarNode('import')
->defaultNull()
->end()
->scalarNode('start')
->defaultNull()
->end()
->arrayNode('end')
->defaultValue(array())
->prototype('scalar')->end()
->end()
->end()
->append($this->createStepsNodeDefinition())
->end()
;
return $processesNode;
}
|
[
"private",
"function",
"createProcessesNodeDefinition",
"(",
")",
"{",
"$",
"processesNode",
"=",
"new",
"ArrayNodeDefinition",
"(",
"'processes'",
")",
";",
"$",
"processesNode",
"->",
"useAttributeAsKey",
"(",
"'name'",
")",
"->",
"prototype",
"(",
"'array'",
")",
"->",
"validate",
"(",
")",
"->",
"ifTrue",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"!",
"empty",
"(",
"$",
"value",
"[",
"'import'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"value",
"[",
"'steps'",
"]",
")",
";",
"}",
")",
"->",
"thenInvalid",
"(",
"'You can\\'t use \"import\" and \"steps\" keys at the same time.'",
")",
"->",
"end",
"(",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'import'",
")",
"->",
"defaultNull",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'start'",
")",
"->",
"defaultNull",
"(",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'end'",
")",
"->",
"defaultValue",
"(",
"array",
"(",
")",
")",
"->",
"prototype",
"(",
"'scalar'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"append",
"(",
"$",
"this",
"->",
"createStepsNodeDefinition",
"(",
")",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"processesNode",
";",
"}"
] |
Create a configuration node to define processes.
@return ArrayNodeDefinition
|
[
"Create",
"a",
"configuration",
"node",
"to",
"define",
"processes",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/DependencyInjection/Configuration.php#L67-L99
|
223,489
|
lexik/LexikWorkflowBundle
|
DependencyInjection/Configuration.php
|
Configuration.createStepsNodeDefinition
|
private function createStepsNodeDefinition()
{
$stepsNode = new ArrayNodeDefinition('steps');
$stepsNode
->defaultValue(array())
->useAttributeAsKey('name')
->prototype('array')
->addDefaultsIfNotSet()
->children()
->scalarNode('label')
->defaultValue('')
->end()
->arrayNode('roles')
->prototype('scalar')->end()
->end()
->arrayNode('model_status')
->validate()
->ifTrue(function ($value) {
return (is_array($value) && count($value) < 2);
})
->thenInvalid('You must specify an array with [ method, constant ]')
->ifTrue(function ($value) {
return ( ! defined($value[1]));
})
->thenInvalid('You must specify a valid constant name as second parameter')
->end()
->prototype('scalar')->end()
->end()
->scalarNode('on_invalid')
->defaultNull()
->end()
->end()
->append($this->createNextStatesNodeDefinition())
->end()
;
return $stepsNode;
}
|
php
|
private function createStepsNodeDefinition()
{
$stepsNode = new ArrayNodeDefinition('steps');
$stepsNode
->defaultValue(array())
->useAttributeAsKey('name')
->prototype('array')
->addDefaultsIfNotSet()
->children()
->scalarNode('label')
->defaultValue('')
->end()
->arrayNode('roles')
->prototype('scalar')->end()
->end()
->arrayNode('model_status')
->validate()
->ifTrue(function ($value) {
return (is_array($value) && count($value) < 2);
})
->thenInvalid('You must specify an array with [ method, constant ]')
->ifTrue(function ($value) {
return ( ! defined($value[1]));
})
->thenInvalid('You must specify a valid constant name as second parameter')
->end()
->prototype('scalar')->end()
->end()
->scalarNode('on_invalid')
->defaultNull()
->end()
->end()
->append($this->createNextStatesNodeDefinition())
->end()
;
return $stepsNode;
}
|
[
"private",
"function",
"createStepsNodeDefinition",
"(",
")",
"{",
"$",
"stepsNode",
"=",
"new",
"ArrayNodeDefinition",
"(",
"'steps'",
")",
";",
"$",
"stepsNode",
"->",
"defaultValue",
"(",
"array",
"(",
")",
")",
"->",
"useAttributeAsKey",
"(",
"'name'",
")",
"->",
"prototype",
"(",
"'array'",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'label'",
")",
"->",
"defaultValue",
"(",
"''",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'roles'",
")",
"->",
"prototype",
"(",
"'scalar'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'model_status'",
")",
"->",
"validate",
"(",
")",
"->",
"ifTrue",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"count",
"(",
"$",
"value",
")",
"<",
"2",
")",
";",
"}",
")",
"->",
"thenInvalid",
"(",
"'You must specify an array with [ method, constant ]'",
")",
"->",
"ifTrue",
"(",
"function",
"(",
"$",
"value",
")",
"{",
"return",
"(",
"!",
"defined",
"(",
"$",
"value",
"[",
"1",
"]",
")",
")",
";",
"}",
")",
"->",
"thenInvalid",
"(",
"'You must specify a valid constant name as second parameter'",
")",
"->",
"end",
"(",
")",
"->",
"prototype",
"(",
"'scalar'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'on_invalid'",
")",
"->",
"defaultNull",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"append",
"(",
"$",
"this",
"->",
"createNextStatesNodeDefinition",
"(",
")",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"stepsNode",
";",
"}"
] |
Create a configuration node to define the steps of a process.
@return ArrayNodeDefinition
|
[
"Create",
"a",
"configuration",
"node",
"to",
"define",
"the",
"steps",
"of",
"a",
"process",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/DependencyInjection/Configuration.php#L106-L147
|
223,490
|
EtonDigital/EDBlogBundle
|
Handler/ArticleHandler.php
|
ArticleHandler.findWritingLockMeta
|
private function findWritingLockMeta(ArticleInterface $article)
{
$metaLock = null;
//search writing_lock data
foreach($article->getMetaData() as $meta)
{
if($meta->getKey() == 'writing_locked')
{
$metaLock = $meta;
break;
}
}
return $metaLock;
}
|
php
|
private function findWritingLockMeta(ArticleInterface $article)
{
$metaLock = null;
//search writing_lock data
foreach($article->getMetaData() as $meta)
{
if($meta->getKey() == 'writing_locked')
{
$metaLock = $meta;
break;
}
}
return $metaLock;
}
|
[
"private",
"function",
"findWritingLockMeta",
"(",
"ArticleInterface",
"$",
"article",
")",
"{",
"$",
"metaLock",
"=",
"null",
";",
"//search writing_lock data",
"foreach",
"(",
"$",
"article",
"->",
"getMetaData",
"(",
")",
"as",
"$",
"meta",
")",
"{",
"if",
"(",
"$",
"meta",
"->",
"getKey",
"(",
")",
"==",
"'writing_locked'",
")",
"{",
"$",
"metaLock",
"=",
"$",
"meta",
";",
"break",
";",
"}",
"}",
"return",
"$",
"metaLock",
";",
"}"
] |
Finds last writing lock
@param ArticleInterface $article
@return mixed
|
[
"Finds",
"last",
"writing",
"lock"
] |
bce97b1991b6201733aa7459712c840d92a96ccc
|
https://github.com/EtonDigital/EDBlogBundle/blob/bce97b1991b6201733aa7459712c840d92a96ccc/Handler/ArticleHandler.php#L90-L106
|
223,491
|
EtonDigital/EDBlogBundle
|
Handler/MediaHandler.php
|
MediaHandler.addToEditHistory
|
public function addToEditHistory($media, $providerReference, $width, $height)
{
$key = 'media_edit_history_' . $media->getId();
$history = $this->session->get($key, null);
if(!$history)
{
$history = array();
}
else
{
$history = unserialize($history);
}
$history[] = array(
'providerReference' => $providerReference,
'width' => $width,
'height' => $height
);
$this->session->set($key, serialize( $history ));
}
|
php
|
public function addToEditHistory($media, $providerReference, $width, $height)
{
$key = 'media_edit_history_' . $media->getId();
$history = $this->session->get($key, null);
if(!$history)
{
$history = array();
}
else
{
$history = unserialize($history);
}
$history[] = array(
'providerReference' => $providerReference,
'width' => $width,
'height' => $height
);
$this->session->set($key, serialize( $history ));
}
|
[
"public",
"function",
"addToEditHistory",
"(",
"$",
"media",
",",
"$",
"providerReference",
",",
"$",
"width",
",",
"$",
"height",
")",
"{",
"$",
"key",
"=",
"'media_edit_history_'",
".",
"$",
"media",
"->",
"getId",
"(",
")",
";",
"$",
"history",
"=",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"$",
"key",
",",
"null",
")",
";",
"if",
"(",
"!",
"$",
"history",
")",
"{",
"$",
"history",
"=",
"array",
"(",
")",
";",
"}",
"else",
"{",
"$",
"history",
"=",
"unserialize",
"(",
"$",
"history",
")",
";",
"}",
"$",
"history",
"[",
"]",
"=",
"array",
"(",
"'providerReference'",
"=>",
"$",
"providerReference",
",",
"'width'",
"=>",
"$",
"width",
",",
"'height'",
"=>",
"$",
"height",
")",
";",
"$",
"this",
"->",
"session",
"->",
"set",
"(",
"$",
"key",
",",
"serialize",
"(",
"$",
"history",
")",
")",
";",
"}"
] |
Keep temparary records of file media edit history
@param $media
@param $providerReference
@param $width
@param $height
|
[
"Keep",
"temparary",
"records",
"of",
"file",
"media",
"edit",
"history"
] |
bce97b1991b6201733aa7459712c840d92a96ccc
|
https://github.com/EtonDigital/EDBlogBundle/blob/bce97b1991b6201733aa7459712c840d92a96ccc/Handler/MediaHandler.php#L66-L87
|
223,492
|
silverstripe/silverstripe-ldap
|
src/Authenticators/LDAPLostPasswordHandler.php
|
LDAPLostPasswordHandler.lostPasswordForm
|
public function lostPasswordForm()
{
$loginFieldLabel = (Config::inst()->get(LDAPAuthenticator::class, 'allow_email_login') === 'yes') ?
_t('SilverStripe\\LDAP\\Forms\\LDAPLoginForm.USERNAMEOREMAIL', 'Username or email') :
_t('SilverStripe\\LDAP\\Forms\\LDAPLoginForm.USERNAME', 'Username');
$loginField = TextField::create('Login', $loginFieldLabel);
$action = FormAction::create(
'forgotPassword',
_t('SilverStripe\\Security\\Security.BUTTONSEND', 'Send me the password reset link')
);
return LostPasswordForm::create(
$this,
$this->authenticatorClass,
'LostPasswordForm',
FieldList::create([$loginField]),
FieldList::create([$action]),
false
);
}
|
php
|
public function lostPasswordForm()
{
$loginFieldLabel = (Config::inst()->get(LDAPAuthenticator::class, 'allow_email_login') === 'yes') ?
_t('SilverStripe\\LDAP\\Forms\\LDAPLoginForm.USERNAMEOREMAIL', 'Username or email') :
_t('SilverStripe\\LDAP\\Forms\\LDAPLoginForm.USERNAME', 'Username');
$loginField = TextField::create('Login', $loginFieldLabel);
$action = FormAction::create(
'forgotPassword',
_t('SilverStripe\\Security\\Security.BUTTONSEND', 'Send me the password reset link')
);
return LostPasswordForm::create(
$this,
$this->authenticatorClass,
'LostPasswordForm',
FieldList::create([$loginField]),
FieldList::create([$action]),
false
);
}
|
[
"public",
"function",
"lostPasswordForm",
"(",
")",
"{",
"$",
"loginFieldLabel",
"=",
"(",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"LDAPAuthenticator",
"::",
"class",
",",
"'allow_email_login'",
")",
"===",
"'yes'",
")",
"?",
"_t",
"(",
"'SilverStripe\\\\LDAP\\\\Forms\\\\LDAPLoginForm.USERNAMEOREMAIL'",
",",
"'Username or email'",
")",
":",
"_t",
"(",
"'SilverStripe\\\\LDAP\\\\Forms\\\\LDAPLoginForm.USERNAME'",
",",
"'Username'",
")",
";",
"$",
"loginField",
"=",
"TextField",
"::",
"create",
"(",
"'Login'",
",",
"$",
"loginFieldLabel",
")",
";",
"$",
"action",
"=",
"FormAction",
"::",
"create",
"(",
"'forgotPassword'",
",",
"_t",
"(",
"'SilverStripe\\\\Security\\\\Security.BUTTONSEND'",
",",
"'Send me the password reset link'",
")",
")",
";",
"return",
"LostPasswordForm",
"::",
"create",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"authenticatorClass",
",",
"'LostPasswordForm'",
",",
"FieldList",
"::",
"create",
"(",
"[",
"$",
"loginField",
"]",
")",
",",
"FieldList",
"::",
"create",
"(",
"[",
"$",
"action",
"]",
")",
",",
"false",
")",
";",
"}"
] |
Factory method for the lost password form
@return Form Returns the lost password form
|
[
"Factory",
"method",
"for",
"the",
"lost",
"password",
"form"
] |
e8e6de4de9d61ad383086bc2fb2a793809cb755e
|
https://github.com/silverstripe/silverstripe-ldap/blob/e8e6de4de9d61ad383086bc2fb2a793809cb755e/src/Authenticators/LDAPLostPasswordHandler.php#L147-L166
|
223,493
|
ConsoleTVs/Links
|
src/Models/Link.php
|
Link.usedBrowsers
|
public function usedBrowsers()
{
$results = [];
foreach ($this->views as $view) {
array_key_exists($view->browser, $results) ? $results[$view->browser]++ : $results[$view->browser] = 1;
}
return $results;
}
|
php
|
public function usedBrowsers()
{
$results = [];
foreach ($this->views as $view) {
array_key_exists($view->browser, $results) ? $results[$view->browser]++ : $results[$view->browser] = 1;
}
return $results;
}
|
[
"public",
"function",
"usedBrowsers",
"(",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"views",
"as",
"$",
"view",
")",
"{",
"array_key_exists",
"(",
"$",
"view",
"->",
"browser",
",",
"$",
"results",
")",
"?",
"$",
"results",
"[",
"$",
"view",
"->",
"browser",
"]",
"++",
":",
"$",
"results",
"[",
"$",
"view",
"->",
"browser",
"]",
"=",
"1",
";",
"}",
"return",
"$",
"results",
";",
"}"
] |
Returns the link browsers.
|
[
"Returns",
"the",
"link",
"browsers",
"."
] |
f9afe304137f8d7682eac9c46f8aa4c82f5e625c
|
https://github.com/ConsoleTVs/Links/blob/f9afe304137f8d7682eac9c46f8aa4c82f5e625c/src/Models/Link.php#L64-L73
|
223,494
|
ConsoleTVs/Links
|
src/Models/Link.php
|
Link.mostUsedBrowser
|
public function mostUsedBrowser()
{
$max = 0;
$max_browser = null;
foreach ($this->usedBrowsers() as $browser => $count) {
if ($count >= $max) {
$max = $count;
$max_browser = $browser;
}
}
return $max_browser;
}
|
php
|
public function mostUsedBrowser()
{
$max = 0;
$max_browser = null;
foreach ($this->usedBrowsers() as $browser => $count) {
if ($count >= $max) {
$max = $count;
$max_browser = $browser;
}
}
return $max_browser;
}
|
[
"public",
"function",
"mostUsedBrowser",
"(",
")",
"{",
"$",
"max",
"=",
"0",
";",
"$",
"max_browser",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"usedBrowsers",
"(",
")",
"as",
"$",
"browser",
"=>",
"$",
"count",
")",
"{",
"if",
"(",
"$",
"count",
">=",
"$",
"max",
")",
"{",
"$",
"max",
"=",
"$",
"count",
";",
"$",
"max_browser",
"=",
"$",
"browser",
";",
"}",
"}",
"return",
"$",
"max_browser",
";",
"}"
] |
Returns the link most used browser.
|
[
"Returns",
"the",
"link",
"most",
"used",
"browser",
"."
] |
f9afe304137f8d7682eac9c46f8aa4c82f5e625c
|
https://github.com/ConsoleTVs/Links/blob/f9afe304137f8d7682eac9c46f8aa4c82f5e625c/src/Models/Link.php#L78-L91
|
223,495
|
ConsoleTVs/Links
|
src/Models/Link.php
|
Link.addView
|
public function addView()
{
$view = View::create([
'link_id' => $this->id,
'language' => Identify::lang()->getLanguage(),
'browser' => Identify::browser()->getName(),
'browser_version' => Identify::browser()->getVersion(),
'os' => Identify::os()->getName(),
'os_version' => Identify::os()->getVersion(),
'ip' => $this->getIP(),
]);
}
|
php
|
public function addView()
{
$view = View::create([
'link_id' => $this->id,
'language' => Identify::lang()->getLanguage(),
'browser' => Identify::browser()->getName(),
'browser_version' => Identify::browser()->getVersion(),
'os' => Identify::os()->getName(),
'os_version' => Identify::os()->getVersion(),
'ip' => $this->getIP(),
]);
}
|
[
"public",
"function",
"addView",
"(",
")",
"{",
"$",
"view",
"=",
"View",
"::",
"create",
"(",
"[",
"'link_id'",
"=>",
"$",
"this",
"->",
"id",
",",
"'language'",
"=>",
"Identify",
"::",
"lang",
"(",
")",
"->",
"getLanguage",
"(",
")",
",",
"'browser'",
"=>",
"Identify",
"::",
"browser",
"(",
")",
"->",
"getName",
"(",
")",
",",
"'browser_version'",
"=>",
"Identify",
"::",
"browser",
"(",
")",
"->",
"getVersion",
"(",
")",
",",
"'os'",
"=>",
"Identify",
"::",
"os",
"(",
")",
"->",
"getName",
"(",
")",
",",
"'os_version'",
"=>",
"Identify",
"::",
"os",
"(",
")",
"->",
"getVersion",
"(",
")",
",",
"'ip'",
"=>",
"$",
"this",
"->",
"getIP",
"(",
")",
",",
"]",
")",
";",
"}"
] |
Adds a new view to the link.
|
[
"Adds",
"a",
"new",
"view",
"to",
"the",
"link",
"."
] |
f9afe304137f8d7682eac9c46f8aa4c82f5e625c
|
https://github.com/ConsoleTVs/Links/blob/f9afe304137f8d7682eac9c46f8aa4c82f5e625c/src/Models/Link.php#L182-L193
|
223,496
|
ConsoleTVs/Links
|
src/Controllers/LinksController.php
|
LinksController.login
|
public function login(Request $request)
{
session(['links.password' => Crypt::encrypt($request->input('password'))]);
if (Crypt::decrypt(session('links.password')) != config('links.password')) {
return redirect()->route('links::login')->with('msg', 'The password is not correct');
}
return redirect()->route('links::links');
}
|
php
|
public function login(Request $request)
{
session(['links.password' => Crypt::encrypt($request->input('password'))]);
if (Crypt::decrypt(session('links.password')) != config('links.password')) {
return redirect()->route('links::login')->with('msg', 'The password is not correct');
}
return redirect()->route('links::links');
}
|
[
"public",
"function",
"login",
"(",
"Request",
"$",
"request",
")",
"{",
"session",
"(",
"[",
"'links.password'",
"=>",
"Crypt",
"::",
"encrypt",
"(",
"$",
"request",
"->",
"input",
"(",
"'password'",
")",
")",
"]",
")",
";",
"if",
"(",
"Crypt",
"::",
"decrypt",
"(",
"session",
"(",
"'links.password'",
")",
")",
"!=",
"config",
"(",
"'links.password'",
")",
")",
"{",
"return",
"redirect",
"(",
")",
"->",
"route",
"(",
"'links::login'",
")",
"->",
"with",
"(",
"'msg'",
",",
"'The password is not correct'",
")",
";",
"}",
"return",
"redirect",
"(",
")",
"->",
"route",
"(",
"'links::links'",
")",
";",
"}"
] |
Login the user.
|
[
"Login",
"the",
"user",
"."
] |
f9afe304137f8d7682eac9c46f8aa4c82f5e625c
|
https://github.com/ConsoleTVs/Links/blob/f9afe304137f8d7682eac9c46f8aa4c82f5e625c/src/Controllers/LinksController.php#L28-L37
|
223,497
|
ConsoleTVs/Links
|
src/Controllers/LinksController.php
|
LinksController.redirect
|
public function redirect($slug)
{
if (! $link = Link::where('slug', $slug)->first()) {
abort(404, 'Unable to find this link');
}
$link->addView();
return redirect($link->url);
}
|
php
|
public function redirect($slug)
{
if (! $link = Link::where('slug', $slug)->first()) {
abort(404, 'Unable to find this link');
}
$link->addView();
return redirect($link->url);
}
|
[
"public",
"function",
"redirect",
"(",
"$",
"slug",
")",
"{",
"if",
"(",
"!",
"$",
"link",
"=",
"Link",
"::",
"where",
"(",
"'slug'",
",",
"$",
"slug",
")",
"->",
"first",
"(",
")",
")",
"{",
"abort",
"(",
"404",
",",
"'Unable to find this link'",
")",
";",
"}",
"$",
"link",
"->",
"addView",
"(",
")",
";",
"return",
"redirect",
"(",
"$",
"link",
"->",
"url",
")",
";",
"}"
] |
Redirects the user to the link.
@param string $slug
|
[
"Redirects",
"the",
"user",
"to",
"the",
"link",
"."
] |
f9afe304137f8d7682eac9c46f8aa4c82f5e625c
|
https://github.com/ConsoleTVs/Links/blob/f9afe304137f8d7682eac9c46f8aa4c82f5e625c/src/Controllers/LinksController.php#L117-L126
|
223,498
|
EtonDigital/EDBlogBundle
|
Model/Entity/Article.php
|
Article.getExcerptText
|
public function getExcerptText()
{
if($this->excerpt)
{
return $this->excerpt;
}
else
{
$rowExcerpt = strip_tags($this->content);
if( strlen($rowExcerpt) > self::EXCERPT_LENGTH)
{
$break = strpos($rowExcerpt, ' ', self::EXCERPT_LENGTH - 10);
$rowExcerpt = substr($rowExcerpt, 0, $break) . '...';
}
return $rowExcerpt;
}
}
|
php
|
public function getExcerptText()
{
if($this->excerpt)
{
return $this->excerpt;
}
else
{
$rowExcerpt = strip_tags($this->content);
if( strlen($rowExcerpt) > self::EXCERPT_LENGTH)
{
$break = strpos($rowExcerpt, ' ', self::EXCERPT_LENGTH - 10);
$rowExcerpt = substr($rowExcerpt, 0, $break) . '...';
}
return $rowExcerpt;
}
}
|
[
"public",
"function",
"getExcerptText",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"excerpt",
")",
"{",
"return",
"$",
"this",
"->",
"excerpt",
";",
"}",
"else",
"{",
"$",
"rowExcerpt",
"=",
"strip_tags",
"(",
"$",
"this",
"->",
"content",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"rowExcerpt",
")",
">",
"self",
"::",
"EXCERPT_LENGTH",
")",
"{",
"$",
"break",
"=",
"strpos",
"(",
"$",
"rowExcerpt",
",",
"' '",
",",
"self",
"::",
"EXCERPT_LENGTH",
"-",
"10",
")",
";",
"$",
"rowExcerpt",
"=",
"substr",
"(",
"$",
"rowExcerpt",
",",
"0",
",",
"$",
"break",
")",
".",
"'...'",
";",
"}",
"return",
"$",
"rowExcerpt",
";",
"}",
"}"
] |
Use this over getExcept in frontend display
@return mixed
|
[
"Use",
"this",
"over",
"getExcept",
"in",
"frontend",
"display"
] |
bce97b1991b6201733aa7459712c840d92a96ccc
|
https://github.com/EtonDigital/EDBlogBundle/blob/bce97b1991b6201733aa7459712c840d92a96ccc/Model/Entity/Article.php#L257-L275
|
223,499
|
wirecard/checkout-client-library
|
library/WirecardCEE/Stdlib/Basket/Item.php
|
WirecardCEE_Stdlib_Basket_Item.getDescription
|
public function getDescription()
{
if(array_key_exists(self::ITEM_DESCRIPTION, $this->_itemData)) {
return (string) $this->_itemData[self::ITEM_DESCRIPTION];
}
return null;
}
|
php
|
public function getDescription()
{
if(array_key_exists(self::ITEM_DESCRIPTION, $this->_itemData)) {
return (string) $this->_itemData[self::ITEM_DESCRIPTION];
}
return null;
}
|
[
"public",
"function",
"getDescription",
"(",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"self",
"::",
"ITEM_DESCRIPTION",
",",
"$",
"this",
"->",
"_itemData",
")",
")",
"{",
"return",
"(",
"string",
")",
"$",
"this",
"->",
"_itemData",
"[",
"self",
"::",
"ITEM_DESCRIPTION",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns the item description
@return string
|
[
"Returns",
"the",
"item",
"description"
] |
ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c
|
https://github.com/wirecard/checkout-client-library/blob/ad0f8c88dfb3c39091c80b1b58e8dd3604f3e25c/library/WirecardCEE/Stdlib/Basket/Item.php#L208-L214
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.