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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
227,800
|
authlete/authlete-php
|
src/Dto/Client.php
|
Client.setGrantTypes
|
public function setGrantTypes(array $grantTypes = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$grantTypes', $grantTypes, '\Authlete\Types\GrantType');
$this->grantTypes = $grantTypes;
return $this;
}
|
php
|
public function setGrantTypes(array $grantTypes = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$grantTypes', $grantTypes, '\Authlete\Types\GrantType');
$this->grantTypes = $grantTypes;
return $this;
}
|
[
"public",
"function",
"setGrantTypes",
"(",
"array",
"$",
"grantTypes",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$grantTypes'",
",",
"$",
"grantTypes",
",",
"'\\Authlete\\Types\\GrantType'",
")",
";",
"$",
"this",
"->",
"grantTypes",
"=",
"$",
"grantTypes",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the "grant_type" values that this client application is declaring
that it will restrict itself to using.
This corresponds to the `grant_types` metadata defined in
[2. Client Metadata](https://openid.net/specs/openid-connect-registration-1_0.html#ClientMetadata)
of [OpenID Connect Dynamic Client Registration 1.0](https://openid.net/specs/openid-connect-registration-1_0.html).
@param GrantType[] $grantTypes
An array of \Authlete\Types\GrantType.
@return Client
`$this` object.
|
[
"Set",
"the",
"grant_type",
"values",
"that",
"this",
"client",
"application",
"is",
"declaring",
"that",
"it",
"will",
"restrict",
"itself",
"to",
"using",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Client.php#L444-L452
|
227,801
|
authlete/authlete-php
|
src/Dto/Client.php
|
Client.setContacts
|
public function setContacts(array $contacts = null)
{
ValidationUtility::ensureNullOrArrayOfString('$contacts', $contacts);
$this->contacts = $contacts;
return $this;
}
|
php
|
public function setContacts(array $contacts = null)
{
ValidationUtility::ensureNullOrArrayOfString('$contacts', $contacts);
$this->contacts = $contacts;
return $this;
}
|
[
"public",
"function",
"setContacts",
"(",
"array",
"$",
"contacts",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfString",
"(",
"'$contacts'",
",",
"$",
"contacts",
")",
";",
"$",
"this",
"->",
"contacts",
"=",
"$",
"contacts",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the email addresses of contacts for this client application.
This corresponds to the `contacts` metadata defined in
[2. Client Metadata](https://openid.net/specs/openid-connect-registration-1_0.html#ClientMetadata)
of [OpenID Connect Dynamic Client Registration 1.0](https://openid.net/specs/openid-connect-registration-1_0.html).
@param string[] $contacts
The email addresses of contacts.
@return Client
`$this` object.
|
[
"Set",
"the",
"email",
"addresses",
"of",
"contacts",
"for",
"this",
"client",
"application",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Client.php#L521-L528
|
227,802
|
authlete/authlete-php
|
src/Dto/Client.php
|
Client.setClientNames
|
public function setClientNames(array $clientNames = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$clientNames', $clientNames, __NAMESPACE__ . '\TaggedValue');
$this->clientNames = $clientNames;
return $this;
}
|
php
|
public function setClientNames(array $clientNames = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$clientNames', $clientNames, __NAMESPACE__ . '\TaggedValue');
$this->clientNames = $clientNames;
return $this;
}
|
[
"public",
"function",
"setClientNames",
"(",
"array",
"$",
"clientNames",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$clientNames'",
",",
"$",
"clientNames",
",",
"__NAMESPACE__",
".",
"'\\TaggedValue'",
")",
";",
"$",
"this",
"->",
"clientNames",
"=",
"$",
"clientNames",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the localized names of this client application.
@param TaggedValue[] $clientNames
The localized client names.
@return Client
`$this` object.
|
[
"Set",
"the",
"localized",
"names",
"of",
"this",
"client",
"application",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Client.php#L591-L599
|
227,803
|
authlete/authlete-php
|
src/Dto/Client.php
|
Client.setLogoUris
|
public function setLogoUris(array $logoUris = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$logoUris', $logoUris, __NAMESPACE__ . '\TaggedValue');
$this->logoUris = $logoUris;
return $this;
}
|
php
|
public function setLogoUris(array $logoUris = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$logoUris', $logoUris, __NAMESPACE__ . '\TaggedValue');
$this->logoUris = $logoUris;
return $this;
}
|
[
"public",
"function",
"setLogoUris",
"(",
"array",
"$",
"logoUris",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$logoUris'",
",",
"$",
"logoUris",
",",
"__NAMESPACE__",
".",
"'\\TaggedValue'",
")",
";",
"$",
"this",
"->",
"logoUris",
"=",
"$",
"logoUris",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the URIs of localized logo images of this client application.
@param TaggedValue[] $logoUris
The URIs of localized logo images of this client application.
@return Client
`$this` object.
|
[
"Set",
"the",
"URIs",
"of",
"localized",
"logo",
"images",
"of",
"this",
"client",
"application",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Client.php#L659-L667
|
227,804
|
authlete/authlete-php
|
src/Dto/Client.php
|
Client.setClientUris
|
public function setClientUris(array $clientUris = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$clientUris', $clientUris, __NAMESPACE__ . '\TaggedValue');
$this->clientUris = $clientUris;
return $this;
}
|
php
|
public function setClientUris(array $clientUris = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$clientUris', $clientUris, __NAMESPACE__ . '\TaggedValue');
$this->clientUris = $clientUris;
return $this;
}
|
[
"public",
"function",
"setClientUris",
"(",
"array",
"$",
"clientUris",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$clientUris'",
",",
"$",
"clientUris",
",",
"__NAMESPACE__",
".",
"'\\TaggedValue'",
")",
";",
"$",
"this",
"->",
"clientUris",
"=",
"$",
"clientUris",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the URIs of localized home pages of this client application.
@param TaggedValue[] $clientUris
The URIs of localized home pages of this client application.
@return Client
`$this` object.
|
[
"Set",
"the",
"URIs",
"of",
"localized",
"home",
"pages",
"of",
"this",
"client",
"application",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Client.php#L730-L738
|
227,805
|
authlete/authlete-php
|
src/Dto/Client.php
|
Client.setPolicyUris
|
public function setPolicyUris(array $policyUris = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$policyUris', $policyUris, __NAMESPACE__ . '\TaggedValue');
$this->policyUris = $policyUris;
return $this;
}
|
php
|
public function setPolicyUris(array $policyUris = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$policyUris', $policyUris, __NAMESPACE__ . '\TaggedValue');
$this->policyUris = $policyUris;
return $this;
}
|
[
"public",
"function",
"setPolicyUris",
"(",
"array",
"$",
"policyUris",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$policyUris'",
",",
"$",
"policyUris",
",",
"__NAMESPACE__",
".",
"'\\TaggedValue'",
")",
";",
"$",
"this",
"->",
"policyUris",
"=",
"$",
"policyUris",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the URIs of localized policy pages of this client application.
@param TaggedValue[] $policyUris
The URIs of localized policy pages of this client application.
@return Client
`$this` object.
|
[
"Set",
"the",
"URIs",
"of",
"localized",
"policy",
"pages",
"of",
"this",
"client",
"application",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Client.php#L803-L811
|
227,806
|
authlete/authlete-php
|
src/Dto/Client.php
|
Client.setTosUris
|
public function setTosUris(array $tosUris = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$tosUris', $tosUris, __NAMESPACE__ . '\TaggedValue');
$this->tosUris = $tosUris;
return $this;
}
|
php
|
public function setTosUris(array $tosUris = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$tosUris', $tosUris, __NAMESPACE__ . '\TaggedValue');
$this->tosUris = $tosUris;
return $this;
}
|
[
"public",
"function",
"setTosUris",
"(",
"array",
"$",
"tosUris",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$tosUris'",
",",
"$",
"tosUris",
",",
"__NAMESPACE__",
".",
"'\\TaggedValue'",
")",
";",
"$",
"this",
"->",
"tosUris",
"=",
"$",
"tosUris",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the URIs of localized "Terms Of Service" pages of this client
application.
@param TaggedValue[] $tosUris
The URIs of localized "Terms Of Service" pages of this client
application.
@return Client
`$this` object.
|
[
"Set",
"the",
"URIs",
"of",
"localized",
"Terms",
"Of",
"Service",
"pages",
"of",
"this",
"client",
"application",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Client.php#L878-L886
|
227,807
|
authlete/authlete-php
|
src/Dto/Client.php
|
Client.setDefaultAcrs
|
public function setDefaultAcrs(array $defaultAcrs = null)
{
ValidationUtility::ensureNullOrArrayOfString('$defaultAcrs', $defaultAcrs);
$this->defaultAcrs = $defaultAcrs;
return $this;
}
|
php
|
public function setDefaultAcrs(array $defaultAcrs = null)
{
ValidationUtility::ensureNullOrArrayOfString('$defaultAcrs', $defaultAcrs);
$this->defaultAcrs = $defaultAcrs;
return $this;
}
|
[
"public",
"function",
"setDefaultAcrs",
"(",
"array",
"$",
"defaultAcrs",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfString",
"(",
"'$defaultAcrs'",
",",
"$",
"defaultAcrs",
")",
";",
"$",
"this",
"->",
"defaultAcrs",
"=",
"$",
"defaultAcrs",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the default list of Authentication Context Class References.
This corresponds to the `default_acr_values` metadata defined in
[2. Client Metadata](https://openid.net/specs/openid-connect-registration-1_0.html#ClientMetadata)
of [OpenID Connect Dynamic Client Registration 1.0](https://openid.net/specs/openid-connect-registration-1_0.html).
@param string[] $defaultAcrs
The default list of Authentication Context Class References.
@return Client
`$this` object.
|
[
"Set",
"the",
"default",
"list",
"of",
"Authentication",
"Context",
"Class",
"References",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Client.php#L1583-L1590
|
227,808
|
authlete/authlete-php
|
src/Dto/Client.php
|
Client.setRequestUris
|
public function setRequestUris(array $requestUris = null)
{
ValidationUtility::ensureNullOrArrayOfString('$requestUris', $requestUris);
$this->requestUris = $requestUris;
return $this;
}
|
php
|
public function setRequestUris(array $requestUris = null)
{
ValidationUtility::ensureNullOrArrayOfString('$requestUris', $requestUris);
$this->requestUris = $requestUris;
return $this;
}
|
[
"public",
"function",
"setRequestUris",
"(",
"array",
"$",
"requestUris",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfString",
"(",
"'$requestUris'",
",",
"$",
"requestUris",
")",
";",
"$",
"this",
"->",
"requestUris",
"=",
"$",
"requestUris",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the request URIs that this client declares it may use.
This corresponds to the `request_uris` metadata defined in
[2. Client Metadata](https://openid.net/specs/openid-connect-registration-1_0.html#ClientMetadata)
of [OpenID Connect Dynamic Client Registration 1.0](https://openid.net/specs/openid-connect-registration-1_0.html).
@param string[] $requestUris
The request URIs.
@return Client
`$this` object.
|
[
"Set",
"the",
"request",
"URIs",
"that",
"this",
"client",
"declares",
"it",
"may",
"use",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Client.php#L1661-L1668
|
227,809
|
authlete/authlete-php
|
src/Dto/ClientListResponse.php
|
ClientListResponse.setClients
|
public function setClients(array $clients = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$clients', $clients, __NAMESPACE__ . '\Client');
$this->clients = $clients;
return $this;
}
|
php
|
public function setClients(array $clients = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$clients', $clients, __NAMESPACE__ . '\Client');
$this->clients = $clients;
return $this;
}
|
[
"public",
"function",
"setClients",
"(",
"array",
"$",
"clients",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$clients'",
",",
"$",
"clients",
",",
"__NAMESPACE__",
".",
"'\\Client'",
")",
";",
"$",
"this",
"->",
"clients",
"=",
"$",
"clients",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the list of client applications that match the query conditions.
@param Client[] $clients
The list of client applications that match the query conditions.
@return ClientListResponse
`$this` object.
|
[
"Set",
"the",
"list",
"of",
"client",
"applications",
"that",
"match",
"the",
"query",
"conditions",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/ClientListResponse.php#L219-L227
|
227,810
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Date.php
|
Date.arabicMonths
|
protected function arabicMonths($mode)
{
$replacements = array();
foreach (
$this->_xml->xpath("//ar_month/mode[@id=$mode]/replace") as $month
) {
array_push($replacements, (string)$month);
}
return $replacements;
}
|
php
|
protected function arabicMonths($mode)
{
$replacements = array();
foreach (
$this->_xml->xpath("//ar_month/mode[@id=$mode]/replace") as $month
) {
array_push($replacements, (string)$month);
}
return $replacements;
}
|
[
"protected",
"function",
"arabicMonths",
"(",
"$",
"mode",
")",
"{",
"$",
"replacements",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_xml",
"->",
"xpath",
"(",
"\"//ar_month/mode[@id=$mode]/replace\"",
")",
"as",
"$",
"month",
")",
"{",
"array_push",
"(",
"$",
"replacements",
",",
"(",
"string",
")",
"$",
"month",
")",
";",
"}",
"return",
"$",
"replacements",
";",
"}"
] |
Add Arabic month names to the replacement array
@param integer $mode Naming mode of months in Arabic where:
2) Arabic month names used in Middle East countries
3) Arabic Transliteration of Gregorian month names
4) Both of 2 and 3 formats together
5) Libya style
6) Algeria and Tunis style
7) Morocco style
@return array Arabic month names in selected style
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Add",
"Arabic",
"month",
"names",
"to",
"the",
"replacement",
"array"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Date.php#L416-L427
|
227,811
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Date.php
|
Date.hjConvert
|
public function hjConvert($Y, $M, $D)
{
if (function_exists('GregorianToJD')) {
$jd = GregorianToJD($M, $D, $Y);
} else {
$jd = $this->gregToJd($M, $D, $Y);
}
list($year, $month, $day) = $this->jdToIslamic($jd);
return array($year, $month, $day);
}
|
php
|
public function hjConvert($Y, $M, $D)
{
if (function_exists('GregorianToJD')) {
$jd = GregorianToJD($M, $D, $Y);
} else {
$jd = $this->gregToJd($M, $D, $Y);
}
list($year, $month, $day) = $this->jdToIslamic($jd);
return array($year, $month, $day);
}
|
[
"public",
"function",
"hjConvert",
"(",
"$",
"Y",
",",
"$",
"M",
",",
"$",
"D",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'GregorianToJD'",
")",
")",
"{",
"$",
"jd",
"=",
"GregorianToJD",
"(",
"$",
"M",
",",
"$",
"D",
",",
"$",
"Y",
")",
";",
"}",
"else",
"{",
"$",
"jd",
"=",
"$",
"this",
"->",
"gregToJd",
"(",
"$",
"M",
",",
"$",
"D",
",",
"$",
"Y",
")",
";",
"}",
"list",
"(",
"$",
"year",
",",
"$",
"month",
",",
"$",
"day",
")",
"=",
"$",
"this",
"->",
"jdToIslamic",
"(",
"$",
"jd",
")",
";",
"return",
"array",
"(",
"$",
"year",
",",
"$",
"month",
",",
"$",
"day",
")",
";",
"}"
] |
Convert given Gregorian date into Hijri date
@param integer $Y Year Gregorian year
@param integer $M Month Gregorian month
@param integer $D Day Gregorian day
@return array Hijri date [int Year, int Month, int Day](Islamic calendar)
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Convert",
"given",
"Gregorian",
"date",
"into",
"Hijri",
"date"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Date.php#L439-L450
|
227,812
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Date.php
|
Date.jdToIslamic
|
protected function jdToIslamic($jd)
{
$l = (int)$jd - 1948440 + 10632;
$n = (int)(($l - 1) / 10631);
$l = $l - 10631 * $n + 354;
$j = (int)((10985 - $l) / 5316) * (int)((50 * $l) / 17719)
+ (int)($l / 5670) * (int)((43 * $l) / 15238);
$l = $l - (int)((30 - $j) / 15) * (int)((17719 * $j) / 50)
- (int)($j / 16) * (int)((15238 * $j) / 43) + 29;
$m = (int)((24 * $l) / 709);
$d = $l - (int)((709 * $m) / 24);
$y = (int)(30 * $n + $j - 30);
return array($y, $m, $d);
}
|
php
|
protected function jdToIslamic($jd)
{
$l = (int)$jd - 1948440 + 10632;
$n = (int)(($l - 1) / 10631);
$l = $l - 10631 * $n + 354;
$j = (int)((10985 - $l) / 5316) * (int)((50 * $l) / 17719)
+ (int)($l / 5670) * (int)((43 * $l) / 15238);
$l = $l - (int)((30 - $j) / 15) * (int)((17719 * $j) / 50)
- (int)($j / 16) * (int)((15238 * $j) / 43) + 29;
$m = (int)((24 * $l) / 709);
$d = $l - (int)((709 * $m) / 24);
$y = (int)(30 * $n + $j - 30);
return array($y, $m, $d);
}
|
[
"protected",
"function",
"jdToIslamic",
"(",
"$",
"jd",
")",
"{",
"$",
"l",
"=",
"(",
"int",
")",
"$",
"jd",
"-",
"1948440",
"+",
"10632",
";",
"$",
"n",
"=",
"(",
"int",
")",
"(",
"(",
"$",
"l",
"-",
"1",
")",
"/",
"10631",
")",
";",
"$",
"l",
"=",
"$",
"l",
"-",
"10631",
"*",
"$",
"n",
"+",
"354",
";",
"$",
"j",
"=",
"(",
"int",
")",
"(",
"(",
"10985",
"-",
"$",
"l",
")",
"/",
"5316",
")",
"*",
"(",
"int",
")",
"(",
"(",
"50",
"*",
"$",
"l",
")",
"/",
"17719",
")",
"+",
"(",
"int",
")",
"(",
"$",
"l",
"/",
"5670",
")",
"*",
"(",
"int",
")",
"(",
"(",
"43",
"*",
"$",
"l",
")",
"/",
"15238",
")",
";",
"$",
"l",
"=",
"$",
"l",
"-",
"(",
"int",
")",
"(",
"(",
"30",
"-",
"$",
"j",
")",
"/",
"15",
")",
"*",
"(",
"int",
")",
"(",
"(",
"17719",
"*",
"$",
"j",
")",
"/",
"50",
")",
"-",
"(",
"int",
")",
"(",
"$",
"j",
"/",
"16",
")",
"*",
"(",
"int",
")",
"(",
"(",
"15238",
"*",
"$",
"j",
")",
"/",
"43",
")",
"+",
"29",
";",
"$",
"m",
"=",
"(",
"int",
")",
"(",
"(",
"24",
"*",
"$",
"l",
")",
"/",
"709",
")",
";",
"$",
"d",
"=",
"$",
"l",
"-",
"(",
"int",
")",
"(",
"(",
"709",
"*",
"$",
"m",
")",
"/",
"24",
")",
";",
"$",
"y",
"=",
"(",
"int",
")",
"(",
"30",
"*",
"$",
"n",
"+",
"$",
"j",
"-",
"30",
")",
";",
"return",
"array",
"(",
"$",
"y",
",",
"$",
"m",
",",
"$",
"d",
")",
";",
"}"
] |
Convert given Julian day into Hijri date
@param integer $jd Julian day
@return array Hijri date [int Year, int Month, int Day](Islamic calendar)
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Convert",
"given",
"Julian",
"day",
"into",
"Hijri",
"date"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Date.php#L460-L474
|
227,813
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Date.php
|
Date.gregToJd
|
protected function gregToJd ($m, $d, $y)
{
if ($m < 3) {
$y--;
$m += 12;
}
if (($y < 1582) || ($y == 1582 && $m < 10)
|| ($y == 1582 && $m == 10 && $d <= 15)
) {
// This is ignored in the GregorianToJD PHP function!
$b = 0;
} else {
$a = (int)($y / 100);
$b = 2 - $a + (int)($a / 4);
}
$jd = (int)(365.25 * ($y + 4716)) + (int)(30.6001 * ($m + 1))
+ $d + $b - 1524.5;
return round($jd);
}
|
php
|
protected function gregToJd ($m, $d, $y)
{
if ($m < 3) {
$y--;
$m += 12;
}
if (($y < 1582) || ($y == 1582 && $m < 10)
|| ($y == 1582 && $m == 10 && $d <= 15)
) {
// This is ignored in the GregorianToJD PHP function!
$b = 0;
} else {
$a = (int)($y / 100);
$b = 2 - $a + (int)($a / 4);
}
$jd = (int)(365.25 * ($y + 4716)) + (int)(30.6001 * ($m + 1))
+ $d + $b - 1524.5;
return round($jd);
}
|
[
"protected",
"function",
"gregToJd",
"(",
"$",
"m",
",",
"$",
"d",
",",
"$",
"y",
")",
"{",
"if",
"(",
"$",
"m",
"<",
"3",
")",
"{",
"$",
"y",
"--",
";",
"$",
"m",
"+=",
"12",
";",
"}",
"if",
"(",
"(",
"$",
"y",
"<",
"1582",
")",
"||",
"(",
"$",
"y",
"==",
"1582",
"&&",
"$",
"m",
"<",
"10",
")",
"||",
"(",
"$",
"y",
"==",
"1582",
"&&",
"$",
"m",
"==",
"10",
"&&",
"$",
"d",
"<=",
"15",
")",
")",
"{",
"// This is ignored in the GregorianToJD PHP function!",
"$",
"b",
"=",
"0",
";",
"}",
"else",
"{",
"$",
"a",
"=",
"(",
"int",
")",
"(",
"$",
"y",
"/",
"100",
")",
";",
"$",
"b",
"=",
"2",
"-",
"$",
"a",
"+",
"(",
"int",
")",
"(",
"$",
"a",
"/",
"4",
")",
";",
"}",
"$",
"jd",
"=",
"(",
"int",
")",
"(",
"365.25",
"*",
"(",
"$",
"y",
"+",
"4716",
")",
")",
"+",
"(",
"int",
")",
"(",
"30.6001",
"*",
"(",
"$",
"m",
"+",
"1",
")",
")",
"+",
"$",
"d",
"+",
"$",
"b",
"-",
"1524.5",
";",
"return",
"round",
"(",
"$",
"jd",
")",
";",
"}"
] |
Converts a Gregorian date to Julian Day Count
@param integer $m The month as a number from 1 (for January)
to 12 (for December)
@param integer $d The day as a number from 1 to 31
@param integer $y The year as a number between -4714 and 9999
@return integer The julian day for the given gregorian date as an integer
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Converts",
"a",
"Gregorian",
"date",
"to",
"Julian",
"Day",
"Count"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Date.php#L504-L525
|
227,814
|
uran1980/yii2-translate-panel
|
models/search/SourceMessageSearch.php
|
SourceMessageSearch.cacheFlush
|
public static function cacheFlush()
{
foreach ( self::getCategories() as $category ) {
foreach ( Yii::$app->i18n->languages as $language ) {
Yii::$app->cache->delete([
'yii\i18n\DbMessageSource',
$category,
$language,
]);
}
}
return true;
}
|
php
|
public static function cacheFlush()
{
foreach ( self::getCategories() as $category ) {
foreach ( Yii::$app->i18n->languages as $language ) {
Yii::$app->cache->delete([
'yii\i18n\DbMessageSource',
$category,
$language,
]);
}
}
return true;
}
|
[
"public",
"static",
"function",
"cacheFlush",
"(",
")",
"{",
"foreach",
"(",
"self",
"::",
"getCategories",
"(",
")",
"as",
"$",
"category",
")",
"{",
"foreach",
"(",
"Yii",
"::",
"$",
"app",
"->",
"i18n",
"->",
"languages",
"as",
"$",
"language",
")",
"{",
"Yii",
"::",
"$",
"app",
"->",
"cache",
"->",
"delete",
"(",
"[",
"'yii\\i18n\\DbMessageSource'",
",",
"$",
"category",
",",
"$",
"language",
",",
"]",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Deletes all translations values from cache.
@return boolean whether the flush operation was successful.
|
[
"Deletes",
"all",
"translations",
"values",
"from",
"cache",
"."
] |
695b3ec0274cb15fe017898875f4c7a421880309
|
https://github.com/uran1980/yii2-translate-panel/blob/695b3ec0274cb15fe017898875f4c7a421880309/models/search/SourceMessageSearch.php#L296-L309
|
227,815
|
uran1980/yii2-translate-panel
|
models/search/SourceMessageSearch.php
|
SourceMessageSearch.tokensEqual
|
protected function tokensEqual($a, $b)
{
if (is_string($a) && is_string($b)) {
return $a === $b;
} elseif (isset($a[0], $a[1], $b[0], $b[1])) {
return $a[0] === $b[0] && $a[1] == $b[1];
}
return false;
}
|
php
|
protected function tokensEqual($a, $b)
{
if (is_string($a) && is_string($b)) {
return $a === $b;
} elseif (isset($a[0], $a[1], $b[0], $b[1])) {
return $a[0] === $b[0] && $a[1] == $b[1];
}
return false;
}
|
[
"protected",
"function",
"tokensEqual",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"a",
")",
"&&",
"is_string",
"(",
"$",
"b",
")",
")",
"{",
"return",
"$",
"a",
"===",
"$",
"b",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"a",
"[",
"0",
"]",
",",
"$",
"a",
"[",
"1",
"]",
",",
"$",
"b",
"[",
"0",
"]",
",",
"$",
"b",
"[",
"1",
"]",
")",
")",
"{",
"return",
"$",
"a",
"[",
"0",
"]",
"===",
"$",
"b",
"[",
"0",
"]",
"&&",
"$",
"a",
"[",
"1",
"]",
"==",
"$",
"b",
"[",
"1",
"]",
";",
"}",
"return",
"false",
";",
"}"
] |
Finds out if two PHP tokens are equal
@param array|string $a
@param array|string $b
@return boolean
@since 2.0.1
|
[
"Finds",
"out",
"if",
"two",
"PHP",
"tokens",
"are",
"equal"
] |
695b3ec0274cb15fe017898875f4c7a421880309
|
https://github.com/uran1980/yii2-translate-panel/blob/695b3ec0274cb15fe017898875f4c7a421880309/models/search/SourceMessageSearch.php#L608-L617
|
227,816
|
genkgo/cache
|
src/Adapter/PredisAdapter.php
|
PredisAdapter.delete
|
public function delete($key)
{
if (strpos($key, '*') !== false) {
$this->deleteGlob($key);
} else {
$this->client->del([$key]);
}
}
|
php
|
public function delete($key)
{
if (strpos($key, '*') !== false) {
$this->deleteGlob($key);
} else {
$this->client->del([$key]);
}
}
|
[
"public",
"function",
"delete",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"'*'",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"deleteGlob",
"(",
"$",
"key",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"client",
"->",
"del",
"(",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}"
] |
Deletes a cache entry
@param $key
@return void
|
[
"Deletes",
"a",
"cache",
"entry"
] |
67408e8f1c555d3b098e639d772ac7d7d906118b
|
https://github.com/genkgo/cache/blob/67408e8f1c555d3b098e639d772ac7d7d906118b/src/Adapter/PredisAdapter.php#L77-L84
|
227,817
|
lawoole/framework
|
src/Homer/Calling/Invokers/RemoteInvoker.php
|
RemoteInvoker.logInvoking
|
protected function logInvoking(Invocation $invocation, Result $result, $time = null)
{
Log::channel('homer')->debug(
sprintf('%s %5.2fms %s->%s',
$result->hasException() ? 'Success' : 'Failure', $time, $invocation->getInterface(),
$invocation->getMethod()
),
[
'during' => $time,
'arguments' => $invocation->getArguments(),
'attachments' => $invocation->getAttachments(),
'result' => $result->getValue(),
'exception' => $result->getException(),
]
);
}
|
php
|
protected function logInvoking(Invocation $invocation, Result $result, $time = null)
{
Log::channel('homer')->debug(
sprintf('%s %5.2fms %s->%s',
$result->hasException() ? 'Success' : 'Failure', $time, $invocation->getInterface(),
$invocation->getMethod()
),
[
'during' => $time,
'arguments' => $invocation->getArguments(),
'attachments' => $invocation->getAttachments(),
'result' => $result->getValue(),
'exception' => $result->getException(),
]
);
}
|
[
"protected",
"function",
"logInvoking",
"(",
"Invocation",
"$",
"invocation",
",",
"Result",
"$",
"result",
",",
"$",
"time",
"=",
"null",
")",
"{",
"Log",
"::",
"channel",
"(",
"'homer'",
")",
"->",
"debug",
"(",
"sprintf",
"(",
"'%s %5.2fms %s->%s'",
",",
"$",
"result",
"->",
"hasException",
"(",
")",
"?",
"'Success'",
":",
"'Failure'",
",",
"$",
"time",
",",
"$",
"invocation",
"->",
"getInterface",
"(",
")",
",",
"$",
"invocation",
"->",
"getMethod",
"(",
")",
")",
",",
"[",
"'during'",
"=>",
"$",
"time",
",",
"'arguments'",
"=>",
"$",
"invocation",
"->",
"getArguments",
"(",
")",
",",
"'attachments'",
"=>",
"$",
"invocation",
"->",
"getAttachments",
"(",
")",
",",
"'result'",
"=>",
"$",
"result",
"->",
"getValue",
"(",
")",
",",
"'exception'",
"=>",
"$",
"result",
"->",
"getException",
"(",
")",
",",
"]",
")",
";",
"}"
] |
Log the invocation.
@param \Lawoole\Homer\Calling\Invocation $invocation
@param \Lawoole\Homer\Calling\Result $result
@param float $time
|
[
"Log",
"the",
"invocation",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Calling/Invokers/RemoteInvoker.php#L86-L101
|
227,818
|
antaresproject/core
|
src/utils/translation/src/FileLoader.php
|
FileLoader.replaceHints
|
public function replaceHints()
{
foreach ($this->hints as $namespace => $path) {
$path = $this->getLangPath($namespace);
if (!is_dir($path)) {
continue;
}
$this->hints[$namespace] = $path;
}
return;
}
|
php
|
public function replaceHints()
{
foreach ($this->hints as $namespace => $path) {
$path = $this->getLangPath($namespace);
if (!is_dir($path)) {
continue;
}
$this->hints[$namespace] = $path;
}
return;
}
|
[
"public",
"function",
"replaceHints",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"hints",
"as",
"$",
"namespace",
"=>",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getLangPath",
"(",
"$",
"namespace",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"hints",
"[",
"$",
"namespace",
"]",
"=",
"$",
"path",
";",
"}",
"return",
";",
"}"
] |
Replace hints after publishing translations
@return void
|
[
"Replace",
"hints",
"after",
"publishing",
"translations"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/translation/src/FileLoader.php#L79-L89
|
227,819
|
antaresproject/core
|
src/utils/translation/src/FileLoader.php
|
FileLoader.addPublishedNamespace
|
public function addPublishedNamespace($namespace, $hint)
{
$path = $this->getLangPath($namespace);
return (is_dir($path)) ? $this->hints[$namespace] = $path : $this->addNamespace($namespace, $hint);
}
|
php
|
public function addPublishedNamespace($namespace, $hint)
{
$path = $this->getLangPath($namespace);
return (is_dir($path)) ? $this->hints[$namespace] = $path : $this->addNamespace($namespace, $hint);
}
|
[
"public",
"function",
"addPublishedNamespace",
"(",
"$",
"namespace",
",",
"$",
"hint",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getLangPath",
"(",
"$",
"namespace",
")",
";",
"return",
"(",
"is_dir",
"(",
"$",
"path",
")",
")",
"?",
"$",
"this",
"->",
"hints",
"[",
"$",
"namespace",
"]",
"=",
"$",
"path",
":",
"$",
"this",
"->",
"addNamespace",
"(",
"$",
"namespace",
",",
"$",
"hint",
")",
";",
"}"
] |
Adds published namespace path to hints container
@param String $namespace
@param String $hint
@return String
|
[
"Adds",
"published",
"namespace",
"path",
"to",
"hints",
"container"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/translation/src/FileLoader.php#L98-L102
|
227,820
|
lawoole/framework
|
src/Homer/HomerServiceProvider.php
|
HomerServiceProvider.registerServerSockets
|
protected function registerServerSockets()
{
$this->app->afterResolving(ServerFactory::class, function ($factory) {
$factory->extendServerSocket('whisper', function ($app, $config) {
return new WhisperServerSocket($app, $config);
});
});
}
|
php
|
protected function registerServerSockets()
{
$this->app->afterResolving(ServerFactory::class, function ($factory) {
$factory->extendServerSocket('whisper', function ($app, $config) {
return new WhisperServerSocket($app, $config);
});
});
}
|
[
"protected",
"function",
"registerServerSockets",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"afterResolving",
"(",
"ServerFactory",
"::",
"class",
",",
"function",
"(",
"$",
"factory",
")",
"{",
"$",
"factory",
"->",
"extendServerSocket",
"(",
"'whisper'",
",",
"function",
"(",
"$",
"app",
",",
"$",
"config",
")",
"{",
"return",
"new",
"WhisperServerSocket",
"(",
"$",
"app",
",",
"$",
"config",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] |
Register all extension socket protocols.
|
[
"Register",
"all",
"extension",
"socket",
"protocols",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/HomerServiceProvider.php#L28-L35
|
227,821
|
lawoole/framework
|
src/Homer/HomerServiceProvider.php
|
HomerServiceProvider.registerHomer
|
protected function registerHomer()
{
$this->app->singleton('homer', function ($app) {
return new HomerManager($app, $app['homer.context'], $app['homer.dispatcher'], $app['config']['homer']);
});
}
|
php
|
protected function registerHomer()
{
$this->app->singleton('homer', function ($app) {
return new HomerManager($app, $app['homer.context'], $app['homer.dispatcher'], $app['config']['homer']);
});
}
|
[
"protected",
"function",
"registerHomer",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'homer'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"HomerManager",
"(",
"$",
"app",
",",
"$",
"app",
"[",
"'homer.context'",
"]",
",",
"$",
"app",
"[",
"'homer.dispatcher'",
"]",
",",
"$",
"app",
"[",
"'config'",
"]",
"[",
"'homer'",
"]",
")",
";",
"}",
")",
";",
"}"
] |
Register the Homer manager.
|
[
"Register",
"the",
"Homer",
"manager",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/HomerServiceProvider.php#L60-L65
|
227,822
|
antaresproject/core
|
src/foundation/src/Support/Factories/MenuFactory.php
|
MenuFactory.resolveExtensionName
|
protected function resolveExtensionName($path)
{
preg_match("/src(.*?)src/", dirname($path), $match);
if (!isset($match[1])) {
throw new \Exception('Unable to resolve valid module path');
}
$name = trim($match[1], DIRECTORY_SEPARATOR);
if (!starts_with($name, ['components', 'modules'])) {
return false;
}
return str_replace('\\', '/', $name);
}
|
php
|
protected function resolveExtensionName($path)
{
preg_match("/src(.*?)src/", dirname($path), $match);
if (!isset($match[1])) {
throw new \Exception('Unable to resolve valid module path');
}
$name = trim($match[1], DIRECTORY_SEPARATOR);
if (!starts_with($name, ['components', 'modules'])) {
return false;
}
return str_replace('\\', '/', $name);
}
|
[
"protected",
"function",
"resolveExtensionName",
"(",
"$",
"path",
")",
"{",
"preg_match",
"(",
"\"/src(.*?)src/\"",
",",
"dirname",
"(",
"$",
"path",
")",
",",
"$",
"match",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"match",
"[",
"1",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Unable to resolve valid module path'",
")",
";",
"}",
"$",
"name",
"=",
"trim",
"(",
"$",
"match",
"[",
"1",
"]",
",",
"DIRECTORY_SEPARATOR",
")",
";",
"if",
"(",
"!",
"starts_with",
"(",
"$",
"name",
",",
"[",
"'components'",
",",
"'modules'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"name",
")",
";",
"}"
] |
resolving extension name by realpath
@param String $path
@return boolean
@throws \Exception
|
[
"resolving",
"extension",
"name",
"by",
"realpath"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Support/Factories/MenuFactory.php#L102-L113
|
227,823
|
gggeek/ggwebservices
|
classes/ggphpsoapclient.php
|
ggPhpSOAPClient.toArray
|
protected function toArray( $data )
{
if ( is_object( $data ) )
{
$data = (array) $data;
}
if ( is_array( $data ) )
{
foreach( $data as $key => $val )
{
$data[$key] = $this->toArray( $val );
}
}
return $data;
}
|
php
|
protected function toArray( $data )
{
if ( is_object( $data ) )
{
$data = (array) $data;
}
if ( is_array( $data ) )
{
foreach( $data as $key => $val )
{
$data[$key] = $this->toArray( $val );
}
}
return $data;
}
|
[
"protected",
"function",
"toArray",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"(",
"array",
")",
"$",
"data",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"toArray",
"(",
"$",
"val",
")",
";",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] |
Converts recursively all objects to arrays
Used eg. when making soap calls and returning results to templates, which
like arrays better than StdClass
|
[
"Converts",
"recursively",
"all",
"objects",
"to",
"arrays",
"Used",
"eg",
".",
"when",
"making",
"soap",
"calls",
"and",
"returning",
"results",
"to",
"templates",
"which",
"like",
"arrays",
"better",
"than",
"StdClass"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggphpsoapclient.php#L255-L269
|
227,824
|
arnaud-lb/alb-oembed
|
lib/Alb/OEmbed/Provider.php
|
Provider.request
|
public function request($resourceUrl, array $params = array())
{
$params = array('url' => $resourceUrl) + $params;
$url = $this->setUrlParams($this->endpoint, $params);
$data = $this->fetchUrl($url);
if (self::TYPE_JSON === $this->type) {
return $this->createResponseFromJson($data);
} else if (self::TYPE_XML === $this->type) {
return $this->createResponseFromXml($data);
}
}
|
php
|
public function request($resourceUrl, array $params = array())
{
$params = array('url' => $resourceUrl) + $params;
$url = $this->setUrlParams($this->endpoint, $params);
$data = $this->fetchUrl($url);
if (self::TYPE_JSON === $this->type) {
return $this->createResponseFromJson($data);
} else if (self::TYPE_XML === $this->type) {
return $this->createResponseFromXml($data);
}
}
|
[
"public",
"function",
"request",
"(",
"$",
"resourceUrl",
",",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"'url'",
"=>",
"$",
"resourceUrl",
")",
"+",
"$",
"params",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"setUrlParams",
"(",
"$",
"this",
"->",
"endpoint",
",",
"$",
"params",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"fetchUrl",
"(",
"$",
"url",
")",
";",
"if",
"(",
"self",
"::",
"TYPE_JSON",
"===",
"$",
"this",
"->",
"type",
")",
"{",
"return",
"$",
"this",
"->",
"createResponseFromJson",
"(",
"$",
"data",
")",
";",
"}",
"else",
"if",
"(",
"self",
"::",
"TYPE_XML",
"===",
"$",
"this",
"->",
"type",
")",
"{",
"return",
"$",
"this",
"->",
"createResponseFromXml",
"(",
"$",
"data",
")",
";",
"}",
"}"
] |
Requests the provider
@param string $resourceUrl Resource URL
@param array $params Request params (e.g. maxheight, maxwidth)
|
[
"Requests",
"the",
"provider"
] |
a14da0282daf88fe290cd507935ece01e7ec8277
|
https://github.com/arnaud-lb/alb-oembed/blob/a14da0282daf88fe290cd507935ece01e7ec8277/lib/Alb/OEmbed/Provider.php#L49-L62
|
227,825
|
arnaud-lb/alb-oembed
|
lib/Alb/OEmbed/Provider.php
|
Provider.createResponseFromXml
|
public function createResponseFromXml($xml)
{
$dom = new \DomDocument($xml);
if (!$dom->loadXML($xml)) {
return;
}
$data = array();
foreach($dom->childNodes as $root) {
if ($root->nodeType !== XML_ELEMENT_NODE) {
continue;
}
foreach($root->childNodes as $node) {
$name = $node->nodeName;
$text = $node->textContent;
$data[$name] = $text;
}
}
return new Response($data);
}
|
php
|
public function createResponseFromXml($xml)
{
$dom = new \DomDocument($xml);
if (!$dom->loadXML($xml)) {
return;
}
$data = array();
foreach($dom->childNodes as $root) {
if ($root->nodeType !== XML_ELEMENT_NODE) {
continue;
}
foreach($root->childNodes as $node) {
$name = $node->nodeName;
$text = $node->textContent;
$data[$name] = $text;
}
}
return new Response($data);
}
|
[
"public",
"function",
"createResponseFromXml",
"(",
"$",
"xml",
")",
"{",
"$",
"dom",
"=",
"new",
"\\",
"DomDocument",
"(",
"$",
"xml",
")",
";",
"if",
"(",
"!",
"$",
"dom",
"->",
"loadXML",
"(",
"$",
"xml",
")",
")",
"{",
"return",
";",
"}",
"$",
"data",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"dom",
"->",
"childNodes",
"as",
"$",
"root",
")",
"{",
"if",
"(",
"$",
"root",
"->",
"nodeType",
"!==",
"XML_ELEMENT_NODE",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"root",
"->",
"childNodes",
"as",
"$",
"node",
")",
"{",
"$",
"name",
"=",
"$",
"node",
"->",
"nodeName",
";",
"$",
"text",
"=",
"$",
"node",
"->",
"textContent",
";",
"$",
"data",
"[",
"$",
"name",
"]",
"=",
"$",
"text",
";",
"}",
"}",
"return",
"new",
"Response",
"(",
"$",
"data",
")",
";",
"}"
] |
Creates a response from a XML string
@param string $xml A XML string
@return Response A Response instance or NULL
|
[
"Creates",
"a",
"response",
"from",
"a",
"XML",
"string"
] |
a14da0282daf88fe290cd507935ece01e7ec8277
|
https://github.com/arnaud-lb/alb-oembed/blob/a14da0282daf88fe290cd507935ece01e7ec8277/lib/Alb/OEmbed/Provider.php#L84-L105
|
227,826
|
antaresproject/core
|
src/foundation/src/Console/Commands/AssembleCommand.php
|
AssembleCommand.refreshApplication
|
protected function refreshApplication()
{
if (!$this->foundation->installed()) {
return;
}
$this->call('extension:detect', ['--quiet' => true]);
$extensions = $this->memory->get('extensions.active', []);
try {
foreach ($extensions as $extension => $config) {
$options = ['name' => $extension, '--force' => true];
$this->call('extension:refresh', $options);
$this->call('extension:update', $options);
}
$this->foundation->make('antares.extension.provider')->writeFreshManifest();
} catch (PDOException $e) {
// Skip if application is unable to make connection to the database.
}
}
|
php
|
protected function refreshApplication()
{
if (!$this->foundation->installed()) {
return;
}
$this->call('extension:detect', ['--quiet' => true]);
$extensions = $this->memory->get('extensions.active', []);
try {
foreach ($extensions as $extension => $config) {
$options = ['name' => $extension, '--force' => true];
$this->call('extension:refresh', $options);
$this->call('extension:update', $options);
}
$this->foundation->make('antares.extension.provider')->writeFreshManifest();
} catch (PDOException $e) {
// Skip if application is unable to make connection to the database.
}
}
|
[
"protected",
"function",
"refreshApplication",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"foundation",
"->",
"installed",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"call",
"(",
"'extension:detect'",
",",
"[",
"'--quiet'",
"=>",
"true",
"]",
")",
";",
"$",
"extensions",
"=",
"$",
"this",
"->",
"memory",
"->",
"get",
"(",
"'extensions.active'",
",",
"[",
"]",
")",
";",
"try",
"{",
"foreach",
"(",
"$",
"extensions",
"as",
"$",
"extension",
"=>",
"$",
"config",
")",
"{",
"$",
"options",
"=",
"[",
"'name'",
"=>",
"$",
"extension",
",",
"'--force'",
"=>",
"true",
"]",
";",
"$",
"this",
"->",
"call",
"(",
"'extension:refresh'",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"call",
"(",
"'extension:update'",
",",
"$",
"options",
")",
";",
"}",
"$",
"this",
"->",
"foundation",
"->",
"make",
"(",
"'antares.extension.provider'",
")",
"->",
"writeFreshManifest",
"(",
")",
";",
"}",
"catch",
"(",
"PDOException",
"$",
"e",
")",
"{",
"// Skip if application is unable to make connection to the database.",
"}",
"}"
] |
Refresh application for Antares.
@return void
|
[
"Refresh",
"application",
"for",
"Antares",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Console/Commands/AssembleCommand.php#L96-L118
|
227,827
|
antaresproject/core
|
src/foundation/src/Console/Commands/AssembleCommand.php
|
AssembleCommand.optimizeApplication
|
protected function optimizeApplication()
{
$this->call('config:clear');
$this->call('route:clear');
$this->call('clear-compiled');
if ($this->laravel->environment('production') && !$this->option('no-cache')) {
$this->call('config:cache');
$this->call('route:cache');
}
if (!$this->option('no-optimize')) {
$this->call('antares:optimize');
}
}
|
php
|
protected function optimizeApplication()
{
$this->call('config:clear');
$this->call('route:clear');
$this->call('clear-compiled');
if ($this->laravel->environment('production') && !$this->option('no-cache')) {
$this->call('config:cache');
$this->call('route:cache');
}
if (!$this->option('no-optimize')) {
$this->call('antares:optimize');
}
}
|
[
"protected",
"function",
"optimizeApplication",
"(",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'config:clear'",
")",
";",
"$",
"this",
"->",
"call",
"(",
"'route:clear'",
")",
";",
"$",
"this",
"->",
"call",
"(",
"'clear-compiled'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"laravel",
"->",
"environment",
"(",
"'production'",
")",
"&&",
"!",
"$",
"this",
"->",
"option",
"(",
"'no-cache'",
")",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'config:cache'",
")",
";",
"$",
"this",
"->",
"call",
"(",
"'route:cache'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"option",
"(",
"'no-optimize'",
")",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'antares:optimize'",
")",
";",
"}",
"}"
] |
Optimize application for Antares.
@return void
|
[
"Optimize",
"application",
"for",
"Antares",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Console/Commands/AssembleCommand.php#L135-L149
|
227,828
|
antaresproject/core
|
src/foundation/src/MenuComposer.php
|
MenuComposer.compose
|
public function compose($classname)
{
if (!class_exists($classname)) {
return false;
}
$instance = $this->app->make($classname);
$params = $instance->getAttribute('boot');
$group = array_get($params, 'group');
$this->app->instance($group, app('antares.widget')->make($group));
app('view')->composer(array_get($params, 'on'), function() use($instance, $group, $params) {
if (!Registry::isRegistered('menu.' . $group)) {
$instance->__construct($this->app, $group);
$instance->handle();
Registry::set('menu.' . $group, $instance);
}
$this->content($params);
});
}
|
php
|
public function compose($classname)
{
if (!class_exists($classname)) {
return false;
}
$instance = $this->app->make($classname);
$params = $instance->getAttribute('boot');
$group = array_get($params, 'group');
$this->app->instance($group, app('antares.widget')->make($group));
app('view')->composer(array_get($params, 'on'), function() use($instance, $group, $params) {
if (!Registry::isRegistered('menu.' . $group)) {
$instance->__construct($this->app, $group);
$instance->handle();
Registry::set('menu.' . $group, $instance);
}
$this->content($params);
});
}
|
[
"public",
"function",
"compose",
"(",
"$",
"classname",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"classname",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"instance",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"$",
"classname",
")",
";",
"$",
"params",
"=",
"$",
"instance",
"->",
"getAttribute",
"(",
"'boot'",
")",
";",
"$",
"group",
"=",
"array_get",
"(",
"$",
"params",
",",
"'group'",
")",
";",
"$",
"this",
"->",
"app",
"->",
"instance",
"(",
"$",
"group",
",",
"app",
"(",
"'antares.widget'",
")",
"->",
"make",
"(",
"$",
"group",
")",
")",
";",
"app",
"(",
"'view'",
")",
"->",
"composer",
"(",
"array_get",
"(",
"$",
"params",
",",
"'on'",
")",
",",
"function",
"(",
")",
"use",
"(",
"$",
"instance",
",",
"$",
"group",
",",
"$",
"params",
")",
"{",
"if",
"(",
"!",
"Registry",
"::",
"isRegistered",
"(",
"'menu.'",
".",
"$",
"group",
")",
")",
"{",
"$",
"instance",
"->",
"__construct",
"(",
"$",
"this",
"->",
"app",
",",
"$",
"group",
")",
";",
"$",
"instance",
"->",
"handle",
"(",
")",
";",
"Registry",
"::",
"set",
"(",
"'menu.'",
".",
"$",
"group",
",",
"$",
"instance",
")",
";",
"}",
"$",
"this",
"->",
"content",
"(",
"$",
"params",
")",
";",
"}",
")",
";",
"}"
] |
listening "on compose" event and attaches menu
@param String $classname
@return boolean
|
[
"listening",
"on",
"compose",
"event",
"and",
"attaches",
"menu"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/MenuComposer.php#L82-L102
|
227,829
|
antaresproject/core
|
src/foundation/src/MenuComposer.php
|
MenuComposer.content
|
protected function content(array $params = [])
{
$resultView = array_get($params, 'view', $this->defaultOptions['view']);
if (!view()->exists($resultView)) {
return false;
}
return $this->app->make('antares.widget')
->make(array_get($params, 'pane', $this->defaultOptions['pane']))
->add(array_get($params, 'name', $this->defaultOptions['name']))
->attributes(array_get($params, 'attributes', $this->defaultOptions['attributes']))
->title(array_get($params, 'title', $this->defaultOptions['title']))
->content(view($resultView, ['container' => array_get($params, 'group')]));
}
|
php
|
protected function content(array $params = [])
{
$resultView = array_get($params, 'view', $this->defaultOptions['view']);
if (!view()->exists($resultView)) {
return false;
}
return $this->app->make('antares.widget')
->make(array_get($params, 'pane', $this->defaultOptions['pane']))
->add(array_get($params, 'name', $this->defaultOptions['name']))
->attributes(array_get($params, 'attributes', $this->defaultOptions['attributes']))
->title(array_get($params, 'title', $this->defaultOptions['title']))
->content(view($resultView, ['container' => array_get($params, 'group')]));
}
|
[
"protected",
"function",
"content",
"(",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"resultView",
"=",
"array_get",
"(",
"$",
"params",
",",
"'view'",
",",
"$",
"this",
"->",
"defaultOptions",
"[",
"'view'",
"]",
")",
";",
"if",
"(",
"!",
"view",
"(",
")",
"->",
"exists",
"(",
"$",
"resultView",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'antares.widget'",
")",
"->",
"make",
"(",
"array_get",
"(",
"$",
"params",
",",
"'pane'",
",",
"$",
"this",
"->",
"defaultOptions",
"[",
"'pane'",
"]",
")",
")",
"->",
"add",
"(",
"array_get",
"(",
"$",
"params",
",",
"'name'",
",",
"$",
"this",
"->",
"defaultOptions",
"[",
"'name'",
"]",
")",
")",
"->",
"attributes",
"(",
"array_get",
"(",
"$",
"params",
",",
"'attributes'",
",",
"$",
"this",
"->",
"defaultOptions",
"[",
"'attributes'",
"]",
")",
")",
"->",
"title",
"(",
"array_get",
"(",
"$",
"params",
",",
"'title'",
",",
"$",
"this",
"->",
"defaultOptions",
"[",
"'title'",
"]",
")",
")",
"->",
"content",
"(",
"view",
"(",
"$",
"resultView",
",",
"[",
"'container'",
"=>",
"array_get",
"(",
"$",
"params",
",",
"'group'",
")",
"]",
")",
")",
";",
"}"
] |
creates content of menu widget
@param array $params
@return boolean
|
[
"creates",
"content",
"of",
"menu",
"widget"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/MenuComposer.php#L110-L122
|
227,830
|
marmelab/SonataElasticaBundle
|
Transformer/ElasticaToModelTransformer.php
|
ElasticaToModelTransformer.transform
|
public function transform(array $elasticaObjects)
{
$results = array();
foreach ($elasticaObjects as $elasticaObject) {
$elasticaObject = $elasticaObject->getHit();
$obj = new $this->objectClass();
$obj->setId($elasticaObject['_id']);
foreach ($elasticaObject['_source'] as $attributeName => $attributeValue) {
if (property_exists($this->objectClass, $attributeName)) {
$method = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $attributeName)));
$obj->{$method}($attributeValue);
}
}
$results[$obj->getId()] = $obj;
}
return $results;
}
|
php
|
public function transform(array $elasticaObjects)
{
$results = array();
foreach ($elasticaObjects as $elasticaObject) {
$elasticaObject = $elasticaObject->getHit();
$obj = new $this->objectClass();
$obj->setId($elasticaObject['_id']);
foreach ($elasticaObject['_source'] as $attributeName => $attributeValue) {
if (property_exists($this->objectClass, $attributeName)) {
$method = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $attributeName)));
$obj->{$method}($attributeValue);
}
}
$results[$obj->getId()] = $obj;
}
return $results;
}
|
[
"public",
"function",
"transform",
"(",
"array",
"$",
"elasticaObjects",
")",
"{",
"$",
"results",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"elasticaObjects",
"as",
"$",
"elasticaObject",
")",
"{",
"$",
"elasticaObject",
"=",
"$",
"elasticaObject",
"->",
"getHit",
"(",
")",
";",
"$",
"obj",
"=",
"new",
"$",
"this",
"->",
"objectClass",
"(",
")",
";",
"$",
"obj",
"->",
"setId",
"(",
"$",
"elasticaObject",
"[",
"'_id'",
"]",
")",
";",
"foreach",
"(",
"$",
"elasticaObject",
"[",
"'_source'",
"]",
"as",
"$",
"attributeName",
"=>",
"$",
"attributeValue",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"this",
"->",
"objectClass",
",",
"$",
"attributeName",
")",
")",
"{",
"$",
"method",
"=",
"'set'",
".",
"str_replace",
"(",
"' '",
",",
"''",
",",
"ucwords",
"(",
"str_replace",
"(",
"'_'",
",",
"' '",
",",
"$",
"attributeName",
")",
")",
")",
";",
"$",
"obj",
"->",
"{",
"$",
"method",
"}",
"(",
"$",
"attributeValue",
")",
";",
"}",
"}",
"$",
"results",
"[",
"$",
"obj",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"obj",
";",
"}",
"return",
"$",
"results",
";",
"}"
] |
Transforms an array of elastica objects into an array of
model objects
@param array $elasticaObjects of elastica objects
@throws \RuntimeException
@return array
|
[
"Transforms",
"an",
"array",
"of",
"elastica",
"objects",
"into",
"an",
"array",
"of",
"model",
"objects"
] |
7b8a2fde72bca7844060fcae6387641478fe7bdc
|
https://github.com/marmelab/SonataElasticaBundle/blob/7b8a2fde72bca7844060fcae6387641478fe7bdc/Transformer/ElasticaToModelTransformer.php#L41-L64
|
227,831
|
antaresproject/core
|
src/components/html/src/Form/Field.php
|
Field.forceEditable
|
public function forceEditable()
{
array_set($this->attributes, 'force_editable', true);
array_set($this->attributes, 'force_displayable', true);
return $this;
}
|
php
|
public function forceEditable()
{
array_set($this->attributes, 'force_editable', true);
array_set($this->attributes, 'force_displayable', true);
return $this;
}
|
[
"public",
"function",
"forceEditable",
"(",
")",
"{",
"array_set",
"(",
"$",
"this",
"->",
"attributes",
",",
"'force_editable'",
",",
"true",
")",
";",
"array_set",
"(",
"$",
"this",
"->",
"attributes",
",",
"'force_displayable'",
",",
"true",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
force edit field
@return \Antares\Html\Form\Field
|
[
"force",
"edit",
"field"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/Field.php#L56-L61
|
227,832
|
antaresproject/core
|
src/components/html/src/Form/Field.php
|
Field.block
|
public function block(array $blockAttrs = [])
{
$this->block = array_merge(array_get($this->attributes, 'block', []), $blockAttrs);
return $this;
}
|
php
|
public function block(array $blockAttrs = [])
{
$this->block = array_merge(array_get($this->attributes, 'block', []), $blockAttrs);
return $this;
}
|
[
"public",
"function",
"block",
"(",
"array",
"$",
"blockAttrs",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"block",
"=",
"array_merge",
"(",
"array_get",
"(",
"$",
"this",
"->",
"attributes",
",",
"'block'",
",",
"[",
"]",
")",
",",
"$",
"blockAttrs",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets block attributes
@param array $blockAttrs
@return \Antares\Html\Form\Field
|
[
"Sets",
"block",
"attributes"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/Field.php#L92-L96
|
227,833
|
antaresproject/core
|
src/components/html/src/Form/Field.php
|
Field.getBlock
|
public function getBlock($key, $default = null)
{
if (!isset($this->attributes['block'])) {
return $default;
}
if (!is_null($key) && !array_key_exists($key, $this->attributes['block'])) {
return $default;
}
if (is_null($key)) {
return $this->attributes['block'];
}
if (!is_null($key) && array_key_exists($key, $this->attributes['block'])) {
return $this->attributes['block'][$key];
}
}
|
php
|
public function getBlock($key, $default = null)
{
if (!isset($this->attributes['block'])) {
return $default;
}
if (!is_null($key) && !array_key_exists($key, $this->attributes['block'])) {
return $default;
}
if (is_null($key)) {
return $this->attributes['block'];
}
if (!is_null($key) && array_key_exists($key, $this->attributes['block'])) {
return $this->attributes['block'][$key];
}
}
|
[
"public",
"function",
"getBlock",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'block'",
"]",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"key",
")",
"&&",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"attributes",
"[",
"'block'",
"]",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"attributes",
"[",
"'block'",
"]",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"key",
")",
"&&",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"attributes",
"[",
"'block'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"attributes",
"[",
"'block'",
"]",
"[",
"$",
"key",
"]",
";",
"}",
"}"
] |
Gets block attributes
@param String $key
@param mixed $default
@return String
|
[
"Gets",
"block",
"attributes"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/Field.php#L105-L119
|
227,834
|
antaresproject/core
|
src/components/memory/src/MemoryServiceProvider.php
|
MemoryServiceProvider.bootMemoryEvent
|
protected function bootMemoryEvent()
{
$app = $this->app;
/** looking for forms * */
//$app->make('events')->listen('antares.forms', function ($name) use ($app) {
$app->make('events')->listen(Form::class, function (Form $event) use ($app) {
$app->make('antares.memory')->make('registry.forms')->put('forms', $event->formName);
});
/** when application is terminating we collect all data from application * */
$app->terminating(function () use ($app) {
if (!app('antares.installed')) {
//$app->make('antares.memory')->finish();
}
});
//$app->make('events')->listen('antares.after.load-service-providers', function() {
$app->make('events')->listen(LoadServiceProviders::class, function() {
$this->app->make('antares.defered.service')->run();
});
}
|
php
|
protected function bootMemoryEvent()
{
$app = $this->app;
/** looking for forms * */
//$app->make('events')->listen('antares.forms', function ($name) use ($app) {
$app->make('events')->listen(Form::class, function (Form $event) use ($app) {
$app->make('antares.memory')->make('registry.forms')->put('forms', $event->formName);
});
/** when application is terminating we collect all data from application * */
$app->terminating(function () use ($app) {
if (!app('antares.installed')) {
//$app->make('antares.memory')->finish();
}
});
//$app->make('events')->listen('antares.after.load-service-providers', function() {
$app->make('events')->listen(LoadServiceProviders::class, function() {
$this->app->make('antares.defered.service')->run();
});
}
|
[
"protected",
"function",
"bootMemoryEvent",
"(",
")",
"{",
"$",
"app",
"=",
"$",
"this",
"->",
"app",
";",
"/** looking for forms * */",
"//$app->make('events')->listen('antares.forms', function ($name) use ($app) {",
"$",
"app",
"->",
"make",
"(",
"'events'",
")",
"->",
"listen",
"(",
"Form",
"::",
"class",
",",
"function",
"(",
"Form",
"$",
"event",
")",
"use",
"(",
"$",
"app",
")",
"{",
"$",
"app",
"->",
"make",
"(",
"'antares.memory'",
")",
"->",
"make",
"(",
"'registry.forms'",
")",
"->",
"put",
"(",
"'forms'",
",",
"$",
"event",
"->",
"formName",
")",
";",
"}",
")",
";",
"/** when application is terminating we collect all data from application * */",
"$",
"app",
"->",
"terminating",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"app",
")",
"{",
"if",
"(",
"!",
"app",
"(",
"'antares.installed'",
")",
")",
"{",
"//$app->make('antares.memory')->finish();",
"}",
"}",
")",
";",
"//$app->make('events')->listen('antares.after.load-service-providers', function() {",
"$",
"app",
"->",
"make",
"(",
"'events'",
")",
"->",
"listen",
"(",
"LoadServiceProviders",
"::",
"class",
",",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'antares.defered.service'",
")",
"->",
"run",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Register memory events during booting.
@return void
|
[
"Register",
"memory",
"events",
"during",
"booting",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/src/MemoryServiceProvider.php#L83-L101
|
227,835
|
lawoole/framework
|
src/Homer/HomerManager.php
|
HomerManager.boot
|
public function boot()
{
if ($this->booted) {
return;
}
$this->booted = true;
$this->resolveServices();
$this->resolveReferences();
}
|
php
|
public function boot()
{
if ($this->booted) {
return;
}
$this->booted = true;
$this->resolveServices();
$this->resolveReferences();
}
|
[
"public",
"function",
"boot",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"booted",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"booted",
"=",
"true",
";",
"$",
"this",
"->",
"resolveServices",
"(",
")",
";",
"$",
"this",
"->",
"resolveReferences",
"(",
")",
";",
"}"
] |
Boot the Homer.
|
[
"Boot",
"the",
"Homer",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/HomerManager.php#L97-L108
|
227,836
|
lawoole/framework
|
src/Homer/HomerManager.php
|
HomerManager.gatherInvokerMiddleware
|
protected function gatherInvokerMiddleware($middleware)
{
$nameMiddleware = $this->config['name_middleware'] ?? [];
$middlewareGroups = $this->config['middleware_groups'] ?? [];
return Collection::make($middleware)->map(function ($middleware) use ($nameMiddleware, $middlewareGroups) {
return (array) MiddlewareNameResolver::resolve($middleware, $nameMiddleware, $middlewareGroups);
})->flatten()->all();
}
|
php
|
protected function gatherInvokerMiddleware($middleware)
{
$nameMiddleware = $this->config['name_middleware'] ?? [];
$middlewareGroups = $this->config['middleware_groups'] ?? [];
return Collection::make($middleware)->map(function ($middleware) use ($nameMiddleware, $middlewareGroups) {
return (array) MiddlewareNameResolver::resolve($middleware, $nameMiddleware, $middlewareGroups);
})->flatten()->all();
}
|
[
"protected",
"function",
"gatherInvokerMiddleware",
"(",
"$",
"middleware",
")",
"{",
"$",
"nameMiddleware",
"=",
"$",
"this",
"->",
"config",
"[",
"'name_middleware'",
"]",
"??",
"[",
"]",
";",
"$",
"middlewareGroups",
"=",
"$",
"this",
"->",
"config",
"[",
"'middleware_groups'",
"]",
"??",
"[",
"]",
";",
"return",
"Collection",
"::",
"make",
"(",
"$",
"middleware",
")",
"->",
"map",
"(",
"function",
"(",
"$",
"middleware",
")",
"use",
"(",
"$",
"nameMiddleware",
",",
"$",
"middlewareGroups",
")",
"{",
"return",
"(",
"array",
")",
"MiddlewareNameResolver",
"::",
"resolve",
"(",
"$",
"middleware",
",",
"$",
"nameMiddleware",
",",
"$",
"middlewareGroups",
")",
";",
"}",
")",
"->",
"flatten",
"(",
")",
"->",
"all",
"(",
")",
";",
"}"
] |
Gather the middleware for the invoker with resolved class names.
@param array $middleware
@return array
|
[
"Gather",
"the",
"middleware",
"for",
"the",
"invoker",
"with",
"resolved",
"class",
"names",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/HomerManager.php#L117-L125
|
227,837
|
lawoole/framework
|
src/Homer/HomerManager.php
|
HomerManager.resolveServices
|
protected function resolveServices()
{
// Do real export services when the server is launching.
$this->app['events']->listen(ServerLaunching::class, function () {
$services = Arr::get($this->config, 'services');
if (! is_array($services) || empty($services)) {
return;
}
foreach ($services as $config) {
$this->resolveService($config);
}
});
}
|
php
|
protected function resolveServices()
{
// Do real export services when the server is launching.
$this->app['events']->listen(ServerLaunching::class, function () {
$services = Arr::get($this->config, 'services');
if (! is_array($services) || empty($services)) {
return;
}
foreach ($services as $config) {
$this->resolveService($config);
}
});
}
|
[
"protected",
"function",
"resolveServices",
"(",
")",
"{",
"// Do real export services when the server is launching.",
"$",
"this",
"->",
"app",
"[",
"'events'",
"]",
"->",
"listen",
"(",
"ServerLaunching",
"::",
"class",
",",
"function",
"(",
")",
"{",
"$",
"services",
"=",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"config",
",",
"'services'",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"services",
")",
"||",
"empty",
"(",
"$",
"services",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"services",
"as",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"resolveService",
"(",
"$",
"config",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Resolve and register all configured services.
|
[
"Resolve",
"and",
"register",
"all",
"configured",
"services",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/HomerManager.php#L130-L144
|
227,838
|
lawoole/framework
|
src/Homer/HomerManager.php
|
HomerManager.resolveService
|
public function resolveService(array $config)
{
$middleware = $this->gatherInvokerMiddleware(array_merge(
$this->config['middleware'] ?? [],
$config['middleware'] ?? []
));
return (new ServiceComponent($this->app, $config))
->setContext($this->context)
->setDispatcher($this->dispatcher)
->setMiddleware($middleware)
->export();
}
|
php
|
public function resolveService(array $config)
{
$middleware = $this->gatherInvokerMiddleware(array_merge(
$this->config['middleware'] ?? [],
$config['middleware'] ?? []
));
return (new ServiceComponent($this->app, $config))
->setContext($this->context)
->setDispatcher($this->dispatcher)
->setMiddleware($middleware)
->export();
}
|
[
"public",
"function",
"resolveService",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"middleware",
"=",
"$",
"this",
"->",
"gatherInvokerMiddleware",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"config",
"[",
"'middleware'",
"]",
"??",
"[",
"]",
",",
"$",
"config",
"[",
"'middleware'",
"]",
"??",
"[",
"]",
")",
")",
";",
"return",
"(",
"new",
"ServiceComponent",
"(",
"$",
"this",
"->",
"app",
",",
"$",
"config",
")",
")",
"->",
"setContext",
"(",
"$",
"this",
"->",
"context",
")",
"->",
"setDispatcher",
"(",
"$",
"this",
"->",
"dispatcher",
")",
"->",
"setMiddleware",
"(",
"$",
"middleware",
")",
"->",
"export",
"(",
")",
";",
"}"
] |
Register a service in the Homer.
@param array $config
@return mixed
|
[
"Register",
"a",
"service",
"in",
"the",
"Homer",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/HomerManager.php#L153-L165
|
227,839
|
lawoole/framework
|
src/Homer/HomerManager.php
|
HomerManager.resolveReferences
|
protected function resolveReferences()
{
$references = $this->config['references'] ?? [];
if (! is_array($references) || empty($references)) {
return;
}
foreach ($references as $config) {
$this->resolveReference($config);
}
}
|
php
|
protected function resolveReferences()
{
$references = $this->config['references'] ?? [];
if (! is_array($references) || empty($references)) {
return;
}
foreach ($references as $config) {
$this->resolveReference($config);
}
}
|
[
"protected",
"function",
"resolveReferences",
"(",
")",
"{",
"$",
"references",
"=",
"$",
"this",
"->",
"config",
"[",
"'references'",
"]",
"??",
"[",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"references",
")",
"||",
"empty",
"(",
"$",
"references",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"references",
"as",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"resolveReference",
"(",
"$",
"config",
")",
";",
"}",
"}"
] |
Resolve and register all configured references.
|
[
"Resolve",
"and",
"register",
"all",
"configured",
"references",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/HomerManager.php#L170-L181
|
227,840
|
lawoole/framework
|
src/Homer/HomerManager.php
|
HomerManager.resolveReference
|
public function resolveReference(array $config)
{
$config = $this->normalizeClientConfig($config);
$middleware = $this->gatherInvokerMiddleware(array_merge(
$config['client']['middleware'] ?? [],
$config['middleware'] ?? []
));
return (new ReferenceComponent($this->app, $config))
->setContext($this->context)
->setProxyFactory($this->proxyFactory)
->setClientFactory($this->clientFactory)
->setMiddleware($middleware)
->refer();
}
|
php
|
public function resolveReference(array $config)
{
$config = $this->normalizeClientConfig($config);
$middleware = $this->gatherInvokerMiddleware(array_merge(
$config['client']['middleware'] ?? [],
$config['middleware'] ?? []
));
return (new ReferenceComponent($this->app, $config))
->setContext($this->context)
->setProxyFactory($this->proxyFactory)
->setClientFactory($this->clientFactory)
->setMiddleware($middleware)
->refer();
}
|
[
"public",
"function",
"resolveReference",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"normalizeClientConfig",
"(",
"$",
"config",
")",
";",
"$",
"middleware",
"=",
"$",
"this",
"->",
"gatherInvokerMiddleware",
"(",
"array_merge",
"(",
"$",
"config",
"[",
"'client'",
"]",
"[",
"'middleware'",
"]",
"??",
"[",
"]",
",",
"$",
"config",
"[",
"'middleware'",
"]",
"??",
"[",
"]",
")",
")",
";",
"return",
"(",
"new",
"ReferenceComponent",
"(",
"$",
"this",
"->",
"app",
",",
"$",
"config",
")",
")",
"->",
"setContext",
"(",
"$",
"this",
"->",
"context",
")",
"->",
"setProxyFactory",
"(",
"$",
"this",
"->",
"proxyFactory",
")",
"->",
"setClientFactory",
"(",
"$",
"this",
"->",
"clientFactory",
")",
"->",
"setMiddleware",
"(",
"$",
"middleware",
")",
"->",
"refer",
"(",
")",
";",
"}"
] |
Register a reference in the Homer.
@param array $config
@return mixed
|
[
"Register",
"a",
"reference",
"in",
"the",
"Homer",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/HomerManager.php#L190-L205
|
227,841
|
lawoole/framework
|
src/Homer/HomerManager.php
|
HomerManager.normalizeClientConfig
|
protected function normalizeClientConfig(array $config)
{
if (! isset($config['client'])) {
$config['client'] = ['url' => $config['url']];
} elseif (is_string($config['client'])) {
$client = Arr::get($this->config, 'clients.'.$config['client']);
if ($client == null) {
throw new InvalidArgumentException('Client '.$config['client'].' doesn\'t configured.');
}
$config['client'] = $client;
}
return $config;
}
|
php
|
protected function normalizeClientConfig(array $config)
{
if (! isset($config['client'])) {
$config['client'] = ['url' => $config['url']];
} elseif (is_string($config['client'])) {
$client = Arr::get($this->config, 'clients.'.$config['client']);
if ($client == null) {
throw new InvalidArgumentException('Client '.$config['client'].' doesn\'t configured.');
}
$config['client'] = $client;
}
return $config;
}
|
[
"protected",
"function",
"normalizeClientConfig",
"(",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'client'",
"]",
")",
")",
"{",
"$",
"config",
"[",
"'client'",
"]",
"=",
"[",
"'url'",
"=>",
"$",
"config",
"[",
"'url'",
"]",
"]",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"config",
"[",
"'client'",
"]",
")",
")",
"{",
"$",
"client",
"=",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"config",
",",
"'clients.'",
".",
"$",
"config",
"[",
"'client'",
"]",
")",
";",
"if",
"(",
"$",
"client",
"==",
"null",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Client '",
".",
"$",
"config",
"[",
"'client'",
"]",
".",
"' doesn\\'t configured.'",
")",
";",
"}",
"$",
"config",
"[",
"'client'",
"]",
"=",
"$",
"client",
";",
"}",
"return",
"$",
"config",
";",
"}"
] |
Normalize the client section in reference configurations.
@param array $config
@return array
|
[
"Normalize",
"the",
"client",
"section",
"in",
"reference",
"configurations",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/HomerManager.php#L214-L229
|
227,842
|
antaresproject/core
|
src/foundation/src/Support/MenuHandler.php
|
MenuHandler.attachIcon
|
protected function attachIcon(Fluent $menu = null)
{
if (!is_null($menu) && !is_null($icon = $this->getAttribute('icon'))) {
$menu->icon($icon);
}
}
|
php
|
protected function attachIcon(Fluent $menu = null)
{
if (!is_null($menu) && !is_null($icon = $this->getAttribute('icon'))) {
$menu->icon($icon);
}
}
|
[
"protected",
"function",
"attachIcon",
"(",
"Fluent",
"$",
"menu",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"menu",
")",
"&&",
"!",
"is_null",
"(",
"$",
"icon",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"'icon'",
")",
")",
")",
"{",
"$",
"menu",
"->",
"icon",
"(",
"$",
"icon",
")",
";",
"}",
"}"
] |
Attach icon to menu.
@param \Illuminate\Support\Fluent|null $menu
@return void
|
[
"Attach",
"icon",
"to",
"menu",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Support/MenuHandler.php#L187-L192
|
227,843
|
antaresproject/core
|
src/foundation/src/Areas.php
|
Areas.refresh
|
public function refresh()
{
$collection = $this->model->query()->get();
$this->areaRoles = $collection;
$filtered = $collection->pluck('area')->unique()->filter(function($element) {
return !is_null($element);
});
$this->areas = $filtered->toArray();
return $this;
}
|
php
|
public function refresh()
{
$collection = $this->model->query()->get();
$this->areaRoles = $collection;
$filtered = $collection->pluck('area')->unique()->filter(function($element) {
return !is_null($element);
});
$this->areas = $filtered->toArray();
return $this;
}
|
[
"public",
"function",
"refresh",
"(",
")",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"model",
"->",
"query",
"(",
")",
"->",
"get",
"(",
")",
";",
"$",
"this",
"->",
"areaRoles",
"=",
"$",
"collection",
";",
"$",
"filtered",
"=",
"$",
"collection",
"->",
"pluck",
"(",
"'area'",
")",
"->",
"unique",
"(",
")",
"->",
"filter",
"(",
"function",
"(",
"$",
"element",
")",
"{",
"return",
"!",
"is_null",
"(",
"$",
"element",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"areas",
"=",
"$",
"filtered",
"->",
"toArray",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Creates levels collection
@return $this
|
[
"Creates",
"levels",
"collection"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Areas.php#L68-L80
|
227,844
|
antaresproject/core
|
src/foundation/src/Areas.php
|
Areas.findMatched
|
public function findMatched($name, $default = null)
{
if (is_null($name)) {
return $default;
}
if (!in_array($name, $this->areas)) {
return $default;
}
return $name;
}
|
php
|
public function findMatched($name, $default = null)
{
if (is_null($name)) {
return $default;
}
if (!in_array($name, $this->areas)) {
return $default;
}
return $name;
}
|
[
"public",
"function",
"findMatched",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"areas",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"return",
"$",
"name",
";",
"}"
] |
Finds matched route prefix name as level name
@param string|null $name
@param string|null $default
@return string|null
|
[
"Finds",
"matched",
"route",
"prefix",
"name",
"as",
"level",
"name"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Areas.php#L89-L98
|
227,845
|
antaresproject/core
|
src/foundation/src/Areas.php
|
Areas.getUserArea
|
public function getUserArea()
{
if (auth()->guest()) {
return '';
}
$user = auth()->user();
$userRoles = $user->roles->pluck('id');
$area = null;
$role = null;
foreach ($userRoles as $userRole) {
$filtered = $this->areaRoles->where('id', $userRole);
if ($filtered->count() > 0) {
$model = $filtered->first();
$role = $model->name;
$area = $model->area;
break;
}
}
return !is_null($area) ? $area : config('antares/foundation::handles', 'antares');
}
|
php
|
public function getUserArea()
{
if (auth()->guest()) {
return '';
}
$user = auth()->user();
$userRoles = $user->roles->pluck('id');
$area = null;
$role = null;
foreach ($userRoles as $userRole) {
$filtered = $this->areaRoles->where('id', $userRole);
if ($filtered->count() > 0) {
$model = $filtered->first();
$role = $model->name;
$area = $model->area;
break;
}
}
return !is_null($area) ? $area : config('antares/foundation::handles', 'antares');
}
|
[
"public",
"function",
"getUserArea",
"(",
")",
"{",
"if",
"(",
"auth",
"(",
")",
"->",
"guest",
"(",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"user",
"=",
"auth",
"(",
")",
"->",
"user",
"(",
")",
";",
"$",
"userRoles",
"=",
"$",
"user",
"->",
"roles",
"->",
"pluck",
"(",
"'id'",
")",
";",
"$",
"area",
"=",
"null",
";",
"$",
"role",
"=",
"null",
";",
"foreach",
"(",
"$",
"userRoles",
"as",
"$",
"userRole",
")",
"{",
"$",
"filtered",
"=",
"$",
"this",
"->",
"areaRoles",
"->",
"where",
"(",
"'id'",
",",
"$",
"userRole",
")",
";",
"if",
"(",
"$",
"filtered",
"->",
"count",
"(",
")",
">",
"0",
")",
"{",
"$",
"model",
"=",
"$",
"filtered",
"->",
"first",
"(",
")",
";",
"$",
"role",
"=",
"$",
"model",
"->",
"name",
";",
"$",
"area",
"=",
"$",
"model",
"->",
"area",
";",
"break",
";",
"}",
"}",
"return",
"!",
"is_null",
"(",
"$",
"area",
")",
"?",
"$",
"area",
":",
"config",
"(",
"'antares/foundation::handles'",
",",
"'antares'",
")",
";",
"}"
] |
Gets user valid level
@return String
|
[
"Gets",
"user",
"valid",
"level"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Areas.php#L105-L124
|
227,846
|
antaresproject/core
|
src/ui/components/templates/src/Processor/DestroyProcessor.php
|
DestroyProcessor.disable
|
public function disable(DestroyListener $listener, $id)
{
try {
DB::transaction(function() use($id) {
$model = ComponentParams::where('id', $id)->first();
$data = $model->data;
$data['disabled'] = true;
$model->data = $data;
$this->repository->saveEntity($model);
});
return $listener->whenDestroySuccess();
} catch (Exception $e) {
Log::emergency($e);
return $listener->whenDestroyError(['message' => $e->getMessage(), 'code' => $e->getCode()]);
}
}
|
php
|
public function disable(DestroyListener $listener, $id)
{
try {
DB::transaction(function() use($id) {
$model = ComponentParams::where('id', $id)->first();
$data = $model->data;
$data['disabled'] = true;
$model->data = $data;
$this->repository->saveEntity($model);
});
return $listener->whenDestroySuccess();
} catch (Exception $e) {
Log::emergency($e);
return $listener->whenDestroyError(['message' => $e->getMessage(), 'code' => $e->getCode()]);
}
}
|
[
"public",
"function",
"disable",
"(",
"DestroyListener",
"$",
"listener",
",",
"$",
"id",
")",
"{",
"try",
"{",
"DB",
"::",
"transaction",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"ComponentParams",
"::",
"where",
"(",
"'id'",
",",
"$",
"id",
")",
"->",
"first",
"(",
")",
";",
"$",
"data",
"=",
"$",
"model",
"->",
"data",
";",
"$",
"data",
"[",
"'disabled'",
"]",
"=",
"true",
";",
"$",
"model",
"->",
"data",
"=",
"$",
"data",
";",
"$",
"this",
"->",
"repository",
"->",
"saveEntity",
"(",
"$",
"model",
")",
";",
"}",
")",
";",
"return",
"$",
"listener",
"->",
"whenDestroySuccess",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Log",
"::",
"emergency",
"(",
"$",
"e",
")",
";",
"return",
"$",
"listener",
"->",
"whenDestroyError",
"(",
"[",
"'message'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"'code'",
"=>",
"$",
"e",
"->",
"getCode",
"(",
")",
"]",
")",
";",
"}",
"}"
] |
Disables ui component
@param numeric $id
@return mixed | array
|
[
"Disables",
"ui",
"component"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Processor/DestroyProcessor.php#L63-L79
|
227,847
|
antaresproject/customfields
|
src/Processor/FieldProcessor.php
|
FieldProcessor.create
|
public function create(FieldCreator $listener, Route $route)
{
$eloquent = Foundation::make('antares.customfields.model');
$form = $this->presenter->form($eloquent, 'create', $route);
$this->fireEvent('form', [$eloquent, $form]);
return $listener->showFieldCreator(compact('eloquent', 'form'));
}
|
php
|
public function create(FieldCreator $listener, Route $route)
{
$eloquent = Foundation::make('antares.customfields.model');
$form = $this->presenter->form($eloquent, 'create', $route);
$this->fireEvent('form', [$eloquent, $form]);
return $listener->showFieldCreator(compact('eloquent', 'form'));
}
|
[
"public",
"function",
"create",
"(",
"FieldCreator",
"$",
"listener",
",",
"Route",
"$",
"route",
")",
"{",
"$",
"eloquent",
"=",
"Foundation",
"::",
"make",
"(",
"'antares.customfields.model'",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"presenter",
"->",
"form",
"(",
"$",
"eloquent",
",",
"'create'",
",",
"$",
"route",
")",
";",
"$",
"this",
"->",
"fireEvent",
"(",
"'form'",
",",
"[",
"$",
"eloquent",
",",
"$",
"form",
"]",
")",
";",
"return",
"$",
"listener",
"->",
"showFieldCreator",
"(",
"compact",
"(",
"'eloquent'",
",",
"'form'",
")",
")",
";",
"}"
] |
creating new custom field form
@param CustomfieldCreator $listener
|
[
"creating",
"new",
"custom",
"field",
"form"
] |
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
|
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Processor/FieldProcessor.php#L77-L83
|
227,848
|
antaresproject/customfields
|
src/Processor/FieldProcessor.php
|
FieldProcessor.store
|
public function store(FieldCreator $listener, array $input)
{
$this->attachValidator();
$validation = $this->validator->on('create')->with($input);
if ($validation->fails()) {
if (app('request')->ajax()) {
return Response::json($validation->getMessageBag()->getMessages(), 200);
}
return $listener->createFieldFailedValidation($validation->getMessageBag());
}
$customfield = Foundation::make('antares.customfields.model');
try {
$this->saving($customfield, $input, 'create');
} catch (Exception $e) {
Log::emergency($e);
return $listener->createFieldFailed(['error' => $e->getMessage()]);
}
return $listener->fieldCreated();
}
|
php
|
public function store(FieldCreator $listener, array $input)
{
$this->attachValidator();
$validation = $this->validator->on('create')->with($input);
if ($validation->fails()) {
if (app('request')->ajax()) {
return Response::json($validation->getMessageBag()->getMessages(), 200);
}
return $listener->createFieldFailedValidation($validation->getMessageBag());
}
$customfield = Foundation::make('antares.customfields.model');
try {
$this->saving($customfield, $input, 'create');
} catch (Exception $e) {
Log::emergency($e);
return $listener->createFieldFailed(['error' => $e->getMessage()]);
}
return $listener->fieldCreated();
}
|
[
"public",
"function",
"store",
"(",
"FieldCreator",
"$",
"listener",
",",
"array",
"$",
"input",
")",
"{",
"$",
"this",
"->",
"attachValidator",
"(",
")",
";",
"$",
"validation",
"=",
"$",
"this",
"->",
"validator",
"->",
"on",
"(",
"'create'",
")",
"->",
"with",
"(",
"$",
"input",
")",
";",
"if",
"(",
"$",
"validation",
"->",
"fails",
"(",
")",
")",
"{",
"if",
"(",
"app",
"(",
"'request'",
")",
"->",
"ajax",
"(",
")",
")",
"{",
"return",
"Response",
"::",
"json",
"(",
"$",
"validation",
"->",
"getMessageBag",
"(",
")",
"->",
"getMessages",
"(",
")",
",",
"200",
")",
";",
"}",
"return",
"$",
"listener",
"->",
"createFieldFailedValidation",
"(",
"$",
"validation",
"->",
"getMessageBag",
"(",
")",
")",
";",
"}",
"$",
"customfield",
"=",
"Foundation",
"::",
"make",
"(",
"'antares.customfields.model'",
")",
";",
"try",
"{",
"$",
"this",
"->",
"saving",
"(",
"$",
"customfield",
",",
"$",
"input",
",",
"'create'",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Log",
"::",
"emergency",
"(",
"$",
"e",
")",
";",
"return",
"$",
"listener",
"->",
"createFieldFailed",
"(",
"[",
"'error'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
"]",
")",
";",
"}",
"return",
"$",
"listener",
"->",
"fieldCreated",
"(",
")",
";",
"}"
] |
storing custom field in db
@param CustomfieldCreator $listener
@param array $input
@return redirect|mixed
|
[
"storing",
"custom",
"field",
"in",
"db"
] |
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
|
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Processor/FieldProcessor.php#L91-L112
|
227,849
|
antaresproject/customfields
|
src/Processor/FieldProcessor.php
|
FieldProcessor.attachValidator
|
protected function attachValidator()
{
return ValidatorFacade::resolver(function($translator, $data, $rules, $messages) {
return new CustomValidator($translator, $data, $rules, $messages);
});
}
|
php
|
protected function attachValidator()
{
return ValidatorFacade::resolver(function($translator, $data, $rules, $messages) {
return new CustomValidator($translator, $data, $rules, $messages);
});
}
|
[
"protected",
"function",
"attachValidator",
"(",
")",
"{",
"return",
"ValidatorFacade",
"::",
"resolver",
"(",
"function",
"(",
"$",
"translator",
",",
"$",
"data",
",",
"$",
"rules",
",",
"$",
"messages",
")",
"{",
"return",
"new",
"CustomValidator",
"(",
"$",
"translator",
",",
"$",
"data",
",",
"$",
"rules",
",",
"$",
"messages",
")",
";",
"}",
")",
";",
"}"
] |
attach custom validation to custom field form
@return mixed
|
[
"attach",
"custom",
"validation",
"to",
"custom",
"field",
"form"
] |
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
|
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Processor/FieldProcessor.php#L119-L124
|
227,850
|
antaresproject/customfields
|
src/Processor/FieldProcessor.php
|
FieldProcessor.update
|
public function update(FieldUpdater $listener, $id, array $input)
{
$customfield = Foundation::make('antares.customfields.model')->findOrFail($id);
$this->attachValidator();
$on = $customfield->imported ? 'imported' : 'update';
$validation = $this->validator->on($on)->with($input);
if ($validation->fails()) {
return $listener->updateFieldFailedValidation($validation->getMessageBag(), $id);
}
try {
$this->saving($customfield, $input, 'update');
} catch (Exception $e) {
Log::emergency($e);
return $listener->updateFieldFailed(['error' => $e->getMessage()]);
}
return $listener->fieldUpdated();
}
|
php
|
public function update(FieldUpdater $listener, $id, array $input)
{
$customfield = Foundation::make('antares.customfields.model')->findOrFail($id);
$this->attachValidator();
$on = $customfield->imported ? 'imported' : 'update';
$validation = $this->validator->on($on)->with($input);
if ($validation->fails()) {
return $listener->updateFieldFailedValidation($validation->getMessageBag(), $id);
}
try {
$this->saving($customfield, $input, 'update');
} catch (Exception $e) {
Log::emergency($e);
return $listener->updateFieldFailed(['error' => $e->getMessage()]);
}
return $listener->fieldUpdated();
}
|
[
"public",
"function",
"update",
"(",
"FieldUpdater",
"$",
"listener",
",",
"$",
"id",
",",
"array",
"$",
"input",
")",
"{",
"$",
"customfield",
"=",
"Foundation",
"::",
"make",
"(",
"'antares.customfields.model'",
")",
"->",
"findOrFail",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"attachValidator",
"(",
")",
";",
"$",
"on",
"=",
"$",
"customfield",
"->",
"imported",
"?",
"'imported'",
":",
"'update'",
";",
"$",
"validation",
"=",
"$",
"this",
"->",
"validator",
"->",
"on",
"(",
"$",
"on",
")",
"->",
"with",
"(",
"$",
"input",
")",
";",
"if",
"(",
"$",
"validation",
"->",
"fails",
"(",
")",
")",
"{",
"return",
"$",
"listener",
"->",
"updateFieldFailedValidation",
"(",
"$",
"validation",
"->",
"getMessageBag",
"(",
")",
",",
"$",
"id",
")",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"saving",
"(",
"$",
"customfield",
",",
"$",
"input",
",",
"'update'",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Log",
"::",
"emergency",
"(",
"$",
"e",
")",
";",
"return",
"$",
"listener",
"->",
"updateFieldFailed",
"(",
"[",
"'error'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
"]",
")",
";",
"}",
"return",
"$",
"listener",
"->",
"fieldUpdated",
"(",
")",
";",
"}"
] |
updates custom field
@param CustomfieldUpdater $listener
@param type $id
|
[
"updates",
"custom",
"field"
] |
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
|
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Processor/FieldProcessor.php#L249-L269
|
227,851
|
antaresproject/customfields
|
src/Processor/FieldProcessor.php
|
FieldProcessor.destroy
|
public function destroy(FieldRemover $listener, $id)
{
$model = Foundation::make('antares.customfields.model')->findOrFail($id);
try {
$this->fireEvent('deleting', [$model]);
DB::transaction(function () use ($model) {
$model->delete();
});
$this->fireEvent('deleted', [$model]);
} catch (Exception $e) {
Log::emergency($ex);
return $listener->removeFieldFailed(['error' => $e->getMessage()]);
}
return $listener->fieldRemoved();
}
|
php
|
public function destroy(FieldRemover $listener, $id)
{
$model = Foundation::make('antares.customfields.model')->findOrFail($id);
try {
$this->fireEvent('deleting', [$model]);
DB::transaction(function () use ($model) {
$model->delete();
});
$this->fireEvent('deleted', [$model]);
} catch (Exception $e) {
Log::emergency($ex);
return $listener->removeFieldFailed(['error' => $e->getMessage()]);
}
return $listener->fieldRemoved();
}
|
[
"public",
"function",
"destroy",
"(",
"FieldRemover",
"$",
"listener",
",",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"Foundation",
"::",
"make",
"(",
"'antares.customfields.model'",
")",
"->",
"findOrFail",
"(",
"$",
"id",
")",
";",
"try",
"{",
"$",
"this",
"->",
"fireEvent",
"(",
"'deleting'",
",",
"[",
"$",
"model",
"]",
")",
";",
"DB",
"::",
"transaction",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"model",
")",
"{",
"$",
"model",
"->",
"delete",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"fireEvent",
"(",
"'deleted'",
",",
"[",
"$",
"model",
"]",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Log",
"::",
"emergency",
"(",
"$",
"ex",
")",
";",
"return",
"$",
"listener",
"->",
"removeFieldFailed",
"(",
"[",
"'error'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
"]",
")",
";",
"}",
"return",
"$",
"listener",
"->",
"fieldRemoved",
"(",
")",
";",
"}"
] |
destroying custom field
@param CustomfieldRemover $listener
@param numeric $id
@return mixed
|
[
"destroying",
"custom",
"field"
] |
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
|
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Processor/FieldProcessor.php#L302-L320
|
227,852
|
gggeek/ggwebservices
|
lib/json/jsonrpc.inc.php
|
jsonrpcresp.serialize
|
function serialize($charset_encoding='')
{
if ($charset_encoding != '')
$this->content_type = 'application/json; charset=' . $charset_encoding;
else
$this->content_type = 'application/json';
$this->payload = serialize_jsonrpcresp($this, $this->id, $charset_encoding);
return $this->payload;
}
|
php
|
function serialize($charset_encoding='')
{
if ($charset_encoding != '')
$this->content_type = 'application/json; charset=' . $charset_encoding;
else
$this->content_type = 'application/json';
$this->payload = serialize_jsonrpcresp($this, $this->id, $charset_encoding);
return $this->payload;
}
|
[
"function",
"serialize",
"(",
"$",
"charset_encoding",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"charset_encoding",
"!=",
"''",
")",
"$",
"this",
"->",
"content_type",
"=",
"'application/json; charset='",
".",
"$",
"charset_encoding",
";",
"else",
"$",
"this",
"->",
"content_type",
"=",
"'application/json'",
";",
"$",
"this",
"->",
"payload",
"=",
"serialize_jsonrpcresp",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"id",
",",
"$",
"charset_encoding",
")",
";",
"return",
"$",
"this",
"->",
"payload",
";",
"}"
] |
Returns json representation of the response.
@param string $charset_encoding the charset to be used for serialization. if null, US-ASCII is assumed
@return string the json representation of the response
@access public
|
[
"Returns",
"json",
"representation",
"of",
"the",
"response",
"."
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/lib/json/jsonrpc.inc.php#L1111-L1119
|
227,853
|
antaresproject/core
|
src/foundation/src/Application.php
|
Application.bootProvider
|
protected function bootProvider(ServiceProvider $provider)
{
parent::bootProvider($provider);
if (method_exists($provider, 'booted')) {
Event::listen('antares.extension: booted', function() use($provider) {
Event::fire(new LoadServiceProviders());
$this->call([$provider, 'booted']);
});
}
}
|
php
|
protected function bootProvider(ServiceProvider $provider)
{
parent::bootProvider($provider);
if (method_exists($provider, 'booted')) {
Event::listen('antares.extension: booted', function() use($provider) {
Event::fire(new LoadServiceProviders());
$this->call([$provider, 'booted']);
});
}
}
|
[
"protected",
"function",
"bootProvider",
"(",
"ServiceProvider",
"$",
"provider",
")",
"{",
"parent",
"::",
"bootProvider",
"(",
"$",
"provider",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"provider",
",",
"'booted'",
")",
")",
"{",
"Event",
"::",
"listen",
"(",
"'antares.extension: booted'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"provider",
")",
"{",
"Event",
"::",
"fire",
"(",
"new",
"LoadServiceProviders",
"(",
")",
")",
";",
"$",
"this",
"->",
"call",
"(",
"[",
"$",
"provider",
",",
"'booted'",
"]",
")",
";",
"}",
")",
";",
"}",
"}"
] |
Boot the given service provider.
@param \Illuminate\Support\ServiceProvider $provider
@return mixed
|
[
"Boot",
"the",
"given",
"service",
"provider",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Application.php#L54-L64
|
227,854
|
antaresproject/core
|
src/components/auth/src/Auth/Multiuser.php
|
Multiuser.validate
|
protected function validate(array $data = array())
{
$id = auth()->user()->id;
if (empty($data)) {
return false;
}
if ((int) array_get($data, 'secondary_user_id') !== $id) {
return false;
}
$primary = array_get($data, 'primary_user_id');
if ($primary === null) {
return false;
}
return true;
}
|
php
|
protected function validate(array $data = array())
{
$id = auth()->user()->id;
if (empty($data)) {
return false;
}
if ((int) array_get($data, 'secondary_user_id') !== $id) {
return false;
}
$primary = array_get($data, 'primary_user_id');
if ($primary === null) {
return false;
}
return true;
}
|
[
"protected",
"function",
"validate",
"(",
"array",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"id",
"=",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"id",
";",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"(",
"int",
")",
"array_get",
"(",
"$",
"data",
",",
"'secondary_user_id'",
")",
"!==",
"$",
"id",
")",
"{",
"return",
"false",
";",
"}",
"$",
"primary",
"=",
"array_get",
"(",
"$",
"data",
",",
"'primary_user_id'",
")",
";",
"if",
"(",
"$",
"primary",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
whether user is in preview state
@param array $data
@return boolean
|
[
"whether",
"user",
"is",
"in",
"preview",
"state"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/auth/src/Auth/Multiuser.php#L36-L51
|
227,855
|
antaresproject/core
|
src/components/html/src/Support/HtmlBuilder.php
|
HtmlBuilder.inline
|
public function inline($source, $attributes = [], $secure = null)
{
return '<script type="text/javascript" ' . $this->attributes($attributes) . '>' . $source . '</script>' . PHP_EOL;
}
|
php
|
public function inline($source, $attributes = [], $secure = null)
{
return '<script type="text/javascript" ' . $this->attributes($attributes) . '>' . $source . '</script>' . PHP_EOL;
}
|
[
"public",
"function",
"inline",
"(",
"$",
"source",
",",
"$",
"attributes",
"=",
"[",
"]",
",",
"$",
"secure",
"=",
"null",
")",
"{",
"return",
"'<script type=\"text/javascript\" '",
".",
"$",
"this",
"->",
"attributes",
"(",
"$",
"attributes",
")",
".",
"'>'",
".",
"$",
"source",
".",
"'</script>'",
".",
"PHP_EOL",
";",
"}"
] |
Generate an inline to a JavaScript code.
@param string $source
@param array $attributes
@param bool $secure
@return string
|
[
"Generate",
"an",
"inline",
"to",
"a",
"JavaScript",
"code",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Support/HtmlBuilder.php#L116-L120
|
227,856
|
antaresproject/customfields
|
src/Http/Validators/CustomValidator.php
|
CustomValidator.validateNameOnCreate
|
public function validateNameOnCreate($attribute, $value, $parameters)
{
$groupId = Input::get('group');
$typeId = Input::get('type');
$exists = Foundation::make('antares.customfields.model.view')
->query()
->where('group_id', $groupId)
->where('type_id', $typeId)
->where('name', $value)
->exists();
if ($exists) {
$this->setCustomMessages(['name-on-create' => trans('antares/customfields::validator.create.name-non-unique')]);
$this->addFailure($attribute, 'name-on-create', []);
return false;
}
return true;
}
|
php
|
public function validateNameOnCreate($attribute, $value, $parameters)
{
$groupId = Input::get('group');
$typeId = Input::get('type');
$exists = Foundation::make('antares.customfields.model.view')
->query()
->where('group_id', $groupId)
->where('type_id', $typeId)
->where('name', $value)
->exists();
if ($exists) {
$this->setCustomMessages(['name-on-create' => trans('antares/customfields::validator.create.name-non-unique')]);
$this->addFailure($attribute, 'name-on-create', []);
return false;
}
return true;
}
|
[
"public",
"function",
"validateNameOnCreate",
"(",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"parameters",
")",
"{",
"$",
"groupId",
"=",
"Input",
"::",
"get",
"(",
"'group'",
")",
";",
"$",
"typeId",
"=",
"Input",
"::",
"get",
"(",
"'type'",
")",
";",
"$",
"exists",
"=",
"Foundation",
"::",
"make",
"(",
"'antares.customfields.model.view'",
")",
"->",
"query",
"(",
")",
"->",
"where",
"(",
"'group_id'",
",",
"$",
"groupId",
")",
"->",
"where",
"(",
"'type_id'",
",",
"$",
"typeId",
")",
"->",
"where",
"(",
"'name'",
",",
"$",
"value",
")",
"->",
"exists",
"(",
")",
";",
"if",
"(",
"$",
"exists",
")",
"{",
"$",
"this",
"->",
"setCustomMessages",
"(",
"[",
"'name-on-create'",
"=>",
"trans",
"(",
"'antares/customfields::validator.create.name-non-unique'",
")",
"]",
")",
";",
"$",
"this",
"->",
"addFailure",
"(",
"$",
"attribute",
",",
"'name-on-create'",
",",
"[",
"]",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
checks unique field creation
@param type $attribute
@param type $value
@param type $parameters
@return boolean
|
[
"checks",
"unique",
"field",
"creation"
] |
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
|
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Http/Validators/CustomValidator.php#L39-L57
|
227,857
|
antaresproject/customfields
|
src/Http/Validators/CustomValidator.php
|
CustomValidator.validateValidatorList
|
public function validateValidatorList($attribute, $value, $parameters)
{
$validators = Input::get('validators');
if (!is_null($validators)) {
foreach ($validators as $index => $id) {
if (isset($value[$id]) && $value[$id] == '') {
$this->setCustomMessages(["validator_custom[{$id}]" => trans('antares/customfields::validator.create.validators-empty-fields')]);
$this->addFailure("validator_custom[{$id}]", "validator_custom[{$id}]", []);
break;
}
}
}
return true;
}
|
php
|
public function validateValidatorList($attribute, $value, $parameters)
{
$validators = Input::get('validators');
if (!is_null($validators)) {
foreach ($validators as $index => $id) {
if (isset($value[$id]) && $value[$id] == '') {
$this->setCustomMessages(["validator_custom[{$id}]" => trans('antares/customfields::validator.create.validators-empty-fields')]);
$this->addFailure("validator_custom[{$id}]", "validator_custom[{$id}]", []);
break;
}
}
}
return true;
}
|
[
"public",
"function",
"validateValidatorList",
"(",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"parameters",
")",
"{",
"$",
"validators",
"=",
"Input",
"::",
"get",
"(",
"'validators'",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"validators",
")",
")",
"{",
"foreach",
"(",
"$",
"validators",
"as",
"$",
"index",
"=>",
"$",
"id",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"value",
"[",
"$",
"id",
"]",
")",
"&&",
"$",
"value",
"[",
"$",
"id",
"]",
"==",
"''",
")",
"{",
"$",
"this",
"->",
"setCustomMessages",
"(",
"[",
"\"validator_custom[{$id}]\"",
"=>",
"trans",
"(",
"'antares/customfields::validator.create.validators-empty-fields'",
")",
"]",
")",
";",
"$",
"this",
"->",
"addFailure",
"(",
"\"validator_custom[{$id}]\"",
",",
"\"validator_custom[{$id}]\"",
",",
"[",
"]",
")",
";",
"break",
";",
"}",
"}",
"}",
"return",
"true",
";",
"}"
] |
validates validator list
@param type $attribute
@param type $value
@param type $parameters
@return boolean
|
[
"validates",
"validator",
"list"
] |
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
|
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Http/Validators/CustomValidator.php#L66-L80
|
227,858
|
antaresproject/customfields
|
src/Http/Validators/CustomValidator.php
|
CustomValidator.validateMinChecked
|
public function validateMinChecked($attribute, $value, $parameters)
{
$input = Input::get($attribute);
if (!isset($parameters[0]) OR ! is_numeric($parameters[0])) {
return true;
}
if (count($input) < $parameters[0]) {
$this->setCustomMessages([$attribute => trans('antares/customfields::validator.checkboxes.min-checked')]);
$this->addFailure($attribute, $attribute, []);
}
return true;
}
|
php
|
public function validateMinChecked($attribute, $value, $parameters)
{
$input = Input::get($attribute);
if (!isset($parameters[0]) OR ! is_numeric($parameters[0])) {
return true;
}
if (count($input) < $parameters[0]) {
$this->setCustomMessages([$attribute => trans('antares/customfields::validator.checkboxes.min-checked')]);
$this->addFailure($attribute, $attribute, []);
}
return true;
}
|
[
"public",
"function",
"validateMinChecked",
"(",
"$",
"attribute",
",",
"$",
"value",
",",
"$",
"parameters",
")",
"{",
"$",
"input",
"=",
"Input",
"::",
"get",
"(",
"$",
"attribute",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"parameters",
"[",
"0",
"]",
")",
"OR",
"!",
"is_numeric",
"(",
"$",
"parameters",
"[",
"0",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"input",
")",
"<",
"$",
"parameters",
"[",
"0",
"]",
")",
"{",
"$",
"this",
"->",
"setCustomMessages",
"(",
"[",
"$",
"attribute",
"=>",
"trans",
"(",
"'antares/customfields::validator.checkboxes.min-checked'",
")",
"]",
")",
";",
"$",
"this",
"->",
"addFailure",
"(",
"$",
"attribute",
",",
"$",
"attribute",
",",
"[",
"]",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
validates when checked checkboxes number is less than config
@param array $attribute
@param array|mixed $value
@param array $parameters
@return boolean
|
[
"validates",
"when",
"checked",
"checkboxes",
"number",
"is",
"less",
"than",
"config"
] |
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
|
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Http/Validators/CustomValidator.php#L89-L102
|
227,859
|
antaresproject/core
|
src/ui/components/datatables/src/Http/Controllers/DatatablesController.php
|
DatatablesController.reorder
|
public function reorder()
{
$data = input('data');
$pos = input('pos');
if (is_null($data) or is_null($pos)) {
return false;
}
$unserialize = unserialize(decrypt($data));
$modelClass = array_get($unserialize, 'model');
$datatableClass = array_get($unserialize, 'datatable');
if (!class_exists($modelClass) or ! class_exists($datatableClass)) {
return false;
}
return app('events')->dispatch(new Reorder($modelClass, $datatableClass, $pos));
}
|
php
|
public function reorder()
{
$data = input('data');
$pos = input('pos');
if (is_null($data) or is_null($pos)) {
return false;
}
$unserialize = unserialize(decrypt($data));
$modelClass = array_get($unserialize, 'model');
$datatableClass = array_get($unserialize, 'datatable');
if (!class_exists($modelClass) or ! class_exists($datatableClass)) {
return false;
}
return app('events')->dispatch(new Reorder($modelClass, $datatableClass, $pos));
}
|
[
"public",
"function",
"reorder",
"(",
")",
"{",
"$",
"data",
"=",
"input",
"(",
"'data'",
")",
";",
"$",
"pos",
"=",
"input",
"(",
"'pos'",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"data",
")",
"or",
"is_null",
"(",
"$",
"pos",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"unserialize",
"=",
"unserialize",
"(",
"decrypt",
"(",
"$",
"data",
")",
")",
";",
"$",
"modelClass",
"=",
"array_get",
"(",
"$",
"unserialize",
",",
"'model'",
")",
";",
"$",
"datatableClass",
"=",
"array_get",
"(",
"$",
"unserialize",
",",
"'datatable'",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"modelClass",
")",
"or",
"!",
"class_exists",
"(",
"$",
"datatableClass",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"app",
"(",
"'events'",
")",
"->",
"dispatch",
"(",
"new",
"Reorder",
"(",
"$",
"modelClass",
",",
"$",
"datatableClass",
",",
"$",
"pos",
")",
")",
";",
"}"
] |
Saves colum filtering options
@param ColumnFilter $filter
@return \Illuminate\Http\JsonResponse
|
[
"Saves",
"colum",
"filtering",
"options"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Http/Controllers/DatatablesController.php#L55-L70
|
227,860
|
antaresproject/core
|
src/components/view/src/ViewServiceProvider.php
|
ViewServiceProvider.registerViewFinder
|
public function registerViewFinder()
{
$this->app->singleton('view.finder', function ($app) {
$paths = $app->make('config')->get('view.paths');
return new FileViewFinder($app->make('files'), $paths);
});
}
|
php
|
public function registerViewFinder()
{
$this->app->singleton('view.finder', function ($app) {
$paths = $app->make('config')->get('view.paths');
return new FileViewFinder($app->make('files'), $paths);
});
}
|
[
"public",
"function",
"registerViewFinder",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'view.finder'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"paths",
"=",
"$",
"app",
"->",
"make",
"(",
"'config'",
")",
"->",
"get",
"(",
"'view.paths'",
")",
";",
"return",
"new",
"FileViewFinder",
"(",
"$",
"app",
"->",
"make",
"(",
"'files'",
")",
",",
"$",
"paths",
")",
";",
"}",
")",
";",
"}"
] |
Register the service provider for view finder.
@return void
|
[
"Register",
"the",
"service",
"provider",
"for",
"view",
"finder",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/ViewServiceProvider.php#L55-L61
|
227,861
|
antaresproject/core
|
src/components/view/src/ViewServiceProvider.php
|
ViewServiceProvider.registerTheme
|
protected function registerTheme()
{
$this->app->singleton('antares.theme', function ($app) {
return new ThemeManager($app);
});
$this->app->singleton('antares.theme.finder', function ($app) {
return new Finder($app);
});
}
|
php
|
protected function registerTheme()
{
$this->app->singleton('antares.theme', function ($app) {
return new ThemeManager($app);
});
$this->app->singleton('antares.theme.finder', function ($app) {
return new Finder($app);
});
}
|
[
"protected",
"function",
"registerTheme",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'antares.theme'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"ThemeManager",
"(",
"$",
"app",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'antares.theme.finder'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"Finder",
"(",
"$",
"app",
")",
";",
"}",
")",
";",
"}"
] |
Register the service provider for theme.
@return void
|
[
"Register",
"the",
"service",
"provider",
"for",
"theme",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/ViewServiceProvider.php#L68-L77
|
227,862
|
antaresproject/core
|
src/components/view/src/Console/OptimizeCommand.php
|
OptimizeCommand.compileViewsInPath
|
protected function compileViewsInPath($path)
{
foreach ($this->laravel['files']->allFiles($path) as $file) {
try {
$engine = $this->laravel['view']->getEngineFromPath($file);
} catch (InvalidArgumentException $e) {
Log::emergency($e);
continue;
}
$this->compileViewFile($engine, $file);
}
}
|
php
|
protected function compileViewsInPath($path)
{
foreach ($this->laravel['files']->allFiles($path) as $file) {
try {
$engine = $this->laravel['view']->getEngineFromPath($file);
} catch (InvalidArgumentException $e) {
Log::emergency($e);
continue;
}
$this->compileViewFile($engine, $file);
}
}
|
[
"protected",
"function",
"compileViewsInPath",
"(",
"$",
"path",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"laravel",
"[",
"'files'",
"]",
"->",
"allFiles",
"(",
"$",
"path",
")",
"as",
"$",
"file",
")",
"{",
"try",
"{",
"$",
"engine",
"=",
"$",
"this",
"->",
"laravel",
"[",
"'view'",
"]",
"->",
"getEngineFromPath",
"(",
"$",
"file",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"Log",
"::",
"emergency",
"(",
"$",
"e",
")",
";",
"continue",
";",
"}",
"$",
"this",
"->",
"compileViewFile",
"(",
"$",
"engine",
",",
"$",
"file",
")",
";",
"}",
"}"
] |
Compile all views files in path.
@param string $path
@return void
|
[
"Compile",
"all",
"views",
"files",
"in",
"path",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Console/OptimizeCommand.php#L78-L90
|
227,863
|
coincheckjp/coincheck-php
|
lib/Coincheck/Order.php
|
Order.cancel
|
public function cancel($params = array())
{
$arr = array( "id" => $params["id"]);
$rawResponse = $this->client->request('delete', 'api/exchange/orders' . '/' . $arr['id'] , $arr);
return $rawResponse;
}
|
php
|
public function cancel($params = array())
{
$arr = array( "id" => $params["id"]);
$rawResponse = $this->client->request('delete', 'api/exchange/orders' . '/' . $arr['id'] , $arr);
return $rawResponse;
}
|
[
"public",
"function",
"cancel",
"(",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"arr",
"=",
"array",
"(",
"\"id\"",
"=>",
"$",
"params",
"[",
"\"id\"",
"]",
")",
";",
"$",
"rawResponse",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'delete'",
",",
"'api/exchange/orders'",
".",
"'/'",
".",
"$",
"arr",
"[",
"'id'",
"]",
",",
"$",
"arr",
")",
";",
"return",
"$",
"rawResponse",
";",
"}"
] |
cancel a created order specified by order id.
Optional argument amount is to refund partially.
@param mixed
@return OrderIdRequest
|
[
"cancel",
"a",
"created",
"order",
"specified",
"by",
"order",
"id",
".",
"Optional",
"argument",
"amount",
"is",
"to",
"refund",
"partially",
"."
] |
5991003cb0ae827697888aeebd0aea0267fad7fa
|
https://github.com/coincheckjp/coincheck-php/blob/5991003cb0ae827697888aeebd0aea0267fad7fa/lib/Coincheck/Order.php#L35-L40
|
227,864
|
antaresproject/core
|
src/ui/components/templates/src/Twig/Resolver.php
|
Resolver.components
|
protected function components()
{
$function = function (array $params = null) {
try {
$this->gridStackAdapter->scripts();
if (!empty($params)) {
return app('ui-components')->findAllByResourceAndNames(uri(), $params);
}
return app('ui-components')->findAllByResource(uri());
} catch (Exception $e) {
Log::emergency($e);
return [];
}
};
return new Twig_SimpleFunction(
'components', $function
);
}
|
php
|
protected function components()
{
$function = function (array $params = null) {
try {
$this->gridStackAdapter->scripts();
if (!empty($params)) {
return app('ui-components')->findAllByResourceAndNames(uri(), $params);
}
return app('ui-components')->findAllByResource(uri());
} catch (Exception $e) {
Log::emergency($e);
return [];
}
};
return new Twig_SimpleFunction(
'components', $function
);
}
|
[
"protected",
"function",
"components",
"(",
")",
"{",
"$",
"function",
"=",
"function",
"(",
"array",
"$",
"params",
"=",
"null",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"gridStackAdapter",
"->",
"scripts",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"params",
")",
")",
"{",
"return",
"app",
"(",
"'ui-components'",
")",
"->",
"findAllByResourceAndNames",
"(",
"uri",
"(",
")",
",",
"$",
"params",
")",
";",
"}",
"return",
"app",
"(",
"'ui-components'",
")",
"->",
"findAllByResource",
"(",
"uri",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Log",
"::",
"emergency",
"(",
"$",
"e",
")",
";",
"return",
"[",
"]",
";",
"}",
"}",
";",
"return",
"new",
"Twig_SimpleFunction",
"(",
"'components'",
",",
"$",
"function",
")",
";",
"}"
] |
Create ui component view helper
@return Twig_SimpleFunction
|
[
"Create",
"ui",
"component",
"view",
"helper"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Twig/Resolver.php#L62-L80
|
227,865
|
joomla-framework/google-api
|
src/Embed/Maps.php
|
Maps.setCenter
|
public function setCenter($location, $title = true, $markeroptions = array())
{
if ($title)
{
$title = \is_string($title) ? $title : null;
if (!$marker = $this->addMarker($location, $title, $markeroptions))
{
return false;
}
$location = $marker['loc'];
}
elseif (\is_string($location))
{
$geocode = $this->geocodeAddress($location);
if (!$geocode)
{
return false;
}
$location = $geocode['geometry']['location'];
$location = array_values($location);
}
$this->setOption('mapcenter', $location);
return $this;
}
|
php
|
public function setCenter($location, $title = true, $markeroptions = array())
{
if ($title)
{
$title = \is_string($title) ? $title : null;
if (!$marker = $this->addMarker($location, $title, $markeroptions))
{
return false;
}
$location = $marker['loc'];
}
elseif (\is_string($location))
{
$geocode = $this->geocodeAddress($location);
if (!$geocode)
{
return false;
}
$location = $geocode['geometry']['location'];
$location = array_values($location);
}
$this->setOption('mapcenter', $location);
return $this;
}
|
[
"public",
"function",
"setCenter",
"(",
"$",
"location",
",",
"$",
"title",
"=",
"true",
",",
"$",
"markeroptions",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"title",
")",
"{",
"$",
"title",
"=",
"\\",
"is_string",
"(",
"$",
"title",
")",
"?",
"$",
"title",
":",
"null",
";",
"if",
"(",
"!",
"$",
"marker",
"=",
"$",
"this",
"->",
"addMarker",
"(",
"$",
"location",
",",
"$",
"title",
",",
"$",
"markeroptions",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"location",
"=",
"$",
"marker",
"[",
"'loc'",
"]",
";",
"}",
"elseif",
"(",
"\\",
"is_string",
"(",
"$",
"location",
")",
")",
"{",
"$",
"geocode",
"=",
"$",
"this",
"->",
"geocodeAddress",
"(",
"$",
"location",
")",
";",
"if",
"(",
"!",
"$",
"geocode",
")",
"{",
"return",
"false",
";",
"}",
"$",
"location",
"=",
"$",
"geocode",
"[",
"'geometry'",
"]",
"[",
"'location'",
"]",
";",
"$",
"location",
"=",
"array_values",
"(",
"$",
"location",
")",
";",
"}",
"$",
"this",
"->",
"setOption",
"(",
"'mapcenter'",
",",
"$",
"location",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Method to set the center of the map
@param mixed $location A latitude/longitude array or an address string
@param mixed $title Title of marker or false for no marker
@param array $markeroptions Options for marker
@return Maps The latitude/longitude of the center or false on failure
@since 1.0
|
[
"Method",
"to",
"set",
"the",
"center",
"of",
"the",
"map"
] |
c78f06cfaba3f0dfc3ce411a335b417a5f0ee904
|
https://github.com/joomla-framework/google-api/blob/c78f06cfaba3f0dfc3ce411a335b417a5f0ee904/src/Embed/Maps.php#L295-L324
|
227,866
|
joomla-framework/google-api
|
src/Embed/Maps.php
|
Maps.addMarker
|
public function addMarker($location, $title = null, $options = array())
{
if (\is_string($location))
{
if (!$title)
{
$title = $location;
}
$geocode = $this->geocodeAddress($location);
if (!$geocode)
{
return false;
}
$location = $geocode['geometry']['location'];
}
elseif (!$title)
{
$title = implode(', ', $location);
}
$location = array_values($location);
$marker = array('loc' => $location, 'title' => $title, 'options' => $options);
$markers = $this->listMarkers();
$markers[] = $marker;
$this->setOption('markers', $markers);
return $marker;
}
|
php
|
public function addMarker($location, $title = null, $options = array())
{
if (\is_string($location))
{
if (!$title)
{
$title = $location;
}
$geocode = $this->geocodeAddress($location);
if (!$geocode)
{
return false;
}
$location = $geocode['geometry']['location'];
}
elseif (!$title)
{
$title = implode(', ', $location);
}
$location = array_values($location);
$marker = array('loc' => $location, 'title' => $title, 'options' => $options);
$markers = $this->listMarkers();
$markers[] = $marker;
$this->setOption('markers', $markers);
return $marker;
}
|
[
"public",
"function",
"addMarker",
"(",
"$",
"location",
",",
"$",
"title",
"=",
"null",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"location",
")",
")",
"{",
"if",
"(",
"!",
"$",
"title",
")",
"{",
"$",
"title",
"=",
"$",
"location",
";",
"}",
"$",
"geocode",
"=",
"$",
"this",
"->",
"geocodeAddress",
"(",
"$",
"location",
")",
";",
"if",
"(",
"!",
"$",
"geocode",
")",
"{",
"return",
"false",
";",
"}",
"$",
"location",
"=",
"$",
"geocode",
"[",
"'geometry'",
"]",
"[",
"'location'",
"]",
";",
"}",
"elseif",
"(",
"!",
"$",
"title",
")",
"{",
"$",
"title",
"=",
"implode",
"(",
"', '",
",",
"$",
"location",
")",
";",
"}",
"$",
"location",
"=",
"array_values",
"(",
"$",
"location",
")",
";",
"$",
"marker",
"=",
"array",
"(",
"'loc'",
"=>",
"$",
"location",
",",
"'title'",
"=>",
"$",
"title",
",",
"'options'",
"=>",
"$",
"options",
")",
";",
"$",
"markers",
"=",
"$",
"this",
"->",
"listMarkers",
"(",
")",
";",
"$",
"markers",
"[",
"]",
"=",
"$",
"marker",
";",
"$",
"this",
"->",
"setOption",
"(",
"'markers'",
",",
"$",
"markers",
")",
";",
"return",
"$",
"marker",
";",
"}"
] |
Add a marker to the map
@param mixed $location A latitude longitude array or an address string
@param mixed $title The hover-text for the marker
@param array $options Options for marker
@return mixed The marker or false on failure
@since 1.0
|
[
"Add",
"a",
"marker",
"to",
"the",
"map"
] |
c78f06cfaba3f0dfc3ce411a335b417a5f0ee904
|
https://github.com/joomla-framework/google-api/blob/c78f06cfaba3f0dfc3ce411a335b417a5f0ee904/src/Embed/Maps.php#L337-L368
|
227,867
|
antaresproject/core
|
src/components/html/src/Builder.php
|
Builder.extend
|
public function extend(Closure $callback = null)
{
!is_null($callback) && call_user_func($callback, $this->grid, $this->container->make('request'), $this->container->make('translator'));
return $this;
}
|
php
|
public function extend(Closure $callback = null)
{
!is_null($callback) && call_user_func($callback, $this->grid, $this->container->make('request'), $this->container->make('translator'));
return $this;
}
|
[
"public",
"function",
"extend",
"(",
"Closure",
"$",
"callback",
"=",
"null",
")",
"{",
"!",
"is_null",
"(",
"$",
"callback",
")",
"&&",
"call_user_func",
"(",
"$",
"callback",
",",
"$",
"this",
"->",
"grid",
",",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"'request'",
")",
",",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"'translator'",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Extend decoration.
@param \Closure $callback
@return $this
|
[
"Extend",
"decoration",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Builder.php#L68-L73
|
227,868
|
antaresproject/customfields
|
src/Events/FormReadyHandler.php
|
FormReadyHandler.handle
|
public function handle(FormBuilder $formBuilder)
{
$grid = $formBuilder->grid;
$fieldsets = $grid->fieldsets();
if (empty($fieldsets)) {
return false;
}
if (!isset($grid->name) or is_null($grid->name)) {
return false;
}
$extension = app('antares.extension')->getActualExtension();
$memory = app('antares.memory')->make('registry');
$namespace = $extension . '.' . $grid->name;
if (is_null($memory->get($namespace))) {
$memory->push($namespace, $namespace);
$memory->finish();
return false;
}
/* @var $formHandler FormHandler */
$formHandler = app('Antares\Customfields\Events\FormHandler');
$formHandler->onViewForm($grid->row(), $formBuilder, $namespace);
}
|
php
|
public function handle(FormBuilder $formBuilder)
{
$grid = $formBuilder->grid;
$fieldsets = $grid->fieldsets();
if (empty($fieldsets)) {
return false;
}
if (!isset($grid->name) or is_null($grid->name)) {
return false;
}
$extension = app('antares.extension')->getActualExtension();
$memory = app('antares.memory')->make('registry');
$namespace = $extension . '.' . $grid->name;
if (is_null($memory->get($namespace))) {
$memory->push($namespace, $namespace);
$memory->finish();
return false;
}
/* @var $formHandler FormHandler */
$formHandler = app('Antares\Customfields\Events\FormHandler');
$formHandler->onViewForm($grid->row(), $formBuilder, $namespace);
}
|
[
"public",
"function",
"handle",
"(",
"FormBuilder",
"$",
"formBuilder",
")",
"{",
"$",
"grid",
"=",
"$",
"formBuilder",
"->",
"grid",
";",
"$",
"fieldsets",
"=",
"$",
"grid",
"->",
"fieldsets",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"fieldsets",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"grid",
"->",
"name",
")",
"or",
"is_null",
"(",
"$",
"grid",
"->",
"name",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"extension",
"=",
"app",
"(",
"'antares.extension'",
")",
"->",
"getActualExtension",
"(",
")",
";",
"$",
"memory",
"=",
"app",
"(",
"'antares.memory'",
")",
"->",
"make",
"(",
"'registry'",
")",
";",
"$",
"namespace",
"=",
"$",
"extension",
".",
"'.'",
".",
"$",
"grid",
"->",
"name",
";",
"if",
"(",
"is_null",
"(",
"$",
"memory",
"->",
"get",
"(",
"$",
"namespace",
")",
")",
")",
"{",
"$",
"memory",
"->",
"push",
"(",
"$",
"namespace",
",",
"$",
"namespace",
")",
";",
"$",
"memory",
"->",
"finish",
"(",
")",
";",
"return",
"false",
";",
"}",
"/* @var $formHandler FormHandler */",
"$",
"formHandler",
"=",
"app",
"(",
"'Antares\\Customfields\\Events\\FormHandler'",
")",
";",
"$",
"formHandler",
"->",
"onViewForm",
"(",
"$",
"grid",
"->",
"row",
"(",
")",
",",
"$",
"formBuilder",
",",
"$",
"namespace",
")",
";",
"}"
] |
event handler on view form with customfields
@param FormBuilder $formBuilder
@return boolean
|
[
"event",
"handler",
"on",
"view",
"form",
"with",
"customfields"
] |
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
|
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Events/FormReadyHandler.php#L36-L59
|
227,869
|
antaresproject/core
|
src/components/html/src/Events/BeforeFormRender.php
|
BeforeFormRender.attributes
|
protected function attributes(FieldContract $control)
{
$attributes = array_only($control->getAttributes(), ['id', 'name', 'value', 'label', 'type']);
$attributes['value'] = ($attributes['value'] instanceof Closure) ? '' : $attributes['value'];
switch ($attributes['type']) {
case 'select':
$attributes['options'] = $this->getOptions($control->options);
break;
}
return $attributes;
}
|
php
|
protected function attributes(FieldContract $control)
{
$attributes = array_only($control->getAttributes(), ['id', 'name', 'value', 'label', 'type']);
$attributes['value'] = ($attributes['value'] instanceof Closure) ? '' : $attributes['value'];
switch ($attributes['type']) {
case 'select':
$attributes['options'] = $this->getOptions($control->options);
break;
}
return $attributes;
}
|
[
"protected",
"function",
"attributes",
"(",
"FieldContract",
"$",
"control",
")",
"{",
"$",
"attributes",
"=",
"array_only",
"(",
"$",
"control",
"->",
"getAttributes",
"(",
")",
",",
"[",
"'id'",
",",
"'name'",
",",
"'value'",
",",
"'label'",
",",
"'type'",
"]",
")",
";",
"$",
"attributes",
"[",
"'value'",
"]",
"=",
"(",
"$",
"attributes",
"[",
"'value'",
"]",
"instanceof",
"Closure",
")",
"?",
"''",
":",
"$",
"attributes",
"[",
"'value'",
"]",
";",
"switch",
"(",
"$",
"attributes",
"[",
"'type'",
"]",
")",
"{",
"case",
"'select'",
":",
"$",
"attributes",
"[",
"'options'",
"]",
"=",
"$",
"this",
"->",
"getOptions",
"(",
"$",
"control",
"->",
"options",
")",
";",
"break",
";",
"}",
"return",
"$",
"attributes",
";",
"}"
] |
form attributes resolver
@param ControlContract $control
@return type
|
[
"form",
"attributes",
"resolver"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Events/BeforeFormRender.php#L119-L129
|
227,870
|
antaresproject/core
|
src/components/html/src/Events/BeforeFormRender.php
|
BeforeFormRender.getOptions
|
protected function getOptions($options = null, $default = [])
{
if (empty($options)) {
return $default;
}
if ($options instanceof Collection) {
return $options->toArray();
}
if ($options instanceof Closure) {
return $this->getOptions(call_user_func($options));
}
if (is_array($options)) {
return $options;
}
return $options->toArray();
}
|
php
|
protected function getOptions($options = null, $default = [])
{
if (empty($options)) {
return $default;
}
if ($options instanceof Collection) {
return $options->toArray();
}
if ($options instanceof Closure) {
return $this->getOptions(call_user_func($options));
}
if (is_array($options)) {
return $options;
}
return $options->toArray();
}
|
[
"protected",
"function",
"getOptions",
"(",
"$",
"options",
"=",
"null",
",",
"$",
"default",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"if",
"(",
"$",
"options",
"instanceof",
"Collection",
")",
"{",
"return",
"$",
"options",
"->",
"toArray",
"(",
")",
";",
"}",
"if",
"(",
"$",
"options",
"instanceof",
"Closure",
")",
"{",
"return",
"$",
"this",
"->",
"getOptions",
"(",
"call_user_func",
"(",
"$",
"options",
")",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"options",
")",
")",
"{",
"return",
"$",
"options",
";",
"}",
"return",
"$",
"options",
"->",
"toArray",
"(",
")",
";",
"}"
] |
recursive field options getter
@param mixed $options
@param array $default
@return Closure
|
[
"recursive",
"field",
"options",
"getter"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Events/BeforeFormRender.php#L138-L153
|
227,871
|
antaresproject/core
|
src/components/view/src/Bootstrap/LoadCurrentTheme.php
|
LoadCurrentTheme.setCurrentTheme
|
protected function setCurrentTheme(Application $app)
{
$memory = $app->make('antares.memory')->makeOrFallback();
$app->make('antares.theme')->setTheme($memory->get('site.theme.frontend'));
$events = $app->make('events');
$events->listen(AdminStarted::class, function () use ($app, $memory, $events) {
$theme = $app->make('antares.theme');
if (auth()->isAny(['member'])) {
$theme->setTheme($memory->get('site.theme.frontend'));
} else {
$theme->setTheme($memory->get('site.theme.backend'));
}
});
$events->listen('composing: *', function () use ($app) {
$app->make('antares.theme')->boot();
});
}
|
php
|
protected function setCurrentTheme(Application $app)
{
$memory = $app->make('antares.memory')->makeOrFallback();
$app->make('antares.theme')->setTheme($memory->get('site.theme.frontend'));
$events = $app->make('events');
$events->listen(AdminStarted::class, function () use ($app, $memory, $events) {
$theme = $app->make('antares.theme');
if (auth()->isAny(['member'])) {
$theme->setTheme($memory->get('site.theme.frontend'));
} else {
$theme->setTheme($memory->get('site.theme.backend'));
}
});
$events->listen('composing: *', function () use ($app) {
$app->make('antares.theme')->boot();
});
}
|
[
"protected",
"function",
"setCurrentTheme",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"memory",
"=",
"$",
"app",
"->",
"make",
"(",
"'antares.memory'",
")",
"->",
"makeOrFallback",
"(",
")",
";",
"$",
"app",
"->",
"make",
"(",
"'antares.theme'",
")",
"->",
"setTheme",
"(",
"$",
"memory",
"->",
"get",
"(",
"'site.theme.frontend'",
")",
")",
";",
"$",
"events",
"=",
"$",
"app",
"->",
"make",
"(",
"'events'",
")",
";",
"$",
"events",
"->",
"listen",
"(",
"AdminStarted",
"::",
"class",
",",
"function",
"(",
")",
"use",
"(",
"$",
"app",
",",
"$",
"memory",
",",
"$",
"events",
")",
"{",
"$",
"theme",
"=",
"$",
"app",
"->",
"make",
"(",
"'antares.theme'",
")",
";",
"if",
"(",
"auth",
"(",
")",
"->",
"isAny",
"(",
"[",
"'member'",
"]",
")",
")",
"{",
"$",
"theme",
"->",
"setTheme",
"(",
"$",
"memory",
"->",
"get",
"(",
"'site.theme.frontend'",
")",
")",
";",
"}",
"else",
"{",
"$",
"theme",
"->",
"setTheme",
"(",
"$",
"memory",
"->",
"get",
"(",
"'site.theme.backend'",
")",
")",
";",
"}",
"}",
")",
";",
"$",
"events",
"->",
"listen",
"(",
"'composing: *'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"app",
")",
"{",
"$",
"app",
"->",
"make",
"(",
"'antares.theme'",
")",
"->",
"boot",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Set current theme for request.
@param \Illuminate\Contracts\Foundation\Application $app
@return void
|
[
"Set",
"current",
"theme",
"for",
"request",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Bootstrap/LoadCurrentTheme.php#L54-L73
|
227,872
|
antaresproject/core
|
src/components/view/src/Bootstrap/LoadCurrentTheme.php
|
LoadCurrentTheme.setThemeResolver
|
protected function setThemeResolver(Application $app)
{
if ($app->resolved('view')) {
$app->make('antares.theme')->resolving();
} else {
$app->resolving('view', function () use ($app) {
$app->make('antares.theme')->resolving();
});
}
}
|
php
|
protected function setThemeResolver(Application $app)
{
if ($app->resolved('view')) {
$app->make('antares.theme')->resolving();
} else {
$app->resolving('view', function () use ($app) {
$app->make('antares.theme')->resolving();
});
}
}
|
[
"protected",
"function",
"setThemeResolver",
"(",
"Application",
"$",
"app",
")",
"{",
"if",
"(",
"$",
"app",
"->",
"resolved",
"(",
"'view'",
")",
")",
"{",
"$",
"app",
"->",
"make",
"(",
"'antares.theme'",
")",
"->",
"resolving",
"(",
")",
";",
"}",
"else",
"{",
"$",
"app",
"->",
"resolving",
"(",
"'view'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"app",
")",
"{",
"$",
"app",
"->",
"make",
"(",
"'antares.theme'",
")",
"->",
"resolving",
"(",
")",
";",
"}",
")",
";",
"}",
"}"
] |
Boot theme resolver.
@param \Illuminate\Contracts\Foundation\Application $app
@return void
|
[
"Boot",
"theme",
"resolver",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Bootstrap/LoadCurrentTheme.php#L82-L91
|
227,873
|
antaresproject/core
|
src/foundation/src/Listeners/BreadcrumbsMenuDependableActions.php
|
BreadcrumbsMenuDependableActions.add
|
protected function add(&$attributes, $actions)
{
$index = 0;
$childs = [];
foreach ($actions as $name => $callback) {
if (!$callback instanceof Closure) {
continue;
}
$called = call_user_func($callback, $this->entity);
if (empty($called) or ! is_array($called)) {
continue;
}
$fluent = $this->createMenuItem($name, $called);
$childs['dependable-action-' . $index] = $fluent;
++$index;
}
$this->menu->offsetSet('childs', array_merge($childs, $attributes['childs']));
}
|
php
|
protected function add(&$attributes, $actions)
{
$index = 0;
$childs = [];
foreach ($actions as $name => $callback) {
if (!$callback instanceof Closure) {
continue;
}
$called = call_user_func($callback, $this->entity);
if (empty($called) or ! is_array($called)) {
continue;
}
$fluent = $this->createMenuItem($name, $called);
$childs['dependable-action-' . $index] = $fluent;
++$index;
}
$this->menu->offsetSet('childs', array_merge($childs, $attributes['childs']));
}
|
[
"protected",
"function",
"add",
"(",
"&",
"$",
"attributes",
",",
"$",
"actions",
")",
"{",
"$",
"index",
"=",
"0",
";",
"$",
"childs",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"name",
"=>",
"$",
"callback",
")",
"{",
"if",
"(",
"!",
"$",
"callback",
"instanceof",
"Closure",
")",
"{",
"continue",
";",
"}",
"$",
"called",
"=",
"call_user_func",
"(",
"$",
"callback",
",",
"$",
"this",
"->",
"entity",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"called",
")",
"or",
"!",
"is_array",
"(",
"$",
"called",
")",
")",
"{",
"continue",
";",
"}",
"$",
"fluent",
"=",
"$",
"this",
"->",
"createMenuItem",
"(",
"$",
"name",
",",
"$",
"called",
")",
";",
"$",
"childs",
"[",
"'dependable-action-'",
".",
"$",
"index",
"]",
"=",
"$",
"fluent",
";",
"++",
"$",
"index",
";",
"}",
"$",
"this",
"->",
"menu",
"->",
"offsetSet",
"(",
"'childs'",
",",
"array_merge",
"(",
"$",
"childs",
",",
"$",
"attributes",
"[",
"'childs'",
"]",
")",
")",
";",
"}"
] |
Adds menu item to breadcrumb menu
@param MenuHandler $menu
@param array $attributes
@param array $actions
|
[
"Adds",
"menu",
"item",
"to",
"breadcrumb",
"menu"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Listeners/BreadcrumbsMenuDependableActions.php#L79-L96
|
227,874
|
antaresproject/core
|
src/foundation/src/Listeners/BreadcrumbsMenuDependableActions.php
|
BreadcrumbsMenuDependableActions.createMenuItem
|
protected function createMenuItem($name, $attributes)
{
$icon = array_get($attributes, 'attributes.data-icon', '');
return new Fluent([
"icon" => starts_with($icon, 'zmdi') ? $icon : 'zmdi-' . $icon,
"link" => array_get($attributes, 'url'),
"title" => array_get($attributes, 'title'),
"id" => $name,
"childs" => []
]);
}
|
php
|
protected function createMenuItem($name, $attributes)
{
$icon = array_get($attributes, 'attributes.data-icon', '');
return new Fluent([
"icon" => starts_with($icon, 'zmdi') ? $icon : 'zmdi-' . $icon,
"link" => array_get($attributes, 'url'),
"title" => array_get($attributes, 'title'),
"id" => $name,
"childs" => []
]);
}
|
[
"protected",
"function",
"createMenuItem",
"(",
"$",
"name",
",",
"$",
"attributes",
")",
"{",
"$",
"icon",
"=",
"array_get",
"(",
"$",
"attributes",
",",
"'attributes.data-icon'",
",",
"''",
")",
";",
"return",
"new",
"Fluent",
"(",
"[",
"\"icon\"",
"=>",
"starts_with",
"(",
"$",
"icon",
",",
"'zmdi'",
")",
"?",
"$",
"icon",
":",
"'zmdi-'",
".",
"$",
"icon",
",",
"\"link\"",
"=>",
"array_get",
"(",
"$",
"attributes",
",",
"'url'",
")",
",",
"\"title\"",
"=>",
"array_get",
"(",
"$",
"attributes",
",",
"'title'",
")",
",",
"\"id\"",
"=>",
"$",
"name",
",",
"\"childs\"",
"=>",
"[",
"]",
"]",
")",
";",
"}"
] |
Creates menu item as Fluent object
@param String $name
@param array $attributes
@return Fluent
|
[
"Creates",
"menu",
"item",
"as",
"Fluent",
"object"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Listeners/BreadcrumbsMenuDependableActions.php#L105-L115
|
227,875
|
antaresproject/core
|
src/components/extension/src/Config/Settings.php
|
Settings.updateData
|
public function updateData(array $data) {
foreach($data as $name => $value) {
$this->data[$name] = $value;
}
}
|
php
|
public function updateData(array $data) {
foreach($data as $name => $value) {
$this->data[$name] = $value;
}
}
|
[
"public",
"function",
"updateData",
"(",
"array",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] |
Updates the settings data by the given array.
@param array $data
@return void
|
[
"Updates",
"the",
"settings",
"data",
"by",
"the",
"given",
"array",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Config/Settings.php#L61-L65
|
227,876
|
antaresproject/core
|
src/components/extension/src/Model/Types.php
|
Types.getTypeByExtension
|
public static function getTypeByExtension(ExtensionContract $extension) : string {
if($extension->isRequired()) {
return self::TYPE_CORE;
}
return self::TYPE_ADDITIONAL;
}
|
php
|
public static function getTypeByExtension(ExtensionContract $extension) : string {
if($extension->isRequired()) {
return self::TYPE_CORE;
}
return self::TYPE_ADDITIONAL;
}
|
[
"public",
"static",
"function",
"getTypeByExtension",
"(",
"ExtensionContract",
"$",
"extension",
")",
":",
"string",
"{",
"if",
"(",
"$",
"extension",
"->",
"isRequired",
"(",
")",
")",
"{",
"return",
"self",
"::",
"TYPE_CORE",
";",
"}",
"return",
"self",
"::",
"TYPE_ADDITIONAL",
";",
"}"
] |
Returns a type by the given extension.
@param ExtensionContract $extension
@return string
|
[
"Returns",
"a",
"type",
"by",
"the",
"given",
"extension",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Model/Types.php#L30-L36
|
227,877
|
antaresproject/core
|
src/ui/components/templates/src/Twig/Component.php
|
Component.component
|
protected function component()
{
$function = function ($params) {
if (($classname = $this->validate($params)) === false) {
return '';
}
if (($object = $this->getInstance($classname, $params)) === false) {
return '';
}
$ajax = $this->isAjax();
$args = func_get_args();
if ((int) $object->getAttribute('disabled') && !$ajax && !isset($args[1])) {
return '';
}
if (isset($args[1]) && $args[1] == true) {
return $object->setView('antares/ui-components::admin.partials._base');
}
return ($ajax) ? $object->render() : $object->show();
};
return new Twig_SimpleFunction(
'component', $function
);
}
|
php
|
protected function component()
{
$function = function ($params) {
if (($classname = $this->validate($params)) === false) {
return '';
}
if (($object = $this->getInstance($classname, $params)) === false) {
return '';
}
$ajax = $this->isAjax();
$args = func_get_args();
if ((int) $object->getAttribute('disabled') && !$ajax && !isset($args[1])) {
return '';
}
if (isset($args[1]) && $args[1] == true) {
return $object->setView('antares/ui-components::admin.partials._base');
}
return ($ajax) ? $object->render() : $object->show();
};
return new Twig_SimpleFunction(
'component', $function
);
}
|
[
"protected",
"function",
"component",
"(",
")",
"{",
"$",
"function",
"=",
"function",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"(",
"$",
"classname",
"=",
"$",
"this",
"->",
"validate",
"(",
"$",
"params",
")",
")",
"===",
"false",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"(",
"$",
"object",
"=",
"$",
"this",
"->",
"getInstance",
"(",
"$",
"classname",
",",
"$",
"params",
")",
")",
"===",
"false",
")",
"{",
"return",
"''",
";",
"}",
"$",
"ajax",
"=",
"$",
"this",
"->",
"isAjax",
"(",
")",
";",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"(",
"int",
")",
"$",
"object",
"->",
"getAttribute",
"(",
"'disabled'",
")",
"&&",
"!",
"$",
"ajax",
"&&",
"!",
"isset",
"(",
"$",
"args",
"[",
"1",
"]",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"args",
"[",
"1",
"]",
")",
"&&",
"$",
"args",
"[",
"1",
"]",
"==",
"true",
")",
"{",
"return",
"$",
"object",
"->",
"setView",
"(",
"'antares/ui-components::admin.partials._base'",
")",
";",
"}",
"return",
"(",
"$",
"ajax",
")",
"?",
"$",
"object",
"->",
"render",
"(",
")",
":",
"$",
"object",
"->",
"show",
"(",
")",
";",
"}",
";",
"return",
"new",
"Twig_SimpleFunction",
"(",
"'component'",
",",
"$",
"function",
")",
";",
"}"
] |
Creates ui component view helper
@return Twig_SimpleFunction
|
[
"Creates",
"ui",
"component",
"view",
"helper"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Twig/Component.php#L65-L89
|
227,878
|
antaresproject/core
|
src/ui/components/templates/src/Twig/Component.php
|
Component.getInstance
|
protected function getInstance($classname, $params)
{
$components = UIComponentsRegistry::get('ui-components');
if (is_null($components)) {
return false;
}
$object = $components->first(function ($value, $key) use($classname) {
return $value instanceof $classname;
});
if (!$object) {
return false;
}
$attributes = array_only(array_get($params, 'data'), ['x', 'y', 'width', 'height', 'disabled', 'id']);
$attributes['id'] = isset($params['id']) ? $params['id'] : null;
$object->setAttributes($attributes);
return $object;
}
|
php
|
protected function getInstance($classname, $params)
{
$components = UIComponentsRegistry::get('ui-components');
if (is_null($components)) {
return false;
}
$object = $components->first(function ($value, $key) use($classname) {
return $value instanceof $classname;
});
if (!$object) {
return false;
}
$attributes = array_only(array_get($params, 'data'), ['x', 'y', 'width', 'height', 'disabled', 'id']);
$attributes['id'] = isset($params['id']) ? $params['id'] : null;
$object->setAttributes($attributes);
return $object;
}
|
[
"protected",
"function",
"getInstance",
"(",
"$",
"classname",
",",
"$",
"params",
")",
"{",
"$",
"components",
"=",
"UIComponentsRegistry",
"::",
"get",
"(",
"'ui-components'",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"components",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"object",
"=",
"$",
"components",
"->",
"first",
"(",
"function",
"(",
"$",
"value",
",",
"$",
"key",
")",
"use",
"(",
"$",
"classname",
")",
"{",
"return",
"$",
"value",
"instanceof",
"$",
"classname",
";",
"}",
")",
";",
"if",
"(",
"!",
"$",
"object",
")",
"{",
"return",
"false",
";",
"}",
"$",
"attributes",
"=",
"array_only",
"(",
"array_get",
"(",
"$",
"params",
",",
"'data'",
")",
",",
"[",
"'x'",
",",
"'y'",
",",
"'width'",
",",
"'height'",
",",
"'disabled'",
",",
"'id'",
"]",
")",
";",
"$",
"attributes",
"[",
"'id'",
"]",
"=",
"isset",
"(",
"$",
"params",
"[",
"'id'",
"]",
")",
"?",
"$",
"params",
"[",
"'id'",
"]",
":",
"null",
";",
"$",
"object",
"->",
"setAttributes",
"(",
"$",
"attributes",
")",
";",
"return",
"$",
"object",
";",
"}"
] |
Gets ui component instance from registry
@param String $classname
@param array $params
@return boolean
|
[
"Gets",
"ui",
"component",
"instance",
"from",
"registry"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Twig/Component.php#L98-L116
|
227,879
|
antaresproject/core
|
src/ui/components/templates/src/Twig/Component.php
|
Component.validate
|
protected function validate($params)
{
if (array_get($params, 'data.dispatchable') === false) {
return false;
}
if (is_null($classname = array_get($params, 'data.classname'))) {
return false;
}
try {
if (!class_exists($classname)) {
return false;
}
} catch (Exception $ex) {
return false;
}
return $classname;
}
|
php
|
protected function validate($params)
{
if (array_get($params, 'data.dispatchable') === false) {
return false;
}
if (is_null($classname = array_get($params, 'data.classname'))) {
return false;
}
try {
if (!class_exists($classname)) {
return false;
}
} catch (Exception $ex) {
return false;
}
return $classname;
}
|
[
"protected",
"function",
"validate",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"array_get",
"(",
"$",
"params",
",",
"'data.dispatchable'",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"classname",
"=",
"array_get",
"(",
"$",
"params",
",",
"'data.classname'",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"classname",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"classname",
";",
"}"
] |
Validates ui component before render
@param array $params
@return boolean
|
[
"Validates",
"ui",
"component",
"before",
"render"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Twig/Component.php#L124-L141
|
227,880
|
antaresproject/core
|
src/ui/components/templates/src/Twig/Component.php
|
Component.getCurrentContentDimension
|
private function getCurrentContentDimension()
{
$current = Route::current();
if (is_null($current)) {
return [];
}
$uri = uri();
$dimensions = app('config')->get("antares/ui-components::dimensions");
return (isset($dimensions[$uri])) ? $dimensions[$uri] : [];
}
|
php
|
private function getCurrentContentDimension()
{
$current = Route::current();
if (is_null($current)) {
return [];
}
$uri = uri();
$dimensions = app('config')->get("antares/ui-components::dimensions");
return (isset($dimensions[$uri])) ? $dimensions[$uri] : [];
}
|
[
"private",
"function",
"getCurrentContentDimension",
"(",
")",
"{",
"$",
"current",
"=",
"Route",
"::",
"current",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"current",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"uri",
"=",
"uri",
"(",
")",
";",
"$",
"dimensions",
"=",
"app",
"(",
"'config'",
")",
"->",
"get",
"(",
"\"antares/ui-components::dimensions\"",
")",
";",
"return",
"(",
"isset",
"(",
"$",
"dimensions",
"[",
"$",
"uri",
"]",
")",
")",
"?",
"$",
"dimensions",
"[",
"$",
"uri",
"]",
":",
"[",
"]",
";",
"}"
] |
Gets current uri content dimension parameters
@return type
|
[
"Gets",
"current",
"uri",
"content",
"dimension",
"parameters"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Twig/Component.php#L158-L167
|
227,881
|
antaresproject/core
|
src/ui/components/templates/src/Twig/Component.php
|
Component.contentParams
|
protected function contentParams()
{
$function = function ($name = 'ui-components') {
try {
$dimension = $this->getCurrentContentDimension();
$repository = app('ui-components');
$config = app('config')->get('antares/ui-components::content');
$attributes = $repository->findOne($config['attributes'], uri());
if (!isset($attributes['width']) && !isset($attributes['height'])) {
$attributes = array_merge($attributes, $dimension);
}
$defaultHeight = array_get($attributes, 'default_height', array_get($config, 'attributes.default_height'));
$defaultWidth = array_get($attributes, 'default_width', array_get($config, 'attributes.default_width'));
$attributes['height'] = !isset($attributes['height']) ? $defaultHeight : $attributes['height'];
$attributes['width'] = !isset($attributes['width']) ? $defaultWidth : $attributes['width'];
return array_merge(array_get($config, 'attributes'), $attributes);
} catch (Exception $e) {
Log::emergency($e);
return false;
}
};
return new Twig_SimpleFunction(
'content_params', $function
);
}
|
php
|
protected function contentParams()
{
$function = function ($name = 'ui-components') {
try {
$dimension = $this->getCurrentContentDimension();
$repository = app('ui-components');
$config = app('config')->get('antares/ui-components::content');
$attributes = $repository->findOne($config['attributes'], uri());
if (!isset($attributes['width']) && !isset($attributes['height'])) {
$attributes = array_merge($attributes, $dimension);
}
$defaultHeight = array_get($attributes, 'default_height', array_get($config, 'attributes.default_height'));
$defaultWidth = array_get($attributes, 'default_width', array_get($config, 'attributes.default_width'));
$attributes['height'] = !isset($attributes['height']) ? $defaultHeight : $attributes['height'];
$attributes['width'] = !isset($attributes['width']) ? $defaultWidth : $attributes['width'];
return array_merge(array_get($config, 'attributes'), $attributes);
} catch (Exception $e) {
Log::emergency($e);
return false;
}
};
return new Twig_SimpleFunction(
'content_params', $function
);
}
|
[
"protected",
"function",
"contentParams",
"(",
")",
"{",
"$",
"function",
"=",
"function",
"(",
"$",
"name",
"=",
"'ui-components'",
")",
"{",
"try",
"{",
"$",
"dimension",
"=",
"$",
"this",
"->",
"getCurrentContentDimension",
"(",
")",
";",
"$",
"repository",
"=",
"app",
"(",
"'ui-components'",
")",
";",
"$",
"config",
"=",
"app",
"(",
"'config'",
")",
"->",
"get",
"(",
"'antares/ui-components::content'",
")",
";",
"$",
"attributes",
"=",
"$",
"repository",
"->",
"findOne",
"(",
"$",
"config",
"[",
"'attributes'",
"]",
",",
"uri",
"(",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'width'",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'height'",
"]",
")",
")",
"{",
"$",
"attributes",
"=",
"array_merge",
"(",
"$",
"attributes",
",",
"$",
"dimension",
")",
";",
"}",
"$",
"defaultHeight",
"=",
"array_get",
"(",
"$",
"attributes",
",",
"'default_height'",
",",
"array_get",
"(",
"$",
"config",
",",
"'attributes.default_height'",
")",
")",
";",
"$",
"defaultWidth",
"=",
"array_get",
"(",
"$",
"attributes",
",",
"'default_width'",
",",
"array_get",
"(",
"$",
"config",
",",
"'attributes.default_width'",
")",
")",
";",
"$",
"attributes",
"[",
"'height'",
"]",
"=",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'height'",
"]",
")",
"?",
"$",
"defaultHeight",
":",
"$",
"attributes",
"[",
"'height'",
"]",
";",
"$",
"attributes",
"[",
"'width'",
"]",
"=",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'width'",
"]",
")",
"?",
"$",
"defaultWidth",
":",
"$",
"attributes",
"[",
"'width'",
"]",
";",
"return",
"array_merge",
"(",
"array_get",
"(",
"$",
"config",
",",
"'attributes'",
")",
",",
"$",
"attributes",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Log",
"::",
"emergency",
"(",
"$",
"e",
")",
";",
"return",
"false",
";",
"}",
"}",
";",
"return",
"new",
"Twig_SimpleFunction",
"(",
"'content_params'",
",",
"$",
"function",
")",
";",
"}"
] |
Gets core content params as ui component
@return Twig_SimpleFunction
|
[
"Gets",
"core",
"content",
"params",
"as",
"ui",
"component"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Twig/Component.php#L174-L200
|
227,882
|
antaresproject/core
|
src/ui/components/templates/src/Twig/Component.php
|
Component.componentAttributes
|
protected function componentAttributes()
{
$function = function ($widget) {
$classname = array_get($widget['attributes'], 'attributes.classname');
if (is_null($classname)) {
return '';
}
$instance = null;
$widgets = Registry::get('ui-components');
if (empty($widgets)) {
return '';
}
foreach ($widgets as $widget) {
if (get_class($widget) == $classname) {
$instance = $widget;
break;
}
}
if (is_null($instance)) {
return '';
}
return serialize($instance->getShared());
};
return new Twig_SimpleFunction(
'component_attributes', $function
);
}
|
php
|
protected function componentAttributes()
{
$function = function ($widget) {
$classname = array_get($widget['attributes'], 'attributes.classname');
if (is_null($classname)) {
return '';
}
$instance = null;
$widgets = Registry::get('ui-components');
if (empty($widgets)) {
return '';
}
foreach ($widgets as $widget) {
if (get_class($widget) == $classname) {
$instance = $widget;
break;
}
}
if (is_null($instance)) {
return '';
}
return serialize($instance->getShared());
};
return new Twig_SimpleFunction(
'component_attributes', $function
);
}
|
[
"protected",
"function",
"componentAttributes",
"(",
")",
"{",
"$",
"function",
"=",
"function",
"(",
"$",
"widget",
")",
"{",
"$",
"classname",
"=",
"array_get",
"(",
"$",
"widget",
"[",
"'attributes'",
"]",
",",
"'attributes.classname'",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"classname",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"instance",
"=",
"null",
";",
"$",
"widgets",
"=",
"Registry",
"::",
"get",
"(",
"'ui-components'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"widgets",
")",
")",
"{",
"return",
"''",
";",
"}",
"foreach",
"(",
"$",
"widgets",
"as",
"$",
"widget",
")",
"{",
"if",
"(",
"get_class",
"(",
"$",
"widget",
")",
"==",
"$",
"classname",
")",
"{",
"$",
"instance",
"=",
"$",
"widget",
";",
"break",
";",
"}",
"}",
"if",
"(",
"is_null",
"(",
"$",
"instance",
")",
")",
"{",
"return",
"''",
";",
"}",
"return",
"serialize",
"(",
"$",
"instance",
"->",
"getShared",
"(",
")",
")",
";",
"}",
";",
"return",
"new",
"Twig_SimpleFunction",
"(",
"'component_attributes'",
",",
"$",
"function",
")",
";",
"}"
] |
Creates twig view helper to verify whether page use widgetable layout
@return Twig_SimpleFunction
|
[
"Creates",
"twig",
"view",
"helper",
"to",
"verify",
"whether",
"page",
"use",
"widgetable",
"layout"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Twig/Component.php#L207-L233
|
227,883
|
antaresproject/core
|
src/ui/components/templates/src/Twig/Component.php
|
Component.componentForced
|
public function componentForced()
{
$function = function ($name = null, array $params = []) {
if (is_null($name)) {
return '';
}
$components = UIComponentsRegistry::get('ui-components', []);
$component = null;
foreach ($components as $item) {
if ($item->getSnakedName() === $name) {
$component = $item;
break;
}
}
if (is_null($component)) {
return '';
}
$this->gridStackAdapter->scripts();
if (!empty($params)) {
$component->setAttributes($params);
}
$classname = 'Antares\UI\UIComponents\Templates\Datatables';
$view = ($component instanceof $classname) ? 'antares/ui-components::admin.partials._forced_datatable' : 'antares/ui-components::admin.partials._forced';
$component->setView($view);
return $component;
};
return new Twig_SimpleFunction(
'component_forced', $function
);
}
|
php
|
public function componentForced()
{
$function = function ($name = null, array $params = []) {
if (is_null($name)) {
return '';
}
$components = UIComponentsRegistry::get('ui-components', []);
$component = null;
foreach ($components as $item) {
if ($item->getSnakedName() === $name) {
$component = $item;
break;
}
}
if (is_null($component)) {
return '';
}
$this->gridStackAdapter->scripts();
if (!empty($params)) {
$component->setAttributes($params);
}
$classname = 'Antares\UI\UIComponents\Templates\Datatables';
$view = ($component instanceof $classname) ? 'antares/ui-components::admin.partials._forced_datatable' : 'antares/ui-components::admin.partials._forced';
$component->setView($view);
return $component;
};
return new Twig_SimpleFunction(
'component_forced', $function
);
}
|
[
"public",
"function",
"componentForced",
"(",
")",
"{",
"$",
"function",
"=",
"function",
"(",
"$",
"name",
"=",
"null",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"components",
"=",
"UIComponentsRegistry",
"::",
"get",
"(",
"'ui-components'",
",",
"[",
"]",
")",
";",
"$",
"component",
"=",
"null",
";",
"foreach",
"(",
"$",
"components",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"getSnakedName",
"(",
")",
"===",
"$",
"name",
")",
"{",
"$",
"component",
"=",
"$",
"item",
";",
"break",
";",
"}",
"}",
"if",
"(",
"is_null",
"(",
"$",
"component",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"this",
"->",
"gridStackAdapter",
"->",
"scripts",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"params",
")",
")",
"{",
"$",
"component",
"->",
"setAttributes",
"(",
"$",
"params",
")",
";",
"}",
"$",
"classname",
"=",
"'Antares\\UI\\UIComponents\\Templates\\Datatables'",
";",
"$",
"view",
"=",
"(",
"$",
"component",
"instanceof",
"$",
"classname",
")",
"?",
"'antares/ui-components::admin.partials._forced_datatable'",
":",
"'antares/ui-components::admin.partials._forced'",
";",
"$",
"component",
"->",
"setView",
"(",
"$",
"view",
")",
";",
"return",
"$",
"component",
";",
"}",
";",
"return",
"new",
"Twig_SimpleFunction",
"(",
"'component_forced'",
",",
"$",
"function",
")",
";",
"}"
] |
Shows forced ui component
@return Twig_SimpleFunction
|
[
"Shows",
"forced",
"ui",
"component"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Twig/Component.php#L240-L273
|
227,884
|
antaresproject/core
|
src/ui/components/templates/src/Twig/Component.php
|
Component.componentsList
|
public function componentsList()
{
$function = function () {
$widgets = app('antares.widget')->make('menu.top.right')->items();
if (!isset($widgets["ui-components-selector"])) {
return [];
}
$childs = $widgets["ui-components-selector"]->childs;
if (empty($childs)) {
return [];
}
$disabled = Registry::get('ui-components.disabled');
$viewed = Registry::get('ui-components.viewed');
foreach ($childs as $index => $child) {
$classname = array_get($child->attributes, 'classname');
if (!is_null($viewed) and ! $viewed->contains($classname)) {
unset($childs[$index]);
}
if (!is_null($disabled) and $disabled->contains($classname)) {
unset($childs[$index]);
}
}
return $childs;
};
return new Twig_SimpleFunction(
'components_list', $function
);
}
|
php
|
public function componentsList()
{
$function = function () {
$widgets = app('antares.widget')->make('menu.top.right')->items();
if (!isset($widgets["ui-components-selector"])) {
return [];
}
$childs = $widgets["ui-components-selector"]->childs;
if (empty($childs)) {
return [];
}
$disabled = Registry::get('ui-components.disabled');
$viewed = Registry::get('ui-components.viewed');
foreach ($childs as $index => $child) {
$classname = array_get($child->attributes, 'classname');
if (!is_null($viewed) and ! $viewed->contains($classname)) {
unset($childs[$index]);
}
if (!is_null($disabled) and $disabled->contains($classname)) {
unset($childs[$index]);
}
}
return $childs;
};
return new Twig_SimpleFunction(
'components_list', $function
);
}
|
[
"public",
"function",
"componentsList",
"(",
")",
"{",
"$",
"function",
"=",
"function",
"(",
")",
"{",
"$",
"widgets",
"=",
"app",
"(",
"'antares.widget'",
")",
"->",
"make",
"(",
"'menu.top.right'",
")",
"->",
"items",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"widgets",
"[",
"\"ui-components-selector\"",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"childs",
"=",
"$",
"widgets",
"[",
"\"ui-components-selector\"",
"]",
"->",
"childs",
";",
"if",
"(",
"empty",
"(",
"$",
"childs",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"disabled",
"=",
"Registry",
"::",
"get",
"(",
"'ui-components.disabled'",
")",
";",
"$",
"viewed",
"=",
"Registry",
"::",
"get",
"(",
"'ui-components.viewed'",
")",
";",
"foreach",
"(",
"$",
"childs",
"as",
"$",
"index",
"=>",
"$",
"child",
")",
"{",
"$",
"classname",
"=",
"array_get",
"(",
"$",
"child",
"->",
"attributes",
",",
"'classname'",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"viewed",
")",
"and",
"!",
"$",
"viewed",
"->",
"contains",
"(",
"$",
"classname",
")",
")",
"{",
"unset",
"(",
"$",
"childs",
"[",
"$",
"index",
"]",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"disabled",
")",
"and",
"$",
"disabled",
"->",
"contains",
"(",
"$",
"classname",
")",
")",
"{",
"unset",
"(",
"$",
"childs",
"[",
"$",
"index",
"]",
")",
";",
"}",
"}",
"return",
"$",
"childs",
";",
"}",
";",
"return",
"new",
"Twig_SimpleFunction",
"(",
"'components_list'",
",",
"$",
"function",
")",
";",
"}"
] |
Prepares ui components list
@return Twig_SimpleFunction
|
[
"Prepares",
"ui",
"components",
"list"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Twig/Component.php#L280-L310
|
227,885
|
lawoole/framework
|
src/Server/ServerFactory.php
|
ServerFactory.make
|
public function make(array $config)
{
$driver = $this->getDriver($config);
// First we will check by the server driver type to see if an extension
// has been registered specifically for that server.
if (isset($this->serverExtensions[$driver])) {
$server = call_user_func($this->serverExtensions[$driver], $config);
}
// Create a built-in server with given driver type.
elseif (method_exists($this, $method = 'create'.Str::studly($driver).'Driver')) {
$server = $this->$method($config);
}
// Otherwise, if the driver type does not support, an exception will be thrown.
else {
throw new InvalidArgumentException("Driver [{$driver}] is not supported.");
}
$this->configureServer($server, $config);
return $server;
}
|
php
|
public function make(array $config)
{
$driver = $this->getDriver($config);
// First we will check by the server driver type to see if an extension
// has been registered specifically for that server.
if (isset($this->serverExtensions[$driver])) {
$server = call_user_func($this->serverExtensions[$driver], $config);
}
// Create a built-in server with given driver type.
elseif (method_exists($this, $method = 'create'.Str::studly($driver).'Driver')) {
$server = $this->$method($config);
}
// Otherwise, if the driver type does not support, an exception will be thrown.
else {
throw new InvalidArgumentException("Driver [{$driver}] is not supported.");
}
$this->configureServer($server, $config);
return $server;
}
|
[
"public",
"function",
"make",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"driver",
"=",
"$",
"this",
"->",
"getDriver",
"(",
"$",
"config",
")",
";",
"// First we will check by the server driver type to see if an extension",
"// has been registered specifically for that server.",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"serverExtensions",
"[",
"$",
"driver",
"]",
")",
")",
"{",
"$",
"server",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"serverExtensions",
"[",
"$",
"driver",
"]",
",",
"$",
"config",
")",
";",
"}",
"// Create a built-in server with given driver type.",
"elseif",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
"=",
"'create'",
".",
"Str",
"::",
"studly",
"(",
"$",
"driver",
")",
".",
"'Driver'",
")",
")",
"{",
"$",
"server",
"=",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"config",
")",
";",
"}",
"// Otherwise, if the driver type does not support, an exception will be thrown.",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Driver [{$driver}] is not supported.\"",
")",
";",
"}",
"$",
"this",
"->",
"configureServer",
"(",
"$",
"server",
",",
"$",
"config",
")",
";",
"return",
"$",
"server",
";",
"}"
] |
Establish a server based on the configuration.
@param array $config
@return \Lawoole\Contracts\Server\Server
|
[
"Establish",
"a",
"server",
"based",
"on",
"the",
"configuration",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/ServerFactory.php#L55-L78
|
227,886
|
lawoole/framework
|
src/Server/ServerFactory.php
|
ServerFactory.getDefaultServerSocket
|
protected function getDefaultServerSocket(array $config)
{
$unixSock = $config['unix_sock'] ?? $this->getDefaultUnixSock();
$serverSocket = new UnixServerSocket($this->app, [
'unix_sock' => $unixSock
]);
$serverSocket->setEventHandler(new ServerEventHandler);
return $serverSocket;
}
|
php
|
protected function getDefaultServerSocket(array $config)
{
$unixSock = $config['unix_sock'] ?? $this->getDefaultUnixSock();
$serverSocket = new UnixServerSocket($this->app, [
'unix_sock' => $unixSock
]);
$serverSocket->setEventHandler(new ServerEventHandler);
return $serverSocket;
}
|
[
"protected",
"function",
"getDefaultServerSocket",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"unixSock",
"=",
"$",
"config",
"[",
"'unix_sock'",
"]",
"??",
"$",
"this",
"->",
"getDefaultUnixSock",
"(",
")",
";",
"$",
"serverSocket",
"=",
"new",
"UnixServerSocket",
"(",
"$",
"this",
"->",
"app",
",",
"[",
"'unix_sock'",
"=>",
"$",
"unixSock",
"]",
")",
";",
"$",
"serverSocket",
"->",
"setEventHandler",
"(",
"new",
"ServerEventHandler",
")",
";",
"return",
"$",
"serverSocket",
";",
"}"
] |
Create a default server socket instance for the server.
@param array $config
@return \Lawoole\Server\ServerSockets\ServerSocket
|
[
"Create",
"a",
"default",
"server",
"socket",
"instance",
"for",
"the",
"server",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/ServerFactory.php#L146-L157
|
227,887
|
lawoole/framework
|
src/Server/ServerFactory.php
|
ServerFactory.configureServer
|
protected function configureServer($server, array $config)
{
if ($handler = $this->parseEventHandler($config)) {
$server->setEventHandler($handler);
}
if (isset($config['listens']) && $config['listens']) {
$this->configureServerSockets($server, $config['listens']);
}
if (isset($config['processes']) && $config['processes']) {
$this->configureProcesses($server, $config['processes']);
}
return $server;
}
|
php
|
protected function configureServer($server, array $config)
{
if ($handler = $this->parseEventHandler($config)) {
$server->setEventHandler($handler);
}
if (isset($config['listens']) && $config['listens']) {
$this->configureServerSockets($server, $config['listens']);
}
if (isset($config['processes']) && $config['processes']) {
$this->configureProcesses($server, $config['processes']);
}
return $server;
}
|
[
"protected",
"function",
"configureServer",
"(",
"$",
"server",
",",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"handler",
"=",
"$",
"this",
"->",
"parseEventHandler",
"(",
"$",
"config",
")",
")",
"{",
"$",
"server",
"->",
"setEventHandler",
"(",
"$",
"handler",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'listens'",
"]",
")",
"&&",
"$",
"config",
"[",
"'listens'",
"]",
")",
"{",
"$",
"this",
"->",
"configureServerSockets",
"(",
"$",
"server",
",",
"$",
"config",
"[",
"'listens'",
"]",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'processes'",
"]",
")",
"&&",
"$",
"config",
"[",
"'processes'",
"]",
")",
"{",
"$",
"this",
"->",
"configureProcesses",
"(",
"$",
"server",
",",
"$",
"config",
"[",
"'processes'",
"]",
")",
";",
"}",
"return",
"$",
"server",
";",
"}"
] |
Configure the server.
@param \Lawoole\Server\Server $server
@param array $config
@return \Lawoole\Server\Server
|
[
"Configure",
"the",
"server",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/ServerFactory.php#L189-L204
|
227,888
|
lawoole/framework
|
src/Server/ServerFactory.php
|
ServerFactory.configureServerSockets
|
protected function configureServerSockets($server, array $serverSockets)
{
foreach ($serverSockets as $config) {
$serverSocket = $this->createServerSocket($config);
if ($handler = $this->parseEventHandler($config)) {
$serverSocket->setEventHandler($handler);
}
$server->listen($serverSocket);
}
}
|
php
|
protected function configureServerSockets($server, array $serverSockets)
{
foreach ($serverSockets as $config) {
$serverSocket = $this->createServerSocket($config);
if ($handler = $this->parseEventHandler($config)) {
$serverSocket->setEventHandler($handler);
}
$server->listen($serverSocket);
}
}
|
[
"protected",
"function",
"configureServerSockets",
"(",
"$",
"server",
",",
"array",
"$",
"serverSockets",
")",
"{",
"foreach",
"(",
"$",
"serverSockets",
"as",
"$",
"config",
")",
"{",
"$",
"serverSocket",
"=",
"$",
"this",
"->",
"createServerSocket",
"(",
"$",
"config",
")",
";",
"if",
"(",
"$",
"handler",
"=",
"$",
"this",
"->",
"parseEventHandler",
"(",
"$",
"config",
")",
")",
"{",
"$",
"serverSocket",
"->",
"setEventHandler",
"(",
"$",
"handler",
")",
";",
"}",
"$",
"server",
"->",
"listen",
"(",
"$",
"serverSocket",
")",
";",
"}",
"}"
] |
Configure the server sockets in the server.
@param \Lawoole\Server\Server $server
@param array $serverSockets
|
[
"Configure",
"the",
"server",
"sockets",
"in",
"the",
"server",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/ServerFactory.php#L212-L223
|
227,889
|
lawoole/framework
|
src/Server/ServerFactory.php
|
ServerFactory.createServerSocket
|
protected function createServerSocket(array $config)
{
$protocol = $config['protocol'] ?? 'tcp';
if (isset($this->serverSocketExtensions[$protocol])) {
$serverSocket = call_user_func($this->serverSocketExtensions[$protocol], $this->app, $config);
if (! $serverSocket instanceof ServerSocketContract) {
throw new InvalidArgumentException(
"The protocol [{$protocol}] resolver must return a ServerSocket instance."
);
}
return $serverSocket;
}
if (method_exists($this, $method = 'create'.Str::studly($protocol).'ServerSocket')) {
return $this->$method($config);
}
throw new InvalidArgumentException("The protocol [{$protocol}] is not supported.");
}
|
php
|
protected function createServerSocket(array $config)
{
$protocol = $config['protocol'] ?? 'tcp';
if (isset($this->serverSocketExtensions[$protocol])) {
$serverSocket = call_user_func($this->serverSocketExtensions[$protocol], $this->app, $config);
if (! $serverSocket instanceof ServerSocketContract) {
throw new InvalidArgumentException(
"The protocol [{$protocol}] resolver must return a ServerSocket instance."
);
}
return $serverSocket;
}
if (method_exists($this, $method = 'create'.Str::studly($protocol).'ServerSocket')) {
return $this->$method($config);
}
throw new InvalidArgumentException("The protocol [{$protocol}] is not supported.");
}
|
[
"protected",
"function",
"createServerSocket",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"protocol",
"=",
"$",
"config",
"[",
"'protocol'",
"]",
"??",
"'tcp'",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"serverSocketExtensions",
"[",
"$",
"protocol",
"]",
")",
")",
"{",
"$",
"serverSocket",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"serverSocketExtensions",
"[",
"$",
"protocol",
"]",
",",
"$",
"this",
"->",
"app",
",",
"$",
"config",
")",
";",
"if",
"(",
"!",
"$",
"serverSocket",
"instanceof",
"ServerSocketContract",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The protocol [{$protocol}] resolver must return a ServerSocket instance.\"",
")",
";",
"}",
"return",
"$",
"serverSocket",
";",
"}",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
"=",
"'create'",
".",
"Str",
"::",
"studly",
"(",
"$",
"protocol",
")",
".",
"'ServerSocket'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"config",
")",
";",
"}",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The protocol [{$protocol}] is not supported.\"",
")",
";",
"}"
] |
Create a server socket instance.
@param array $config
@return \Lawoole\Contracts\Server\ServerSocket
|
[
"Create",
"a",
"server",
"socket",
"instance",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/ServerFactory.php#L243-L264
|
227,890
|
lawoole/framework
|
src/Server/ServerFactory.php
|
ServerFactory.configureProcesses
|
protected function configureProcesses($server, array $processes)
{
foreach ($processes as $config) {
$process = $this->createProcess($config);
if ($handler = $this->parseEventHandler($config)) {
$process->setEventHandler($handler);
}
$server->fork($process);
}
}
|
php
|
protected function configureProcesses($server, array $processes)
{
foreach ($processes as $config) {
$process = $this->createProcess($config);
if ($handler = $this->parseEventHandler($config)) {
$process->setEventHandler($handler);
}
$server->fork($process);
}
}
|
[
"protected",
"function",
"configureProcesses",
"(",
"$",
"server",
",",
"array",
"$",
"processes",
")",
"{",
"foreach",
"(",
"$",
"processes",
"as",
"$",
"config",
")",
"{",
"$",
"process",
"=",
"$",
"this",
"->",
"createProcess",
"(",
"$",
"config",
")",
";",
"if",
"(",
"$",
"handler",
"=",
"$",
"this",
"->",
"parseEventHandler",
"(",
"$",
"config",
")",
")",
"{",
"$",
"process",
"->",
"setEventHandler",
"(",
"$",
"handler",
")",
";",
"}",
"$",
"server",
"->",
"fork",
"(",
"$",
"process",
")",
";",
"}",
"}"
] |
Configure the processes in the server.
@param \Lawoole\Server\Server $server
@param array $processes
|
[
"Configure",
"the",
"processes",
"in",
"the",
"server",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/ServerFactory.php#L332-L343
|
227,891
|
antaresproject/core
|
src/components/memory/src/DeferedService.php
|
DeferedService.run
|
public function run()
{
if (!$this->validate()) {
return false;
}
return DB::transaction(function() {
$events = $this->getDeferedEvents();
foreach ($events as $event) {
if (!empty($event->value)) {
continue;
}
$event->value = Event::fire($event->name);
$event->save();
}
});
}
|
php
|
public function run()
{
if (!$this->validate()) {
return false;
}
return DB::transaction(function() {
$events = $this->getDeferedEvents();
foreach ($events as $event) {
if (!empty($event->value)) {
continue;
}
$event->value = Event::fire($event->name);
$event->save();
}
});
}
|
[
"public",
"function",
"run",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validate",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"DB",
"::",
"transaction",
"(",
"function",
"(",
")",
"{",
"$",
"events",
"=",
"$",
"this",
"->",
"getDeferedEvents",
"(",
")",
";",
"foreach",
"(",
"$",
"events",
"as",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"event",
"->",
"value",
")",
")",
"{",
"continue",
";",
"}",
"$",
"event",
"->",
"value",
"=",
"Event",
"::",
"fire",
"(",
"$",
"event",
"->",
"name",
")",
";",
"$",
"event",
"->",
"save",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
fires all defered events
@return boolean
|
[
"fires",
"all",
"defered",
"events"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/src/DeferedService.php#L36-L54
|
227,892
|
lawoole/framework
|
src/Homer/Serialize/Factory.php
|
Factory.serializer
|
public function serializer($type = null)
{
$type = $type ?? 'php';
if (isset($this->serializers[$type])) {
return $this->serializers[$type];
}
return $this->serializers[$type] = $this->resolve($type);
}
|
php
|
public function serializer($type = null)
{
$type = $type ?? 'php';
if (isset($this->serializers[$type])) {
return $this->serializers[$type];
}
return $this->serializers[$type] = $this->resolve($type);
}
|
[
"public",
"function",
"serializer",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"type",
"=",
"$",
"type",
"??",
"'php'",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"serializers",
"[",
"$",
"type",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"serializers",
"[",
"$",
"type",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"serializers",
"[",
"$",
"type",
"]",
"=",
"$",
"this",
"->",
"resolve",
"(",
"$",
"type",
")",
";",
"}"
] |
Get the serializer by type.
@param string $type
@return \Lawoole\Homer\Serialize\Serializer
|
[
"Get",
"the",
"serializer",
"by",
"type",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Serialize/Factory.php#L22-L31
|
227,893
|
antaresproject/core
|
src/foundation/src/Traits/UploadableTrait.php
|
UploadableTrait.resolveTempFileName
|
protected function resolveTempFileName(UploadedFile $file)
{
$name = $file->getClientOriginalName();
$extension = File::extension($name);
$subdir = sha1(time());
$directory = storage_path() . '/app/uploads/' . $subdir;
$filename = sha1(time() . time()) . ".{$extension}";
return ['directory' => $directory, 'subdir' => $subdir, 'filename' => $filename];
}
|
php
|
protected function resolveTempFileName(UploadedFile $file)
{
$name = $file->getClientOriginalName();
$extension = File::extension($name);
$subdir = sha1(time());
$directory = storage_path() . '/app/uploads/' . $subdir;
$filename = sha1(time() . time()) . ".{$extension}";
return ['directory' => $directory, 'subdir' => $subdir, 'filename' => $filename];
}
|
[
"protected",
"function",
"resolveTempFileName",
"(",
"UploadedFile",
"$",
"file",
")",
"{",
"$",
"name",
"=",
"$",
"file",
"->",
"getClientOriginalName",
"(",
")",
";",
"$",
"extension",
"=",
"File",
"::",
"extension",
"(",
"$",
"name",
")",
";",
"$",
"subdir",
"=",
"sha1",
"(",
"time",
"(",
")",
")",
";",
"$",
"directory",
"=",
"storage_path",
"(",
")",
".",
"'/app/uploads/'",
".",
"$",
"subdir",
";",
"$",
"filename",
"=",
"sha1",
"(",
"time",
"(",
")",
".",
"time",
"(",
")",
")",
".",
"\".{$extension}\"",
";",
"return",
"[",
"'directory'",
"=>",
"$",
"directory",
",",
"'subdir'",
"=>",
"$",
"subdir",
",",
"'filename'",
"=>",
"$",
"filename",
"]",
";",
"}"
] |
upload file temporary resolver
@param \Symfony\Component\HttpFoundation\File\UploadedFile $file
@return type
|
[
"upload",
"file",
"temporary",
"resolver"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Traits/UploadableTrait.php#L42-L50
|
227,894
|
antaresproject/core
|
src/foundation/src/Traits/UploadableTrait.php
|
UploadableTrait.unzip
|
protected function unzip($source, $destination)
{
@mkdir($destination, 0777, true);
$zip = new ZipArchive;
if ($zip->open($source) === true) {
$zip->extractTo($destination);
$zip->close();
return true;
} else {
throw new \Exception('Unable to open module package file');
}
}
|
php
|
protected function unzip($source, $destination)
{
@mkdir($destination, 0777, true);
$zip = new ZipArchive;
if ($zip->open($source) === true) {
$zip->extractTo($destination);
$zip->close();
return true;
} else {
throw new \Exception('Unable to open module package file');
}
}
|
[
"protected",
"function",
"unzip",
"(",
"$",
"source",
",",
"$",
"destination",
")",
"{",
"@",
"mkdir",
"(",
"$",
"destination",
",",
"0777",
",",
"true",
")",
";",
"$",
"zip",
"=",
"new",
"ZipArchive",
";",
"if",
"(",
"$",
"zip",
"->",
"open",
"(",
"$",
"source",
")",
"===",
"true",
")",
"{",
"$",
"zip",
"->",
"extractTo",
"(",
"$",
"destination",
")",
";",
"$",
"zip",
"->",
"close",
"(",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Unable to open module package file'",
")",
";",
"}",
"}"
] |
unziping module package
@param String $source
@param String $destination
@return boolean
@throws \Exception
|
[
"unziping",
"module",
"package"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Traits/UploadableTrait.php#L71-L82
|
227,895
|
antaresproject/core
|
src/foundation/src/Traits/UploadableTrait.php
|
UploadableTrait.getPackageName
|
protected function getPackageName($path)
{
if (ends_with($path, '.zip')) {
$path = dirname($path);
}
$manifest = new Manifest(new Filesystem(), $path);
return $manifest->get('package');
}
|
php
|
protected function getPackageName($path)
{
if (ends_with($path, '.zip')) {
$path = dirname($path);
}
$manifest = new Manifest(new Filesystem(), $path);
return $manifest->get('package');
}
|
[
"protected",
"function",
"getPackageName",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"ends_with",
"(",
"$",
"path",
",",
"'.zip'",
")",
")",
"{",
"$",
"path",
"=",
"dirname",
"(",
"$",
"path",
")",
";",
"}",
"$",
"manifest",
"=",
"new",
"Manifest",
"(",
"new",
"Filesystem",
"(",
")",
",",
"$",
"path",
")",
";",
"return",
"$",
"manifest",
"->",
"get",
"(",
"'package'",
")",
";",
"}"
] |
gets theme name by manifest
@param String $path
@return String
|
[
"gets",
"theme",
"name",
"by",
"manifest"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Traits/UploadableTrait.php#L90-L97
|
227,896
|
antaresproject/core
|
src/components/html/src/Validation/Validator.php
|
Validator.uniqueMessages
|
protected function uniqueMessages($messageBag, $messageBagFromCustom = null)
{
if (is_null($messageBagFromCustom)) {
return $messageBag;
}
$messages = $messageBagFromCustom->getMessages();
foreach ($messages as $key => $value) {
if (empty($value)) {
continue;
}
foreach ($value as $messageName) {
if ($messageBag->has($key, $messageName)) {
continue;
}
$messageBag->add($key, $messageName);
}
}
return $messageBag;
}
|
php
|
protected function uniqueMessages($messageBag, $messageBagFromCustom = null)
{
if (is_null($messageBagFromCustom)) {
return $messageBag;
}
$messages = $messageBagFromCustom->getMessages();
foreach ($messages as $key => $value) {
if (empty($value)) {
continue;
}
foreach ($value as $messageName) {
if ($messageBag->has($key, $messageName)) {
continue;
}
$messageBag->add($key, $messageName);
}
}
return $messageBag;
}
|
[
"protected",
"function",
"uniqueMessages",
"(",
"$",
"messageBag",
",",
"$",
"messageBagFromCustom",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"messageBagFromCustom",
")",
")",
"{",
"return",
"$",
"messageBag",
";",
"}",
"$",
"messages",
"=",
"$",
"messageBagFromCustom",
"->",
"getMessages",
"(",
")",
";",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"value",
"as",
"$",
"messageName",
")",
"{",
"if",
"(",
"$",
"messageBag",
"->",
"has",
"(",
"$",
"key",
",",
"$",
"messageName",
")",
")",
"{",
"continue",
";",
"}",
"$",
"messageBag",
"->",
"add",
"(",
"$",
"key",
",",
"$",
"messageName",
")",
";",
"}",
"}",
"return",
"$",
"messageBag",
";",
"}"
] |
unify message bugs from custom validators and from form
@param \Illuminate\Support\MessageBag $messageBag
@param \Illuminate\Support\MessageBag $messageBagFromCustom
@return \Illuminate\Support\MessageBag
|
[
"unify",
"message",
"bugs",
"from",
"custom",
"validators",
"and",
"from",
"form"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Validation/Validator.php#L152-L170
|
227,897
|
antaresproject/core
|
src/components/html/src/Validation/Validator.php
|
Validator.whenValidated
|
protected function whenValidated($messageBag, $sendHeaders)
{
$messages = empty($messageBag) ? [] : $messageBag->getMessages();
if ($this->request->ajax() && $sendHeaders) {
$return = [];
foreach ($messages as $key => $phrases) {
if (str_contains($key, '[]')) {
$key = str_replace(['[', ']'], '_', $key);
}
$return[$key] = $phrases;
}
return $this->response($return);
}
if (!empty($messages)) {
$this->messageBag = $messageBag;
return false;
}
return true;
}
|
php
|
protected function whenValidated($messageBag, $sendHeaders)
{
$messages = empty($messageBag) ? [] : $messageBag->getMessages();
if ($this->request->ajax() && $sendHeaders) {
$return = [];
foreach ($messages as $key => $phrases) {
if (str_contains($key, '[]')) {
$key = str_replace(['[', ']'], '_', $key);
}
$return[$key] = $phrases;
}
return $this->response($return);
}
if (!empty($messages)) {
$this->messageBag = $messageBag;
return false;
}
return true;
}
|
[
"protected",
"function",
"whenValidated",
"(",
"$",
"messageBag",
",",
"$",
"sendHeaders",
")",
"{",
"$",
"messages",
"=",
"empty",
"(",
"$",
"messageBag",
")",
"?",
"[",
"]",
":",
"$",
"messageBag",
"->",
"getMessages",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"ajax",
"(",
")",
"&&",
"$",
"sendHeaders",
")",
"{",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"key",
"=>",
"$",
"phrases",
")",
"{",
"if",
"(",
"str_contains",
"(",
"$",
"key",
",",
"'[]'",
")",
")",
"{",
"$",
"key",
"=",
"str_replace",
"(",
"[",
"'['",
",",
"']'",
"]",
",",
"'_'",
",",
"$",
"key",
")",
";",
"}",
"$",
"return",
"[",
"$",
"key",
"]",
"=",
"$",
"phrases",
";",
"}",
"return",
"$",
"this",
"->",
"response",
"(",
"$",
"return",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"messages",
")",
")",
"{",
"$",
"this",
"->",
"messageBag",
"=",
"$",
"messageBag",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
after form validation
@param $messageBag
@param $sendHeaders
@return bool
|
[
"after",
"form",
"validation"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Validation/Validator.php#L179-L198
|
227,898
|
antaresproject/core
|
src/components/html/src/Validation/Validator.php
|
Validator.response
|
protected function response(array $messages = [])
{
$response = Response::json($messages, 200);
$response->sendHeaders();
$response->sendContent();
app()->terminate();
exit;
}
|
php
|
protected function response(array $messages = [])
{
$response = Response::json($messages, 200);
$response->sendHeaders();
$response->sendContent();
app()->terminate();
exit;
}
|
[
"protected",
"function",
"response",
"(",
"array",
"$",
"messages",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"Response",
"::",
"json",
"(",
"$",
"messages",
",",
"200",
")",
";",
"$",
"response",
"->",
"sendHeaders",
"(",
")",
";",
"$",
"response",
"->",
"sendContent",
"(",
")",
";",
"app",
"(",
")",
"->",
"terminate",
"(",
")",
";",
"exit",
";",
"}"
] |
send proper headers and terminate application
@param array $messages
@return bool
|
[
"send",
"proper",
"headers",
"and",
"terminate",
"application"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Validation/Validator.php#L206-L213
|
227,899
|
antaresproject/customfields
|
src/Http/Forms/FieldFormFactory.php
|
FieldFormFactory.shouldContainValueField
|
protected function shouldContainValueField($typeId = null)
{
if (is_null($typeId)) {
return false;
}
$model = FieldType::query()->findOrFail($typeId);
return $model->name == 'select' or ( $model->name == 'input' and in_array($model->type, ['radio', 'checkbox']));
}
|
php
|
protected function shouldContainValueField($typeId = null)
{
if (is_null($typeId)) {
return false;
}
$model = FieldType::query()->findOrFail($typeId);
return $model->name == 'select' or ( $model->name == 'input' and in_array($model->type, ['radio', 'checkbox']));
}
|
[
"protected",
"function",
"shouldContainValueField",
"(",
"$",
"typeId",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"typeId",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"model",
"=",
"FieldType",
"::",
"query",
"(",
")",
"->",
"findOrFail",
"(",
"$",
"typeId",
")",
";",
"return",
"$",
"model",
"->",
"name",
"==",
"'select'",
"or",
"(",
"$",
"model",
"->",
"name",
"==",
"'input'",
"and",
"in_array",
"(",
"$",
"model",
"->",
"type",
",",
"[",
"'radio'",
",",
"'checkbox'",
"]",
")",
")",
";",
"}"
] |
Whether field should contain value input
@param mixed $typeId
@return boolean
|
[
"Whether",
"field",
"should",
"contain",
"value",
"input"
] |
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
|
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Http/Forms/FieldFormFactory.php#L222-L229
|
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.