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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
32,700 | ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectMaemoTablet | function DetectMaemoTablet()
{
if (stripos($this->useragent, $this->maemo) > -1)
return $this->true;
//For Nokia N810, must be Linux + Tablet, or else it could be something else.
if ((stripos($this->useragent, $this->linux) > -1)
&& (stripos($this->useragent, $this->deviceTablet) > -1)
&& ($this->DetectWebOSTablet() == $this->false)
&& ($this->DetectAndroid() == $this->false))
return $this->true;
else
return $this->false;
} | php | function DetectMaemoTablet()
{
if (stripos($this->useragent, $this->maemo) > -1)
return $this->true;
//For Nokia N810, must be Linux + Tablet, or else it could be something else.
if ((stripos($this->useragent, $this->linux) > -1)
&& (stripos($this->useragent, $this->deviceTablet) > -1)
&& ($this->DetectWebOSTablet() == $this->false)
&& ($this->DetectAndroid() == $this->false))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectMaemoTablet",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"maemo",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"//For Nokia N810, must be Linux + Tablet, or else it could be something else. \r",
"if",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"linux",
")",
">",
"-",
"1",
")",
"&&",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceTablet",
")",
">",
"-",
"1",
")",
"&&",
"(",
"$",
"this",
"->",
"DetectWebOSTablet",
"(",
")",
"==",
"$",
"this",
"->",
"false",
")",
"&&",
"(",
"$",
"this",
"->",
"DetectAndroid",
"(",
")",
"==",
"$",
"this",
"->",
"false",
")",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
"false",
";",
"}"
] | Detects if the current device is on one of the Maemo-based Nokia Internet Tablets. | [
"Detects",
"if",
"the",
"current",
"device",
"is",
"on",
"one",
"of",
"the",
"Maemo",
"-",
"based",
"Nokia",
"Internet",
"Tablets",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L939-L951 |
32,701 | ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectGameConsole | function DetectGameConsole()
{
if ($this->DetectSonyPlaystation() == $this->true)
return $this->true;
else if ($this->DetectNintendo() == $this->true)
return $this->true;
else if ($this->DetectXbox() == $this->true)
return $this->true;
else
return $this->false;
} | php | function DetectGameConsole()
{
if ($this->DetectSonyPlaystation() == $this->true)
return $this->true;
else if ($this->DetectNintendo() == $this->true)
return $this->true;
else if ($this->DetectXbox() == $this->true)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectGameConsole",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"DetectSonyPlaystation",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"if",
"(",
"$",
"this",
"->",
"DetectNintendo",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"if",
"(",
"$",
"this",
"->",
"DetectXbox",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
"false",
";",
"}"
] | Includes many handheld consoles. | [
"Includes",
"many",
"handheld",
"consoles",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L966-L976 |
32,702 | ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectSonyPlaystation | function DetectSonyPlaystation()
{
if (stripos($this->useragent, $this->devicePlaystation) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectSonyPlaystation()
{
if (stripos($this->useragent, $this->devicePlaystation) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectSonyPlaystation",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"devicePlaystation",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
"false",
";",
"}"
] | Detects if the current device is a Sony Playstation. | [
"Detects",
"if",
"the",
"current",
"device",
"is",
"a",
"Sony",
"Playstation",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L980-L986 |
32,703 | ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectGamingHandheld | function DetectGamingHandheld()
{
if ((stripos($this->useragent, $this->devicePlaystation) > -1) &&
(stripos($this->useragent, $this->devicePlaystationVita) > -1))
return $this->true;
else
return $this->false;
} | php | function DetectGamingHandheld()
{
if ((stripos($this->useragent, $this->devicePlaystation) > -1) &&
(stripos($this->useragent, $this->devicePlaystationVita) > -1))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectGamingHandheld",
"(",
")",
"{",
"if",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"devicePlaystation",
")",
">",
"-",
"1",
")",
"&&",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"devicePlaystationVita",
")",
">",
"-",
"1",
")",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
"false",
";",
"}"
] | a touchscreen and modern iPhone-class browser. Includes the Playstation Vita. | [
"a",
"touchscreen",
"and",
"modern",
"iPhone",
"-",
"class",
"browser",
".",
"Includes",
"the",
"Playstation",
"Vita",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L991-L998 |
32,704 | ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectNintendo | function DetectNintendo()
{
if (stripos($this->useragent, $this->deviceNintendo) > -1 ||
stripos($this->useragent, $this->deviceWii) > -1 ||
stripos($this->useragent, $this->deviceNintendoDs) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectNintendo()
{
if (stripos($this->useragent, $this->deviceNintendo) > -1 ||
stripos($this->useragent, $this->deviceWii) > -1 ||
stripos($this->useragent, $this->deviceNintendoDs) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectNintendo",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceNintendo",
")",
">",
"-",
"1",
"||",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceWii",
")",
">",
"-",
"1",
"||",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceNintendoDs",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
"false",
";",
"}"
] | Detects if the current device is a Nintendo game device. | [
"Detects",
"if",
"the",
"current",
"device",
"is",
"a",
"Nintendo",
"game",
"device",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1002-L1010 |
32,705 | ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectXbox | function DetectXbox()
{
if (stripos($this->useragent, $this->deviceXbox) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectXbox()
{
if (stripos($this->useragent, $this->deviceXbox) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectXbox",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceXbox",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
"false",
";",
"}"
] | Detects if the current device is a Microsoft Xbox. | [
"Detects",
"if",
"the",
"current",
"device",
"is",
"a",
"Microsoft",
"Xbox",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1014-L1020 |
32,706 | ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectBrewDevice | function DetectBrewDevice()
{
if (stripos($this->useragent, $this->deviceBrew) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectBrewDevice()
{
if (stripos($this->useragent, $this->deviceBrew) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectBrewDevice",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceBrew",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
"false",
";",
"}"
] | Detects whether the device is a Brew-powered device. | [
"Detects",
"whether",
"the",
"device",
"is",
"a",
"Brew",
"-",
"powered",
"device",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1024-L1030 |
32,707 | ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectWapWml | function DetectWapWml()
{
if (stripos($this->httpaccept, $this->vndwap) > -1 ||
stripos($this->httpaccept, $this->wml) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectWapWml()
{
if (stripos($this->httpaccept, $this->vndwap) > -1 ||
stripos($this->httpaccept, $this->wml) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectWapWml",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"httpaccept",
",",
"$",
"this",
"->",
"vndwap",
")",
">",
"-",
"1",
"||",
"stripos",
"(",
"$",
"this",
"->",
"httpaccept",
",",
"$",
"this",
"->",
"wml",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
"false",
";",
"}"
] | Detects whether the device supports WAP or WML. | [
"Detects",
"whether",
"the",
"device",
"supports",
"WAP",
"or",
"WML",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1034-L1041 |
32,708 | ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectMidpCapable | function DetectMidpCapable()
{
if (stripos($this->useragent, $this->deviceMidp) > -1 ||
stripos($this->httpaccept, $this->deviceMidp) > -1)
return $this->true;
else
return $this->false;
} | php | function DetectMidpCapable()
{
if (stripos($this->useragent, $this->deviceMidp) > -1 ||
stripos($this->httpaccept, $this->deviceMidp) > -1)
return $this->true;
else
return $this->false;
} | [
"function",
"DetectMidpCapable",
"(",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"deviceMidp",
")",
">",
"-",
"1",
"||",
"stripos",
"(",
"$",
"this",
"->",
"httpaccept",
",",
"$",
"this",
"->",
"deviceMidp",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
"false",
";",
"}"
] | Detects if the current device supports MIDP, a mobile Java technology. | [
"Detects",
"if",
"the",
"current",
"device",
"supports",
"MIDP",
"a",
"mobile",
"Java",
"technology",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1045-L1052 |
32,709 | ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectMobileQuick | function DetectMobileQuick()
{
if ($this->initCompleted == $this->true ||
$this->isMobilePhone == $this->true)
return $this->isMobilePhone;
//Let's exclude tablets
if ($this->isTierTablet == $this->true)
return $this->false;
//Most mobile browsing is done on smartphones
if ($this->DetectSmartphone() == $this->true)
return $this->true;
//Catch-all for many mobile devices
if (stripos($this->useragent, $this->mobile) > -1)
return $this->true;
if ($this->DetectOperaMobile() == $this->true)
return $this->true;
//We also look for Kindle devices
if ($this->DetectKindle() == $this->true ||
$this->DetectAmazonSilk() == $this->true)
return $this->true;
if (($this->DetectWapWml() == $this->true)
|| ($this->DetectMidpCapable() == $this->true)
|| ($this->DetectBrewDevice() == $this->true))
return $this->true;
if ((stripos($this->useragent, $this->engineNetfront) > -1)
|| (stripos($this->useragent, $this->engineUpBrowser) > -1))
return $this->true;
return $this->false;
} | php | function DetectMobileQuick()
{
if ($this->initCompleted == $this->true ||
$this->isMobilePhone == $this->true)
return $this->isMobilePhone;
//Let's exclude tablets
if ($this->isTierTablet == $this->true)
return $this->false;
//Most mobile browsing is done on smartphones
if ($this->DetectSmartphone() == $this->true)
return $this->true;
//Catch-all for many mobile devices
if (stripos($this->useragent, $this->mobile) > -1)
return $this->true;
if ($this->DetectOperaMobile() == $this->true)
return $this->true;
//We also look for Kindle devices
if ($this->DetectKindle() == $this->true ||
$this->DetectAmazonSilk() == $this->true)
return $this->true;
if (($this->DetectWapWml() == $this->true)
|| ($this->DetectMidpCapable() == $this->true)
|| ($this->DetectBrewDevice() == $this->true))
return $this->true;
if ((stripos($this->useragent, $this->engineNetfront) > -1)
|| (stripos($this->useragent, $this->engineUpBrowser) > -1))
return $this->true;
return $this->false;
} | [
"function",
"DetectMobileQuick",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initCompleted",
"==",
"$",
"this",
"->",
"true",
"||",
"$",
"this",
"->",
"isMobilePhone",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"isMobilePhone",
";",
"//Let's exclude tablets\r",
"if",
"(",
"$",
"this",
"->",
"isTierTablet",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"false",
";",
"//Most mobile browsing is done on smartphones\r",
"if",
"(",
"$",
"this",
"->",
"DetectSmartphone",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"true",
";",
"//Catch-all for many mobile devices\r",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"mobile",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"DetectOperaMobile",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"true",
";",
"//We also look for Kindle devices\r",
"if",
"(",
"$",
"this",
"->",
"DetectKindle",
"(",
")",
"==",
"$",
"this",
"->",
"true",
"||",
"$",
"this",
"->",
"DetectAmazonSilk",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"true",
";",
"if",
"(",
"(",
"$",
"this",
"->",
"DetectWapWml",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"||",
"(",
"$",
"this",
"->",
"DetectMidpCapable",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"||",
"(",
"$",
"this",
"->",
"DetectBrewDevice",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
")",
"return",
"$",
"this",
"->",
"true",
";",
"if",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"engineNetfront",
")",
">",
"-",
"1",
")",
"||",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"engineUpBrowser",
")",
">",
"-",
"1",
")",
")",
"return",
"$",
"this",
"->",
"true",
";",
"return",
"$",
"this",
"->",
"false",
";",
"}"
] | as well as smartphone-class devices. Excludes Apple iPads and other modern tablets. | [
"as",
"well",
"as",
"smartphone",
"-",
"class",
"devices",
".",
"Excludes",
"Apple",
"iPads",
"and",
"other",
"modern",
"tablets",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1082-L1118 |
32,710 | ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectMobileLong | function DetectMobileLong()
{
if ($this->DetectMobileQuick() == $this->true)
return $this->true;
if ($this->DetectGameConsole() == $this->true)
return $this->true;
if (($this->DetectDangerHiptop() == $this->true)
|| ($this->DetectMaemoTablet() == $this->true)
|| ($this->DetectSonyMylo() == $this->true)
|| ($this->DetectArchos() == $this->true))
return $this->true;
if ((stripos($this->useragent, $this->devicePda) > -1) &&
!(stripos($this->useragent, $this->disUpdate) > -1))
return $this->true;
//Detect older phones from certain manufacturers and operators.
if ((stripos($this->useragent, $this->uplink) > -1)
|| (stripos($this->useragent, $this->engineOpenWeb) > -1)
|| (stripos($this->useragent, $this->manuSamsung1) > -1)
|| (stripos($this->useragent, $this->manuSonyEricsson) > -1)
|| (stripos($this->useragent, $this->manuericsson) > -1)
|| (stripos($this->useragent, $this->svcDocomo) > -1)
|| (stripos($this->useragent, $this->svcKddi) > -1)
|| (stripos($this->useragent, $this->svcVodafone) > -1))
return $this->true;
return $this->false;
} | php | function DetectMobileLong()
{
if ($this->DetectMobileQuick() == $this->true)
return $this->true;
if ($this->DetectGameConsole() == $this->true)
return $this->true;
if (($this->DetectDangerHiptop() == $this->true)
|| ($this->DetectMaemoTablet() == $this->true)
|| ($this->DetectSonyMylo() == $this->true)
|| ($this->DetectArchos() == $this->true))
return $this->true;
if ((stripos($this->useragent, $this->devicePda) > -1) &&
!(stripos($this->useragent, $this->disUpdate) > -1))
return $this->true;
//Detect older phones from certain manufacturers and operators.
if ((stripos($this->useragent, $this->uplink) > -1)
|| (stripos($this->useragent, $this->engineOpenWeb) > -1)
|| (stripos($this->useragent, $this->manuSamsung1) > -1)
|| (stripos($this->useragent, $this->manuSonyEricsson) > -1)
|| (stripos($this->useragent, $this->manuericsson) > -1)
|| (stripos($this->useragent, $this->svcDocomo) > -1)
|| (stripos($this->useragent, $this->svcKddi) > -1)
|| (stripos($this->useragent, $this->svcVodafone) > -1))
return $this->true;
return $this->false;
} | [
"function",
"DetectMobileLong",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"DetectMobileQuick",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"DetectGameConsole",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"true",
";",
"if",
"(",
"(",
"$",
"this",
"->",
"DetectDangerHiptop",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"||",
"(",
"$",
"this",
"->",
"DetectMaemoTablet",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"||",
"(",
"$",
"this",
"->",
"DetectSonyMylo",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"||",
"(",
"$",
"this",
"->",
"DetectArchos",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
")",
"return",
"$",
"this",
"->",
"true",
";",
"if",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"devicePda",
")",
">",
"-",
"1",
")",
"&&",
"!",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"disUpdate",
")",
">",
"-",
"1",
")",
")",
"return",
"$",
"this",
"->",
"true",
";",
"//Detect older phones from certain manufacturers and operators. \r",
"if",
"(",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"uplink",
")",
">",
"-",
"1",
")",
"||",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"engineOpenWeb",
")",
">",
"-",
"1",
")",
"||",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"manuSamsung1",
")",
">",
"-",
"1",
")",
"||",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"manuSonyEricsson",
")",
">",
"-",
"1",
")",
"||",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"manuericsson",
")",
">",
"-",
"1",
")",
"||",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"svcDocomo",
")",
">",
"-",
"1",
")",
"||",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"svcKddi",
")",
">",
"-",
"1",
")",
"||",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"svcVodafone",
")",
">",
"-",
"1",
")",
")",
"return",
"$",
"this",
"->",
"true",
";",
"return",
"$",
"this",
"->",
"false",
";",
"}"
] | but no promises on thoroughness! | [
"but",
"no",
"promises",
"on",
"thoroughness!"
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1127-L1156 |
32,711 | ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectTierIphone | function DetectTierIphone()
{
if ($this->initCompleted == $this->true ||
$this->isTierIphone == $this->true)
return $this->isTierIphone;
if (($this->DetectIphoneOrIpod() == $this->true)
|| ($this->DetectAndroidPhone() == $this->true)
|| ($this->DetectWindowsPhone() == $this->true)
|| ($this->DetectBlackBerry10Phone() == $this->true)
|| ($this->DetectPalmWebOS() == $this->true)
|| ($this->DetectBada() == $this->true)
|| ($this->DetectTizen() == $this->true)
|| ($this->DetectFirefoxOSPhone() == $this->true)
|| ($this->DetectSailfishPhone() == $this->true)
|| ($this->DetectUbuntuPhone() == $this->true)
|| ($this->DetectGamingHandheld() == $this->true))
return $this->true;
//Note: BB10 phone is in the previous paragraph
if (($this->DetectBlackBerryWebKit() == $this->true) &&
($this->DetectBlackBerryTouch() == $this->true))
return $this->true;
else
return $this->false;
} | php | function DetectTierIphone()
{
if ($this->initCompleted == $this->true ||
$this->isTierIphone == $this->true)
return $this->isTierIphone;
if (($this->DetectIphoneOrIpod() == $this->true)
|| ($this->DetectAndroidPhone() == $this->true)
|| ($this->DetectWindowsPhone() == $this->true)
|| ($this->DetectBlackBerry10Phone() == $this->true)
|| ($this->DetectPalmWebOS() == $this->true)
|| ($this->DetectBada() == $this->true)
|| ($this->DetectTizen() == $this->true)
|| ($this->DetectFirefoxOSPhone() == $this->true)
|| ($this->DetectSailfishPhone() == $this->true)
|| ($this->DetectUbuntuPhone() == $this->true)
|| ($this->DetectGamingHandheld() == $this->true))
return $this->true;
//Note: BB10 phone is in the previous paragraph
if (($this->DetectBlackBerryWebKit() == $this->true) &&
($this->DetectBlackBerryTouch() == $this->true))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectTierIphone",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initCompleted",
"==",
"$",
"this",
"->",
"true",
"||",
"$",
"this",
"->",
"isTierIphone",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"isTierIphone",
";",
"if",
"(",
"(",
"$",
"this",
"->",
"DetectIphoneOrIpod",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"||",
"(",
"$",
"this",
"->",
"DetectAndroidPhone",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"||",
"(",
"$",
"this",
"->",
"DetectWindowsPhone",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"||",
"(",
"$",
"this",
"->",
"DetectBlackBerry10Phone",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"||",
"(",
"$",
"this",
"->",
"DetectPalmWebOS",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"||",
"(",
"$",
"this",
"->",
"DetectBada",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"||",
"(",
"$",
"this",
"->",
"DetectTizen",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"||",
"(",
"$",
"this",
"->",
"DetectFirefoxOSPhone",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"||",
"(",
"$",
"this",
"->",
"DetectSailfishPhone",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"||",
"(",
"$",
"this",
"->",
"DetectUbuntuPhone",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"||",
"(",
"$",
"this",
"->",
"DetectGamingHandheld",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
")",
"return",
"$",
"this",
"->",
"true",
";",
"//Note: BB10 phone is in the previous paragraph\r",
"if",
"(",
"(",
"$",
"this",
"->",
"DetectBlackBerryWebKit",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"&&",
"(",
"$",
"this",
"->",
"DetectBlackBerryTouch",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
"false",
";",
"}"
] | Includes iPhone, iPod Touch, Android, Windows Phone, BB10, Playstation Vita, etc. | [
"Includes",
"iPhone",
"iPod",
"Touch",
"Android",
"Windows",
"Phone",
"BB10",
"Playstation",
"Vita",
"etc",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1191-L1217 |
32,712 | ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectTierRichCss | function DetectTierRichCss()
{
if ($this->initCompleted == $this->true ||
$this->isTierRichCss == $this->true)
return $this->isTierRichCss;
if ($this->DetectMobileQuick() == $this->true)
{
//Exclude iPhone Tier and e-Ink Kindle devices
if (($this->DetectTierIphone() == $this->true) ||
($this->DetectKindle() == $this->true))
return $this->false;
//The following devices are explicitly ok.
if ($this->DetectWebkit() == $this->true) //Any WebKit
return $this->true;
if ($this->DetectS60OssBrowser() == $this->true)
return $this->true;
//Note: 'High' BlackBerry devices ONLY
if ($this->DetectBlackBerryHigh() == $this->true)
return $this->true;
//Older Windows 'Mobile' isn't good enough for iPhone Tier.
if ($this->DetectWindowsMobile() == $this->true)
return $this->true;
if (stripos($this->useragent, $this->engineTelecaQ) > -1)
return $this->true;
//default
else
return $this->false;
}
else
return $this->false;
} | php | function DetectTierRichCss()
{
if ($this->initCompleted == $this->true ||
$this->isTierRichCss == $this->true)
return $this->isTierRichCss;
if ($this->DetectMobileQuick() == $this->true)
{
//Exclude iPhone Tier and e-Ink Kindle devices
if (($this->DetectTierIphone() == $this->true) ||
($this->DetectKindle() == $this->true))
return $this->false;
//The following devices are explicitly ok.
if ($this->DetectWebkit() == $this->true) //Any WebKit
return $this->true;
if ($this->DetectS60OssBrowser() == $this->true)
return $this->true;
//Note: 'High' BlackBerry devices ONLY
if ($this->DetectBlackBerryHigh() == $this->true)
return $this->true;
//Older Windows 'Mobile' isn't good enough for iPhone Tier.
if ($this->DetectWindowsMobile() == $this->true)
return $this->true;
if (stripos($this->useragent, $this->engineTelecaQ) > -1)
return $this->true;
//default
else
return $this->false;
}
else
return $this->false;
} | [
"function",
"DetectTierRichCss",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initCompleted",
"==",
"$",
"this",
"->",
"true",
"||",
"$",
"this",
"->",
"isTierRichCss",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"isTierRichCss",
";",
"if",
"(",
"$",
"this",
"->",
"DetectMobileQuick",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"{",
"//Exclude iPhone Tier and e-Ink Kindle devices\r",
"if",
"(",
"(",
"$",
"this",
"->",
"DetectTierIphone",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"||",
"(",
"$",
"this",
"->",
"DetectKindle",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
")",
"return",
"$",
"this",
"->",
"false",
";",
"//The following devices are explicitly ok.\r",
"if",
"(",
"$",
"this",
"->",
"DetectWebkit",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"//Any WebKit\r",
"return",
"$",
"this",
"->",
"true",
";",
"if",
"(",
"$",
"this",
"->",
"DetectS60OssBrowser",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"true",
";",
"//Note: 'High' BlackBerry devices ONLY\r",
"if",
"(",
"$",
"this",
"->",
"DetectBlackBerryHigh",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"true",
";",
"//Older Windows 'Mobile' isn't good enough for iPhone Tier. \r",
"if",
"(",
"$",
"this",
"->",
"DetectWindowsMobile",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"true",
";",
"if",
"(",
"stripos",
"(",
"$",
"this",
"->",
"useragent",
",",
"$",
"this",
"->",
"engineTelecaQ",
")",
">",
"-",
"1",
")",
"return",
"$",
"this",
"->",
"true",
";",
"//default\r",
"else",
"return",
"$",
"this",
"->",
"false",
";",
"}",
"else",
"return",
"$",
"this",
"->",
"false",
";",
"}"
] | Excludes all iPhone Tier devices. | [
"Excludes",
"all",
"iPhone",
"Tier",
"devices",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1225-L1260 |
32,713 | ahand/mobileesp | PHP/mdetect.php | uagent_info.DetectTierOtherPhones | function DetectTierOtherPhones()
{
if ($this->initCompleted == $this->true ||
$this->isTierGenericMobile == $this->true)
return $this->isTierGenericMobile;
//Exclude devices in the other 2 categories
if (($this->DetectMobileLong() == $this->true)
&& ($this->DetectTierIphone() == $this->false)
&& ($this->DetectTierRichCss() == $this->false))
return $this->true;
else
return $this->false;
} | php | function DetectTierOtherPhones()
{
if ($this->initCompleted == $this->true ||
$this->isTierGenericMobile == $this->true)
return $this->isTierGenericMobile;
//Exclude devices in the other 2 categories
if (($this->DetectMobileLong() == $this->true)
&& ($this->DetectTierIphone() == $this->false)
&& ($this->DetectTierRichCss() == $this->false))
return $this->true;
else
return $this->false;
} | [
"function",
"DetectTierOtherPhones",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"initCompleted",
"==",
"$",
"this",
"->",
"true",
"||",
"$",
"this",
"->",
"isTierGenericMobile",
"==",
"$",
"this",
"->",
"true",
")",
"return",
"$",
"this",
"->",
"isTierGenericMobile",
";",
"//Exclude devices in the other 2 categories \r",
"if",
"(",
"(",
"$",
"this",
"->",
"DetectMobileLong",
"(",
")",
"==",
"$",
"this",
"->",
"true",
")",
"&&",
"(",
"$",
"this",
"->",
"DetectTierIphone",
"(",
")",
"==",
"$",
"this",
"->",
"false",
")",
"&&",
"(",
"$",
"this",
"->",
"DetectTierRichCss",
"(",
")",
"==",
"$",
"this",
"->",
"false",
")",
")",
"return",
"$",
"this",
"->",
"true",
";",
"else",
"return",
"$",
"this",
"->",
"false",
";",
"}"
] | but excludes the iPhone and RichCSS Tier devices. | [
"but",
"excludes",
"the",
"iPhone",
"and",
"RichCSS",
"Tier",
"devices",
"."
] | c02055dbe9baee63aab11438f4d7b5d25075d347 | https://github.com/ahand/mobileesp/blob/c02055dbe9baee63aab11438f4d7b5d25075d347/PHP/mdetect.php#L1266-L1279 |
32,714 | plank/laravel-metable | src/DataType/Registry.php | Registry.getHandlerForType | public function getHandlerForType(string $type) : HandlerInterface
{
if ($this->hasHandlerForType($type)) {
return $this->handlers[$type];
}
throw DataTypeException::handlerNotFound($type);
} | php | public function getHandlerForType(string $type) : HandlerInterface
{
if ($this->hasHandlerForType($type)) {
return $this->handlers[$type];
}
throw DataTypeException::handlerNotFound($type);
} | [
"public",
"function",
"getHandlerForType",
"(",
"string",
"$",
"type",
")",
":",
"HandlerInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"hasHandlerForType",
"(",
"$",
"type",
")",
")",
"{",
"return",
"$",
"this",
"->",
"handlers",
"[",
"$",
"type",
"]",
";",
"}",
"throw",
"DataTypeException",
"::",
"handlerNotFound",
"(",
"$",
"type",
")",
";",
"}"
] | Retrieve the handler assigned to a given type identifier.
@param string $type
@throws DataTypeException if no handler is found.
@return HandlerInterface | [
"Retrieve",
"the",
"handler",
"assigned",
"to",
"a",
"given",
"type",
"identifier",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/DataType/Registry.php#L43-L50 |
32,715 | plank/laravel-metable | src/DataType/Registry.php | Registry.getTypeForValue | public function getTypeForValue($value) : string
{
foreach ($this->handlers as $type => $handler) {
if ($handler->canHandleValue($value)) {
return $type;
}
}
throw DataTypeException::handlerNotFoundForValue($value);
} | php | public function getTypeForValue($value) : string
{
foreach ($this->handlers as $type => $handler) {
if ($handler->canHandleValue($value)) {
return $type;
}
}
throw DataTypeException::handlerNotFoundForValue($value);
} | [
"public",
"function",
"getTypeForValue",
"(",
"$",
"value",
")",
":",
"string",
"{",
"foreach",
"(",
"$",
"this",
"->",
"handlers",
"as",
"$",
"type",
"=>",
"$",
"handler",
")",
"{",
"if",
"(",
"$",
"handler",
"->",
"canHandleValue",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"type",
";",
"}",
"}",
"throw",
"DataTypeException",
"::",
"handlerNotFoundForValue",
"(",
"$",
"value",
")",
";",
"}"
] | Find a data type Handler that is able to operate on the value, return the type identifier associated with it.
@param mixed $value
@throws DataTypeException if no handler can handle the value.
@return string | [
"Find",
"a",
"data",
"type",
"Handler",
"that",
"is",
"able",
"to",
"operate",
"on",
"the",
"value",
"return",
"the",
"type",
"identifier",
"associated",
"with",
"it",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/DataType/Registry.php#L85-L94 |
32,716 | plank/laravel-metable | src/Metable.php | Metable.setMeta | public function setMeta(string $key, $value)
{
if ($this->hasMeta($key)) {
$meta = $this->getMetaRecord($key);
$meta->setAttribute('value', $value);
$meta->save();
} else {
$meta = $this->makeMeta($key, $value);
$this->meta()->save($meta);
}
// Update cached relationship, if necessary.
if ($this->relationLoaded('meta')) {
$this->meta[$key] = $meta;
}
} | php | public function setMeta(string $key, $value)
{
if ($this->hasMeta($key)) {
$meta = $this->getMetaRecord($key);
$meta->setAttribute('value', $value);
$meta->save();
} else {
$meta = $this->makeMeta($key, $value);
$this->meta()->save($meta);
}
// Update cached relationship, if necessary.
if ($this->relationLoaded('meta')) {
$this->meta[$key] = $meta;
}
} | [
"public",
"function",
"setMeta",
"(",
"string",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasMeta",
"(",
"$",
"key",
")",
")",
"{",
"$",
"meta",
"=",
"$",
"this",
"->",
"getMetaRecord",
"(",
"$",
"key",
")",
";",
"$",
"meta",
"->",
"setAttribute",
"(",
"'value'",
",",
"$",
"value",
")",
";",
"$",
"meta",
"->",
"save",
"(",
")",
";",
"}",
"else",
"{",
"$",
"meta",
"=",
"$",
"this",
"->",
"makeMeta",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"meta",
"(",
")",
"->",
"save",
"(",
"$",
"meta",
")",
";",
"}",
"// Update cached relationship, if necessary.",
"if",
"(",
"$",
"this",
"->",
"relationLoaded",
"(",
"'meta'",
")",
")",
"{",
"$",
"this",
"->",
"meta",
"[",
"$",
"key",
"]",
"=",
"$",
"meta",
";",
"}",
"}"
] | Add or update the value of the `Meta` at a given key.
@param string $key
@param mixed $value | [
"Add",
"or",
"update",
"the",
"value",
"of",
"the",
"Meta",
"at",
"a",
"given",
"key",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L48-L63 |
32,717 | plank/laravel-metable | src/Metable.php | Metable.syncMeta | public function syncMeta($array)
{
$meta = [];
foreach ($array as $key => $value) {
$meta[$key] = $this->makeMeta($key, $value);
}
$this->meta()->delete();
$this->meta()->saveMany($meta);
// Update cached relationship.
$collection = $this->makeMeta()->newCollection($meta);
$this->setRelation('meta', $collection);
} | php | public function syncMeta($array)
{
$meta = [];
foreach ($array as $key => $value) {
$meta[$key] = $this->makeMeta($key, $value);
}
$this->meta()->delete();
$this->meta()->saveMany($meta);
// Update cached relationship.
$collection = $this->makeMeta()->newCollection($meta);
$this->setRelation('meta', $collection);
} | [
"public",
"function",
"syncMeta",
"(",
"$",
"array",
")",
"{",
"$",
"meta",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"meta",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"makeMeta",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"meta",
"(",
")",
"->",
"delete",
"(",
")",
";",
"$",
"this",
"->",
"meta",
"(",
")",
"->",
"saveMany",
"(",
"$",
"meta",
")",
";",
"// Update cached relationship.",
"$",
"collection",
"=",
"$",
"this",
"->",
"makeMeta",
"(",
")",
"->",
"newCollection",
"(",
"$",
"meta",
")",
";",
"$",
"this",
"->",
"setRelation",
"(",
"'meta'",
",",
"$",
"collection",
")",
";",
"}"
] | Replace all associated `Meta` with the keys and values provided.
@param array|Traversable $array
@return void | [
"Replace",
"all",
"associated",
"Meta",
"with",
"the",
"keys",
"and",
"values",
"provided",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L72-L86 |
32,718 | plank/laravel-metable | src/Metable.php | Metable.getMeta | public function getMeta(string $key, $default = null)
{
if ($this->hasMeta($key)) {
return $this->getMetaRecord($key)->getAttribute('value');
}
return $default;
} | php | public function getMeta(string $key, $default = null)
{
if ($this->hasMeta($key)) {
return $this->getMetaRecord($key)->getAttribute('value');
}
return $default;
} | [
"public",
"function",
"getMeta",
"(",
"string",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasMeta",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getMetaRecord",
"(",
"$",
"key",
")",
"->",
"getAttribute",
"(",
"'value'",
")",
";",
"}",
"return",
"$",
"default",
";",
"}"
] | Retrieve the value of the `Meta` at a given key.
@param string $key
@param mixed $default Fallback value if no Meta is found.
@return mixed | [
"Retrieve",
"the",
"value",
"of",
"the",
"Meta",
"at",
"a",
"given",
"key",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L96-L103 |
32,719 | plank/laravel-metable | src/Metable.php | Metable.scopeWhereHasMeta | public function scopeWhereHasMeta(Builder $q, $key)
{
$q->whereHas('meta', function (Builder $q) use ($key) {
$q->whereIn('key', (array) $key);
});
} | php | public function scopeWhereHasMeta(Builder $q, $key)
{
$q->whereHas('meta', function (Builder $q) use ($key) {
$q->whereIn('key', (array) $key);
});
} | [
"public",
"function",
"scopeWhereHasMeta",
"(",
"Builder",
"$",
"q",
",",
"$",
"key",
")",
"{",
"$",
"q",
"->",
"whereHas",
"(",
"'meta'",
",",
"function",
"(",
"Builder",
"$",
"q",
")",
"use",
"(",
"$",
"key",
")",
"{",
"$",
"q",
"->",
"whereIn",
"(",
"'key'",
",",
"(",
"array",
")",
"$",
"key",
")",
";",
"}",
")",
";",
"}"
] | Query scope to restrict the query to records which have `Meta` attached to a given key.
If an array of keys is passed instead, will restrict the query to records having one or more Meta with any of the keys.
@param Builder $q
@param string|array $key
@return void | [
"Query",
"scope",
"to",
"restrict",
"the",
"query",
"to",
"records",
"which",
"have",
"Meta",
"attached",
"to",
"a",
"given",
"key",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L174-L179 |
32,720 | plank/laravel-metable | src/Metable.php | Metable.scopeWhereDoesntHaveMeta | public function scopeWhereDoesntHaveMeta(Builder $q, $key)
{
$q->whereDoesntHave('meta', function (Builder $q) use ($key) {
$q->whereIn('key', (array) $key);
});
} | php | public function scopeWhereDoesntHaveMeta(Builder $q, $key)
{
$q->whereDoesntHave('meta', function (Builder $q) use ($key) {
$q->whereIn('key', (array) $key);
});
} | [
"public",
"function",
"scopeWhereDoesntHaveMeta",
"(",
"Builder",
"$",
"q",
",",
"$",
"key",
")",
"{",
"$",
"q",
"->",
"whereDoesntHave",
"(",
"'meta'",
",",
"function",
"(",
"Builder",
"$",
"q",
")",
"use",
"(",
"$",
"key",
")",
"{",
"$",
"q",
"->",
"whereIn",
"(",
"'key'",
",",
"(",
"array",
")",
"$",
"key",
")",
";",
"}",
")",
";",
"}"
] | Query scope to restrict the query to records which doesnt have `Meta` attached to a given key.
If an array of keys is passed instead, will restrict the query to records having one or more Meta with any of the keys.
@param Builder $q
@param string|array $key
@return void | [
"Query",
"scope",
"to",
"restrict",
"the",
"query",
"to",
"records",
"which",
"doesnt",
"have",
"Meta",
"attached",
"to",
"a",
"given",
"key",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L191-L196 |
32,721 | plank/laravel-metable | src/Metable.php | Metable.scopeWhereHasMetaKeys | public function scopeWhereHasMetaKeys(Builder $q, array $keys)
{
$q->whereHas('meta', function (Builder $q) use ($keys) {
$q->whereIn('key', $keys);
}, '=', count($keys));
} | php | public function scopeWhereHasMetaKeys(Builder $q, array $keys)
{
$q->whereHas('meta', function (Builder $q) use ($keys) {
$q->whereIn('key', $keys);
}, '=', count($keys));
} | [
"public",
"function",
"scopeWhereHasMetaKeys",
"(",
"Builder",
"$",
"q",
",",
"array",
"$",
"keys",
")",
"{",
"$",
"q",
"->",
"whereHas",
"(",
"'meta'",
",",
"function",
"(",
"Builder",
"$",
"q",
")",
"use",
"(",
"$",
"keys",
")",
"{",
"$",
"q",
"->",
"whereIn",
"(",
"'key'",
",",
"$",
"keys",
")",
";",
"}",
",",
"'='",
",",
"count",
"(",
"$",
"keys",
")",
")",
";",
"}"
] | Query scope to restrict the query to records which have `Meta` for all of the provided keys.
@param Builder $q
@param array $keys
@return void | [
"Query",
"scope",
"to",
"restrict",
"the",
"query",
"to",
"records",
"which",
"have",
"Meta",
"for",
"all",
"of",
"the",
"provided",
"keys",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L206-L211 |
32,722 | plank/laravel-metable | src/Metable.php | Metable.scopeWhereMeta | public function scopeWhereMeta(Builder $q, string $key, $operator, $value = null)
{
// Shift arguments if no operator is present.
if (!isset($value)) {
$value = $operator;
$operator = '=';
}
// Convert value to its serialized version for comparison.
if (!is_string($value)) {
$value = $this->makeMeta($key, $value)->getRawValue();
}
$q->whereHas('meta', function (Builder $q) use ($key, $operator, $value) {
$q->where('key', $key);
$q->where('value', $operator, $value);
});
} | php | public function scopeWhereMeta(Builder $q, string $key, $operator, $value = null)
{
// Shift arguments if no operator is present.
if (!isset($value)) {
$value = $operator;
$operator = '=';
}
// Convert value to its serialized version for comparison.
if (!is_string($value)) {
$value = $this->makeMeta($key, $value)->getRawValue();
}
$q->whereHas('meta', function (Builder $q) use ($key, $operator, $value) {
$q->where('key', $key);
$q->where('value', $operator, $value);
});
} | [
"public",
"function",
"scopeWhereMeta",
"(",
"Builder",
"$",
"q",
",",
"string",
"$",
"key",
",",
"$",
"operator",
",",
"$",
"value",
"=",
"null",
")",
"{",
"// Shift arguments if no operator is present.",
"if",
"(",
"!",
"isset",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"operator",
";",
"$",
"operator",
"=",
"'='",
";",
"}",
"// Convert value to its serialized version for comparison.",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"makeMeta",
"(",
"$",
"key",
",",
"$",
"value",
")",
"->",
"getRawValue",
"(",
")",
";",
"}",
"$",
"q",
"->",
"whereHas",
"(",
"'meta'",
",",
"function",
"(",
"Builder",
"$",
"q",
")",
"use",
"(",
"$",
"key",
",",
"$",
"operator",
",",
"$",
"value",
")",
"{",
"$",
"q",
"->",
"where",
"(",
"'key'",
",",
"$",
"key",
")",
";",
"$",
"q",
"->",
"where",
"(",
"'value'",
",",
"$",
"operator",
",",
"$",
"value",
")",
";",
"}",
")",
";",
"}"
] | Query scope to restrict the query to records which have `Meta` with a specific key and value.
If the `$value` parameter is omitted, the $operator parameter will be considered the value.
Values will be serialized to a string before comparison. If using the `>`, `>=`, `<`, or `<=` comparison operators, note that the value will be compared as a string. If comparing numeric values, use `Metable::scopeWhereMetaNumeric()` instead.
@param Builder $q
@param string $key
@param mixed $operator
@param mixed $value
@return void | [
"Query",
"scope",
"to",
"restrict",
"the",
"query",
"to",
"records",
"which",
"have",
"Meta",
"with",
"a",
"specific",
"key",
"and",
"value",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L227-L244 |
32,723 | plank/laravel-metable | src/Metable.php | Metable.scopeWhereMetaNumeric | public function scopeWhereMetaNumeric(Builder $q, string $key, string $operator, $value)
{
// Since we are manually interpolating into the query,
// escape the operator to protect against injection.
$validOperators = ['<', '<=', '>', '>=', '=', '<>', '!='];
$operator = in_array($operator, $validOperators) ? $operator : '=';
$field = $q->getQuery()->getGrammar()->wrap($this->meta()->getRelated()->getTable().'.value');
$q->whereHas('meta', function (Builder $q) use ($key, $operator, $value, $field) {
$q->where('key', $key);
$q->whereRaw("cast({$field} as decimal) {$operator} ?", [(float) $value]);
});
} | php | public function scopeWhereMetaNumeric(Builder $q, string $key, string $operator, $value)
{
// Since we are manually interpolating into the query,
// escape the operator to protect against injection.
$validOperators = ['<', '<=', '>', '>=', '=', '<>', '!='];
$operator = in_array($operator, $validOperators) ? $operator : '=';
$field = $q->getQuery()->getGrammar()->wrap($this->meta()->getRelated()->getTable().'.value');
$q->whereHas('meta', function (Builder $q) use ($key, $operator, $value, $field) {
$q->where('key', $key);
$q->whereRaw("cast({$field} as decimal) {$operator} ?", [(float) $value]);
});
} | [
"public",
"function",
"scopeWhereMetaNumeric",
"(",
"Builder",
"$",
"q",
",",
"string",
"$",
"key",
",",
"string",
"$",
"operator",
",",
"$",
"value",
")",
"{",
"// Since we are manually interpolating into the query,",
"// escape the operator to protect against injection.",
"$",
"validOperators",
"=",
"[",
"'<'",
",",
"'<='",
",",
"'>'",
",",
"'>='",
",",
"'='",
",",
"'<>'",
",",
"'!='",
"]",
";",
"$",
"operator",
"=",
"in_array",
"(",
"$",
"operator",
",",
"$",
"validOperators",
")",
"?",
"$",
"operator",
":",
"'='",
";",
"$",
"field",
"=",
"$",
"q",
"->",
"getQuery",
"(",
")",
"->",
"getGrammar",
"(",
")",
"->",
"wrap",
"(",
"$",
"this",
"->",
"meta",
"(",
")",
"->",
"getRelated",
"(",
")",
"->",
"getTable",
"(",
")",
".",
"'.value'",
")",
";",
"$",
"q",
"->",
"whereHas",
"(",
"'meta'",
",",
"function",
"(",
"Builder",
"$",
"q",
")",
"use",
"(",
"$",
"key",
",",
"$",
"operator",
",",
"$",
"value",
",",
"$",
"field",
")",
"{",
"$",
"q",
"->",
"where",
"(",
"'key'",
",",
"$",
"key",
")",
";",
"$",
"q",
"->",
"whereRaw",
"(",
"\"cast({$field} as decimal) {$operator} ?\"",
",",
"[",
"(",
"float",
")",
"$",
"value",
"]",
")",
";",
"}",
")",
";",
"}"
] | Query scope to restrict the query to records which have `Meta` with a specific key and numeric value.
Performs numeric comparison instead of string comparison.
@param Builder $q
@param string $key
@param string $operator
@param int|float $value
@return void | [
"Query",
"scope",
"to",
"restrict",
"the",
"query",
"to",
"records",
"which",
"have",
"Meta",
"with",
"a",
"specific",
"key",
"and",
"numeric",
"value",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L258-L270 |
32,724 | plank/laravel-metable | src/Metable.php | Metable.scopeWhereMetaIn | public function scopeWhereMetaIn(Builder $q, string $key, array $values)
{
$values = array_map(function ($val) use ($key) {
return is_string($val) ? $val : $this->makeMeta($key, $val)->getRawValue();
}, $values);
$q->whereHas('meta', function (Builder $q) use ($key, $values) {
$q->where('key', $key);
$q->whereIn('value', $values);
});
} | php | public function scopeWhereMetaIn(Builder $q, string $key, array $values)
{
$values = array_map(function ($val) use ($key) {
return is_string($val) ? $val : $this->makeMeta($key, $val)->getRawValue();
}, $values);
$q->whereHas('meta', function (Builder $q) use ($key, $values) {
$q->where('key', $key);
$q->whereIn('value', $values);
});
} | [
"public",
"function",
"scopeWhereMetaIn",
"(",
"Builder",
"$",
"q",
",",
"string",
"$",
"key",
",",
"array",
"$",
"values",
")",
"{",
"$",
"values",
"=",
"array_map",
"(",
"function",
"(",
"$",
"val",
")",
"use",
"(",
"$",
"key",
")",
"{",
"return",
"is_string",
"(",
"$",
"val",
")",
"?",
"$",
"val",
":",
"$",
"this",
"->",
"makeMeta",
"(",
"$",
"key",
",",
"$",
"val",
")",
"->",
"getRawValue",
"(",
")",
";",
"}",
",",
"$",
"values",
")",
";",
"$",
"q",
"->",
"whereHas",
"(",
"'meta'",
",",
"function",
"(",
"Builder",
"$",
"q",
")",
"use",
"(",
"$",
"key",
",",
"$",
"values",
")",
"{",
"$",
"q",
"->",
"where",
"(",
"'key'",
",",
"$",
"key",
")",
";",
"$",
"q",
"->",
"whereIn",
"(",
"'value'",
",",
"$",
"values",
")",
";",
"}",
")",
";",
"}"
] | Query scope to restrict the query to records which have `Meta` with a specific key and a value within a specified set of options.
@param Builder $q
@param string $key
@param array $values
@return void | [
"Query",
"scope",
"to",
"restrict",
"the",
"query",
"to",
"records",
"which",
"have",
"Meta",
"with",
"a",
"specific",
"key",
"and",
"a",
"value",
"within",
"a",
"specified",
"set",
"of",
"options",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L281-L291 |
32,725 | plank/laravel-metable | src/Metable.php | Metable.scopeOrderByMeta | public function scopeOrderByMeta(Builder $q, string $key, string $direction = 'asc', $strict = false)
{
$table = $this->joinMetaTable($q, $key, $strict ? 'inner' : 'left');
$q->orderBy("{$table}.value", $direction);
} | php | public function scopeOrderByMeta(Builder $q, string $key, string $direction = 'asc', $strict = false)
{
$table = $this->joinMetaTable($q, $key, $strict ? 'inner' : 'left');
$q->orderBy("{$table}.value", $direction);
} | [
"public",
"function",
"scopeOrderByMeta",
"(",
"Builder",
"$",
"q",
",",
"string",
"$",
"key",
",",
"string",
"$",
"direction",
"=",
"'asc'",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"joinMetaTable",
"(",
"$",
"q",
",",
"$",
"key",
",",
"$",
"strict",
"?",
"'inner'",
":",
"'left'",
")",
";",
"$",
"q",
"->",
"orderBy",
"(",
"\"{$table}.value\"",
",",
"$",
"direction",
")",
";",
"}"
] | Query scope to order the query results by the string value of an attached meta.
@param Builder $q
@param string $key
@param string $direction
@param bool $strict if true, will exclude records that do not have meta for the provided `$key`.
@return void | [
"Query",
"scope",
"to",
"order",
"the",
"query",
"results",
"by",
"the",
"string",
"value",
"of",
"an",
"attached",
"meta",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L303-L307 |
32,726 | plank/laravel-metable | src/Metable.php | Metable.scopeOrderByMetaNumeric | public function scopeOrderByMetaNumeric(Builder $q, string $key, string $direction = 'asc', $strict = false)
{
$table = $this->joinMetaTable($q, $key, $strict ? 'inner' : 'left');
$direction = strtolower($direction) == 'asc' ? 'asc' : 'desc';
$field = $q->getQuery()->getGrammar()->wrap("{$table}.value");
$q->orderByRaw("cast({$field} as decimal) $direction");
} | php | public function scopeOrderByMetaNumeric(Builder $q, string $key, string $direction = 'asc', $strict = false)
{
$table = $this->joinMetaTable($q, $key, $strict ? 'inner' : 'left');
$direction = strtolower($direction) == 'asc' ? 'asc' : 'desc';
$field = $q->getQuery()->getGrammar()->wrap("{$table}.value");
$q->orderByRaw("cast({$field} as decimal) $direction");
} | [
"public",
"function",
"scopeOrderByMetaNumeric",
"(",
"Builder",
"$",
"q",
",",
"string",
"$",
"key",
",",
"string",
"$",
"direction",
"=",
"'asc'",
",",
"$",
"strict",
"=",
"false",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"joinMetaTable",
"(",
"$",
"q",
",",
"$",
"key",
",",
"$",
"strict",
"?",
"'inner'",
":",
"'left'",
")",
";",
"$",
"direction",
"=",
"strtolower",
"(",
"$",
"direction",
")",
"==",
"'asc'",
"?",
"'asc'",
":",
"'desc'",
";",
"$",
"field",
"=",
"$",
"q",
"->",
"getQuery",
"(",
")",
"->",
"getGrammar",
"(",
")",
"->",
"wrap",
"(",
"\"{$table}.value\"",
")",
";",
"$",
"q",
"->",
"orderByRaw",
"(",
"\"cast({$field} as decimal) $direction\"",
")",
";",
"}"
] | Query scope to order the query results by the numeric value of an attached meta.
@param Builder $q
@param string $key
@param string $direction
@param bool $strict if true, will exclude records that do not have meta for the provided `$key`.
@return void | [
"Query",
"scope",
"to",
"order",
"the",
"query",
"results",
"by",
"the",
"numeric",
"value",
"of",
"an",
"attached",
"meta",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L319-L326 |
32,727 | plank/laravel-metable | src/Metable.php | Metable.joinMetaTable | private function joinMetaTable(Builder $q, string $key, $type = 'left')
{
$relation = $this->meta();
$metaTable = $relation->getRelated()->getTable();
// Create an alias for the join, to allow the same
// table to be joined multiple times for different keys.
$alias = $metaTable.'__'.$key;
// If no explicit select columns are specified,
// avoid column collision by excluding meta table from select.
if (!$q->getQuery()->columns) {
$q->select($this->getTable().'.*');
}
// Join the meta table to the query
$q->join("{$metaTable} as {$alias}", function (JoinClause $q) use ($relation, $key, $alias) {
// Laravel 5.4 changed the method names here
$foreign_key = method_exists($relation, 'getForeignKeyName') ? $relation->getForeignKeyName() : $relation->getPlainForeignKey();
$type = method_exists($relation, 'getForeignKeyName') ? $relation->getMorphType() : $relation->getPlainMorphType();
$q->on($relation->getQualifiedParentKeyName(), '=', $alias.'.'.$foreign_key)
->where($alias.'.key', '=', $key)
->where($alias.'.'.$type, '=', get_class($this));
}, null, null, $type);
// Return the alias so that the calling context can
// reference the table.
return $alias;
} | php | private function joinMetaTable(Builder $q, string $key, $type = 'left')
{
$relation = $this->meta();
$metaTable = $relation->getRelated()->getTable();
// Create an alias for the join, to allow the same
// table to be joined multiple times for different keys.
$alias = $metaTable.'__'.$key;
// If no explicit select columns are specified,
// avoid column collision by excluding meta table from select.
if (!$q->getQuery()->columns) {
$q->select($this->getTable().'.*');
}
// Join the meta table to the query
$q->join("{$metaTable} as {$alias}", function (JoinClause $q) use ($relation, $key, $alias) {
// Laravel 5.4 changed the method names here
$foreign_key = method_exists($relation, 'getForeignKeyName') ? $relation->getForeignKeyName() : $relation->getPlainForeignKey();
$type = method_exists($relation, 'getForeignKeyName') ? $relation->getMorphType() : $relation->getPlainMorphType();
$q->on($relation->getQualifiedParentKeyName(), '=', $alias.'.'.$foreign_key)
->where($alias.'.key', '=', $key)
->where($alias.'.'.$type, '=', get_class($this));
}, null, null, $type);
// Return the alias so that the calling context can
// reference the table.
return $alias;
} | [
"private",
"function",
"joinMetaTable",
"(",
"Builder",
"$",
"q",
",",
"string",
"$",
"key",
",",
"$",
"type",
"=",
"'left'",
")",
"{",
"$",
"relation",
"=",
"$",
"this",
"->",
"meta",
"(",
")",
";",
"$",
"metaTable",
"=",
"$",
"relation",
"->",
"getRelated",
"(",
")",
"->",
"getTable",
"(",
")",
";",
"// Create an alias for the join, to allow the same",
"// table to be joined multiple times for different keys.",
"$",
"alias",
"=",
"$",
"metaTable",
".",
"'__'",
".",
"$",
"key",
";",
"// If no explicit select columns are specified,",
"// avoid column collision by excluding meta table from select.",
"if",
"(",
"!",
"$",
"q",
"->",
"getQuery",
"(",
")",
"->",
"columns",
")",
"{",
"$",
"q",
"->",
"select",
"(",
"$",
"this",
"->",
"getTable",
"(",
")",
".",
"'.*'",
")",
";",
"}",
"// Join the meta table to the query",
"$",
"q",
"->",
"join",
"(",
"\"{$metaTable} as {$alias}\"",
",",
"function",
"(",
"JoinClause",
"$",
"q",
")",
"use",
"(",
"$",
"relation",
",",
"$",
"key",
",",
"$",
"alias",
")",
"{",
"// Laravel 5.4 changed the method names here",
"$",
"foreign_key",
"=",
"method_exists",
"(",
"$",
"relation",
",",
"'getForeignKeyName'",
")",
"?",
"$",
"relation",
"->",
"getForeignKeyName",
"(",
")",
":",
"$",
"relation",
"->",
"getPlainForeignKey",
"(",
")",
";",
"$",
"type",
"=",
"method_exists",
"(",
"$",
"relation",
",",
"'getForeignKeyName'",
")",
"?",
"$",
"relation",
"->",
"getMorphType",
"(",
")",
":",
"$",
"relation",
"->",
"getPlainMorphType",
"(",
")",
";",
"$",
"q",
"->",
"on",
"(",
"$",
"relation",
"->",
"getQualifiedParentKeyName",
"(",
")",
",",
"'='",
",",
"$",
"alias",
".",
"'.'",
".",
"$",
"foreign_key",
")",
"->",
"where",
"(",
"$",
"alias",
".",
"'.key'",
",",
"'='",
",",
"$",
"key",
")",
"->",
"where",
"(",
"$",
"alias",
".",
"'.'",
".",
"$",
"type",
",",
"'='",
",",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"}",
",",
"null",
",",
"null",
",",
"$",
"type",
")",
";",
"// Return the alias so that the calling context can",
"// reference the table.",
"return",
"$",
"alias",
";",
"}"
] | Join the meta table to the query.
@param Builder $q
@param string $key
@param string $type Join type.
@return string | [
"Join",
"the",
"meta",
"table",
"to",
"the",
"query",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L337-L366 |
32,728 | plank/laravel-metable | src/Metable.php | Metable.getMetaCollection | private function getMetaCollection()
{
if (!$this->relationLoaded('meta')) {
$this->setRelation('meta', $this->meta()->get());
}
return $this->getRelation('meta');
} | php | private function getMetaCollection()
{
if (!$this->relationLoaded('meta')) {
$this->setRelation('meta', $this->meta()->get());
}
return $this->getRelation('meta');
} | [
"private",
"function",
"getMetaCollection",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"relationLoaded",
"(",
"'meta'",
")",
")",
"{",
"$",
"this",
"->",
"setRelation",
"(",
"'meta'",
",",
"$",
"this",
"->",
"meta",
"(",
")",
"->",
"get",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getRelation",
"(",
"'meta'",
")",
";",
"}"
] | fetch all meta for the model, if necessary.
In Laravel versions prior to 5.3, relations that are lazy loaded by the
`getRelationFromMethod()` method ( invoked by the `__get()` magic method)
are not passed through the `setRelation()` method, so we load the relation
manually.
@return mixed | [
"fetch",
"all",
"meta",
"for",
"the",
"model",
"if",
"necessary",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L378-L385 |
32,729 | plank/laravel-metable | src/Metable.php | Metable.makeMeta | protected function makeMeta(string $key = '', $value = '') : Meta
{
$className = $this->getMetaClassName();
$meta = new $className([
'key' => $key,
'value' => $value,
]);
return $meta;
} | php | protected function makeMeta(string $key = '', $value = '') : Meta
{
$className = $this->getMetaClassName();
$meta = new $className([
'key' => $key,
'value' => $value,
]);
return $meta;
} | [
"protected",
"function",
"makeMeta",
"(",
"string",
"$",
"key",
"=",
"''",
",",
"$",
"value",
"=",
"''",
")",
":",
"Meta",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"getMetaClassName",
"(",
")",
";",
"$",
"meta",
"=",
"new",
"$",
"className",
"(",
"[",
"'key'",
"=>",
"$",
"key",
",",
"'value'",
"=>",
"$",
"value",
",",
"]",
")",
";",
"return",
"$",
"meta",
";",
"}"
] | Create a new `Meta` record.
@param string $key
@param mixed $value
@return Meta | [
"Create",
"a",
"new",
"Meta",
"record",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Metable.php#L418-L428 |
32,730 | plank/laravel-metable | src/DataType/ModelCollectionHandler.php | ModelCollectionHandler.loadModels | private function loadModels(array $items)
{
$classes = [];
$results = [];
// Retrieve a list of keys to load from each class.
foreach ($items as $item) {
if (!is_null($item['key'])) {
$classes[$item['class']][] = $item['key'];
}
}
// Iterate list of classes and load all records matching a key.
foreach ($classes as $class => $keys) {
$model = new $class();
$results[$class] = $model->whereIn($model->getKeyName(), $keys)->get()->keyBy($model->getKeyName());
}
return $results;
} | php | private function loadModels(array $items)
{
$classes = [];
$results = [];
// Retrieve a list of keys to load from each class.
foreach ($items as $item) {
if (!is_null($item['key'])) {
$classes[$item['class']][] = $item['key'];
}
}
// Iterate list of classes and load all records matching a key.
foreach ($classes as $class => $keys) {
$model = new $class();
$results[$class] = $model->whereIn($model->getKeyName(), $keys)->get()->keyBy($model->getKeyName());
}
return $results;
} | [
"private",
"function",
"loadModels",
"(",
"array",
"$",
"items",
")",
"{",
"$",
"classes",
"=",
"[",
"]",
";",
"$",
"results",
"=",
"[",
"]",
";",
"// Retrieve a list of keys to load from each class.",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"item",
"[",
"'key'",
"]",
")",
")",
"{",
"$",
"classes",
"[",
"$",
"item",
"[",
"'class'",
"]",
"]",
"[",
"]",
"=",
"$",
"item",
"[",
"'key'",
"]",
";",
"}",
"}",
"// Iterate list of classes and load all records matching a key.",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"class",
"=>",
"$",
"keys",
")",
"{",
"$",
"model",
"=",
"new",
"$",
"class",
"(",
")",
";",
"$",
"results",
"[",
"$",
"class",
"]",
"=",
"$",
"model",
"->",
"whereIn",
"(",
"$",
"model",
"->",
"getKeyName",
"(",
")",
",",
"$",
"keys",
")",
"->",
"get",
"(",
")",
"->",
"keyBy",
"(",
"$",
"model",
"->",
"getKeyName",
"(",
")",
")",
";",
"}",
"return",
"$",
"results",
";",
"}"
] | Load each model instance, grouped by class.
@param array $items
@return array | [
"Load",
"each",
"model",
"instance",
"grouped",
"by",
"class",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/DataType/ModelCollectionHandler.php#L75-L94 |
32,731 | plank/laravel-metable | src/MetableServiceProvider.php | MetableServiceProvider.registerDataTypeRegistry | protected function registerDataTypeRegistry()
{
$this->app->singleton(Registry::class, function () {
$registry = new Registry();
foreach (config('metable.datatypes') as $handler) {
$registry->addHandler(new $handler());
}
return $registry;
});
$this->app->alias(Registry::class, 'metable.datatype.registry');
} | php | protected function registerDataTypeRegistry()
{
$this->app->singleton(Registry::class, function () {
$registry = new Registry();
foreach (config('metable.datatypes') as $handler) {
$registry->addHandler(new $handler());
}
return $registry;
});
$this->app->alias(Registry::class, 'metable.datatype.registry');
} | [
"protected",
"function",
"registerDataTypeRegistry",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"Registry",
"::",
"class",
",",
"function",
"(",
")",
"{",
"$",
"registry",
"=",
"new",
"Registry",
"(",
")",
";",
"foreach",
"(",
"config",
"(",
"'metable.datatypes'",
")",
"as",
"$",
"handler",
")",
"{",
"$",
"registry",
"->",
"addHandler",
"(",
"new",
"$",
"handler",
"(",
")",
")",
";",
"}",
"return",
"$",
"registry",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"Registry",
"::",
"class",
",",
"'metable.datatype.registry'",
")",
";",
"}"
] | Add the DataType Registry to the service container.
@return void | [
"Add",
"the",
"DataType",
"Registry",
"to",
"the",
"service",
"container",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/MetableServiceProvider.php#L53-L64 |
32,732 | plank/laravel-metable | src/Meta.php | Meta.getValueAttribute | public function getValueAttribute()
{
if (!isset($this->cachedValue)) {
$this->cachedValue = $this->getDataTypeRegistry()
->getHandlerForType($this->type)
->unserializeValue($this->attributes['value']);
}
return $this->cachedValue;
} | php | public function getValueAttribute()
{
if (!isset($this->cachedValue)) {
$this->cachedValue = $this->getDataTypeRegistry()
->getHandlerForType($this->type)
->unserializeValue($this->attributes['value']);
}
return $this->cachedValue;
} | [
"public",
"function",
"getValueAttribute",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cachedValue",
")",
")",
"{",
"$",
"this",
"->",
"cachedValue",
"=",
"$",
"this",
"->",
"getDataTypeRegistry",
"(",
")",
"->",
"getHandlerForType",
"(",
"$",
"this",
"->",
"type",
")",
"->",
"unserializeValue",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'value'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cachedValue",
";",
"}"
] | Accessor for value.
Will unserialize the value before returning it.
Successive access will be loaded from cache.
@return mixed | [
"Accessor",
"for",
"value",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Meta.php#L65-L74 |
32,733 | plank/laravel-metable | src/Meta.php | Meta.setValueAttribute | public function setValueAttribute($value)
{
$registry = $this->getDataTypeRegistry();
$this->attributes['type'] = $registry->getTypeForValue($value);
$this->attributes['value'] = $registry->getHandlerForType($this->type)
->serializeValue($value);
$this->cachedValue = null;
} | php | public function setValueAttribute($value)
{
$registry = $this->getDataTypeRegistry();
$this->attributes['type'] = $registry->getTypeForValue($value);
$this->attributes['value'] = $registry->getHandlerForType($this->type)
->serializeValue($value);
$this->cachedValue = null;
} | [
"public",
"function",
"setValueAttribute",
"(",
"$",
"value",
")",
"{",
"$",
"registry",
"=",
"$",
"this",
"->",
"getDataTypeRegistry",
"(",
")",
";",
"$",
"this",
"->",
"attributes",
"[",
"'type'",
"]",
"=",
"$",
"registry",
"->",
"getTypeForValue",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"attributes",
"[",
"'value'",
"]",
"=",
"$",
"registry",
"->",
"getHandlerForType",
"(",
"$",
"this",
"->",
"type",
")",
"->",
"serializeValue",
"(",
"$",
"value",
")",
";",
"$",
"this",
"->",
"cachedValue",
"=",
"null",
";",
"}"
] | Mutator for value.
The `type` attribute will be automatically updated to match the datatype of the input.
@param mixed $value | [
"Mutator",
"for",
"value",
"."
] | 414aa3707d8f91170e505ed7228bb74e31d8e35b | https://github.com/plank/laravel-metable/blob/414aa3707d8f91170e505ed7228bb74e31d8e35b/src/Meta.php#L83-L92 |
32,734 | SimplyCodedSoftware/integration-messaging | src/Messaging/Config/MessagingSystemConfiguration.php | MessagingSystemConfiguration.buildMessagingSystemFromConfiguration | public function buildMessagingSystemFromConfiguration(ReferenceSearchService $referenceSearchService): ConfiguredMessagingSystem
{
foreach ($this->messageHandlerBuilders as $messageHandlerBuilder) {
if (!array_key_exists($messageHandlerBuilder->getInputMessageChannelName(), $this->channelBuilders)) {
if (array_key_exists($messageHandlerBuilder->getInputMessageChannelName(), $this->defaultChannelBuilders)) {
$this->channelBuilders[$messageHandlerBuilder->getInputMessageChannelName()] = $this->defaultChannelBuilders[$messageHandlerBuilder->getInputMessageChannelName()];
} else {
$this->channelBuilders[$messageHandlerBuilder->getInputMessageChannelName()] = SimpleMessageChannelBuilder::createDirectMessageChannel($messageHandlerBuilder->getInputMessageChannelName());
}
}
}
$interfaceToCallRegistry = InterfaceToCallRegistry::createWithInterfaces($this->interfacesToCall);
$converters = [];
foreach ($this->converterBuilders as $converterBuilder) {
$converters[] = $converterBuilder->build($referenceSearchService);
}
$referenceSearchService = InMemoryReferenceSearchService::createWithReferenceService($referenceSearchService, [
ConversionService::REFERENCE_NAME => AutoCollectionConversionService::createWith($converters),
InterfaceToCallRegistry::REFERENCE_NAME => $interfaceToCallRegistry
]);
$channelResolver = $this->createChannelResolver($referenceSearchService);
$this->configureInterceptors($interfaceToCallRegistry);
/** @var GatewayBuilder[][] $preparedGateways */
$preparedGateways = [];
foreach ($this->gatewayBuilders as $gatewayBuilder) {
$preparedGateways[$gatewayBuilder->getReferenceName()][] = $gatewayBuilder;
}
$gateways = $this->configureGateways($preparedGateways, $referenceSearchService, $channelResolver);
$consumerEndpointFactory = new ConsumerEndpointFactory($channelResolver, $referenceSearchService, $this->consumerFactories, $this->pollingMetadata);
$consumers = [];
foreach ($this->messageHandlerBuilders as $messageHandlerBuilder) {
$consumers[] = $consumerEndpointFactory->createForMessageHandler($messageHandlerBuilder);
}
foreach ($this->channelAdapters as $channelAdapter) {
$consumers[] = $channelAdapter->build($channelResolver, $referenceSearchService, array_key_exists($channelAdapter->getEndpointId(), $this->pollingMetadata) ? $this->pollingMetadata[$channelAdapter->getEndpointId()] : null);
}
return MessagingSystem::create($consumers, $gateways, $channelResolver);
} | php | public function buildMessagingSystemFromConfiguration(ReferenceSearchService $referenceSearchService): ConfiguredMessagingSystem
{
foreach ($this->messageHandlerBuilders as $messageHandlerBuilder) {
if (!array_key_exists($messageHandlerBuilder->getInputMessageChannelName(), $this->channelBuilders)) {
if (array_key_exists($messageHandlerBuilder->getInputMessageChannelName(), $this->defaultChannelBuilders)) {
$this->channelBuilders[$messageHandlerBuilder->getInputMessageChannelName()] = $this->defaultChannelBuilders[$messageHandlerBuilder->getInputMessageChannelName()];
} else {
$this->channelBuilders[$messageHandlerBuilder->getInputMessageChannelName()] = SimpleMessageChannelBuilder::createDirectMessageChannel($messageHandlerBuilder->getInputMessageChannelName());
}
}
}
$interfaceToCallRegistry = InterfaceToCallRegistry::createWithInterfaces($this->interfacesToCall);
$converters = [];
foreach ($this->converterBuilders as $converterBuilder) {
$converters[] = $converterBuilder->build($referenceSearchService);
}
$referenceSearchService = InMemoryReferenceSearchService::createWithReferenceService($referenceSearchService, [
ConversionService::REFERENCE_NAME => AutoCollectionConversionService::createWith($converters),
InterfaceToCallRegistry::REFERENCE_NAME => $interfaceToCallRegistry
]);
$channelResolver = $this->createChannelResolver($referenceSearchService);
$this->configureInterceptors($interfaceToCallRegistry);
/** @var GatewayBuilder[][] $preparedGateways */
$preparedGateways = [];
foreach ($this->gatewayBuilders as $gatewayBuilder) {
$preparedGateways[$gatewayBuilder->getReferenceName()][] = $gatewayBuilder;
}
$gateways = $this->configureGateways($preparedGateways, $referenceSearchService, $channelResolver);
$consumerEndpointFactory = new ConsumerEndpointFactory($channelResolver, $referenceSearchService, $this->consumerFactories, $this->pollingMetadata);
$consumers = [];
foreach ($this->messageHandlerBuilders as $messageHandlerBuilder) {
$consumers[] = $consumerEndpointFactory->createForMessageHandler($messageHandlerBuilder);
}
foreach ($this->channelAdapters as $channelAdapter) {
$consumers[] = $channelAdapter->build($channelResolver, $referenceSearchService, array_key_exists($channelAdapter->getEndpointId(), $this->pollingMetadata) ? $this->pollingMetadata[$channelAdapter->getEndpointId()] : null);
}
return MessagingSystem::create($consumers, $gateways, $channelResolver);
} | [
"public",
"function",
"buildMessagingSystemFromConfiguration",
"(",
"ReferenceSearchService",
"$",
"referenceSearchService",
")",
":",
"ConfiguredMessagingSystem",
"{",
"foreach",
"(",
"$",
"this",
"->",
"messageHandlerBuilders",
"as",
"$",
"messageHandlerBuilder",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"messageHandlerBuilder",
"->",
"getInputMessageChannelName",
"(",
")",
",",
"$",
"this",
"->",
"channelBuilders",
")",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"messageHandlerBuilder",
"->",
"getInputMessageChannelName",
"(",
")",
",",
"$",
"this",
"->",
"defaultChannelBuilders",
")",
")",
"{",
"$",
"this",
"->",
"channelBuilders",
"[",
"$",
"messageHandlerBuilder",
"->",
"getInputMessageChannelName",
"(",
")",
"]",
"=",
"$",
"this",
"->",
"defaultChannelBuilders",
"[",
"$",
"messageHandlerBuilder",
"->",
"getInputMessageChannelName",
"(",
")",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"channelBuilders",
"[",
"$",
"messageHandlerBuilder",
"->",
"getInputMessageChannelName",
"(",
")",
"]",
"=",
"SimpleMessageChannelBuilder",
"::",
"createDirectMessageChannel",
"(",
"$",
"messageHandlerBuilder",
"->",
"getInputMessageChannelName",
"(",
")",
")",
";",
"}",
"}",
"}",
"$",
"interfaceToCallRegistry",
"=",
"InterfaceToCallRegistry",
"::",
"createWithInterfaces",
"(",
"$",
"this",
"->",
"interfacesToCall",
")",
";",
"$",
"converters",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"converterBuilders",
"as",
"$",
"converterBuilder",
")",
"{",
"$",
"converters",
"[",
"]",
"=",
"$",
"converterBuilder",
"->",
"build",
"(",
"$",
"referenceSearchService",
")",
";",
"}",
"$",
"referenceSearchService",
"=",
"InMemoryReferenceSearchService",
"::",
"createWithReferenceService",
"(",
"$",
"referenceSearchService",
",",
"[",
"ConversionService",
"::",
"REFERENCE_NAME",
"=>",
"AutoCollectionConversionService",
"::",
"createWith",
"(",
"$",
"converters",
")",
",",
"InterfaceToCallRegistry",
"::",
"REFERENCE_NAME",
"=>",
"$",
"interfaceToCallRegistry",
"]",
")",
";",
"$",
"channelResolver",
"=",
"$",
"this",
"->",
"createChannelResolver",
"(",
"$",
"referenceSearchService",
")",
";",
"$",
"this",
"->",
"configureInterceptors",
"(",
"$",
"interfaceToCallRegistry",
")",
";",
"/** @var GatewayBuilder[][] $preparedGateways */",
"$",
"preparedGateways",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"gatewayBuilders",
"as",
"$",
"gatewayBuilder",
")",
"{",
"$",
"preparedGateways",
"[",
"$",
"gatewayBuilder",
"->",
"getReferenceName",
"(",
")",
"]",
"[",
"]",
"=",
"$",
"gatewayBuilder",
";",
"}",
"$",
"gateways",
"=",
"$",
"this",
"->",
"configureGateways",
"(",
"$",
"preparedGateways",
",",
"$",
"referenceSearchService",
",",
"$",
"channelResolver",
")",
";",
"$",
"consumerEndpointFactory",
"=",
"new",
"ConsumerEndpointFactory",
"(",
"$",
"channelResolver",
",",
"$",
"referenceSearchService",
",",
"$",
"this",
"->",
"consumerFactories",
",",
"$",
"this",
"->",
"pollingMetadata",
")",
";",
"$",
"consumers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"messageHandlerBuilders",
"as",
"$",
"messageHandlerBuilder",
")",
"{",
"$",
"consumers",
"[",
"]",
"=",
"$",
"consumerEndpointFactory",
"->",
"createForMessageHandler",
"(",
"$",
"messageHandlerBuilder",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"channelAdapters",
"as",
"$",
"channelAdapter",
")",
"{",
"$",
"consumers",
"[",
"]",
"=",
"$",
"channelAdapter",
"->",
"build",
"(",
"$",
"channelResolver",
",",
"$",
"referenceSearchService",
",",
"array_key_exists",
"(",
"$",
"channelAdapter",
"->",
"getEndpointId",
"(",
")",
",",
"$",
"this",
"->",
"pollingMetadata",
")",
"?",
"$",
"this",
"->",
"pollingMetadata",
"[",
"$",
"channelAdapter",
"->",
"getEndpointId",
"(",
")",
"]",
":",
"null",
")",
";",
"}",
"return",
"MessagingSystem",
"::",
"create",
"(",
"$",
"consumers",
",",
"$",
"gateways",
",",
"$",
"channelResolver",
")",
";",
"}"
] | Initialize messaging system from current configuration
@param ReferenceSearchService $referenceSearchService
@return ConfiguredMessagingSystem
@throws NoConsumerFactoryForBuilderException
@throws MessagingException | [
"Initialize",
"messaging",
"system",
"from",
"current",
"configuration"
] | d2d19c64f115adb554952962853a047d40be08bd | https://github.com/SimplyCodedSoftware/integration-messaging/blob/d2d19c64f115adb554952962853a047d40be08bd/src/Messaging/Config/MessagingSystemConfiguration.php#L430-L475 |
32,735 | opis-colibri/framework | src/ItemCollectors/RouteCollector.php | RouteCollector.all | public function all(string $path, callable $action, string $name = null): HttpRoute
{
return $this->handle($path, $action, ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'], $name);
} | php | public function all(string $path, callable $action, string $name = null): HttpRoute
{
return $this->handle($path, $action, ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'], $name);
} | [
"public",
"function",
"all",
"(",
"string",
"$",
"path",
",",
"callable",
"$",
"action",
",",
"string",
"$",
"name",
"=",
"null",
")",
":",
"HttpRoute",
"{",
"return",
"$",
"this",
"->",
"handle",
"(",
"$",
"path",
",",
"$",
"action",
",",
"[",
"'GET'",
",",
"'POST'",
",",
"'PUT'",
",",
"'PATCH'",
",",
"'DELETE'",
"]",
",",
"$",
"name",
")",
";",
"}"
] | Defines a new route that will intercept all HTTP requests
@param string $path The path to match
@param callable $action An action that will be executed
@param string $name (optional) Route name
@return HttpRoute | [
"Defines",
"a",
"new",
"route",
"that",
"will",
"intercept",
"all",
"HTTP",
"requests"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/ItemCollectors/RouteCollector.php#L113-L116 |
32,736 | opis-colibri/framework | src/ItemCollectors/RouteCollector.php | RouteCollector.handle | protected function handle(string $path, callable $action, $method, string $name = null): HttpRoute
{
if (!is_array($method)) {
$method = [$method];
}
/** @var HttpRoute $route */
$route = $this->data->createRoute($this->prefix . $path, $action, $name);
$route->method(...$method);
return $route;
} | php | protected function handle(string $path, callable $action, $method, string $name = null): HttpRoute
{
if (!is_array($method)) {
$method = [$method];
}
/** @var HttpRoute $route */
$route = $this->data->createRoute($this->prefix . $path, $action, $name);
$route->method(...$method);
return $route;
} | [
"protected",
"function",
"handle",
"(",
"string",
"$",
"path",
",",
"callable",
"$",
"action",
",",
"$",
"method",
",",
"string",
"$",
"name",
"=",
"null",
")",
":",
"HttpRoute",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"method",
")",
")",
"{",
"$",
"method",
"=",
"[",
"$",
"method",
"]",
";",
"}",
"/** @var HttpRoute $route */",
"$",
"route",
"=",
"$",
"this",
"->",
"data",
"->",
"createRoute",
"(",
"$",
"this",
"->",
"prefix",
".",
"$",
"path",
",",
"$",
"action",
",",
"$",
"name",
")",
";",
"$",
"route",
"->",
"method",
"(",
"...",
"$",
"method",
")",
";",
"return",
"$",
"route",
";",
"}"
] | Defines a new route
@param string $path The path to match
@param callable $action An action that will be executed
@param string|array $method Request's method
@param string $name (optional) Route name
@return HttpRoute | [
"Defines",
"a",
"new",
"route"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/ItemCollectors/RouteCollector.php#L198-L207 |
32,737 | zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Menu/Builder.php | Builder.build | public function build($name, Request $request)
{
$ret = $this->factory->createItem($name);
$menus = $this->loadRoots($request);
if (!isset($menus[$name])) {
return $ret;
}
$requestLocale = $request->get('_locale');
if (!isset($this->menus[$requestLocale][$name])) {
$rootIdToNameMap = array_combine(array_column($menus, 0), array_keys($menus));
if (in_array($name, $this->preloadMenus)) {
$menusToLoad = [];
foreach ($this->preloadMenus as $preloadMenuName) {
if (!isset($menus[$preloadMenuName])) {
continue;
}
$menusToLoad[$preloadMenuName] = $menus[$preloadMenuName];
}
} else {
$menusToLoad[$name] = $menus[$name];
}
$query = 'SELECT root, menu_item.* FROM menu_item WHERE ';
$i = 0;
// `$vals` contains [id, lft, rgt]
foreach ($menusToLoad as $vals) {
if ($i ++ > 0) {
$query .= ' OR ';
}
$query .= vsprintf('(root=%d AND lft BETWEEN %d AND %d AND id <> root)', $vals);
}
$query .= ' ORDER BY root, lft';
foreach ($this->em->getConnection()->query($query)->fetchAll(\PDO::FETCH_GROUP) as $rootId => $menu) {
if (!isset($rootIdToNameMap)) {
continue;
}
$menuName = $rootIdToNameMap[$rootId];
$this->menus[$requestLocale][$menuName]= $this->factory->createItem($menuName);
$this->addMenuItemHierarchy(
$request,
$this->menuItemEntity->buildTree($menu),
$this->menus[$requestLocale][$menuName]
);
}
}
if (isset($this->menus[$requestLocale][$name])) {
$ret = $this->menus[$requestLocale][$name];
if (is_callable([$ret, 'setCurrentUri'])) {
$ret->setCurrentUri($request->getRequestUri());
}
}
return $ret;
} | php | public function build($name, Request $request)
{
$ret = $this->factory->createItem($name);
$menus = $this->loadRoots($request);
if (!isset($menus[$name])) {
return $ret;
}
$requestLocale = $request->get('_locale');
if (!isset($this->menus[$requestLocale][$name])) {
$rootIdToNameMap = array_combine(array_column($menus, 0), array_keys($menus));
if (in_array($name, $this->preloadMenus)) {
$menusToLoad = [];
foreach ($this->preloadMenus as $preloadMenuName) {
if (!isset($menus[$preloadMenuName])) {
continue;
}
$menusToLoad[$preloadMenuName] = $menus[$preloadMenuName];
}
} else {
$menusToLoad[$name] = $menus[$name];
}
$query = 'SELECT root, menu_item.* FROM menu_item WHERE ';
$i = 0;
// `$vals` contains [id, lft, rgt]
foreach ($menusToLoad as $vals) {
if ($i ++ > 0) {
$query .= ' OR ';
}
$query .= vsprintf('(root=%d AND lft BETWEEN %d AND %d AND id <> root)', $vals);
}
$query .= ' ORDER BY root, lft';
foreach ($this->em->getConnection()->query($query)->fetchAll(\PDO::FETCH_GROUP) as $rootId => $menu) {
if (!isset($rootIdToNameMap)) {
continue;
}
$menuName = $rootIdToNameMap[$rootId];
$this->menus[$requestLocale][$menuName]= $this->factory->createItem($menuName);
$this->addMenuItemHierarchy(
$request,
$this->menuItemEntity->buildTree($menu),
$this->menus[$requestLocale][$menuName]
);
}
}
if (isset($this->menus[$requestLocale][$name])) {
$ret = $this->menus[$requestLocale][$name];
if (is_callable([$ret, 'setCurrentUri'])) {
$ret->setCurrentUri($request->getRequestUri());
}
}
return $ret;
} | [
"public",
"function",
"build",
"(",
"$",
"name",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"factory",
"->",
"createItem",
"(",
"$",
"name",
")",
";",
"$",
"menus",
"=",
"$",
"this",
"->",
"loadRoots",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"menus",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"ret",
";",
"}",
"$",
"requestLocale",
"=",
"$",
"request",
"->",
"get",
"(",
"'_locale'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"menus",
"[",
"$",
"requestLocale",
"]",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"rootIdToNameMap",
"=",
"array_combine",
"(",
"array_column",
"(",
"$",
"menus",
",",
"0",
")",
",",
"array_keys",
"(",
"$",
"menus",
")",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"preloadMenus",
")",
")",
"{",
"$",
"menusToLoad",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"preloadMenus",
"as",
"$",
"preloadMenuName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"menus",
"[",
"$",
"preloadMenuName",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"menusToLoad",
"[",
"$",
"preloadMenuName",
"]",
"=",
"$",
"menus",
"[",
"$",
"preloadMenuName",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"menusToLoad",
"[",
"$",
"name",
"]",
"=",
"$",
"menus",
"[",
"$",
"name",
"]",
";",
"}",
"$",
"query",
"=",
"'SELECT root, menu_item.* FROM menu_item WHERE '",
";",
"$",
"i",
"=",
"0",
";",
"// `$vals` contains [id, lft, rgt]",
"foreach",
"(",
"$",
"menusToLoad",
"as",
"$",
"vals",
")",
"{",
"if",
"(",
"$",
"i",
"++",
">",
"0",
")",
"{",
"$",
"query",
".=",
"' OR '",
";",
"}",
"$",
"query",
".=",
"vsprintf",
"(",
"'(root=%d AND lft BETWEEN %d AND %d AND id <> root)'",
",",
"$",
"vals",
")",
";",
"}",
"$",
"query",
".=",
"' ORDER BY root, lft'",
";",
"foreach",
"(",
"$",
"this",
"->",
"em",
"->",
"getConnection",
"(",
")",
"->",
"query",
"(",
"$",
"query",
")",
"->",
"fetchAll",
"(",
"\\",
"PDO",
"::",
"FETCH_GROUP",
")",
"as",
"$",
"rootId",
"=>",
"$",
"menu",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"rootIdToNameMap",
")",
")",
"{",
"continue",
";",
"}",
"$",
"menuName",
"=",
"$",
"rootIdToNameMap",
"[",
"$",
"rootId",
"]",
";",
"$",
"this",
"->",
"menus",
"[",
"$",
"requestLocale",
"]",
"[",
"$",
"menuName",
"]",
"=",
"$",
"this",
"->",
"factory",
"->",
"createItem",
"(",
"$",
"menuName",
")",
";",
"$",
"this",
"->",
"addMenuItemHierarchy",
"(",
"$",
"request",
",",
"$",
"this",
"->",
"menuItemEntity",
"->",
"buildTree",
"(",
"$",
"menu",
")",
",",
"$",
"this",
"->",
"menus",
"[",
"$",
"requestLocale",
"]",
"[",
"$",
"menuName",
"]",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"menus",
"[",
"$",
"requestLocale",
"]",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"menus",
"[",
"$",
"requestLocale",
"]",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"is_callable",
"(",
"[",
"$",
"ret",
",",
"'setCurrentUri'",
"]",
")",
")",
"{",
"$",
"ret",
"->",
"setCurrentUri",
"(",
"$",
"request",
"->",
"getRequestUri",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | Create the menu based on the doctrine model.
@param string $name
@param \Symfony\Component\HttpFoundation\Request $request
@return ItemInterface
@throws \InvalidArgumentException | [
"Create",
"the",
"menu",
"based",
"on",
"the",
"doctrine",
"model",
"."
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Menu/Builder.php#L103-L166 |
32,738 | zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Menu/Builder.php | Builder.getRootItemByName | public function getRootItemByName($name, $request)
{
$menus = $this->loadRoots($request);
if (!isset($menus[$name])) {
return null;
}
return $this->menuItemEntity->find($menus[$name][0]);
} | php | public function getRootItemByName($name, $request)
{
$menus = $this->loadRoots($request);
if (!isset($menus[$name])) {
return null;
}
return $this->menuItemEntity->find($menus[$name][0]);
} | [
"public",
"function",
"getRootItemByName",
"(",
"$",
"name",
",",
"$",
"request",
")",
"{",
"$",
"menus",
"=",
"$",
"this",
"->",
"loadRoots",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"menus",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"menuItemEntity",
"->",
"find",
"(",
"$",
"menus",
"[",
"$",
"name",
"]",
"[",
"0",
"]",
")",
";",
"}"
] | Get the root item based on the specified name and request.
@param string $name
@param Request $request
@return mixed | [
"Get",
"the",
"root",
"item",
"based",
"on",
"the",
"specified",
"name",
"and",
"request",
"."
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Menu/Builder.php#L175-L184 |
32,739 | zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Menu/Builder.php | Builder.hasRootItemByName | public function hasRootItemByName($name, $request)
{
$menus = $this->loadRoots($request);
return isset($menus[$name]);
} | php | public function hasRootItemByName($name, $request)
{
$menus = $this->loadRoots($request);
return isset($menus[$name]);
} | [
"public",
"function",
"hasRootItemByName",
"(",
"$",
"name",
",",
"$",
"request",
")",
"{",
"$",
"menus",
"=",
"$",
"this",
"->",
"loadRoots",
"(",
"$",
"request",
")",
";",
"return",
"isset",
"(",
"$",
"menus",
"[",
"$",
"name",
"]",
")",
";",
"}"
] | Check if a root item exists.
@param string $name
@param Request $request
@return bool | [
"Check",
"if",
"a",
"root",
"item",
"exists",
"."
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Menu/Builder.php#L193-L197 |
32,740 | zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Menu/Builder.php | Builder.loadRoots | protected function loadRoots(Request $request)
{
$locale = $request->get('_locale', $this->defaultLocale);
if (isset($this->roots[$locale])) {
return $this->roots[$locale];
}
$connection = $this->em->getConnection();
$where = 'lvl=0';
if ($locale) {
$where .= sprintf(' AND (language IS NULL OR language=%s)', $connection->quote($locale));
} else {
$where .= ' AND language IS NULL';
}
$rows = $connection->query('SELECT id, name, language, lft, rgt FROM menu_item WHERE ' . $where)->fetchAll(\PDO::FETCH_NUM);
foreach ($rows as list($id, $name, $language, $lft, $rgt)) {
// if the language is null, and the root items is already loaded; ignore it.
if (null === $language && isset($this->roots[$name])) {
continue;
}
$this->roots[$locale][$name] = [$id, $lft, $rgt];
}
if (!isset($this->roots[$locale])) {
return [];
}
return $this->roots[$locale];
} | php | protected function loadRoots(Request $request)
{
$locale = $request->get('_locale', $this->defaultLocale);
if (isset($this->roots[$locale])) {
return $this->roots[$locale];
}
$connection = $this->em->getConnection();
$where = 'lvl=0';
if ($locale) {
$where .= sprintf(' AND (language IS NULL OR language=%s)', $connection->quote($locale));
} else {
$where .= ' AND language IS NULL';
}
$rows = $connection->query('SELECT id, name, language, lft, rgt FROM menu_item WHERE ' . $where)->fetchAll(\PDO::FETCH_NUM);
foreach ($rows as list($id, $name, $language, $lft, $rgt)) {
// if the language is null, and the root items is already loaded; ignore it.
if (null === $language && isset($this->roots[$name])) {
continue;
}
$this->roots[$locale][$name] = [$id, $lft, $rgt];
}
if (!isset($this->roots[$locale])) {
return [];
}
return $this->roots[$locale];
} | [
"protected",
"function",
"loadRoots",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"locale",
"=",
"$",
"request",
"->",
"get",
"(",
"'_locale'",
",",
"$",
"this",
"->",
"defaultLocale",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"roots",
"[",
"$",
"locale",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"roots",
"[",
"$",
"locale",
"]",
";",
"}",
"$",
"connection",
"=",
"$",
"this",
"->",
"em",
"->",
"getConnection",
"(",
")",
";",
"$",
"where",
"=",
"'lvl=0'",
";",
"if",
"(",
"$",
"locale",
")",
"{",
"$",
"where",
".=",
"sprintf",
"(",
"' AND (language IS NULL OR language=%s)'",
",",
"$",
"connection",
"->",
"quote",
"(",
"$",
"locale",
")",
")",
";",
"}",
"else",
"{",
"$",
"where",
".=",
"' AND language IS NULL'",
";",
"}",
"$",
"rows",
"=",
"$",
"connection",
"->",
"query",
"(",
"'SELECT id, name, language, lft, rgt FROM menu_item WHERE '",
".",
"$",
"where",
")",
"->",
"fetchAll",
"(",
"\\",
"PDO",
"::",
"FETCH_NUM",
")",
";",
"foreach",
"(",
"$",
"rows",
"as",
"list",
"(",
"$",
"id",
",",
"$",
"name",
",",
"$",
"language",
",",
"$",
"lft",
",",
"$",
"rgt",
")",
")",
"{",
"// if the language is null, and the root items is already loaded; ignore it.",
"if",
"(",
"null",
"===",
"$",
"language",
"&&",
"isset",
"(",
"$",
"this",
"->",
"roots",
"[",
"$",
"name",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"roots",
"[",
"$",
"locale",
"]",
"[",
"$",
"name",
"]",
"=",
"[",
"$",
"id",
",",
"$",
"lft",
",",
"$",
"rgt",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"roots",
"[",
"$",
"locale",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"roots",
"[",
"$",
"locale",
"]",
";",
"}"
] | Preload all roots for the specified locale.
@param Request $request
@return array | [
"Preload",
"all",
"roots",
"for",
"the",
"specified",
"locale",
"."
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Menu/Builder.php#L205-L237 |
32,741 | zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Menu/Builder.php | Builder.addMenuItemHierarchy | public function addMenuItemHierarchy($request, $children, $parent)
{
$ret = 0;
foreach ($children as $child) {
$ret++;
$item = $this->addMenuItem($request, $child, $parent);
if (!empty($child['__children'])) {
$ret += $this->addMenuItemHierarchy($request, $child['__children'], $item);
}
}
return $ret;
} | php | public function addMenuItemHierarchy($request, $children, $parent)
{
$ret = 0;
foreach ($children as $child) {
$ret++;
$item = $this->addMenuItem($request, $child, $parent);
if (!empty($child['__children'])) {
$ret += $this->addMenuItemHierarchy($request, $child['__children'], $item);
}
}
return $ret;
} | [
"public",
"function",
"addMenuItemHierarchy",
"(",
"$",
"request",
",",
"$",
"children",
",",
"$",
"parent",
")",
"{",
"$",
"ret",
"=",
"0",
";",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child",
")",
"{",
"$",
"ret",
"++",
";",
"$",
"item",
"=",
"$",
"this",
"->",
"addMenuItem",
"(",
"$",
"request",
",",
"$",
"child",
",",
"$",
"parent",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"child",
"[",
"'__children'",
"]",
")",
")",
"{",
"$",
"ret",
"+=",
"$",
"this",
"->",
"addMenuItemHierarchy",
"(",
"$",
"request",
",",
"$",
"child",
"[",
"'__children'",
"]",
",",
"$",
"item",
")",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] | Add menu item hierarchy
@param Request $request
@param mixed $children
@param ItemInterface $parent
@return int | [
"Add",
"menu",
"item",
"hierarchy"
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Menu/Builder.php#L271-L282 |
32,742 | zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Menu/Builder.php | Builder.addMenuItem | public function addMenuItem(Request $request, array $item, MenuItem $menu)
{
$attributes = array();
// if the menu item has a name, add it as a css class.
if ($name = $item['name']) {
$attributes['class'] = $name;
}
if (empty($item['path'])) {
$uri = null;
} elseif (preg_match('!^(?:https?://|mailto:)!', $item['path'])) {
$uri = $item['path'];
} else {
$baseUrl = $request->getBaseUrl();
$uri = $baseUrl . '/' . ltrim($item['path'], '/');
}
$menuItem = $menu->addChild(
$item['id'],
array(
'uri' => $uri,
'attributes' => $attributes,
'label' => $item['title']
)
);
if (!empty($item['json_data'])) {
$item['json_data'] = @json_decode($item['json_data']);
}
$menuItem->setExtras($item);
return $menuItem;
} | php | public function addMenuItem(Request $request, array $item, MenuItem $menu)
{
$attributes = array();
// if the menu item has a name, add it as a css class.
if ($name = $item['name']) {
$attributes['class'] = $name;
}
if (empty($item['path'])) {
$uri = null;
} elseif (preg_match('!^(?:https?://|mailto:)!', $item['path'])) {
$uri = $item['path'];
} else {
$baseUrl = $request->getBaseUrl();
$uri = $baseUrl . '/' . ltrim($item['path'], '/');
}
$menuItem = $menu->addChild(
$item['id'],
array(
'uri' => $uri,
'attributes' => $attributes,
'label' => $item['title']
)
);
if (!empty($item['json_data'])) {
$item['json_data'] = @json_decode($item['json_data']);
}
$menuItem->setExtras($item);
return $menuItem;
} | [
"public",
"function",
"addMenuItem",
"(",
"Request",
"$",
"request",
",",
"array",
"$",
"item",
",",
"MenuItem",
"$",
"menu",
")",
"{",
"$",
"attributes",
"=",
"array",
"(",
")",
";",
"// if the menu item has a name, add it as a css class.",
"if",
"(",
"$",
"name",
"=",
"$",
"item",
"[",
"'name'",
"]",
")",
"{",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"$",
"name",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"item",
"[",
"'path'",
"]",
")",
")",
"{",
"$",
"uri",
"=",
"null",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'!^(?:https?://|mailto:)!'",
",",
"$",
"item",
"[",
"'path'",
"]",
")",
")",
"{",
"$",
"uri",
"=",
"$",
"item",
"[",
"'path'",
"]",
";",
"}",
"else",
"{",
"$",
"baseUrl",
"=",
"$",
"request",
"->",
"getBaseUrl",
"(",
")",
";",
"$",
"uri",
"=",
"$",
"baseUrl",
".",
"'/'",
".",
"ltrim",
"(",
"$",
"item",
"[",
"'path'",
"]",
",",
"'/'",
")",
";",
"}",
"$",
"menuItem",
"=",
"$",
"menu",
"->",
"addChild",
"(",
"$",
"item",
"[",
"'id'",
"]",
",",
"array",
"(",
"'uri'",
"=>",
"$",
"uri",
",",
"'attributes'",
"=>",
"$",
"attributes",
",",
"'label'",
"=>",
"$",
"item",
"[",
"'title'",
"]",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'json_data'",
"]",
")",
")",
"{",
"$",
"item",
"[",
"'json_data'",
"]",
"=",
"@",
"json_decode",
"(",
"$",
"item",
"[",
"'json_data'",
"]",
")",
";",
"}",
"$",
"menuItem",
"->",
"setExtras",
"(",
"$",
"item",
")",
";",
"return",
"$",
"menuItem",
";",
"}"
] | Utility method to convert MenuItem's from the doctrine model to Knp MenuItems
@param \Symfony\Component\HttpFoundation\Request $request
@param array $item
@param MenuItem $menu
@return ItemInterface | [
"Utility",
"method",
"to",
"convert",
"MenuItem",
"s",
"from",
"the",
"doctrine",
"model",
"to",
"Knp",
"MenuItems"
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Menu/Builder.php#L293-L325 |
32,743 | zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Menu/Builder.php | Builder.addGhostItem | public function addGhostItem(Request $request, $item)
{
$item->addChild(
$this->factory->createItem(
$item['id'],
array(
'uri' => $request->getRequestUri(),
'display' => false,
'label' => $item['title']
)
)
);
} | php | public function addGhostItem(Request $request, $item)
{
$item->addChild(
$this->factory->createItem(
$item['id'],
array(
'uri' => $request->getRequestUri(),
'display' => false,
'label' => $item['title']
)
)
);
} | [
"public",
"function",
"addGhostItem",
"(",
"Request",
"$",
"request",
",",
"$",
"item",
")",
"{",
"$",
"item",
"->",
"addChild",
"(",
"$",
"this",
"->",
"factory",
"->",
"createItem",
"(",
"$",
"item",
"[",
"'id'",
"]",
",",
"array",
"(",
"'uri'",
"=>",
"$",
"request",
"->",
"getRequestUri",
"(",
")",
",",
"'display'",
"=>",
"false",
",",
"'label'",
"=>",
"$",
"item",
"[",
"'title'",
"]",
")",
")",
")",
";",
"}"
] | Adds an item on the fly that was not originally in the menu.
@param \Symfony\Component\HttpFoundation\Request $request
@param ItemInterface $item
@return void | [
"Adds",
"an",
"item",
"on",
"the",
"fly",
"that",
"was",
"not",
"originally",
"in",
"the",
"menu",
"."
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Menu/Builder.php#L334-L346 |
32,744 | SimplyCodedSoftware/integration-messaging | src/Messaging/Handler/Enricher/Converter/EnrichPayloadWithExpressionBuilder.php | EnrichPayloadWithExpressionBuilder.createWithMapping | public static function createWithMapping(string $propertyPath, string $expression, string $mappingExpression) : self
{
return new self($propertyPath, $expression, $mappingExpression);
} | php | public static function createWithMapping(string $propertyPath, string $expression, string $mappingExpression) : self
{
return new self($propertyPath, $expression, $mappingExpression);
} | [
"public",
"static",
"function",
"createWithMapping",
"(",
"string",
"$",
"propertyPath",
",",
"string",
"$",
"expression",
",",
"string",
"$",
"mappingExpression",
")",
":",
"self",
"{",
"return",
"new",
"self",
"(",
"$",
"propertyPath",
",",
"$",
"expression",
",",
"$",
"mappingExpression",
")",
";",
"}"
] | Enrich multiple paths
@param string $propertyPath path to enriched context e.g. [orders][*][person]
@param string $expression should return array, that will be mapped to set in property path e.g. payload
@param string $mappingExpression when evaluates to true, then specific element is put in property path e.g. requestContext['personId'] == replyContext['personId']
@return EnrichPayloadWithExpressionBuilder | [
"Enrich",
"multiple",
"paths"
] | d2d19c64f115adb554952962853a047d40be08bd | https://github.com/SimplyCodedSoftware/integration-messaging/blob/d2d19c64f115adb554952962853a047d40be08bd/src/Messaging/Handler/Enricher/Converter/EnrichPayloadWithExpressionBuilder.php#L81-L84 |
32,745 | SimplyCodedSoftware/integration-messaging | src/Messaging/Handler/TypeDescriptor.php | TypeDescriptor.resolveGenericTypes | public function resolveGenericTypes() : array
{
if (!$this->isCollection()) {
throw InvalidArgumentException::create("Can't resolve collection type on non collection");
}
preg_match(self::COLLECTION_TYPE_REGEX, $this->type, $match);
return [TypeDescriptor::create(trim($match[1]))];
} | php | public function resolveGenericTypes() : array
{
if (!$this->isCollection()) {
throw InvalidArgumentException::create("Can't resolve collection type on non collection");
}
preg_match(self::COLLECTION_TYPE_REGEX, $this->type, $match);
return [TypeDescriptor::create(trim($match[1]))];
} | [
"public",
"function",
"resolveGenericTypes",
"(",
")",
":",
"array",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isCollection",
"(",
")",
")",
"{",
"throw",
"InvalidArgumentException",
"::",
"create",
"(",
"\"Can't resolve collection type on non collection\"",
")",
";",
"}",
"preg_match",
"(",
"self",
"::",
"COLLECTION_TYPE_REGEX",
",",
"$",
"this",
"->",
"type",
",",
"$",
"match",
")",
";",
"return",
"[",
"TypeDescriptor",
"::",
"create",
"(",
"trim",
"(",
"$",
"match",
"[",
"1",
"]",
")",
")",
"]",
";",
"}"
] | Should be called only, if type descriptor is collection
@return TypeDescriptor[]
@throws InvalidArgumentException
@throws \SimplyCodedSoftware\Messaging\MessagingException | [
"Should",
"be",
"called",
"only",
"if",
"type",
"descriptor",
"is",
"collection"
] | d2d19c64f115adb554952962853a047d40be08bd | https://github.com/SimplyCodedSoftware/integration-messaging/blob/d2d19c64f115adb554952962853a047d40be08bd/src/Messaging/Handler/TypeDescriptor.php#L182-L191 |
32,746 | opis-colibri/framework | src/Application.php | Application.getHttpRouter | public function getHttpRouter(): HttpRouter
{
if ($this->httpRouter === null) {
$this->httpRouter = new HttpRouter($this);
}
return $this->httpRouter;
} | php | public function getHttpRouter(): HttpRouter
{
if ($this->httpRouter === null) {
$this->httpRouter = new HttpRouter($this);
}
return $this->httpRouter;
} | [
"public",
"function",
"getHttpRouter",
"(",
")",
":",
"HttpRouter",
"{",
"if",
"(",
"$",
"this",
"->",
"httpRouter",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"httpRouter",
"=",
"new",
"HttpRouter",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
"->",
"httpRouter",
";",
"}"
] | Get the HTTP router
@return HttpRouter | [
"Get",
"the",
"HTTP",
"router"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/Application.php#L237-L244 |
32,747 | opis-colibri/framework | src/Application.php | Application.getContainer | public function getContainer(): Container
{
if ($this->containerInstance === null) {
$this->containerInstance = $this->getCollector()->getContracts();
}
return $this->containerInstance;
} | php | public function getContainer(): Container
{
if ($this->containerInstance === null) {
$this->containerInstance = $this->getCollector()->getContracts();
}
return $this->containerInstance;
} | [
"public",
"function",
"getContainer",
"(",
")",
":",
"Container",
"{",
"if",
"(",
"$",
"this",
"->",
"containerInstance",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"containerInstance",
"=",
"$",
"this",
"->",
"getCollector",
"(",
")",
"->",
"getContracts",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"containerInstance",
";",
"}"
] | Return the dependency injection container
@return Container | [
"Return",
"the",
"dependency",
"injection",
"container"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/Application.php#L287-L294 |
32,748 | opis-colibri/framework | src/Application.php | Application.getPlaceholder | public function getPlaceholder(): Placeholder
{
if ($this->placeholderInstance === null) {
$this->placeholderInstance = new Placeholder();
}
return $this->placeholderInstance;
} | php | public function getPlaceholder(): Placeholder
{
if ($this->placeholderInstance === null) {
$this->placeholderInstance = new Placeholder();
}
return $this->placeholderInstance;
} | [
"public",
"function",
"getPlaceholder",
"(",
")",
":",
"Placeholder",
"{",
"if",
"(",
"$",
"this",
"->",
"placeholderInstance",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"placeholderInstance",
"=",
"new",
"Placeholder",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"placeholderInstance",
";",
"}"
] | Get a placeholder object
@return Placeholder | [
"Get",
"a",
"placeholder",
"object"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/Application.php#L338-L345 |
32,749 | opis-colibri/framework | src/Application.php | Application.getValidator | public function getValidator(): Validator
{
if ($this->validator === null) {
$this->validator = new Validator(new ValidatorCollection(), $this->getPlaceholder());
}
return $this->validator;
} | php | public function getValidator(): Validator
{
if ($this->validator === null) {
$this->validator = new Validator(new ValidatorCollection(), $this->getPlaceholder());
}
return $this->validator;
} | [
"public",
"function",
"getValidator",
"(",
")",
":",
"Validator",
"{",
"if",
"(",
"$",
"this",
"->",
"validator",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"validator",
"=",
"new",
"Validator",
"(",
"new",
"ValidatorCollection",
"(",
")",
",",
"$",
"this",
"->",
"getPlaceholder",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"validator",
";",
"}"
] | Returns validator instance
@return Validator | [
"Returns",
"validator",
"instance"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/Application.php#L352-L359 |
32,750 | opis-colibri/framework | src/Application.php | Application.getCache | public function getCache(string $storage = 'default'): CacheInterface
{
if (!isset($this->cache[$storage])) {
if ($storage === 'default') {
if (!isset($this->implicit['cache'])) {
throw new \RuntimeException('The default cache storage was not set');
}
$this->cache[$storage] = $this->implicit['cache'];
} else {
$this->cache[$storage] = $this->getCollector()->getCacheDriver($storage);
}
}
return $this->cache[$storage];
} | php | public function getCache(string $storage = 'default'): CacheInterface
{
if (!isset($this->cache[$storage])) {
if ($storage === 'default') {
if (!isset($this->implicit['cache'])) {
throw new \RuntimeException('The default cache storage was not set');
}
$this->cache[$storage] = $this->implicit['cache'];
} else {
$this->cache[$storage] = $this->getCollector()->getCacheDriver($storage);
}
}
return $this->cache[$storage];
} | [
"public",
"function",
"getCache",
"(",
"string",
"$",
"storage",
"=",
"'default'",
")",
":",
"CacheInterface",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"storage",
"]",
")",
")",
"{",
"if",
"(",
"$",
"storage",
"===",
"'default'",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"implicit",
"[",
"'cache'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The default cache storage was not set'",
")",
";",
"}",
"$",
"this",
"->",
"cache",
"[",
"$",
"storage",
"]",
"=",
"$",
"this",
"->",
"implicit",
"[",
"'cache'",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"cache",
"[",
"$",
"storage",
"]",
"=",
"$",
"this",
"->",
"getCollector",
"(",
")",
"->",
"getCacheDriver",
"(",
"$",
"storage",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"cache",
"[",
"$",
"storage",
"]",
";",
"}"
] | Returns a caching storage
@param string $storage (optional) Storage name
@return CacheInterface | [
"Returns",
"a",
"caching",
"storage"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/Application.php#L368-L382 |
32,751 | opis-colibri/framework | src/Application.php | Application.getSession | public function getSession(): ISession
{
if ($this->session === null) {
if (!isset($this->implicit['session'])) {
throw new \RuntimeException('The default session storage was not set');
}
$this->session = new Session($this->getCollector()->getSessionHandler($this->implicit['session']));
}
return $this->session;
} | php | public function getSession(): ISession
{
if ($this->session === null) {
if (!isset($this->implicit['session'])) {
throw new \RuntimeException('The default session storage was not set');
}
$this->session = new Session($this->getCollector()->getSessionHandler($this->implicit['session']));
}
return $this->session;
} | [
"public",
"function",
"getSession",
"(",
")",
":",
"ISession",
"{",
"if",
"(",
"$",
"this",
"->",
"session",
"===",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"implicit",
"[",
"'session'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The default session storage was not set'",
")",
";",
"}",
"$",
"this",
"->",
"session",
"=",
"new",
"Session",
"(",
"$",
"this",
"->",
"getCollector",
"(",
")",
"->",
"getSessionHandler",
"(",
"$",
"this",
"->",
"implicit",
"[",
"'session'",
"]",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"session",
";",
"}"
] | Returns a session storage
@return ISession | [
"Returns",
"a",
"session",
"storage"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/Application.php#L389-L399 |
32,752 | opis-colibri/framework | src/Application.php | Application.getConfig | public function getConfig(string $driver = 'default'): IDataStore
{
if (!isset($this->config[$driver])) {
if ($driver === 'default') {
if (!isset($this->implicit['config'])) {
throw new \RuntimeException('The default config storage was not set');
}
$this->config[$driver] = $this->implicit['config'];
} else {
$this->config[$driver] = $this->getCollector()->getConfigDriver($driver);
}
}
return $this->config[$driver];
} | php | public function getConfig(string $driver = 'default'): IDataStore
{
if (!isset($this->config[$driver])) {
if ($driver === 'default') {
if (!isset($this->implicit['config'])) {
throw new \RuntimeException('The default config storage was not set');
}
$this->config[$driver] = $this->implicit['config'];
} else {
$this->config[$driver] = $this->getCollector()->getConfigDriver($driver);
}
}
return $this->config[$driver];
} | [
"public",
"function",
"getConfig",
"(",
"string",
"$",
"driver",
"=",
"'default'",
")",
":",
"IDataStore",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"$",
"driver",
"]",
")",
")",
"{",
"if",
"(",
"$",
"driver",
"===",
"'default'",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"implicit",
"[",
"'config'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The default config storage was not set'",
")",
";",
"}",
"$",
"this",
"->",
"config",
"[",
"$",
"driver",
"]",
"=",
"$",
"this",
"->",
"implicit",
"[",
"'config'",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"config",
"[",
"$",
"driver",
"]",
"=",
"$",
"this",
"->",
"getCollector",
"(",
")",
"->",
"getConfigDriver",
"(",
"$",
"driver",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"config",
"[",
"$",
"driver",
"]",
";",
"}"
] | Returns a config storage
@param string $driver (optional) Driver's name
@return IDataStore | [
"Returns",
"a",
"config",
"storage"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/Application.php#L408-L422 |
32,753 | opis-colibri/framework | src/Application.php | Application.getDatabase | public function getDatabase(string $connection = 'default'): Database
{
if (!isset($this->database[$connection])) {
$this->database[$connection] = new Database($this->getConnection($connection));
}
return $this->database[$connection];
} | php | public function getDatabase(string $connection = 'default'): Database
{
if (!isset($this->database[$connection])) {
$this->database[$connection] = new Database($this->getConnection($connection));
}
return $this->database[$connection];
} | [
"public",
"function",
"getDatabase",
"(",
"string",
"$",
"connection",
"=",
"'default'",
")",
":",
"Database",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"database",
"[",
"$",
"connection",
"]",
")",
")",
"{",
"$",
"this",
"->",
"database",
"[",
"$",
"connection",
"]",
"=",
"new",
"Database",
"(",
"$",
"this",
"->",
"getConnection",
"(",
"$",
"connection",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"database",
"[",
"$",
"connection",
"]",
";",
"}"
] | Returns a database abstraction layer
@param string $connection (optional) Connection name
@return Database | [
"Returns",
"a",
"database",
"abstraction",
"layer"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/Application.php#L458-L465 |
32,754 | opis-colibri/framework | src/Application.php | Application.getEntityManager | public function getEntityManager(string $connection = 'default'): EntityManager
{
if (!isset($this->entityManager[$connection])) {
$this->entityManager[$connection] = new EntityManager($this->getConnection($connection));
}
return $this->entityManager[$connection];
} | php | public function getEntityManager(string $connection = 'default'): EntityManager
{
if (!isset($this->entityManager[$connection])) {
$this->entityManager[$connection] = new EntityManager($this->getConnection($connection));
}
return $this->entityManager[$connection];
} | [
"public",
"function",
"getEntityManager",
"(",
"string",
"$",
"connection",
"=",
"'default'",
")",
":",
"EntityManager",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"entityManager",
"[",
"$",
"connection",
"]",
")",
")",
"{",
"$",
"this",
"->",
"entityManager",
"[",
"$",
"connection",
"]",
"=",
"new",
"EntityManager",
"(",
"$",
"this",
"->",
"getConnection",
"(",
"$",
"connection",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"entityManager",
"[",
"$",
"connection",
"]",
";",
"}"
] | Returns an entity manager
@param string|null $connection (optional) Connection name
@return EntityManager | [
"Returns",
"an",
"entity",
"manager"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/Application.php#L486-L493 |
32,755 | opis-colibri/framework | src/Application.php | Application.getLog | public function getLog(string $logger = 'default'): LoggerInterface
{
if (!isset($this->loggers[$logger])) {
if ($logger === 'default') {
if (!isset($this->implicit['logger'])) {
throw new \RuntimeException('The default logger was not set');
}
$this->loggers[$logger] = $this->implicit['logger'];
} else {
$this->loggers[$logger] = $this->getCollector()->getLogger($logger);
}
}
return $this->loggers[$logger];
} | php | public function getLog(string $logger = 'default'): LoggerInterface
{
if (!isset($this->loggers[$logger])) {
if ($logger === 'default') {
if (!isset($this->implicit['logger'])) {
throw new \RuntimeException('The default logger was not set');
}
$this->loggers[$logger] = $this->implicit['logger'];
} else {
$this->loggers[$logger] = $this->getCollector()->getLogger($logger);
}
}
return $this->loggers[$logger];
} | [
"public",
"function",
"getLog",
"(",
"string",
"$",
"logger",
"=",
"'default'",
")",
":",
"LoggerInterface",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"loggers",
"[",
"$",
"logger",
"]",
")",
")",
"{",
"if",
"(",
"$",
"logger",
"===",
"'default'",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"implicit",
"[",
"'logger'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The default logger was not set'",
")",
";",
"}",
"$",
"this",
"->",
"loggers",
"[",
"$",
"logger",
"]",
"=",
"$",
"this",
"->",
"implicit",
"[",
"'logger'",
"]",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"loggers",
"[",
"$",
"logger",
"]",
"=",
"$",
"this",
"->",
"getCollector",
"(",
")",
"->",
"getLogger",
"(",
"$",
"logger",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"loggers",
"[",
"$",
"logger",
"]",
";",
"}"
] | Returns a logger
@param string $logger Logger's name
@return LoggerInterface | [
"Returns",
"a",
"logger"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/Application.php#L502-L516 |
32,756 | opis-colibri/framework | src/Application.php | Application.clearCachedObjects | public function clearCachedObjects()
{
$this->containerInstance = null;
$this->eventDispatcher = null;
$this->viewRenderer = null;
$this->session = null;
$this->httpRouter = null;
$this->collectorList = null;
$this->cache = [];
$this->config = [];
$this->connection = [];
$this->database = [];
$this->entityManager = [];
TemplateStream::clearCache();
} | php | public function clearCachedObjects()
{
$this->containerInstance = null;
$this->eventDispatcher = null;
$this->viewRenderer = null;
$this->session = null;
$this->httpRouter = null;
$this->collectorList = null;
$this->cache = [];
$this->config = [];
$this->connection = [];
$this->database = [];
$this->entityManager = [];
TemplateStream::clearCache();
} | [
"public",
"function",
"clearCachedObjects",
"(",
")",
"{",
"$",
"this",
"->",
"containerInstance",
"=",
"null",
";",
"$",
"this",
"->",
"eventDispatcher",
"=",
"null",
";",
"$",
"this",
"->",
"viewRenderer",
"=",
"null",
";",
"$",
"this",
"->",
"session",
"=",
"null",
";",
"$",
"this",
"->",
"httpRouter",
"=",
"null",
";",
"$",
"this",
"->",
"collectorList",
"=",
"null",
";",
"$",
"this",
"->",
"cache",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"config",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"connection",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"database",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"entityManager",
"=",
"[",
"]",
";",
"TemplateStream",
"::",
"clearCache",
"(",
")",
";",
"}"
] | Clear cached objects | [
"Clear",
"cached",
"objects"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/Application.php#L680-L694 |
32,757 | opis-colibri/framework | src/Application.php | Application.enable | public function enable(Module $module, bool $recollect = true, bool $recursive = false): bool
{
$action = function (Module $module): bool {
$installer = $module->installer();
if ($installer === null) {
return true;
}
if (!class_exists($installer) || !is_subclass_of($installer, Installer::class, true)) {
return false;
}
/** @var Installer $installer */
$installer = new $installer($module);
try {
$installer->enable();
return true;
} catch (Throwable $e) {
$installer->enableError($e);
return false;
}
};
$callback = function (Module $module) use ($recollect) {
$this->notify($module, 'enabled', true);
if ($recollect) {
$this->getCollector()->recollect();
}
$this->emit('module.enabled.' . $module->name());
};
$manager = $this->moduleManager();
if ($recursive) {
foreach ($manager->recursiveDependencies($module) as $dependency) {
if (!$dependency->isInstalled()) {
if (!$this->install($dependency, $recollect, false)) {
return false;
}
}
if (!$dependency->isEnabled()) {
if (!$manager->enable($dependency, $action, $callback)) {
return false;
}
}
}
if (!$module->isInstalled() && !$this->install($module, $recollect, false)) {
return false;
}
}
return $manager->enable($module, $action, $callback);
} | php | public function enable(Module $module, bool $recollect = true, bool $recursive = false): bool
{
$action = function (Module $module): bool {
$installer = $module->installer();
if ($installer === null) {
return true;
}
if (!class_exists($installer) || !is_subclass_of($installer, Installer::class, true)) {
return false;
}
/** @var Installer $installer */
$installer = new $installer($module);
try {
$installer->enable();
return true;
} catch (Throwable $e) {
$installer->enableError($e);
return false;
}
};
$callback = function (Module $module) use ($recollect) {
$this->notify($module, 'enabled', true);
if ($recollect) {
$this->getCollector()->recollect();
}
$this->emit('module.enabled.' . $module->name());
};
$manager = $this->moduleManager();
if ($recursive) {
foreach ($manager->recursiveDependencies($module) as $dependency) {
if (!$dependency->isInstalled()) {
if (!$this->install($dependency, $recollect, false)) {
return false;
}
}
if (!$dependency->isEnabled()) {
if (!$manager->enable($dependency, $action, $callback)) {
return false;
}
}
}
if (!$module->isInstalled() && !$this->install($module, $recollect, false)) {
return false;
}
}
return $manager->enable($module, $action, $callback);
} | [
"public",
"function",
"enable",
"(",
"Module",
"$",
"module",
",",
"bool",
"$",
"recollect",
"=",
"true",
",",
"bool",
"$",
"recursive",
"=",
"false",
")",
":",
"bool",
"{",
"$",
"action",
"=",
"function",
"(",
"Module",
"$",
"module",
")",
":",
"bool",
"{",
"$",
"installer",
"=",
"$",
"module",
"->",
"installer",
"(",
")",
";",
"if",
"(",
"$",
"installer",
"===",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"installer",
")",
"||",
"!",
"is_subclass_of",
"(",
"$",
"installer",
",",
"Installer",
"::",
"class",
",",
"true",
")",
")",
"{",
"return",
"false",
";",
"}",
"/** @var Installer $installer */",
"$",
"installer",
"=",
"new",
"$",
"installer",
"(",
"$",
"module",
")",
";",
"try",
"{",
"$",
"installer",
"->",
"enable",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Throwable",
"$",
"e",
")",
"{",
"$",
"installer",
"->",
"enableError",
"(",
"$",
"e",
")",
";",
"return",
"false",
";",
"}",
"}",
";",
"$",
"callback",
"=",
"function",
"(",
"Module",
"$",
"module",
")",
"use",
"(",
"$",
"recollect",
")",
"{",
"$",
"this",
"->",
"notify",
"(",
"$",
"module",
",",
"'enabled'",
",",
"true",
")",
";",
"if",
"(",
"$",
"recollect",
")",
"{",
"$",
"this",
"->",
"getCollector",
"(",
")",
"->",
"recollect",
"(",
")",
";",
"}",
"$",
"this",
"->",
"emit",
"(",
"'module.enabled.'",
".",
"$",
"module",
"->",
"name",
"(",
")",
")",
";",
"}",
";",
"$",
"manager",
"=",
"$",
"this",
"->",
"moduleManager",
"(",
")",
";",
"if",
"(",
"$",
"recursive",
")",
"{",
"foreach",
"(",
"$",
"manager",
"->",
"recursiveDependencies",
"(",
"$",
"module",
")",
"as",
"$",
"dependency",
")",
"{",
"if",
"(",
"!",
"$",
"dependency",
"->",
"isInstalled",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"install",
"(",
"$",
"dependency",
",",
"$",
"recollect",
",",
"false",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"dependency",
"->",
"isEnabled",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"manager",
"->",
"enable",
"(",
"$",
"dependency",
",",
"$",
"action",
",",
"$",
"callback",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"$",
"module",
"->",
"isInstalled",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"install",
"(",
"$",
"module",
",",
"$",
"recollect",
",",
"false",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"$",
"manager",
"->",
"enable",
"(",
"$",
"module",
",",
"$",
"action",
",",
"$",
"callback",
")",
";",
"}"
] | Enable a module
@param Module $module
@param boolean $recollect (optional)
@param boolean $recursive (optional)
@return boolean | [
"Enable",
"a",
"module"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/Application.php#L905-L960 |
32,758 | opis-colibri/framework | src/Application.php | Application.disable | public function disable(Module $module, bool $recollect = true, bool $recursive = false): bool
{
$action = function (Module $module) {
$installer = $module->installer();
if ($installer === null) {
return true;
}
if (!class_exists($installer) || !is_subclass_of($installer, Installer::class, true)) {
return false;
}
/** @var Installer $installer */
$installer = new $installer($module);
try {
$installer->disable();
return true;
} catch (Throwable $e) {
$installer->disableError($e);
return false;
}
};
$callback = function (Module $module) use ($recollect) {
$this->notify($module, 'enabled', false);
if ($recollect) {
$this->getCollector()->recollect();
}
$this->emit('module.disabled.' . $module->name());
};
$manager = $this->moduleManager();
if ($recursive) {
foreach ($manager->recursiveDependants($module) as $dependant) {
if ($dependant->isEnabled()) {
if (!$manager->disable($dependant, $action, $callback)) {
return false;
}
}
if ($dependant->isInstalled()) {
if (!$this->uninstall($dependant, $recollect, false)) {
return false;
}
}
}
}
return $manager->disable($module, $action, $callback);
} | php | public function disable(Module $module, bool $recollect = true, bool $recursive = false): bool
{
$action = function (Module $module) {
$installer = $module->installer();
if ($installer === null) {
return true;
}
if (!class_exists($installer) || !is_subclass_of($installer, Installer::class, true)) {
return false;
}
/** @var Installer $installer */
$installer = new $installer($module);
try {
$installer->disable();
return true;
} catch (Throwable $e) {
$installer->disableError($e);
return false;
}
};
$callback = function (Module $module) use ($recollect) {
$this->notify($module, 'enabled', false);
if ($recollect) {
$this->getCollector()->recollect();
}
$this->emit('module.disabled.' . $module->name());
};
$manager = $this->moduleManager();
if ($recursive) {
foreach ($manager->recursiveDependants($module) as $dependant) {
if ($dependant->isEnabled()) {
if (!$manager->disable($dependant, $action, $callback)) {
return false;
}
}
if ($dependant->isInstalled()) {
if (!$this->uninstall($dependant, $recollect, false)) {
return false;
}
}
}
}
return $manager->disable($module, $action, $callback);
} | [
"public",
"function",
"disable",
"(",
"Module",
"$",
"module",
",",
"bool",
"$",
"recollect",
"=",
"true",
",",
"bool",
"$",
"recursive",
"=",
"false",
")",
":",
"bool",
"{",
"$",
"action",
"=",
"function",
"(",
"Module",
"$",
"module",
")",
"{",
"$",
"installer",
"=",
"$",
"module",
"->",
"installer",
"(",
")",
";",
"if",
"(",
"$",
"installer",
"===",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"installer",
")",
"||",
"!",
"is_subclass_of",
"(",
"$",
"installer",
",",
"Installer",
"::",
"class",
",",
"true",
")",
")",
"{",
"return",
"false",
";",
"}",
"/** @var Installer $installer */",
"$",
"installer",
"=",
"new",
"$",
"installer",
"(",
"$",
"module",
")",
";",
"try",
"{",
"$",
"installer",
"->",
"disable",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Throwable",
"$",
"e",
")",
"{",
"$",
"installer",
"->",
"disableError",
"(",
"$",
"e",
")",
";",
"return",
"false",
";",
"}",
"}",
";",
"$",
"callback",
"=",
"function",
"(",
"Module",
"$",
"module",
")",
"use",
"(",
"$",
"recollect",
")",
"{",
"$",
"this",
"->",
"notify",
"(",
"$",
"module",
",",
"'enabled'",
",",
"false",
")",
";",
"if",
"(",
"$",
"recollect",
")",
"{",
"$",
"this",
"->",
"getCollector",
"(",
")",
"->",
"recollect",
"(",
")",
";",
"}",
"$",
"this",
"->",
"emit",
"(",
"'module.disabled.'",
".",
"$",
"module",
"->",
"name",
"(",
")",
")",
";",
"}",
";",
"$",
"manager",
"=",
"$",
"this",
"->",
"moduleManager",
"(",
")",
";",
"if",
"(",
"$",
"recursive",
")",
"{",
"foreach",
"(",
"$",
"manager",
"->",
"recursiveDependants",
"(",
"$",
"module",
")",
"as",
"$",
"dependant",
")",
"{",
"if",
"(",
"$",
"dependant",
"->",
"isEnabled",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"manager",
"->",
"disable",
"(",
"$",
"dependant",
",",
"$",
"action",
",",
"$",
"callback",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"dependant",
"->",
"isInstalled",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"uninstall",
"(",
"$",
"dependant",
",",
"$",
"recollect",
",",
"false",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"manager",
"->",
"disable",
"(",
"$",
"module",
",",
"$",
"action",
",",
"$",
"callback",
")",
";",
"}"
] | Disable a module
@param Module $module
@param boolean $recollect (optional)
@param boolean $recursive (optional)
@return boolean | [
"Disable",
"a",
"module"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/Application.php#L971-L1022 |
32,759 | zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Manager/MenuManager.php | MenuManager.flush | public function flush($flushEntityManager = false)
{
$this->queue->rewind();
while ($this->queue->valid()) {
list($item, $mode) = $this->queue->dequeue();
switch ($mode) {
case self::REMOVE:
if (($repo = $this->getRepository(get_class($item))) && $repo instanceof NestedTreeRepository) {
$repo->removeFromTree($item);
} else {
$this->doctrine->getManager()->remove($item);
}
break;
case self::ADD:
$this->doctrine->getManager()->persist($item);
break;
}
$this->queue->next();
}
if ($flushEntityManager) {
$this->doctrine->getManager()->flush();
}
} | php | public function flush($flushEntityManager = false)
{
$this->queue->rewind();
while ($this->queue->valid()) {
list($item, $mode) = $this->queue->dequeue();
switch ($mode) {
case self::REMOVE:
if (($repo = $this->getRepository(get_class($item))) && $repo instanceof NestedTreeRepository) {
$repo->removeFromTree($item);
} else {
$this->doctrine->getManager()->remove($item);
}
break;
case self::ADD:
$this->doctrine->getManager()->persist($item);
break;
}
$this->queue->next();
}
if ($flushEntityManager) {
$this->doctrine->getManager()->flush();
}
} | [
"public",
"function",
"flush",
"(",
"$",
"flushEntityManager",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"queue",
"->",
"rewind",
"(",
")",
";",
"while",
"(",
"$",
"this",
"->",
"queue",
"->",
"valid",
"(",
")",
")",
"{",
"list",
"(",
"$",
"item",
",",
"$",
"mode",
")",
"=",
"$",
"this",
"->",
"queue",
"->",
"dequeue",
"(",
")",
";",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"self",
"::",
"REMOVE",
":",
"if",
"(",
"(",
"$",
"repo",
"=",
"$",
"this",
"->",
"getRepository",
"(",
"get_class",
"(",
"$",
"item",
")",
")",
")",
"&&",
"$",
"repo",
"instanceof",
"NestedTreeRepository",
")",
"{",
"$",
"repo",
"->",
"removeFromTree",
"(",
"$",
"item",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"doctrine",
"->",
"getManager",
"(",
")",
"->",
"remove",
"(",
"$",
"item",
")",
";",
"}",
"break",
";",
"case",
"self",
"::",
"ADD",
":",
"$",
"this",
"->",
"doctrine",
"->",
"getManager",
"(",
")",
"->",
"persist",
"(",
"$",
"item",
")",
";",
"break",
";",
"}",
"$",
"this",
"->",
"queue",
"->",
"next",
"(",
")",
";",
"}",
"if",
"(",
"$",
"flushEntityManager",
")",
"{",
"$",
"this",
"->",
"doctrine",
"->",
"getManager",
"(",
")",
"->",
"flush",
"(",
")",
";",
"}",
"}"
] | Registers a menu item to remove
@param bool $flushEntityManager | [
"Registers",
"a",
"menu",
"item",
"to",
"remove"
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Manager/MenuManager.php#L71-L95 |
32,760 | spiral/reactor | src/ClassDeclaration.php | ClassDeclaration.setInterfaces | public function setInterfaces(array $interfaces): ClassDeclaration
{
$this->interfaces = [];
foreach ($interfaces as $interface) {
$this->addInterface($interface);
}
return $this;
} | php | public function setInterfaces(array $interfaces): ClassDeclaration
{
$this->interfaces = [];
foreach ($interfaces as $interface) {
$this->addInterface($interface);
}
return $this;
} | [
"public",
"function",
"setInterfaces",
"(",
"array",
"$",
"interfaces",
")",
":",
"ClassDeclaration",
"{",
"$",
"this",
"->",
"interfaces",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"interfaces",
"as",
"$",
"interface",
")",
"{",
"$",
"this",
"->",
"addInterface",
"(",
"$",
"interface",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Declare class interfaces.
@param array $interfaces
@return self | [
"Declare",
"class",
"interfaces",
"."
] | 222a70249127f1c515238358f2ee0a91d00f9a51 | https://github.com/spiral/reactor/blob/222a70249127f1c515238358f2ee0a91d00f9a51/src/ClassDeclaration.php#L125-L133 |
32,761 | spiral/reactor | src/ClassDeclaration.php | ClassDeclaration.setTraits | public function setTraits(array $traits): ClassDeclaration
{
$this->traits = [];
foreach ($traits as $trait) {
$this->addTrait($trait);
}
return $this;
} | php | public function setTraits(array $traits): ClassDeclaration
{
$this->traits = [];
foreach ($traits as $trait) {
$this->addTrait($trait);
}
return $this;
} | [
"public",
"function",
"setTraits",
"(",
"array",
"$",
"traits",
")",
":",
"ClassDeclaration",
"{",
"$",
"this",
"->",
"traits",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"traits",
"as",
"$",
"trait",
")",
"{",
"$",
"this",
"->",
"addTrait",
"(",
"$",
"trait",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Declare class traits.
@param array $traits
@return self | [
"Declare",
"class",
"traits",
"."
] | 222a70249127f1c515238358f2ee0a91d00f9a51 | https://github.com/spiral/reactor/blob/222a70249127f1c515238358f2ee0a91d00f9a51/src/ClassDeclaration.php#L188-L196 |
32,762 | spiral/reactor | src/Partial/Property.php | Property.mountIndents | private function mountIndents(string $serialized, int $indentLevel): string
{
$lines = explode("\n", $serialized);
foreach ($lines as &$line) {
$line = $this->addIndent($line, $indentLevel);
unset($line);
}
return ltrim(join("\n", $lines));
} | php | private function mountIndents(string $serialized, int $indentLevel): string
{
$lines = explode("\n", $serialized);
foreach ($lines as &$line) {
$line = $this->addIndent($line, $indentLevel);
unset($line);
}
return ltrim(join("\n", $lines));
} | [
"private",
"function",
"mountIndents",
"(",
"string",
"$",
"serialized",
",",
"int",
"$",
"indentLevel",
")",
":",
"string",
"{",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"serialized",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"&",
"$",
"line",
")",
"{",
"$",
"line",
"=",
"$",
"this",
"->",
"addIndent",
"(",
"$",
"line",
",",
"$",
"indentLevel",
")",
";",
"unset",
"(",
"$",
"line",
")",
";",
"}",
"return",
"ltrim",
"(",
"join",
"(",
"\"\\n\"",
",",
"$",
"lines",
")",
")",
";",
"}"
] | Mount indentation to value. Attention, to be applied to arrays only!
@param string $serialized
@param int $indentLevel
@return string | [
"Mount",
"indentation",
"to",
"value",
".",
"Attention",
"to",
"be",
"applied",
"to",
"arrays",
"only!"
] | 222a70249127f1c515238358f2ee0a91d00f9a51 | https://github.com/spiral/reactor/blob/222a70249127f1c515238358f2ee0a91d00f9a51/src/Partial/Property.php#L143-L152 |
32,763 | zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Twig/Extension.php | Extension.activeTrail | public function activeTrail($item)
{
if (is_null($item)) {
return null;
}
if (!$item instanceof MenuItem) {
throw new \UnexpectedValueException(sprintf('$ITEM must be \Knp\Menu\MenuItem not "%s"', get_class($item)));
}
$stack = array();
do {
$stack[]= $item;
} while ($item = $item->getParent());
return array_reverse($stack);
} | php | public function activeTrail($item)
{
if (is_null($item)) {
return null;
}
if (!$item instanceof MenuItem) {
throw new \UnexpectedValueException(sprintf('$ITEM must be \Knp\Menu\MenuItem not "%s"', get_class($item)));
}
$stack = array();
do {
$stack[]= $item;
} while ($item = $item->getParent());
return array_reverse($stack);
} | [
"public",
"function",
"activeTrail",
"(",
"$",
"item",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"item",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"item",
"instanceof",
"MenuItem",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"sprintf",
"(",
"'$ITEM must be \\Knp\\Menu\\MenuItem not \"%s\"'",
",",
"get_class",
"(",
"$",
"item",
")",
")",
")",
";",
"}",
"$",
"stack",
"=",
"array",
"(",
")",
";",
"do",
"{",
"$",
"stack",
"[",
"]",
"=",
"$",
"item",
";",
"}",
"while",
"(",
"$",
"item",
"=",
"$",
"item",
"->",
"getParent",
"(",
")",
")",
";",
"return",
"array_reverse",
"(",
"$",
"stack",
")",
";",
"}"
] | Returns the active trail for the given menuItem
@param MenuItem|null $item
@return array | [
"Returns",
"the",
"active",
"trail",
"for",
"the",
"given",
"menuItem"
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Twig/Extension.php#L90-L107 |
32,764 | zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Twig/Extension.php | Extension.current | public function current($item, $level = null)
{
if (is_null($item)) {
return null;
}
if (!$item instanceof MenuItem) {
throw new \UnexpectedValueException(sprintf('$ITEM must be \Knp\Menu\MenuItem not "%s"', get_class($item)));
}
/** @var MenuItem $child */
foreach ($item->getChildren() as $child) {
if (
(null !== $this->matcher && $this->matcher->isAncestor($child))
|| (null === $this->matcher && $child->isCurrentAncestor())
) {
if ($level !== null and $level == $child->getLevel()) {
return $child;
}
return $this->current($child);
}
if (
(null !== $this->matcher && $this->matcher->isCurrent($child))
|| (null === $this->matcher && $child->isCurrent())
) {
return $child;
}
}
return null;
} | php | public function current($item, $level = null)
{
if (is_null($item)) {
return null;
}
if (!$item instanceof MenuItem) {
throw new \UnexpectedValueException(sprintf('$ITEM must be \Knp\Menu\MenuItem not "%s"', get_class($item)));
}
/** @var MenuItem $child */
foreach ($item->getChildren() as $child) {
if (
(null !== $this->matcher && $this->matcher->isAncestor($child))
|| (null === $this->matcher && $child->isCurrentAncestor())
) {
if ($level !== null and $level == $child->getLevel()) {
return $child;
}
return $this->current($child);
}
if (
(null !== $this->matcher && $this->matcher->isCurrent($child))
|| (null === $this->matcher && $child->isCurrent())
) {
return $child;
}
}
return null;
} | [
"public",
"function",
"current",
"(",
"$",
"item",
",",
"$",
"level",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"item",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"item",
"instanceof",
"MenuItem",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"sprintf",
"(",
"'$ITEM must be \\Knp\\Menu\\MenuItem not \"%s\"'",
",",
"get_class",
"(",
"$",
"item",
")",
")",
")",
";",
"}",
"/** @var MenuItem $child */",
"foreach",
"(",
"$",
"item",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"(",
"null",
"!==",
"$",
"this",
"->",
"matcher",
"&&",
"$",
"this",
"->",
"matcher",
"->",
"isAncestor",
"(",
"$",
"child",
")",
")",
"||",
"(",
"null",
"===",
"$",
"this",
"->",
"matcher",
"&&",
"$",
"child",
"->",
"isCurrentAncestor",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"level",
"!==",
"null",
"and",
"$",
"level",
"==",
"$",
"child",
"->",
"getLevel",
"(",
")",
")",
"{",
"return",
"$",
"child",
";",
"}",
"return",
"$",
"this",
"->",
"current",
"(",
"$",
"child",
")",
";",
"}",
"if",
"(",
"(",
"null",
"!==",
"$",
"this",
"->",
"matcher",
"&&",
"$",
"this",
"->",
"matcher",
"->",
"isCurrent",
"(",
"$",
"child",
")",
")",
"||",
"(",
"null",
"===",
"$",
"this",
"->",
"matcher",
"&&",
"$",
"child",
"->",
"isCurrent",
"(",
")",
")",
")",
"{",
"return",
"$",
"child",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns the current menu item given a root menu item
@param MenuItem|null $item
@param int $level
@return MenuItem|null | [
"Returns",
"the",
"current",
"menu",
"item",
"given",
"a",
"root",
"menu",
"item"
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Twig/Extension.php#L116-L148 |
32,765 | spiral/reactor | src/Serializer.php | Serializer.serialize | public function serialize($value): string
{
if (is_array($value)) {
return $this->packArray($value);
}
return $this->packValue($value);
} | php | public function serialize($value): string
{
if (is_array($value)) {
return $this->packArray($value);
}
return $this->packValue($value);
} | [
"public",
"function",
"serialize",
"(",
"$",
"value",
")",
":",
"string",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"this",
"->",
"packArray",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
"->",
"packValue",
"(",
"$",
"value",
")",
";",
"}"
] | Serialize array.
@param mixed $value
@return string | [
"Serialize",
"array",
"."
] | 222a70249127f1c515238358f2ee0a91d00f9a51 | https://github.com/spiral/reactor/blob/222a70249127f1c515238358f2ee0a91d00f9a51/src/Serializer.php#L32-L39 |
32,766 | spiral/reactor | src/Serializer.php | Serializer.packValue | protected function packValue($value): string
{
if ($value instanceof DeclarationInterface) {
//No indentation here
return $value->render();
}
if (is_null($value)) {
return "null";
}
if (is_bool($value)) {
return ($value ? "true" : "false");
}
if (is_object($value) && method_exists($value, '__set_state')) {
return var_export($value, true);
}
if (!is_string($value) && !is_numeric($value)) {
throw new SerializeException("Unable to pack non scalar value");
}
if (is_string($value) && class_exists($value)) {
$reflection = new \ReflectionClass($value);
if ($value === $reflection->getName()) {
return '\\' . $reflection->getName() . '::class';
}
}
return var_export($value, true);
} | php | protected function packValue($value): string
{
if ($value instanceof DeclarationInterface) {
//No indentation here
return $value->render();
}
if (is_null($value)) {
return "null";
}
if (is_bool($value)) {
return ($value ? "true" : "false");
}
if (is_object($value) && method_exists($value, '__set_state')) {
return var_export($value, true);
}
if (!is_string($value) && !is_numeric($value)) {
throw new SerializeException("Unable to pack non scalar value");
}
if (is_string($value) && class_exists($value)) {
$reflection = new \ReflectionClass($value);
if ($value === $reflection->getName()) {
return '\\' . $reflection->getName() . '::class';
}
}
return var_export($value, true);
} | [
"protected",
"function",
"packValue",
"(",
"$",
"value",
")",
":",
"string",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"DeclarationInterface",
")",
"{",
"//No indentation here",
"return",
"$",
"value",
"->",
"render",
"(",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"return",
"\"null\"",
";",
"}",
"if",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"return",
"(",
"$",
"value",
"?",
"\"true\"",
":",
"\"false\"",
")",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"&&",
"method_exists",
"(",
"$",
"value",
",",
"'__set_state'",
")",
")",
"{",
"return",
"var_export",
"(",
"$",
"value",
",",
"true",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
"&&",
"!",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"SerializeException",
"(",
"\"Unable to pack non scalar value\"",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
"&&",
"class_exists",
"(",
"$",
"value",
")",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"value",
"===",
"$",
"reflection",
"->",
"getName",
"(",
")",
")",
"{",
"return",
"'\\\\'",
".",
"$",
"reflection",
"->",
"getName",
"(",
")",
".",
"'::class'",
";",
"}",
"}",
"return",
"var_export",
"(",
"$",
"value",
",",
"true",
")",
";",
"}"
] | Pack array key value into string.
@param mixed $value
@return string
@throws SerializeException | [
"Pack",
"array",
"key",
"value",
"into",
"string",
"."
] | 222a70249127f1c515238358f2ee0a91d00f9a51 | https://github.com/spiral/reactor/blob/222a70249127f1c515238358f2ee0a91d00f9a51/src/Serializer.php#L101-L132 |
32,767 | opis-colibri/framework | src/ItemCollectors/EventHandlerCollector.php | EventHandlerCollector.handle | public function handle(string $event, callable $callback): Route
{
$route = $this->data
->createRoute($event, $callback)
->set('priority', $this->crtPriority);
$this->data->sort();
return $route;
} | php | public function handle(string $event, callable $callback): Route
{
$route = $this->data
->createRoute($event, $callback)
->set('priority', $this->crtPriority);
$this->data->sort();
return $route;
} | [
"public",
"function",
"handle",
"(",
"string",
"$",
"event",
",",
"callable",
"$",
"callback",
")",
":",
"Route",
"{",
"$",
"route",
"=",
"$",
"this",
"->",
"data",
"->",
"createRoute",
"(",
"$",
"event",
",",
"$",
"callback",
")",
"->",
"set",
"(",
"'priority'",
",",
"$",
"this",
"->",
"crtPriority",
")",
";",
"$",
"this",
"->",
"data",
"->",
"sort",
"(",
")",
";",
"return",
"$",
"route",
";",
"}"
] | Register a new event handler
@param string $event Event name
@param callable $callback A callback that will be executed
@return Route | [
"Register",
"a",
"new",
"event",
"handler"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/ItemCollectors/EventHandlerCollector.php#L45-L54 |
32,768 | opis-colibri/framework | src/ItemCollectors/ViewEngineCollector.php | ViewEngineCollector.register | public function register(callable $factory): self
{
$this->data->register($factory, $this->crtPriority);
return $this;
} | php | public function register(callable $factory): self
{
$this->data->register($factory, $this->crtPriority);
return $this;
} | [
"public",
"function",
"register",
"(",
"callable",
"$",
"factory",
")",
":",
"self",
"{",
"$",
"this",
"->",
"data",
"->",
"register",
"(",
"$",
"factory",
",",
"$",
"this",
"->",
"crtPriority",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Defines a new view engine
@param callable $factory
@return ViewEngineCollector | [
"Defines",
"a",
"new",
"view",
"engine"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/ItemCollectors/ViewEngineCollector.php#L43-L47 |
32,769 | spiral/reactor | src/Aggregator.php | Aggregator.has | public function has(string $name): bool
{
foreach ($this->elements as $element) {
if ($element instanceof NamedInterface && $element->getName() == $name) {
return true;
}
}
return false;
} | php | public function has(string $name): bool
{
foreach ($this->elements as $element) {
if ($element instanceof NamedInterface && $element->getName() == $name) {
return true;
}
}
return false;
} | [
"public",
"function",
"has",
"(",
"string",
"$",
"name",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"this",
"->",
"elements",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"element",
"instanceof",
"NamedInterface",
"&&",
"$",
"element",
"->",
"getName",
"(",
")",
"==",
"$",
"name",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Check if aggregation has named element with given name.
@param string $name
@return bool | [
"Check",
"if",
"aggregation",
"has",
"named",
"element",
"with",
"given",
"name",
"."
] | 222a70249127f1c515238358f2ee0a91d00f9a51 | https://github.com/spiral/reactor/blob/222a70249127f1c515238358f2ee0a91d00f9a51/src/Aggregator.php#L67-L76 |
32,770 | spiral/reactor | src/Aggregator.php | Aggregator.add | public function add(DeclarationInterface $element): Aggregator
{
$reflector = new \ReflectionObject($element);
$allowed = false;
foreach ($this->allowed as $class) {
if ($reflector->isSubclassOf($class) || get_class($element) == $class) {
$allowed = true;
break;
}
}
if (!$allowed) {
$type = get_class($element);
throw new ReactorException("Elements with type '{$type}' are not allowed");
}
$this->elements[] = $element;
return $this;
} | php | public function add(DeclarationInterface $element): Aggregator
{
$reflector = new \ReflectionObject($element);
$allowed = false;
foreach ($this->allowed as $class) {
if ($reflector->isSubclassOf($class) || get_class($element) == $class) {
$allowed = true;
break;
}
}
if (!$allowed) {
$type = get_class($element);
throw new ReactorException("Elements with type '{$type}' are not allowed");
}
$this->elements[] = $element;
return $this;
} | [
"public",
"function",
"add",
"(",
"DeclarationInterface",
"$",
"element",
")",
":",
"Aggregator",
"{",
"$",
"reflector",
"=",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"element",
")",
";",
"$",
"allowed",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"allowed",
"as",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"reflector",
"->",
"isSubclassOf",
"(",
"$",
"class",
")",
"||",
"get_class",
"(",
"$",
"element",
")",
"==",
"$",
"class",
")",
"{",
"$",
"allowed",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"allowed",
")",
"{",
"$",
"type",
"=",
"get_class",
"(",
"$",
"element",
")",
";",
"throw",
"new",
"ReactorException",
"(",
"\"Elements with type '{$type}' are not allowed\"",
")",
";",
"}",
"$",
"this",
"->",
"elements",
"[",
"]",
"=",
"$",
"element",
";",
"return",
"$",
"this",
";",
"}"
] | Add new element.
@param DeclarationInterface $element
@return self
@throws ReactorException | [
"Add",
"new",
"element",
"."
] | 222a70249127f1c515238358f2ee0a91d00f9a51 | https://github.com/spiral/reactor/blob/222a70249127f1c515238358f2ee0a91d00f9a51/src/Aggregator.php#L86-L106 |
32,771 | spiral/reactor | src/Aggregator.php | Aggregator.remove | public function remove(string $name): Aggregator
{
foreach ($this->elements as $index => $element) {
if ($element instanceof NamedInterface && $element->getName() == $name) {
unset($this->elements[$index]);
}
}
return $this;
} | php | public function remove(string $name): Aggregator
{
foreach ($this->elements as $index => $element) {
if ($element instanceof NamedInterface && $element->getName() == $name) {
unset($this->elements[$index]);
}
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"string",
"$",
"name",
")",
":",
"Aggregator",
"{",
"foreach",
"(",
"$",
"this",
"->",
"elements",
"as",
"$",
"index",
"=>",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"element",
"instanceof",
"NamedInterface",
"&&",
"$",
"element",
"->",
"getName",
"(",
")",
"==",
"$",
"name",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"elements",
"[",
"$",
"index",
"]",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Remove element by it's name.
@param string $name
@return self | [
"Remove",
"element",
"by",
"it",
"s",
"name",
"."
] | 222a70249127f1c515238358f2ee0a91d00f9a51 | https://github.com/spiral/reactor/blob/222a70249127f1c515238358f2ee0a91d00f9a51/src/Aggregator.php#L129-L138 |
32,772 | opis-colibri/framework | src/Collector/Manager.php | Manager.recollect | public function recollect(bool $fresh = true): bool
{
if (!$this->app->getCache()->clear()) {
return false;
}
$this->collectorsIncluded = false;
$list = $this->app->getCollectorList($fresh);
if ($fresh) {
$this->cache = [];
$this->app->clearCachedObjects();
$this->router = new Router();
$this->container = $container = new Container();
foreach ($list as $name => $collector) {
$container->alias($name, $collector['class']);
$container->singleton($collector['class']);
}
}
foreach (array_keys($list) as $entry) {
$this->collect($entry, $fresh);
}
$this->app->getEventDispatcher()->emit("system.collect");
return true;
} | php | public function recollect(bool $fresh = true): bool
{
if (!$this->app->getCache()->clear()) {
return false;
}
$this->collectorsIncluded = false;
$list = $this->app->getCollectorList($fresh);
if ($fresh) {
$this->cache = [];
$this->app->clearCachedObjects();
$this->router = new Router();
$this->container = $container = new Container();
foreach ($list as $name => $collector) {
$container->alias($name, $collector['class']);
$container->singleton($collector['class']);
}
}
foreach (array_keys($list) as $entry) {
$this->collect($entry, $fresh);
}
$this->app->getEventDispatcher()->emit("system.collect");
return true;
} | [
"public",
"function",
"recollect",
"(",
"bool",
"$",
"fresh",
"=",
"true",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"app",
"->",
"getCache",
"(",
")",
"->",
"clear",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"collectorsIncluded",
"=",
"false",
";",
"$",
"list",
"=",
"$",
"this",
"->",
"app",
"->",
"getCollectorList",
"(",
"$",
"fresh",
")",
";",
"if",
"(",
"$",
"fresh",
")",
"{",
"$",
"this",
"->",
"cache",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"app",
"->",
"clearCachedObjects",
"(",
")",
";",
"$",
"this",
"->",
"router",
"=",
"new",
"Router",
"(",
")",
";",
"$",
"this",
"->",
"container",
"=",
"$",
"container",
"=",
"new",
"Container",
"(",
")",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"name",
"=>",
"$",
"collector",
")",
"{",
"$",
"container",
"->",
"alias",
"(",
"$",
"name",
",",
"$",
"collector",
"[",
"'class'",
"]",
")",
";",
"$",
"container",
"->",
"singleton",
"(",
"$",
"collector",
"[",
"'class'",
"]",
")",
";",
"}",
"}",
"foreach",
"(",
"array_keys",
"(",
"$",
"list",
")",
"as",
"$",
"entry",
")",
"{",
"$",
"this",
"->",
"collect",
"(",
"$",
"entry",
",",
"$",
"fresh",
")",
";",
"}",
"$",
"this",
"->",
"app",
"->",
"getEventDispatcher",
"(",
")",
"->",
"emit",
"(",
"\"system.collect\"",
")",
";",
"return",
"true",
";",
"}"
] | Recollect all items
@param bool $fresh (optional)
@return bool | [
"Recollect",
"all",
"items"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/Collector/Manager.php#L331-L358 |
32,773 | opis-colibri/framework | src/Collector/Manager.php | Manager.register | public function register(string $name, string $class, string $description, array $options = [])
{
$name = strtolower($name);
$this->app->getConfig()->write('collectors.' . $name, [
'class' => $class,
'description' => $description,
'options' => $options,
]);
$this->container->singleton($class);
$this->container->alias($name, $class);
} | php | public function register(string $name, string $class, string $description, array $options = [])
{
$name = strtolower($name);
$this->app->getConfig()->write('collectors.' . $name, [
'class' => $class,
'description' => $description,
'options' => $options,
]);
$this->container->singleton($class);
$this->container->alias($name, $class);
} | [
"public",
"function",
"register",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"class",
",",
"string",
"$",
"description",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"name",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"app",
"->",
"getConfig",
"(",
")",
"->",
"write",
"(",
"'collectors.'",
".",
"$",
"name",
",",
"[",
"'class'",
"=>",
"$",
"class",
",",
"'description'",
"=>",
"$",
"description",
",",
"'options'",
"=>",
"$",
"options",
",",
"]",
")",
";",
"$",
"this",
"->",
"container",
"->",
"singleton",
"(",
"$",
"class",
")",
";",
"$",
"this",
"->",
"container",
"->",
"alias",
"(",
"$",
"name",
",",
"$",
"class",
")",
";",
"}"
] | Register a new collector
@param string $name
@param string $class
@param string $description
@param array $options | [
"Register",
"a",
"new",
"collector"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/Collector/Manager.php#L368-L379 |
32,774 | spiral/reactor | src/Traits/CommentTrait.php | CommentTrait.setComment | public function setComment($comment): self
{
if (!empty($comment)) {
if (is_array($comment)) {
$this->docComment->setLines($comment);
} elseif (is_string($comment)) {
$this->docComment->setString($comment);
}
}
return $this;
} | php | public function setComment($comment): self
{
if (!empty($comment)) {
if (is_array($comment)) {
$this->docComment->setLines($comment);
} elseif (is_string($comment)) {
$this->docComment->setString($comment);
}
}
return $this;
} | [
"public",
"function",
"setComment",
"(",
"$",
"comment",
")",
":",
"self",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"comment",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"comment",
")",
")",
"{",
"$",
"this",
"->",
"docComment",
"->",
"setLines",
"(",
"$",
"comment",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"comment",
")",
")",
"{",
"$",
"this",
"->",
"docComment",
"->",
"setString",
"(",
"$",
"comment",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Set comment value.
@param string|array $comment
@return $this | [
"Set",
"comment",
"value",
"."
] | 222a70249127f1c515238358f2ee0a91d00f9a51 | https://github.com/spiral/reactor/blob/222a70249127f1c515238358f2ee0a91d00f9a51/src/Traits/CommentTrait.php#L41-L52 |
32,775 | spiral/reactor | src/Traits/CommentTrait.php | CommentTrait.initComment | private function initComment($comment)
{
if (empty($this->docComment)) {
$this->docComment = new Comment();
}
$this->setComment($comment);
} | php | private function initComment($comment)
{
if (empty($this->docComment)) {
$this->docComment = new Comment();
}
$this->setComment($comment);
} | [
"private",
"function",
"initComment",
"(",
"$",
"comment",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"docComment",
")",
")",
"{",
"$",
"this",
"->",
"docComment",
"=",
"new",
"Comment",
"(",
")",
";",
"}",
"$",
"this",
"->",
"setComment",
"(",
"$",
"comment",
")",
";",
"}"
] | Init comment value.
@param string|array $comment | [
"Init",
"comment",
"value",
"."
] | 222a70249127f1c515238358f2ee0a91d00f9a51 | https://github.com/spiral/reactor/blob/222a70249127f1c515238358f2ee0a91d00f9a51/src/Traits/CommentTrait.php#L59-L66 |
32,776 | SimplyCodedSoftware/integration-messaging | src/Amqp/AmqpQueue.php | AmqpQueue.withArgument | public function withArgument(string $name, $value) : self
{
$this->enqueueQueue->setArgument($name, $value);
return $this;
} | php | public function withArgument(string $name, $value) : self
{
$this->enqueueQueue->setArgument($name, $value);
return $this;
} | [
"public",
"function",
"withArgument",
"(",
"string",
"$",
"name",
",",
"$",
"value",
")",
":",
"self",
"{",
"$",
"this",
"->",
"enqueueQueue",
"->",
"setArgument",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] | optional, used by plugins and broker-specific features such as message TTL, queue length limit, etc
@param string $name
@param $value
@return AmqpQueue | [
"optional",
"used",
"by",
"plugins",
"and",
"broker",
"-",
"specific",
"features",
"such",
"as",
"message",
"TTL",
"queue",
"length",
"limit",
"etc"
] | d2d19c64f115adb554952962853a047d40be08bd | https://github.com/SimplyCodedSoftware/integration-messaging/blob/d2d19c64f115adb554952962853a047d40be08bd/src/Amqp/AmqpQueue.php#L110-L115 |
32,777 | SimplyCodedSoftware/integration-messaging | src/DomainModel/Config/AggregateMessagingModule.php | AggregateMessagingModule.create | public static function create(AnnotationRegistrationService $annotationRegistrationService): AnnotationModule
{
return new self(
ParameterConverterAnnotationFactory::create(),
$annotationRegistrationService->findRegistrationsFor(Aggregate::class, CommandHandler::class),
$annotationRegistrationService->findRegistrationsFor(MessageEndpoint::class, CommandHandler::class),
$annotationRegistrationService->findRegistrationsFor(Aggregate::class, QueryHandler::class),
$annotationRegistrationService->findRegistrationsFor(MessageEndpoint::class, QueryHandler::class),
$annotationRegistrationService->findRegistrationsFor(Aggregate::class, EventHandler::class),
$annotationRegistrationService->findRegistrationsFor(MessageEndpoint::class, EventHandler::class)
);
} | php | public static function create(AnnotationRegistrationService $annotationRegistrationService): AnnotationModule
{
return new self(
ParameterConverterAnnotationFactory::create(),
$annotationRegistrationService->findRegistrationsFor(Aggregate::class, CommandHandler::class),
$annotationRegistrationService->findRegistrationsFor(MessageEndpoint::class, CommandHandler::class),
$annotationRegistrationService->findRegistrationsFor(Aggregate::class, QueryHandler::class),
$annotationRegistrationService->findRegistrationsFor(MessageEndpoint::class, QueryHandler::class),
$annotationRegistrationService->findRegistrationsFor(Aggregate::class, EventHandler::class),
$annotationRegistrationService->findRegistrationsFor(MessageEndpoint::class, EventHandler::class)
);
} | [
"public",
"static",
"function",
"create",
"(",
"AnnotationRegistrationService",
"$",
"annotationRegistrationService",
")",
":",
"AnnotationModule",
"{",
"return",
"new",
"self",
"(",
"ParameterConverterAnnotationFactory",
"::",
"create",
"(",
")",
",",
"$",
"annotationRegistrationService",
"->",
"findRegistrationsFor",
"(",
"Aggregate",
"::",
"class",
",",
"CommandHandler",
"::",
"class",
")",
",",
"$",
"annotationRegistrationService",
"->",
"findRegistrationsFor",
"(",
"MessageEndpoint",
"::",
"class",
",",
"CommandHandler",
"::",
"class",
")",
",",
"$",
"annotationRegistrationService",
"->",
"findRegistrationsFor",
"(",
"Aggregate",
"::",
"class",
",",
"QueryHandler",
"::",
"class",
")",
",",
"$",
"annotationRegistrationService",
"->",
"findRegistrationsFor",
"(",
"MessageEndpoint",
"::",
"class",
",",
"QueryHandler",
"::",
"class",
")",
",",
"$",
"annotationRegistrationService",
"->",
"findRegistrationsFor",
"(",
"Aggregate",
"::",
"class",
",",
"EventHandler",
"::",
"class",
")",
",",
"$",
"annotationRegistrationService",
"->",
"findRegistrationsFor",
"(",
"MessageEndpoint",
"::",
"class",
",",
"EventHandler",
"::",
"class",
")",
")",
";",
"}"
] | In here we should provide messaging component for module
@inheritDoc | [
"In",
"here",
"we",
"should",
"provide",
"messaging",
"component",
"for",
"module"
] | d2d19c64f115adb554952962853a047d40be08bd | https://github.com/SimplyCodedSoftware/integration-messaging/blob/d2d19c64f115adb554952962853a047d40be08bd/src/DomainModel/Config/AggregateMessagingModule.php#L110-L121 |
32,778 | opis-colibri/framework | src/Util/Mutex.php | Mutex.lock | public function lock(bool $wait = true): bool
{
if ($this->fp === null) {
$this->fp = fopen($this->file, 'r');
}
return flock($this->fp, $wait ? LOCK_EX : LOCK_EX | LOCK_NB);
} | php | public function lock(bool $wait = true): bool
{
if ($this->fp === null) {
$this->fp = fopen($this->file, 'r');
}
return flock($this->fp, $wait ? LOCK_EX : LOCK_EX | LOCK_NB);
} | [
"public",
"function",
"lock",
"(",
"bool",
"$",
"wait",
"=",
"true",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"fp",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"fp",
"=",
"fopen",
"(",
"$",
"this",
"->",
"file",
",",
"'r'",
")",
";",
"}",
"return",
"flock",
"(",
"$",
"this",
"->",
"fp",
",",
"$",
"wait",
"?",
"LOCK_EX",
":",
"LOCK_EX",
"|",
"LOCK_NB",
")",
";",
"}"
] | Acquire the mutex
@param bool $wait
@return boolean | [
"Acquire",
"the",
"mutex"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/Util/Mutex.php#L69-L76 |
32,779 | spiral/reactor | src/Partial/Parameter.php | Parameter.setDefaultValue | public function setDefaultValue($defaultValue): Parameter
{
$this->isOptional = true;
$this->defaultValue = $defaultValue;
return $this;
} | php | public function setDefaultValue($defaultValue): Parameter
{
$this->isOptional = true;
$this->defaultValue = $defaultValue;
return $this;
} | [
"public",
"function",
"setDefaultValue",
"(",
"$",
"defaultValue",
")",
":",
"Parameter",
"{",
"$",
"this",
"->",
"isOptional",
"=",
"true",
";",
"$",
"this",
"->",
"defaultValue",
"=",
"$",
"defaultValue",
";",
"return",
"$",
"this",
";",
"}"
] | Set parameter default value.
@param mixed $defaultValue
@return self | [
"Set",
"parameter",
"default",
"value",
"."
] | 222a70249127f1c515238358f2ee0a91d00f9a51 | https://github.com/spiral/reactor/blob/222a70249127f1c515238358f2ee0a91d00f9a51/src/Partial/Parameter.php#L113-L119 |
32,780 | zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Security/Authorization/MenuVoter.php | MenuVoter.userIsAllowed | protected function userIsAllowed(TokenInterface $token)
{
/** @var \Symfony\Component\Security\Core\Role\RoleInterface $role */
foreach ($this->hierarchy->getReachableRoles($token->getRoles()) as $role) {
if ($role->getRole() === self::ROLE_ADMIN_MENU_ITEM) {
return true;
}
}
return false;
} | php | protected function userIsAllowed(TokenInterface $token)
{
/** @var \Symfony\Component\Security\Core\Role\RoleInterface $role */
foreach ($this->hierarchy->getReachableRoles($token->getRoles()) as $role) {
if ($role->getRole() === self::ROLE_ADMIN_MENU_ITEM) {
return true;
}
}
return false;
} | [
"protected",
"function",
"userIsAllowed",
"(",
"TokenInterface",
"$",
"token",
")",
"{",
"/** @var \\Symfony\\Component\\Security\\Core\\Role\\RoleInterface $role */",
"foreach",
"(",
"$",
"this",
"->",
"hierarchy",
"->",
"getReachableRoles",
"(",
"$",
"token",
"->",
"getRoles",
"(",
")",
")",
"as",
"$",
"role",
")",
"{",
"if",
"(",
"$",
"role",
"->",
"getRole",
"(",
")",
"===",
"self",
"::",
"ROLE_ADMIN_MENU_ITEM",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Calculate whether the current token is allowed.
@param TokenInterface $token
@return bool | [
"Calculate",
"whether",
"the",
"current",
"token",
"is",
"allowed",
"."
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Security/Authorization/MenuVoter.php#L95-L104 |
32,781 | zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Url/MenuItemNameUrlProvider.php | MenuItemNameUrlProvider.supports | public function supports($name)
{
if (!isset($this->loaded[$this->router->getContext()->getParameter('_locale')])) {
$this->loadMappings();
$this->loaded[$this->router->getContext()->getParameter('_locale')] = true;
}
return parent::supports($name);
} | php | public function supports($name)
{
if (!isset($this->loaded[$this->router->getContext()->getParameter('_locale')])) {
$this->loadMappings();
$this->loaded[$this->router->getContext()->getParameter('_locale')] = true;
}
return parent::supports($name);
} | [
"public",
"function",
"supports",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"loaded",
"[",
"$",
"this",
"->",
"router",
"->",
"getContext",
"(",
")",
"->",
"getParameter",
"(",
"'_locale'",
")",
"]",
")",
")",
"{",
"$",
"this",
"->",
"loadMappings",
"(",
")",
";",
"$",
"this",
"->",
"loaded",
"[",
"$",
"this",
"->",
"router",
"->",
"getContext",
"(",
")",
"->",
"getParameter",
"(",
"'_locale'",
")",
"]",
"=",
"true",
";",
"}",
"return",
"parent",
"::",
"supports",
"(",
"$",
"name",
")",
";",
"}"
] | If it supports the given name
@param mixed $name
@return bool|mixed | [
"If",
"it",
"supports",
"the",
"given",
"name"
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Url/MenuItemNameUrlProvider.php#L46-L54 |
32,782 | zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Url/MenuItemNameUrlProvider.php | MenuItemNameUrlProvider.loadMappings | protected function loadMappings()
{
// using a subquery to allow for FETCH_KEY_PAIR
$query = '
SELECT
name, path
FROM (
SELECT
menu_item.name,
menu_item.path,
COALESCE(menu_item.language, root_item.language) language
FROM
menu_item INNER JOIN menu_item root_item ON (menu_item.root=root_item.id)
WHERE
menu_item.path IS NOT NULL
AND menu_item.name IS NOT NULL AND LENGTH(menu_item.name) > 0
HAVING
language IS NULL OR language=:lang
) s
ORDER BY
language=:lang DESC
';
$stmt = $this->em->getConnection()->prepare($query);
$stmt->execute([':lang' => $this->router->getContext()->getParameter('_locale')]);
$this->addAll($stmt->fetchAll(\PDO::FETCH_KEY_PAIR));
} | php | protected function loadMappings()
{
// using a subquery to allow for FETCH_KEY_PAIR
$query = '
SELECT
name, path
FROM (
SELECT
menu_item.name,
menu_item.path,
COALESCE(menu_item.language, root_item.language) language
FROM
menu_item INNER JOIN menu_item root_item ON (menu_item.root=root_item.id)
WHERE
menu_item.path IS NOT NULL
AND menu_item.name IS NOT NULL AND LENGTH(menu_item.name) > 0
HAVING
language IS NULL OR language=:lang
) s
ORDER BY
language=:lang DESC
';
$stmt = $this->em->getConnection()->prepare($query);
$stmt->execute([':lang' => $this->router->getContext()->getParameter('_locale')]);
$this->addAll($stmt->fetchAll(\PDO::FETCH_KEY_PAIR));
} | [
"protected",
"function",
"loadMappings",
"(",
")",
"{",
"// using a subquery to allow for FETCH_KEY_PAIR",
"$",
"query",
"=",
"'\n SELECT\n name, path\n FROM (\n SELECT\n menu_item.name,\n menu_item.path,\n COALESCE(menu_item.language, root_item.language) language\n FROM\n menu_item INNER JOIN menu_item root_item ON (menu_item.root=root_item.id)\n WHERE\n menu_item.path IS NOT NULL\n AND menu_item.name IS NOT NULL AND LENGTH(menu_item.name) > 0\n HAVING\n language IS NULL OR language=:lang\n ) s\n ORDER BY\n language=:lang DESC\n '",
";",
"$",
"stmt",
"=",
"$",
"this",
"->",
"em",
"->",
"getConnection",
"(",
")",
"->",
"prepare",
"(",
"$",
"query",
")",
";",
"$",
"stmt",
"->",
"execute",
"(",
"[",
"':lang'",
"=>",
"$",
"this",
"->",
"router",
"->",
"getContext",
"(",
")",
"->",
"getParameter",
"(",
"'_locale'",
")",
"]",
")",
";",
"$",
"this",
"->",
"addAll",
"(",
"$",
"stmt",
"->",
"fetchAll",
"(",
"\\",
"PDO",
"::",
"FETCH_KEY_PAIR",
")",
")",
";",
"}"
] | Loads all mappings from the url, based on the current request locale. | [
"Loads",
"all",
"mappings",
"from",
"the",
"url",
"based",
"on",
"the",
"current",
"request",
"locale",
"."
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Url/MenuItemNameUrlProvider.php#L59-L84 |
32,783 | zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Url/MenuItemNameUrlProvider.php | MenuItemNameUrlProvider.suggest | public function suggest($pattern)
{
$menuItems = $this->repository->createQueryBuilder('m')
->andWhere('m.name LIKE :pattern')
->getQuery()
->execute(array('pattern' => '%' . $pattern . '%'));
$suggestions = array();
foreach ($menuItems as $item) {
$suggestions[]= array(
'value' => $item->getName(),
'label' => sprintf('%s (menu item)', $item)
);
}
return $suggestions;
} | php | public function suggest($pattern)
{
$menuItems = $this->repository->createQueryBuilder('m')
->andWhere('m.name LIKE :pattern')
->getQuery()
->execute(array('pattern' => '%' . $pattern . '%'));
$suggestions = array();
foreach ($menuItems as $item) {
$suggestions[]= array(
'value' => $item->getName(),
'label' => sprintf('%s (menu item)', $item)
);
}
return $suggestions;
} | [
"public",
"function",
"suggest",
"(",
"$",
"pattern",
")",
"{",
"$",
"menuItems",
"=",
"$",
"this",
"->",
"repository",
"->",
"createQueryBuilder",
"(",
"'m'",
")",
"->",
"andWhere",
"(",
"'m.name LIKE :pattern'",
")",
"->",
"getQuery",
"(",
")",
"->",
"execute",
"(",
"array",
"(",
"'pattern'",
"=>",
"'%'",
".",
"$",
"pattern",
".",
"'%'",
")",
")",
";",
"$",
"suggestions",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"menuItems",
"as",
"$",
"item",
")",
"{",
"$",
"suggestions",
"[",
"]",
"=",
"array",
"(",
"'value'",
"=>",
"$",
"item",
"->",
"getName",
"(",
")",
",",
"'label'",
"=>",
"sprintf",
"(",
"'%s (menu item)'",
",",
"$",
"item",
")",
")",
";",
"}",
"return",
"$",
"suggestions",
";",
"}"
] | Suggest url's based on the passed pattern. The return value must be an array containing "label" and "value" keys.
@param string $pattern
@return mixed | [
"Suggest",
"url",
"s",
"based",
"on",
"the",
"passed",
"pattern",
".",
"The",
"return",
"value",
"must",
"be",
"an",
"array",
"containing",
"label",
"and",
"value",
"keys",
"."
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Url/MenuItemNameUrlProvider.php#L92-L108 |
32,784 | zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Form/Subscriber/MenuItemPersistenceSubscriber.php | MenuItemPersistenceSubscriber.postSetData | public function postSetData(FormEvent $e)
{
if ($e->getData() === null) {
return;
}
// Checks if the form has a given property
// A property can be removed in a child class but the eventSubscriber still exists
if (!$e->getForm()->has($this->property)) {
return;
}
if ($this->provider->supports($e->getData())) {
if ($item = $this->mm->getItemBy(array(':path' => $this->provider->url($e->getData())))) {
$item->setAddToMenu(true);
$e->getForm()->get($this->property)->setData($item);
}
}
} | php | public function postSetData(FormEvent $e)
{
if ($e->getData() === null) {
return;
}
// Checks if the form has a given property
// A property can be removed in a child class but the eventSubscriber still exists
if (!$e->getForm()->has($this->property)) {
return;
}
if ($this->provider->supports($e->getData())) {
if ($item = $this->mm->getItemBy(array(':path' => $this->provider->url($e->getData())))) {
$item->setAddToMenu(true);
$e->getForm()->get($this->property)->setData($item);
}
}
} | [
"public",
"function",
"postSetData",
"(",
"FormEvent",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"->",
"getData",
"(",
")",
"===",
"null",
")",
"{",
"return",
";",
"}",
"// Checks if the form has a given property",
"// A property can be removed in a child class but the eventSubscriber still exists",
"if",
"(",
"!",
"$",
"e",
"->",
"getForm",
"(",
")",
"->",
"has",
"(",
"$",
"this",
"->",
"property",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"provider",
"->",
"supports",
"(",
"$",
"e",
"->",
"getData",
"(",
")",
")",
")",
"{",
"if",
"(",
"$",
"item",
"=",
"$",
"this",
"->",
"mm",
"->",
"getItemBy",
"(",
"array",
"(",
"':path'",
"=>",
"$",
"this",
"->",
"provider",
"->",
"url",
"(",
"$",
"e",
"->",
"getData",
"(",
")",
")",
")",
")",
")",
"{",
"$",
"item",
"->",
"setAddToMenu",
"(",
"true",
")",
";",
"$",
"e",
"->",
"getForm",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"property",
")",
"->",
"setData",
"(",
"$",
"item",
")",
";",
"}",
"}",
"}"
] | POST_SET_DATA event handler
@param FormEvent $e
@return void | [
"POST_SET_DATA",
"event",
"handler"
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Form/Subscriber/MenuItemPersistenceSubscriber.php#L52-L69 |
32,785 | opis-colibri/framework | src/ItemCollectors/RouterGlobalsCollector.php | RouterGlobalsCollector.mixin | public function mixin(string $name, callable $callback): self
{
$this->data->mixin($name, $callback);
return $this;
} | php | public function mixin(string $name, callable $callback): self
{
$this->data->mixin($name, $callback);
return $this;
} | [
"public",
"function",
"mixin",
"(",
"string",
"$",
"name",
",",
"callable",
"$",
"callback",
")",
":",
"self",
"{",
"$",
"this",
"->",
"data",
"->",
"mixin",
"(",
"$",
"name",
",",
"$",
"callback",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set a global mixin
@param string $name
@param callable $callback
@return $this | [
"Set",
"a",
"global",
"mixin"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/ItemCollectors/RouterGlobalsCollector.php#L44-L48 |
32,786 | opis-colibri/framework | src/ItemCollectors/RouterGlobalsCollector.php | RouterGlobalsCollector.bind | public function bind(string $name, callable $callback): self
{
$this->data->bind($name, $callback);
return $this;
} | php | public function bind(string $name, callable $callback): self
{
$this->data->bind($name, $callback);
return $this;
} | [
"public",
"function",
"bind",
"(",
"string",
"$",
"name",
",",
"callable",
"$",
"callback",
")",
":",
"self",
"{",
"$",
"this",
"->",
"data",
"->",
"bind",
"(",
"$",
"name",
",",
"$",
"callback",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Defines a global binding
@param string $name The name of the binding
@param callable $callback A callback that will return the binding's value
@return $this | [
"Defines",
"a",
"global",
"binding"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/ItemCollectors/RouterGlobalsCollector.php#L58-L62 |
32,787 | opis-colibri/framework | src/ItemCollectors/RouterGlobalsCollector.php | RouterGlobalsCollector.callback | public function callback(string $name, callable $callback): self
{
$this->data->callback($name, $callback);
return $this;
} | php | public function callback(string $name, callable $callback): self
{
$this->data->callback($name, $callback);
return $this;
} | [
"public",
"function",
"callback",
"(",
"string",
"$",
"name",
",",
"callable",
"$",
"callback",
")",
":",
"self",
"{",
"$",
"this",
"->",
"data",
"->",
"callback",
"(",
"$",
"name",
",",
"$",
"callback",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Defines a global callback
@param string $name The name of the callback
@param callable $callback A callback
@return $this | [
"Defines",
"a",
"global",
"callback"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/ItemCollectors/RouterGlobalsCollector.php#L72-L76 |
32,788 | opis-colibri/framework | src/ItemCollectors/RouterGlobalsCollector.php | RouterGlobalsCollector.implicit | public function implicit(string $name, $value): self
{
$this->data->implicit($name, $value);
return $this;
} | php | public function implicit(string $name, $value): self
{
$this->data->implicit($name, $value);
return $this;
} | [
"public",
"function",
"implicit",
"(",
"string",
"$",
"name",
",",
"$",
"value",
")",
":",
"self",
"{",
"$",
"this",
"->",
"data",
"->",
"implicit",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set a global implicit value for a wildcard
@param string $name The name of the wildcard
@param mixed $value The implicit value
@return $this | [
"Set",
"a",
"global",
"implicit",
"value",
"for",
"a",
"wildcard"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/ItemCollectors/RouterGlobalsCollector.php#L86-L90 |
32,789 | opis-colibri/framework | src/ItemCollectors/RouterGlobalsCollector.php | RouterGlobalsCollector.placeholder | public function placeholder(string $name, string $value): self
{
$this->data->placeholder($name, $value);
return $this;
} | php | public function placeholder(string $name, string $value): self
{
$this->data->placeholder($name, $value);
return $this;
} | [
"public",
"function",
"placeholder",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"value",
")",
":",
"self",
"{",
"$",
"this",
"->",
"data",
"->",
"placeholder",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Set a global placeholder
@param string $name The name of the wildcard
@param string $value A regex expression
@return $this | [
"Set",
"a",
"global",
"placeholder"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/ItemCollectors/RouterGlobalsCollector.php#L100-L104 |
32,790 | opis-colibri/framework | src/ItemCollectors/ViewCollector.php | ViewCollector.handle | public function handle(string $pattern, callable $resolver): Route
{
$route = $this->data
->createRoute($pattern, $resolver)
->set('priority', $this->crtPriority);
$this->data->sort();
return $route;
} | php | public function handle(string $pattern, callable $resolver): Route
{
$route = $this->data
->createRoute($pattern, $resolver)
->set('priority', $this->crtPriority);
$this->data->sort();
return $route;
} | [
"public",
"function",
"handle",
"(",
"string",
"$",
"pattern",
",",
"callable",
"$",
"resolver",
")",
":",
"Route",
"{",
"$",
"route",
"=",
"$",
"this",
"->",
"data",
"->",
"createRoute",
"(",
"$",
"pattern",
",",
"$",
"resolver",
")",
"->",
"set",
"(",
"'priority'",
",",
"$",
"this",
"->",
"crtPriority",
")",
";",
"$",
"this",
"->",
"data",
"->",
"sort",
"(",
")",
";",
"return",
"$",
"route",
";",
"}"
] | Defines a new view route
@param string $pattern View's pattern
@param callable $resolver A callback that will resolve a view route into a path
@return Route | [
"Defines",
"a",
"new",
"view",
"route"
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/ItemCollectors/ViewCollector.php#L46-L55 |
32,791 | spiral/reactor | src/NamespaceDeclaration.php | NamespaceDeclaration.addElement | public function addElement(DeclarationInterface $element): NamespaceDeclaration
{
$this->elements->add($element);
if ($element instanceof DependedInterface) {
$this->addUses($element->getDependencies());
}
return $this;
} | php | public function addElement(DeclarationInterface $element): NamespaceDeclaration
{
$this->elements->add($element);
if ($element instanceof DependedInterface) {
$this->addUses($element->getDependencies());
}
return $this;
} | [
"public",
"function",
"addElement",
"(",
"DeclarationInterface",
"$",
"element",
")",
":",
"NamespaceDeclaration",
"{",
"$",
"this",
"->",
"elements",
"->",
"add",
"(",
"$",
"element",
")",
";",
"if",
"(",
"$",
"element",
"instanceof",
"DependedInterface",
")",
"{",
"$",
"this",
"->",
"addUses",
"(",
"$",
"element",
"->",
"getDependencies",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Method will automatically mount requested uses is any.
@param DeclarationInterface $element
@return self
@throws Exception\ReactorException | [
"Method",
"will",
"automatically",
"mount",
"requested",
"uses",
"is",
"any",
"."
] | 222a70249127f1c515238358f2ee0a91d00f9a51 | https://github.com/spiral/reactor/blob/222a70249127f1c515238358f2ee0a91d00f9a51/src/NamespaceDeclaration.php#L54-L62 |
32,792 | opis-colibri/framework | src/ItemCollectors/ContractCollector.php | ContractCollector.alias | public function alias(string $alias, string $concrete): self
{
$this->data->alias($alias, $concrete);
return $this;
} | php | public function alias(string $alias, string $concrete): self
{
$this->data->alias($alias, $concrete);
return $this;
} | [
"public",
"function",
"alias",
"(",
"string",
"$",
"alias",
",",
"string",
"$",
"concrete",
")",
":",
"self",
"{",
"$",
"this",
"->",
"data",
"->",
"alias",
"(",
"$",
"alias",
",",
"$",
"concrete",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Alias a type.
@param string $alias An alias for the specified class or interface
@param string $concrete Concrete class or interface name
@return self Self reference | [
"Alias",
"a",
"type",
"."
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/ItemCollectors/ContractCollector.php#L60-L64 |
32,793 | opis-colibri/framework | src/ItemCollectors/ContractCollector.php | ContractCollector.singleton | public function singleton(string $abstract, $concrete = null, array $arguments = []): self
{
$this->data->singleton($abstract, $concrete, $arguments);
return $this;
} | php | public function singleton(string $abstract, $concrete = null, array $arguments = []): self
{
$this->data->singleton($abstract, $concrete, $arguments);
return $this;
} | [
"public",
"function",
"singleton",
"(",
"string",
"$",
"abstract",
",",
"$",
"concrete",
"=",
"null",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
")",
":",
"self",
"{",
"$",
"this",
"->",
"data",
"->",
"singleton",
"(",
"$",
"abstract",
",",
"$",
"concrete",
",",
"$",
"arguments",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Register a singleton binding with the container.
@param string $abstract Class name or interface name
@param string|callable|null $concrete
@param array $arguments
@return self | [
"Register",
"a",
"singleton",
"binding",
"with",
"the",
"container",
"."
] | 22b2f0ed31876a05c9a7813c6881d2ba2b5039b8 | https://github.com/opis-colibri/framework/blob/22b2f0ed31876a05c9a7813c6881d2ba2b5039b8/src/ItemCollectors/ContractCollector.php#L88-L92 |
32,794 | zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Provider/DatabaseMenuProvider.php | DatabaseMenuProvider.get | public function get($name, array $options = array())
{
return $this->builder->build($name, $this->container->get('request_stack')->getCurrentRequest());
} | php | public function get($name, array $options = array())
{
return $this->builder->build($name, $this->container->get('request_stack')->getCurrentRequest());
} | [
"public",
"function",
"get",
"(",
"$",
"name",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"builder",
"->",
"build",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'request_stack'",
")",
"->",
"getCurrentRequest",
"(",
")",
")",
";",
"}"
] | Retrieves a menu by its name
@param string $name
@param array $options
@return \Knp\Menu\ItemInterface
@throws \InvalidArgumentException if the menu does not exists | [
"Retrieves",
"a",
"menu",
"by",
"its",
"name"
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Provider/DatabaseMenuProvider.php#L51-L54 |
32,795 | zicht/menu-bundle | src/Zicht/Bundle/MenuBundle/Provider/DatabaseMenuProvider.php | DatabaseMenuProvider.has | public function has($name, array $options = array())
{
$root = $this->builder->hasRootItemByName($name, $this->container->get('request_stack')->getCurrentRequest());
return null !== $root;
} | php | public function has($name, array $options = array())
{
$root = $this->builder->hasRootItemByName($name, $this->container->get('request_stack')->getCurrentRequest());
return null !== $root;
} | [
"public",
"function",
"has",
"(",
"$",
"name",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"root",
"=",
"$",
"this",
"->",
"builder",
"->",
"hasRootItemByName",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'request_stack'",
")",
"->",
"getCurrentRequest",
"(",
")",
")",
";",
"return",
"null",
"!==",
"$",
"root",
";",
"}"
] | Checks whether a menu exists in this provider
@param string $name
@param array $options
@return bool | [
"Checks",
"whether",
"a",
"menu",
"exists",
"in",
"this",
"provider"
] | b6f22d50025297ad686c8f3afb7b6afe736b7f97 | https://github.com/zicht/menu-bundle/blob/b6f22d50025297ad686c8f3afb7b6afe736b7f97/src/Zicht/Bundle/MenuBundle/Provider/DatabaseMenuProvider.php#L63-L68 |
32,796 | SimplyCodedSoftware/integration-messaging | src/Amqp/AmqpExchange.php | AmqpExchange.withArgument | public function withArgument(string $name, $value) : self
{
$this->enqueueExchange->setArgument($name, $value);
return $this;
} | php | public function withArgument(string $name, $value) : self
{
$this->enqueueExchange->setArgument($name, $value);
return $this;
} | [
"public",
"function",
"withArgument",
"(",
"string",
"$",
"name",
",",
"$",
"value",
")",
":",
"self",
"{",
"$",
"this",
"->",
"enqueueExchange",
"->",
"setArgument",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] | optional, used by plugins and broker-specific features
@param string $name
@param $value
@return AmqpExchange | [
"optional",
"used",
"by",
"plugins",
"and",
"broker",
"-",
"specific",
"features"
] | d2d19c64f115adb554952962853a047d40be08bd | https://github.com/SimplyCodedSoftware/integration-messaging/blob/d2d19c64f115adb554952962853a047d40be08bd/src/Amqp/AmqpExchange.php#L72-L77 |
32,797 | spiral/reactor | src/Partial/Method.php | Method.setSource | public function setSource($source): Method
{
if (!empty($source)) {
if (is_array($source)) {
$this->source->setLines($source);
} elseif (is_string($source)) {
$this->source->setString($source);
}
}
return $this;
} | php | public function setSource($source): Method
{
if (!empty($source)) {
if (is_array($source)) {
$this->source->setLines($source);
} elseif (is_string($source)) {
$this->source->setString($source);
}
}
return $this;
} | [
"public",
"function",
"setSource",
"(",
"$",
"source",
")",
":",
"Method",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"source",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"source",
")",
")",
"{",
"$",
"this",
"->",
"source",
"->",
"setLines",
"(",
"$",
"source",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"source",
")",
")",
"{",
"$",
"this",
"->",
"source",
"->",
"setString",
"(",
"$",
"source",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Set method source.
@param string|array $source
@return self | [
"Set",
"method",
"source",
"."
] | 222a70249127f1c515238358f2ee0a91d00f9a51 | https://github.com/spiral/reactor/blob/222a70249127f1c515238358f2ee0a91d00f9a51/src/Partial/Method.php#L85-L96 |
32,798 | spiral/reactor | src/Partial/Method.php | Method.initSource | private function initSource($source)
{
if (empty($this->source)) {
$this->source = new Source();
}
if (!empty($source)) {
if (is_array($source)) {
$this->source->setLines($source);
} elseif (is_string($source)) {
$this->source->setString($source);
}
}
} | php | private function initSource($source)
{
if (empty($this->source)) {
$this->source = new Source();
}
if (!empty($source)) {
if (is_array($source)) {
$this->source->setLines($source);
} elseif (is_string($source)) {
$this->source->setString($source);
}
}
} | [
"private",
"function",
"initSource",
"(",
"$",
"source",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"source",
")",
")",
"{",
"$",
"this",
"->",
"source",
"=",
"new",
"Source",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"source",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"source",
")",
")",
"{",
"$",
"this",
"->",
"source",
"->",
"setLines",
"(",
"$",
"source",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"source",
")",
")",
"{",
"$",
"this",
"->",
"source",
"->",
"setString",
"(",
"$",
"source",
")",
";",
"}",
"}",
"}"
] | Init source value.
@param string|array $source | [
"Init",
"source",
"value",
"."
] | 222a70249127f1c515238358f2ee0a91d00f9a51 | https://github.com/spiral/reactor/blob/222a70249127f1c515238358f2ee0a91d00f9a51/src/Partial/Method.php#L164-L177 |
32,799 | SidRoberts/phalcon-events | src/View/NotFoundListener.php | NotFoundListener.notFoundView | public function notFoundView(Event $event, ViewInterface $view, $enginePath) : bool
{
if ($enginePath && !is_array($enginePath)) {
$enginePath = [$enginePath];
}
$message = sprintf(
"View was not found in any of the views directory. Active render paths: [%s]",
($enginePath ? join(", ", $enginePath) : gettype($enginePath))
);
$this->logger->error($message);
return true;
} | php | public function notFoundView(Event $event, ViewInterface $view, $enginePath) : bool
{
if ($enginePath && !is_array($enginePath)) {
$enginePath = [$enginePath];
}
$message = sprintf(
"View was not found in any of the views directory. Active render paths: [%s]",
($enginePath ? join(", ", $enginePath) : gettype($enginePath))
);
$this->logger->error($message);
return true;
} | [
"public",
"function",
"notFoundView",
"(",
"Event",
"$",
"event",
",",
"ViewInterface",
"$",
"view",
",",
"$",
"enginePath",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"enginePath",
"&&",
"!",
"is_array",
"(",
"$",
"enginePath",
")",
")",
"{",
"$",
"enginePath",
"=",
"[",
"$",
"enginePath",
"]",
";",
"}",
"$",
"message",
"=",
"sprintf",
"(",
"\"View was not found in any of the views directory. Active render paths: [%s]\"",
",",
"(",
"$",
"enginePath",
"?",
"join",
"(",
"\", \"",
",",
"$",
"enginePath",
")",
":",
"gettype",
"(",
"$",
"enginePath",
")",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"error",
"(",
"$",
"message",
")",
";",
"return",
"true",
";",
"}"
] | Notify about not found views. | [
"Notify",
"about",
"not",
"found",
"views",
"."
] | 3a05bde730cb0fa20aab498746d05e8e11b738cc | https://github.com/SidRoberts/phalcon-events/blob/3a05bde730cb0fa20aab498746d05e8e11b738cc/src/View/NotFoundListener.php#L32-L46 |
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.