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
|
---|---|---|---|---|---|---|---|---|---|---|---|
19,600 | 2amigos/yiifoundation | helpers/Foundation.php | Foundation.registerCoreScripts | public static function registerCoreScripts(
$useZepto = false,
$minimized = true,
$position = \CClientScript::POS_END
) {
/** @var CClientScript $cs */
$cs = \Yii::app()->getClientScript();
if ($useZepto) {
$cs->registerScriptFile(static::getAssetsUrl() . '/js/vendor/zepto.js');
} else {
$cs->registerCoreScript('jquery');
}
// normalizer goes at the head no matter what
$cs->registerScriptFile(static::getAssetsUrl() . '/js/vendor/custom.modernizr.js', \CClientScript::POS_HEAD);
$script = $minimized
? '/js/foundation.min.js'
: '/js/foundation/foundation.js';
$cs->registerScriptFile(static::getAssetsUrl() . $script, $position);
$cs->registerScript(__CLASS__, '$(document).foundation();');
} | php | public static function registerCoreScripts(
$useZepto = false,
$minimized = true,
$position = \CClientScript::POS_END
) {
/** @var CClientScript $cs */
$cs = \Yii::app()->getClientScript();
if ($useZepto) {
$cs->registerScriptFile(static::getAssetsUrl() . '/js/vendor/zepto.js');
} else {
$cs->registerCoreScript('jquery');
}
// normalizer goes at the head no matter what
$cs->registerScriptFile(static::getAssetsUrl() . '/js/vendor/custom.modernizr.js', \CClientScript::POS_HEAD);
$script = $minimized
? '/js/foundation.min.js'
: '/js/foundation/foundation.js';
$cs->registerScriptFile(static::getAssetsUrl() . $script, $position);
$cs->registerScript(__CLASS__, '$(document).foundation();');
} | [
"public",
"static",
"function",
"registerCoreScripts",
"(",
"$",
"useZepto",
"=",
"false",
",",
"$",
"minimized",
"=",
"true",
",",
"$",
"position",
"=",
"\\",
"CClientScript",
"::",
"POS_END",
")",
"{",
"/** @var CClientScript $cs */",
"$",
"cs",
"=",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"getClientScript",
"(",
")",
";",
"if",
"(",
"$",
"useZepto",
")",
"{",
"$",
"cs",
"->",
"registerScriptFile",
"(",
"static",
"::",
"getAssetsUrl",
"(",
")",
".",
"'/js/vendor/zepto.js'",
")",
";",
"}",
"else",
"{",
"$",
"cs",
"->",
"registerCoreScript",
"(",
"'jquery'",
")",
";",
"}",
"// normalizer goes at the head no matter what",
"$",
"cs",
"->",
"registerScriptFile",
"(",
"static",
"::",
"getAssetsUrl",
"(",
")",
".",
"'/js/vendor/custom.modernizr.js'",
",",
"\\",
"CClientScript",
"::",
"POS_HEAD",
")",
";",
"$",
"script",
"=",
"$",
"minimized",
"?",
"'/js/foundation.min.js'",
":",
"'/js/foundation/foundation.js'",
";",
"$",
"cs",
"->",
"registerScriptFile",
"(",
"static",
"::",
"getAssetsUrl",
"(",
")",
".",
"$",
"script",
",",
"$",
"position",
")",
";",
"$",
"cs",
"->",
"registerScript",
"(",
"__CLASS__",
",",
"'$(document).foundation();'",
")",
";",
"}"
]
| Registers jQuery and Foundation JavaScript.
@param bool $useZepto whether to use zepto or not
@param bool $minimized whether to register full minimized library or not
@param int $position the position to register the core script | [
"Registers",
"jQuery",
"and",
"Foundation",
"JavaScript",
"."
]
| 49bed0d3ca1a9bac9299000e48a2661bdc8f9a29 | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Foundation.php#L42-L62 |
19,601 | 2amigos/yiifoundation | helpers/Foundation.php | Foundation.isCoreRegistered | public static function isCoreRegistered($minimized = true, $position = \CClientScript::POS_END)
{
$script = $minimized
? '/js/foundation.min.js'
: '/js/foundation/foundation.js';
return \Yii::app()->getClientScript()
->isScriptFileRegistered(static::getAssetsUrl() . $script, $position);
} | php | public static function isCoreRegistered($minimized = true, $position = \CClientScript::POS_END)
{
$script = $minimized
? '/js/foundation.min.js'
: '/js/foundation/foundation.js';
return \Yii::app()->getClientScript()
->isScriptFileRegistered(static::getAssetsUrl() . $script, $position);
} | [
"public",
"static",
"function",
"isCoreRegistered",
"(",
"$",
"minimized",
"=",
"true",
",",
"$",
"position",
"=",
"\\",
"CClientScript",
"::",
"POS_END",
")",
"{",
"$",
"script",
"=",
"$",
"minimized",
"?",
"'/js/foundation.min.js'",
":",
"'/js/foundation/foundation.js'",
";",
"return",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"getClientScript",
"(",
")",
"->",
"isScriptFileRegistered",
"(",
"static",
"::",
"getAssetsUrl",
"(",
")",
".",
"$",
"script",
",",
"$",
"position",
")",
";",
"}"
]
| Checks whether the core script has been registered or not
@param bool $minimized whether to check full minimized library or not
@param int $position the position to register the core script
@return bool | [
"Checks",
"whether",
"the",
"core",
"script",
"has",
"been",
"registered",
"or",
"not"
]
| 49bed0d3ca1a9bac9299000e48a2661bdc8f9a29 | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Foundation.php#L70-L78 |
19,602 | 2amigos/yiifoundation | helpers/Foundation.php | Foundation.registerFonts | public static function registerFonts($fonts = array())
{
if (empty($fonts))
return;
foreach ($fonts as $font) {
Icon::registerIconFontSet($font);
}
} | php | public static function registerFonts($fonts = array())
{
if (empty($fonts))
return;
foreach ($fonts as $font) {
Icon::registerIconFontSet($font);
}
} | [
"public",
"static",
"function",
"registerFonts",
"(",
"$",
"fonts",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"fonts",
")",
")",
"return",
";",
"foreach",
"(",
"$",
"fonts",
"as",
"$",
"font",
")",
"{",
"Icon",
"::",
"registerIconFontSet",
"(",
"$",
"font",
")",
";",
"}",
"}"
]
| Registers foundation fonts
@param mixed $fonts the array or string name to register. | [
"Registers",
"foundation",
"fonts"
]
| 49bed0d3ca1a9bac9299000e48a2661bdc8f9a29 | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Foundation.php#L84-L92 |
19,603 | 2amigos/yiifoundation | helpers/Foundation.php | Foundation.registerCoreCss | public static function registerCoreCss()
{
$fileName = \YII_DEBUG ? 'foundation.css' : 'foundation.min.css';
\Yii::app()->clientScript->registerCssFile(static::getAssetsUrl() . '/css/normalize.css');
\Yii::app()->clientScript->registerCssFile(static::getAssetsUrl() . '/css/' . $fileName);
} | php | public static function registerCoreCss()
{
$fileName = \YII_DEBUG ? 'foundation.css' : 'foundation.min.css';
\Yii::app()->clientScript->registerCssFile(static::getAssetsUrl() . '/css/normalize.css');
\Yii::app()->clientScript->registerCssFile(static::getAssetsUrl() . '/css/' . $fileName);
} | [
"public",
"static",
"function",
"registerCoreCss",
"(",
")",
"{",
"$",
"fileName",
"=",
"\\",
"YII_DEBUG",
"?",
"'foundation.css'",
":",
"'foundation.min.css'",
";",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"clientScript",
"->",
"registerCssFile",
"(",
"static",
"::",
"getAssetsUrl",
"(",
")",
".",
"'/css/normalize.css'",
")",
";",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"clientScript",
"->",
"registerCssFile",
"(",
"static",
"::",
"getAssetsUrl",
"(",
")",
".",
"'/css/'",
".",
"$",
"fileName",
")",
";",
"}"
]
| Registers the Foundation CSS. | [
"Registers",
"the",
"Foundation",
"CSS",
"."
]
| 49bed0d3ca1a9bac9299000e48a2661bdc8f9a29 | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Foundation.php#L97-L103 |
19,604 | 2amigos/yiifoundation | helpers/Foundation.php | Foundation.getAssetsUrl | public static function getAssetsUrl($forceCopyAssets = false, $cdn = false)
{
if (!isset(static::$assetsUrl)) {
if ($cdn) {
static::$assetsUrl = '//cdn.jsdelivr.net/foundation/4.3.1/';
} else {
$assetsPath = static::getAssetsPath();
static::$assetsUrl = \Yii::app()->assetManager->publish($assetsPath, true, -1, $forceCopyAssets);
}
}
return static::$assetsUrl;
} | php | public static function getAssetsUrl($forceCopyAssets = false, $cdn = false)
{
if (!isset(static::$assetsUrl)) {
if ($cdn) {
static::$assetsUrl = '//cdn.jsdelivr.net/foundation/4.3.1/';
} else {
$assetsPath = static::getAssetsPath();
static::$assetsUrl = \Yii::app()->assetManager->publish($assetsPath, true, -1, $forceCopyAssets);
}
}
return static::$assetsUrl;
} | [
"public",
"static",
"function",
"getAssetsUrl",
"(",
"$",
"forceCopyAssets",
"=",
"false",
",",
"$",
"cdn",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"assetsUrl",
")",
")",
"{",
"if",
"(",
"$",
"cdn",
")",
"{",
"static",
"::",
"$",
"assetsUrl",
"=",
"'//cdn.jsdelivr.net/foundation/4.3.1/'",
";",
"}",
"else",
"{",
"$",
"assetsPath",
"=",
"static",
"::",
"getAssetsPath",
"(",
")",
";",
"static",
"::",
"$",
"assetsUrl",
"=",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"assetManager",
"->",
"publish",
"(",
"$",
"assetsPath",
",",
"true",
",",
"-",
"1",
",",
"$",
"forceCopyAssets",
")",
";",
"}",
"}",
"return",
"static",
"::",
"$",
"assetsUrl",
";",
"}"
]
| Returns the url to the published assets folder.
@param bool $forceCopyAssets whether to force assets registration or not
@param bool $cdn whether to use CDN version or not
@return string the url. | [
"Returns",
"the",
"url",
"to",
"the",
"published",
"assets",
"folder",
"."
]
| 49bed0d3ca1a9bac9299000e48a2661bdc8f9a29 | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Foundation.php#L111-L122 |
19,605 | 2amigos/yiifoundation | helpers/Foundation.php | Foundation.registerScriptFile | public static function registerScriptFile($asset, $position = \CClientScript::POS_END)
{
\Yii::app()->clientScript->registerScriptFile(static::getAssetsUrl() . "/{$asset}", $position);
} | php | public static function registerScriptFile($asset, $position = \CClientScript::POS_END)
{
\Yii::app()->clientScript->registerScriptFile(static::getAssetsUrl() . "/{$asset}", $position);
} | [
"public",
"static",
"function",
"registerScriptFile",
"(",
"$",
"asset",
",",
"$",
"position",
"=",
"\\",
"CClientScript",
"::",
"POS_END",
")",
"{",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"clientScript",
"->",
"registerScriptFile",
"(",
"static",
"::",
"getAssetsUrl",
"(",
")",
".",
"\"/{$asset}\"",
",",
"$",
"position",
")",
";",
"}"
]
| Registers a specific js assets file
@param string $asset the assets file (ie 'foundation/foundation.abide.js'
@param int $position the position where the script should be registered on the page | [
"Registers",
"a",
"specific",
"js",
"assets",
"file"
]
| 49bed0d3ca1a9bac9299000e48a2661bdc8f9a29 | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Foundation.php#L152-L155 |
19,606 | 2amigos/yiifoundation | helpers/Foundation.php | Foundation.registerBlockGridIeSupport | public static function registerBlockGridIeSupport($position = \CClientScript::POS_END)
{
\Yii::app()->getClientScript()
->registerScript(
__CLASS__,
"(function($){ $(function(){
$('.block-grid.two-up>li:nth-child(2n+1)').css({clear: 'both'});
$('.block-grid.three-up>li:nth-child(3n+1)').css({clear: 'both'});
$('.block-grid.four-up>li:nth-child(4n+1)').css({clear: 'both'});
$('.block-grid.five-up>li:nth-child(5n+1)').css({clear: 'both'});
});})(jQuery);
",
$position
);
} | php | public static function registerBlockGridIeSupport($position = \CClientScript::POS_END)
{
\Yii::app()->getClientScript()
->registerScript(
__CLASS__,
"(function($){ $(function(){
$('.block-grid.two-up>li:nth-child(2n+1)').css({clear: 'both'});
$('.block-grid.three-up>li:nth-child(3n+1)').css({clear: 'both'});
$('.block-grid.four-up>li:nth-child(4n+1)').css({clear: 'both'});
$('.block-grid.five-up>li:nth-child(5n+1)').css({clear: 'both'});
});})(jQuery);
",
$position
);
} | [
"public",
"static",
"function",
"registerBlockGridIeSupport",
"(",
"$",
"position",
"=",
"\\",
"CClientScript",
"::",
"POS_END",
")",
"{",
"\\",
"Yii",
"::",
"app",
"(",
")",
"->",
"getClientScript",
"(",
")",
"->",
"registerScript",
"(",
"__CLASS__",
",",
"\"(function($){ $(function(){\n $('.block-grid.two-up>li:nth-child(2n+1)').css({clear: 'both'});\n $('.block-grid.three-up>li:nth-child(3n+1)').css({clear: 'both'});\n $('.block-grid.four-up>li:nth-child(4n+1)').css({clear: 'both'});\n $('.block-grid.five-up>li:nth-child(5n+1)').css({clear: 'both'});\n });})(jQuery);\n \"",
",",
"$",
"position",
")",
";",
"}"
]
| Registers block-grid support for ie8 if set by its `ie8Support` attribute.
@param int $position the position to render the script | [
"Registers",
"block",
"-",
"grid",
"support",
"for",
"ie8",
"if",
"set",
"by",
"its",
"ie8Support",
"attribute",
"."
]
| 49bed0d3ca1a9bac9299000e48a2661bdc8f9a29 | https://github.com/2amigos/yiifoundation/blob/49bed0d3ca1a9bac9299000e48a2661bdc8f9a29/helpers/Foundation.php#L193-L207 |
19,607 | lmammino/e-foundation | src/Variation/Model/VariableTrait.php | VariableTrait.setMasterVariant | public function setMasterVariant(VariantInterface $masterVariant)
{
$masterVariant->setMaster(true);
/** @var VariantInterface $variant */
foreach ($this->variants as $variant) {
if ($variant->isMaster() && $variant !== $masterVariant) {
$variant->setMaster(false);
}
}
if (!$this->variants->contains($masterVariant)) {
$masterVariant->setObject($this);
$this->variants->add($masterVariant);
}
return $this;
} | php | public function setMasterVariant(VariantInterface $masterVariant)
{
$masterVariant->setMaster(true);
/** @var VariantInterface $variant */
foreach ($this->variants as $variant) {
if ($variant->isMaster() && $variant !== $masterVariant) {
$variant->setMaster(false);
}
}
if (!$this->variants->contains($masterVariant)) {
$masterVariant->setObject($this);
$this->variants->add($masterVariant);
}
return $this;
} | [
"public",
"function",
"setMasterVariant",
"(",
"VariantInterface",
"$",
"masterVariant",
")",
"{",
"$",
"masterVariant",
"->",
"setMaster",
"(",
"true",
")",
";",
"/** @var VariantInterface $variant */",
"foreach",
"(",
"$",
"this",
"->",
"variants",
"as",
"$",
"variant",
")",
"{",
"if",
"(",
"$",
"variant",
"->",
"isMaster",
"(",
")",
"&&",
"$",
"variant",
"!==",
"$",
"masterVariant",
")",
"{",
"$",
"variant",
"->",
"setMaster",
"(",
"false",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"variants",
"->",
"contains",
"(",
"$",
"masterVariant",
")",
")",
"{",
"$",
"masterVariant",
"->",
"setObject",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"variants",
"->",
"add",
"(",
"$",
"masterVariant",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Set the master variant
@param VariantInterface $masterVariant
@return $this | [
"Set",
"the",
"master",
"variant"
]
| 198b7047d93eb11c9bc0c7ddf0bfa8229d42807a | https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Variation/Model/VariableTrait.php#L84-L101 |
19,608 | lmammino/e-foundation | src/Variation/Model/VariableTrait.php | VariableTrait.addVariant | public function addVariant(VariantInterface $variant)
{
if (!$this->hasVariant($variant)) {
$variant->setObject($this);
$this->variants->add($variant);
}
return $this;
} | php | public function addVariant(VariantInterface $variant)
{
if (!$this->hasVariant($variant)) {
$variant->setObject($this);
$this->variants->add($variant);
}
return $this;
} | [
"public",
"function",
"addVariant",
"(",
"VariantInterface",
"$",
"variant",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasVariant",
"(",
"$",
"variant",
")",
")",
"{",
"$",
"variant",
"->",
"setObject",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"variants",
"->",
"add",
"(",
"$",
"variant",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Adds a variant
@param VariantInterface $variant
@return $this | [
"Adds",
"a",
"variant"
]
| 198b7047d93eb11c9bc0c7ddf0bfa8229d42807a | https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Variation/Model/VariableTrait.php#L120-L128 |
19,609 | lmammino/e-foundation | src/Variation/Model/VariableTrait.php | VariableTrait.removeVariant | public function removeVariant(VariantInterface $variant)
{
if ($this->hasVariant($variant)) {
$variant->setObject(null);
$this->variants->removeElement($variant);
}
return $this;
} | php | public function removeVariant(VariantInterface $variant)
{
if ($this->hasVariant($variant)) {
$variant->setObject(null);
$this->variants->removeElement($variant);
}
return $this;
} | [
"public",
"function",
"removeVariant",
"(",
"VariantInterface",
"$",
"variant",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasVariant",
"(",
"$",
"variant",
")",
")",
"{",
"$",
"variant",
"->",
"setObject",
"(",
"null",
")",
";",
"$",
"this",
"->",
"variants",
"->",
"removeElement",
"(",
"$",
"variant",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Removes a variant
@param VariantInterface $variant
@return $this | [
"Removes",
"a",
"variant"
]
| 198b7047d93eb11c9bc0c7ddf0bfa8229d42807a | https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Variation/Model/VariableTrait.php#L137-L145 |
19,610 | lmammino/e-foundation | src/Variation/Model/VariableTrait.php | VariableTrait.setVariabilityOptions | public function setVariabilityOptions(Collection $variabilityOptions)
{
foreach ($variabilityOptions as $variabilityOption) {
$this->addVariabilityOption($variabilityOption);
}
return $this;
} | php | public function setVariabilityOptions(Collection $variabilityOptions)
{
foreach ($variabilityOptions as $variabilityOption) {
$this->addVariabilityOption($variabilityOption);
}
return $this;
} | [
"public",
"function",
"setVariabilityOptions",
"(",
"Collection",
"$",
"variabilityOptions",
")",
"{",
"foreach",
"(",
"$",
"variabilityOptions",
"as",
"$",
"variabilityOption",
")",
"{",
"$",
"this",
"->",
"addVariabilityOption",
"(",
"$",
"variabilityOption",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Sets all variability options
@param Collection $variabilityOptions
@return $this | [
"Sets",
"all",
"variability",
"options"
]
| 198b7047d93eb11c9bc0c7ddf0bfa8229d42807a | https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Variation/Model/VariableTrait.php#L186-L193 |
19,611 | lmammino/e-foundation | src/Variation/Model/VariableTrait.php | VariableTrait.addVariabilityOption | public function addVariabilityOption(OptionInterface $variabilityOption)
{
if (!$this->hasVariabilityOption($variabilityOption)) {
$this->variabilityOptions->add($variabilityOption);
}
return $this;
} | php | public function addVariabilityOption(OptionInterface $variabilityOption)
{
if (!$this->hasVariabilityOption($variabilityOption)) {
$this->variabilityOptions->add($variabilityOption);
}
return $this;
} | [
"public",
"function",
"addVariabilityOption",
"(",
"OptionInterface",
"$",
"variabilityOption",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasVariabilityOption",
"(",
"$",
"variabilityOption",
")",
")",
"{",
"$",
"this",
"->",
"variabilityOptions",
"->",
"add",
"(",
"$",
"variabilityOption",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Adds a given variability option
@param OptionInterface $variabilityOption
@return $this | [
"Adds",
"a",
"given",
"variability",
"option"
]
| 198b7047d93eb11c9bc0c7ddf0bfa8229d42807a | https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Variation/Model/VariableTrait.php#L202-L209 |
19,612 | lmammino/e-foundation | src/Variation/Model/VariableTrait.php | VariableTrait.removeVariabilityOption | public function removeVariabilityOption(OptionInterface $variabilityOption)
{
if ($this->hasVariabilityOption($variabilityOption)) {
$this->variabilityOptions->removeElement($variabilityOption);
}
return $this;
} | php | public function removeVariabilityOption(OptionInterface $variabilityOption)
{
if ($this->hasVariabilityOption($variabilityOption)) {
$this->variabilityOptions->removeElement($variabilityOption);
}
return $this;
} | [
"public",
"function",
"removeVariabilityOption",
"(",
"OptionInterface",
"$",
"variabilityOption",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasVariabilityOption",
"(",
"$",
"variabilityOption",
")",
")",
"{",
"$",
"this",
"->",
"variabilityOptions",
"->",
"removeElement",
"(",
"$",
"variabilityOption",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Removes a given variability option
@param OptionInterface $variabilityOption
@return $this | [
"Removes",
"a",
"given",
"variability",
"option"
]
| 198b7047d93eb11c9bc0c7ddf0bfa8229d42807a | https://github.com/lmammino/e-foundation/blob/198b7047d93eb11c9bc0c7ddf0bfa8229d42807a/src/Variation/Model/VariableTrait.php#L218-L225 |
19,613 | nyeholt/silverstripe-external-content | thirdparty/Zend/Uri/Http.php | Zend_Uri_Http._parseUri | protected function _parseUri($schemeSpecific)
{
// High-level decomposition parser
$pattern = '~^((//)([^/?#]*))([^?#]*)(\?([^#]*))?(#(.*))?$~';
$status = @preg_match($pattern, $schemeSpecific, $matches);
if ($status === false) {
require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('Internal error: scheme-specific decomposition failed');
}
// Failed decomposition; no further processing needed
if ($status === false) {
return;
}
// Save URI components that need no further decomposition
$this->_path = isset($matches[4]) === true ? $matches[4] : '';
$this->_query = isset($matches[6]) === true ? $matches[6] : '';
$this->_fragment = isset($matches[8]) === true ? $matches[8] : '';
// Additional decomposition to get username, password, host, and port
$combo = isset($matches[3]) === true ? $matches[3] : '';
$pattern = '~^(([^:@]*)(:([^@]*))?@)?([^:]+)(:(.*))?$~';
$status = @preg_match($pattern, $combo, $matches);
if ($status === false) {
require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('Internal error: authority decomposition failed');
}
// Failed decomposition; no further processing needed
if ($status === false) {
return;
}
// Save remaining URI components
$this->_username = isset($matches[2]) === true ? $matches[2] : '';
$this->_password = isset($matches[4]) === true ? $matches[4] : '';
$this->_host = isset($matches[5]) === true ? $matches[5] : '';
$this->_port = isset($matches[7]) === true ? $matches[7] : '';
} | php | protected function _parseUri($schemeSpecific)
{
// High-level decomposition parser
$pattern = '~^((//)([^/?#]*))([^?#]*)(\?([^#]*))?(#(.*))?$~';
$status = @preg_match($pattern, $schemeSpecific, $matches);
if ($status === false) {
require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('Internal error: scheme-specific decomposition failed');
}
// Failed decomposition; no further processing needed
if ($status === false) {
return;
}
// Save URI components that need no further decomposition
$this->_path = isset($matches[4]) === true ? $matches[4] : '';
$this->_query = isset($matches[6]) === true ? $matches[6] : '';
$this->_fragment = isset($matches[8]) === true ? $matches[8] : '';
// Additional decomposition to get username, password, host, and port
$combo = isset($matches[3]) === true ? $matches[3] : '';
$pattern = '~^(([^:@]*)(:([^@]*))?@)?([^:]+)(:(.*))?$~';
$status = @preg_match($pattern, $combo, $matches);
if ($status === false) {
require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('Internal error: authority decomposition failed');
}
// Failed decomposition; no further processing needed
if ($status === false) {
return;
}
// Save remaining URI components
$this->_username = isset($matches[2]) === true ? $matches[2] : '';
$this->_password = isset($matches[4]) === true ? $matches[4] : '';
$this->_host = isset($matches[5]) === true ? $matches[5] : '';
$this->_port = isset($matches[7]) === true ? $matches[7] : '';
} | [
"protected",
"function",
"_parseUri",
"(",
"$",
"schemeSpecific",
")",
"{",
"// High-level decomposition parser",
"$",
"pattern",
"=",
"'~^((//)([^/?#]*))([^?#]*)(\\?([^#]*))?(#(.*))?$~'",
";",
"$",
"status",
"=",
"@",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"schemeSpecific",
",",
"$",
"matches",
")",
";",
"if",
"(",
"$",
"status",
"===",
"false",
")",
"{",
"require_once",
"'Zend/Uri/Exception.php'",
";",
"throw",
"new",
"Zend_Uri_Exception",
"(",
"'Internal error: scheme-specific decomposition failed'",
")",
";",
"}",
"// Failed decomposition; no further processing needed",
"if",
"(",
"$",
"status",
"===",
"false",
")",
"{",
"return",
";",
"}",
"// Save URI components that need no further decomposition",
"$",
"this",
"->",
"_path",
"=",
"isset",
"(",
"$",
"matches",
"[",
"4",
"]",
")",
"===",
"true",
"?",
"$",
"matches",
"[",
"4",
"]",
":",
"''",
";",
"$",
"this",
"->",
"_query",
"=",
"isset",
"(",
"$",
"matches",
"[",
"6",
"]",
")",
"===",
"true",
"?",
"$",
"matches",
"[",
"6",
"]",
":",
"''",
";",
"$",
"this",
"->",
"_fragment",
"=",
"isset",
"(",
"$",
"matches",
"[",
"8",
"]",
")",
"===",
"true",
"?",
"$",
"matches",
"[",
"8",
"]",
":",
"''",
";",
"// Additional decomposition to get username, password, host, and port",
"$",
"combo",
"=",
"isset",
"(",
"$",
"matches",
"[",
"3",
"]",
")",
"===",
"true",
"?",
"$",
"matches",
"[",
"3",
"]",
":",
"''",
";",
"$",
"pattern",
"=",
"'~^(([^:@]*)(:([^@]*))?@)?([^:]+)(:(.*))?$~'",
";",
"$",
"status",
"=",
"@",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"combo",
",",
"$",
"matches",
")",
";",
"if",
"(",
"$",
"status",
"===",
"false",
")",
"{",
"require_once",
"'Zend/Uri/Exception.php'",
";",
"throw",
"new",
"Zend_Uri_Exception",
"(",
"'Internal error: authority decomposition failed'",
")",
";",
"}",
"// Failed decomposition; no further processing needed",
"if",
"(",
"$",
"status",
"===",
"false",
")",
"{",
"return",
";",
"}",
"// Save remaining URI components",
"$",
"this",
"->",
"_username",
"=",
"isset",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
"===",
"true",
"?",
"$",
"matches",
"[",
"2",
"]",
":",
"''",
";",
"$",
"this",
"->",
"_password",
"=",
"isset",
"(",
"$",
"matches",
"[",
"4",
"]",
")",
"===",
"true",
"?",
"$",
"matches",
"[",
"4",
"]",
":",
"''",
";",
"$",
"this",
"->",
"_host",
"=",
"isset",
"(",
"$",
"matches",
"[",
"5",
"]",
")",
"===",
"true",
"?",
"$",
"matches",
"[",
"5",
"]",
":",
"''",
";",
"$",
"this",
"->",
"_port",
"=",
"isset",
"(",
"$",
"matches",
"[",
"7",
"]",
")",
"===",
"true",
"?",
"$",
"matches",
"[",
"7",
"]",
":",
"''",
";",
"}"
]
| Parse the scheme-specific portion of the URI and place its parts into instance variables.
@param string $schemeSpecific The scheme-specific portion to parse
@throws Zend_Uri_Exception When scheme-specific decoposition fails
@throws Zend_Uri_Exception When authority decomposition fails
@return void | [
"Parse",
"the",
"scheme",
"-",
"specific",
"portion",
"of",
"the",
"URI",
"and",
"place",
"its",
"parts",
"into",
"instance",
"variables",
"."
]
| 1c6da8c56ef717225ff904e1522aff94ed051601 | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Uri/Http.php#L198-L238 |
19,614 | nyeholt/silverstripe-external-content | thirdparty/Zend/Uri/Http.php | Zend_Uri_Http.getUri | public function getUri()
{
if ($this->valid() === false) {
require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('One or more parts of the URI are invalid');
}
$password = strlen($this->_password) > 0 ? ":$this->_password" : '';
$auth = strlen($this->_username) > 0 ? "$this->_username$password@" : '';
$port = strlen($this->_port) > 0 ? ":$this->_port" : '';
$query = strlen($this->_query) > 0 ? "?$this->_query" : '';
$fragment = strlen($this->_fragment) > 0 ? "#$this->_fragment" : '';
return $this->_scheme
. '://'
. $auth
. $this->_host
. $port
. $this->_path
. $query
. $fragment;
} | php | public function getUri()
{
if ($this->valid() === false) {
require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('One or more parts of the URI are invalid');
}
$password = strlen($this->_password) > 0 ? ":$this->_password" : '';
$auth = strlen($this->_username) > 0 ? "$this->_username$password@" : '';
$port = strlen($this->_port) > 0 ? ":$this->_port" : '';
$query = strlen($this->_query) > 0 ? "?$this->_query" : '';
$fragment = strlen($this->_fragment) > 0 ? "#$this->_fragment" : '';
return $this->_scheme
. '://'
. $auth
. $this->_host
. $port
. $this->_path
. $query
. $fragment;
} | [
"public",
"function",
"getUri",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"valid",
"(",
")",
"===",
"false",
")",
"{",
"require_once",
"'Zend/Uri/Exception.php'",
";",
"throw",
"new",
"Zend_Uri_Exception",
"(",
"'One or more parts of the URI are invalid'",
")",
";",
"}",
"$",
"password",
"=",
"strlen",
"(",
"$",
"this",
"->",
"_password",
")",
">",
"0",
"?",
"\":$this->_password\"",
":",
"''",
";",
"$",
"auth",
"=",
"strlen",
"(",
"$",
"this",
"->",
"_username",
")",
">",
"0",
"?",
"\"$this->_username$password@\"",
":",
"''",
";",
"$",
"port",
"=",
"strlen",
"(",
"$",
"this",
"->",
"_port",
")",
">",
"0",
"?",
"\":$this->_port\"",
":",
"''",
";",
"$",
"query",
"=",
"strlen",
"(",
"$",
"this",
"->",
"_query",
")",
">",
"0",
"?",
"\"?$this->_query\"",
":",
"''",
";",
"$",
"fragment",
"=",
"strlen",
"(",
"$",
"this",
"->",
"_fragment",
")",
">",
"0",
"?",
"\"#$this->_fragment\"",
":",
"''",
";",
"return",
"$",
"this",
"->",
"_scheme",
".",
"'://'",
".",
"$",
"auth",
".",
"$",
"this",
"->",
"_host",
".",
"$",
"port",
".",
"$",
"this",
"->",
"_path",
".",
"$",
"query",
".",
"$",
"fragment",
";",
"}"
]
| Returns a URI based on current values of the instance variables. If any
part of the URI does not pass validation, then an exception is thrown.
@throws Zend_Uri_Exception When one or more parts of the URI are invalid
@return string | [
"Returns",
"a",
"URI",
"based",
"on",
"current",
"values",
"of",
"the",
"instance",
"variables",
".",
"If",
"any",
"part",
"of",
"the",
"URI",
"does",
"not",
"pass",
"validation",
"then",
"an",
"exception",
"is",
"thrown",
"."
]
| 1c6da8c56ef717225ff904e1522aff94ed051601 | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Uri/Http.php#L247-L268 |
19,615 | nyeholt/silverstripe-external-content | thirdparty/Zend/Uri/Http.php | Zend_Uri_Http.validatePath | public function validatePath($path = null)
{
if ($path === null) {
$path = $this->_path;
}
// If the path is empty, then it is considered valid
if (strlen($path) === 0) {
return true;
}
// Determine whether the path is well-formed
$pattern = '/^' . $this->_regex['path'] . '$/';
$status = @preg_match($pattern, $path);
if ($status === false) {
require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('Internal error: path validation failed');
}
return (boolean) $status;
} | php | public function validatePath($path = null)
{
if ($path === null) {
$path = $this->_path;
}
// If the path is empty, then it is considered valid
if (strlen($path) === 0) {
return true;
}
// Determine whether the path is well-formed
$pattern = '/^' . $this->_regex['path'] . '$/';
$status = @preg_match($pattern, $path);
if ($status === false) {
require_once 'Zend/Uri/Exception.php';
throw new Zend_Uri_Exception('Internal error: path validation failed');
}
return (boolean) $status;
} | [
"public",
"function",
"validatePath",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"path",
"===",
"null",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"_path",
";",
"}",
"// If the path is empty, then it is considered valid",
"if",
"(",
"strlen",
"(",
"$",
"path",
")",
"===",
"0",
")",
"{",
"return",
"true",
";",
"}",
"// Determine whether the path is well-formed",
"$",
"pattern",
"=",
"'/^'",
".",
"$",
"this",
"->",
"_regex",
"[",
"'path'",
"]",
".",
"'$/'",
";",
"$",
"status",
"=",
"@",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"path",
")",
";",
"if",
"(",
"$",
"status",
"===",
"false",
")",
"{",
"require_once",
"'Zend/Uri/Exception.php'",
";",
"throw",
"new",
"Zend_Uri_Exception",
"(",
"'Internal error: path validation failed'",
")",
";",
"}",
"return",
"(",
"boolean",
")",
"$",
"status",
";",
"}"
]
| Returns true if and only if the path string passes validation. If no path is passed,
then the path contained in the instance variable is used.
@param string $path The HTTP path
@throws Zend_Uri_Exception When path validation fails
@return boolean | [
"Returns",
"true",
"if",
"and",
"only",
"if",
"the",
"path",
"string",
"passes",
"validation",
".",
"If",
"no",
"path",
"is",
"passed",
"then",
"the",
"path",
"contained",
"in",
"the",
"instance",
"variable",
"is",
"used",
"."
]
| 1c6da8c56ef717225ff904e1522aff94ed051601 | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Uri/Http.php#L542-L562 |
19,616 | periaptio/empress-generator | src/Generators/BaseGenerator.php | BaseGenerator.generateContent | protected function generateContent($templatePath, $templateData)
{
$template = $this->getTemplate($templatePath);
$content = $this->compile($template, $templateData);
return $content;
} | php | protected function generateContent($templatePath, $templateData)
{
$template = $this->getTemplate($templatePath);
$content = $this->compile($template, $templateData);
return $content;
} | [
"protected",
"function",
"generateContent",
"(",
"$",
"templatePath",
",",
"$",
"templateData",
")",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"getTemplate",
"(",
"$",
"templatePath",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"compile",
"(",
"$",
"template",
",",
"$",
"templateData",
")",
";",
"return",
"$",
"content",
";",
"}"
]
| Generate content with template data is given.
@param array $templateData
@return string | [
"Generate",
"content",
"with",
"template",
"data",
"is",
"given",
"."
]
| 749fb4b12755819e9c97377ebfb446ee0822168a | https://github.com/periaptio/empress-generator/blob/749fb4b12755819e9c97377ebfb446ee0822168a/src/Generators/BaseGenerator.php#L138-L145 |
19,617 | periaptio/empress-generator | src/Generators/BaseGenerator.php | BaseGenerator.getTemplate | protected function getTemplate($templatePath)
{
$path = base_path('resources/generator-templates/'.$templatePath.'.stub');
if (!file_exists($path)) {
$path = __DIR__.'/../../templates/'.$templatePath.'.stub';
}
return $this->fileHelper->get($path);
} | php | protected function getTemplate($templatePath)
{
$path = base_path('resources/generator-templates/'.$templatePath.'.stub');
if (!file_exists($path)) {
$path = __DIR__.'/../../templates/'.$templatePath.'.stub';
}
return $this->fileHelper->get($path);
} | [
"protected",
"function",
"getTemplate",
"(",
"$",
"templatePath",
")",
"{",
"$",
"path",
"=",
"base_path",
"(",
"'resources/generator-templates/'",
".",
"$",
"templatePath",
".",
"'.stub'",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"__DIR__",
".",
"'/../../templates/'",
".",
"$",
"templatePath",
".",
"'.stub'",
";",
"}",
"return",
"$",
"this",
"->",
"fileHelper",
"->",
"get",
"(",
"$",
"path",
")",
";",
"}"
]
| Get the template for the generator.
@param string $templatePath
@return string | [
"Get",
"the",
"template",
"for",
"the",
"generator",
"."
]
| 749fb4b12755819e9c97377ebfb446ee0822168a | https://github.com/periaptio/empress-generator/blob/749fb4b12755819e9c97377ebfb446ee0822168a/src/Generators/BaseGenerator.php#L153-L162 |
19,618 | webforge-labs/psc-cms | lib/Psc/System/LoggerObject.php | LoggerObject.logError | public function logError(\Exception $e, $detailLevel = 1, $level = 1) {
if ($detailLevel >= 5) {
return $this->log("\n".'ERROR: '.\Psc\Exception::getExceptionText($e, 'text'));
} else {
return $this->log("\n".'ERROR: Exception: '.$e->getMessage(), $level);
}
} | php | public function logError(\Exception $e, $detailLevel = 1, $level = 1) {
if ($detailLevel >= 5) {
return $this->log("\n".'ERROR: '.\Psc\Exception::getExceptionText($e, 'text'));
} else {
return $this->log("\n".'ERROR: Exception: '.$e->getMessage(), $level);
}
} | [
"public",
"function",
"logError",
"(",
"\\",
"Exception",
"$",
"e",
",",
"$",
"detailLevel",
"=",
"1",
",",
"$",
"level",
"=",
"1",
")",
"{",
"if",
"(",
"$",
"detailLevel",
">=",
"5",
")",
"{",
"return",
"$",
"this",
"->",
"log",
"(",
"\"\\n\"",
".",
"'ERROR: '",
".",
"\\",
"Psc",
"\\",
"Exception",
"::",
"getExceptionText",
"(",
"$",
"e",
",",
"'text'",
")",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"log",
"(",
"\"\\n\"",
".",
"'ERROR: Exception: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"level",
")",
";",
"}",
"}"
]
| ab detailLevel >= 5 wird der exceptionTrace mit geloggt | [
"ab",
"detailLevel",
">",
"=",
"5",
"wird",
"der",
"exceptionTrace",
"mit",
"geloggt"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/System/LoggerObject.php#L42-L48 |
19,619 | ray-di/Ray.ValidateModule | src/ValidateInterceptor.php | ValidateInterceptor.getOnValidate | private function getOnValidate(\ReflectionMethod $method)
{
/** @var $valid Valid */
$valid = $this->reader->getMethodAnnotation($method, Valid::class);
$class = $method->getDeclaringClass();
$onMethods = $this->findOnMethods($class, $valid);
if ($onMethods[0] && $onMethods[0] instanceof \ReflectionMethod) {
return $onMethods;
}
throw new ValidateMethodNotFound($method->getShortName());
} | php | private function getOnValidate(\ReflectionMethod $method)
{
/** @var $valid Valid */
$valid = $this->reader->getMethodAnnotation($method, Valid::class);
$class = $method->getDeclaringClass();
$onMethods = $this->findOnMethods($class, $valid);
if ($onMethods[0] && $onMethods[0] instanceof \ReflectionMethod) {
return $onMethods;
}
throw new ValidateMethodNotFound($method->getShortName());
} | [
"private",
"function",
"getOnValidate",
"(",
"\\",
"ReflectionMethod",
"$",
"method",
")",
"{",
"/** @var $valid Valid */",
"$",
"valid",
"=",
"$",
"this",
"->",
"reader",
"->",
"getMethodAnnotation",
"(",
"$",
"method",
",",
"Valid",
"::",
"class",
")",
";",
"$",
"class",
"=",
"$",
"method",
"->",
"getDeclaringClass",
"(",
")",
";",
"$",
"onMethods",
"=",
"$",
"this",
"->",
"findOnMethods",
"(",
"$",
"class",
",",
"$",
"valid",
")",
";",
"if",
"(",
"$",
"onMethods",
"[",
"0",
"]",
"&&",
"$",
"onMethods",
"[",
"0",
"]",
"instanceof",
"\\",
"ReflectionMethod",
")",
"{",
"return",
"$",
"onMethods",
";",
"}",
"throw",
"new",
"ValidateMethodNotFound",
"(",
"$",
"method",
"->",
"getShortName",
"(",
")",
")",
";",
"}"
]
| Return Validate and OnFailure method
@param \ReflectionMethod $method
@return \ReflectionMethod[] [$onValidateMethod, $onFailureMethod] | [
"Return",
"Validate",
"and",
"OnFailure",
"method"
]
| 7e4e3c4a05e11dc989d689202ac6ae625695588e | https://github.com/ray-di/Ray.ValidateModule/blob/7e4e3c4a05e11dc989d689202ac6ae625695588e/src/ValidateInterceptor.php#L56-L66 |
19,620 | ray-di/Ray.ValidateModule | src/ValidateInterceptor.php | ValidateInterceptor.validate | private function validate(MethodInvocation $invocation, \ReflectionMethod $onValidate, \ReflectionMethod $onFailure = null)
{
$validation = $onValidate->invokeArgs($invocation->getThis(), (array) $invocation->getArguments());
if ($validation instanceof Validation && $validation->getMessages()) {
/* @var $validation Validation */
$validation->setInvocation($invocation);
$failure = $this->getFailure($invocation, $validation, $onFailure);
if ($failure instanceof \Exception) {
throw $failure;
}
return [false, $failure];
}
return [true, null];
} | php | private function validate(MethodInvocation $invocation, \ReflectionMethod $onValidate, \ReflectionMethod $onFailure = null)
{
$validation = $onValidate->invokeArgs($invocation->getThis(), (array) $invocation->getArguments());
if ($validation instanceof Validation && $validation->getMessages()) {
/* @var $validation Validation */
$validation->setInvocation($invocation);
$failure = $this->getFailure($invocation, $validation, $onFailure);
if ($failure instanceof \Exception) {
throw $failure;
}
return [false, $failure];
}
return [true, null];
} | [
"private",
"function",
"validate",
"(",
"MethodInvocation",
"$",
"invocation",
",",
"\\",
"ReflectionMethod",
"$",
"onValidate",
",",
"\\",
"ReflectionMethod",
"$",
"onFailure",
"=",
"null",
")",
"{",
"$",
"validation",
"=",
"$",
"onValidate",
"->",
"invokeArgs",
"(",
"$",
"invocation",
"->",
"getThis",
"(",
")",
",",
"(",
"array",
")",
"$",
"invocation",
"->",
"getArguments",
"(",
")",
")",
";",
"if",
"(",
"$",
"validation",
"instanceof",
"Validation",
"&&",
"$",
"validation",
"->",
"getMessages",
"(",
")",
")",
"{",
"/* @var $validation Validation */",
"$",
"validation",
"->",
"setInvocation",
"(",
"$",
"invocation",
")",
";",
"$",
"failure",
"=",
"$",
"this",
"->",
"getFailure",
"(",
"$",
"invocation",
",",
"$",
"validation",
",",
"$",
"onFailure",
")",
";",
"if",
"(",
"$",
"failure",
"instanceof",
"\\",
"Exception",
")",
"{",
"throw",
"$",
"failure",
";",
"}",
"return",
"[",
"false",
",",
"$",
"failure",
"]",
";",
"}",
"return",
"[",
"true",
",",
"null",
"]",
";",
"}"
]
| Validate with Validate method
@param MethodInvocation $invocation
@param \ReflectionMethod $onValidate
@param \ReflectionMethod $onFailure
@throws \Exception
@return bool|mixed|InvalidArgumentException | [
"Validate",
"with",
"Validate",
"method"
]
| 7e4e3c4a05e11dc989d689202ac6ae625695588e | https://github.com/ray-di/Ray.ValidateModule/blob/7e4e3c4a05e11dc989d689202ac6ae625695588e/src/ValidateInterceptor.php#L79-L94 |
19,621 | ray-di/Ray.ValidateModule | src/ValidateInterceptor.php | ValidateInterceptor.getFailure | private function getFailure(MethodInvocation $invocation, FailureInterface $failure, \ReflectionMethod $onFailure = null)
{
if ($onFailure) {
return $onFailure->invoke($invocation->getThis(), $failure);
}
return $this->failureException($invocation, $failure);
} | php | private function getFailure(MethodInvocation $invocation, FailureInterface $failure, \ReflectionMethod $onFailure = null)
{
if ($onFailure) {
return $onFailure->invoke($invocation->getThis(), $failure);
}
return $this->failureException($invocation, $failure);
} | [
"private",
"function",
"getFailure",
"(",
"MethodInvocation",
"$",
"invocation",
",",
"FailureInterface",
"$",
"failure",
",",
"\\",
"ReflectionMethod",
"$",
"onFailure",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"onFailure",
")",
"{",
"return",
"$",
"onFailure",
"->",
"invoke",
"(",
"$",
"invocation",
"->",
"getThis",
"(",
")",
",",
"$",
"failure",
")",
";",
"}",
"return",
"$",
"this",
"->",
"failureException",
"(",
"$",
"invocation",
",",
"$",
"failure",
")",
";",
"}"
]
| Return result OnFailure
@param MethodInvocation $invocation
@param FailureInterface $failure
@param \ReflectionMethod $onFailure
@return mixed|InvalidArgumentException | [
"Return",
"result",
"OnFailure"
]
| 7e4e3c4a05e11dc989d689202ac6ae625695588e | https://github.com/ray-di/Ray.ValidateModule/blob/7e4e3c4a05e11dc989d689202ac6ae625695588e/src/ValidateInterceptor.php#L105-L112 |
19,622 | ray-di/Ray.ValidateModule | src/ValidateInterceptor.php | ValidateInterceptor.failureException | private function failureException(MethodInvocation $invocation, FailureInterface $failure)
{
$class = new \ReflectionClass($invocation->getThis());
$className = $class->implementsInterface(WeavedInterface::class) ? $class->getParentClass()->name : $class->name;
$errors = json_encode($failure->getMessages());
$msg = sprintf('%s::%s() %s', $className, $invocation->getMethod()->name, $errors);
return new InvalidArgumentException($msg, 400);
} | php | private function failureException(MethodInvocation $invocation, FailureInterface $failure)
{
$class = new \ReflectionClass($invocation->getThis());
$className = $class->implementsInterface(WeavedInterface::class) ? $class->getParentClass()->name : $class->name;
$errors = json_encode($failure->getMessages());
$msg = sprintf('%s::%s() %s', $className, $invocation->getMethod()->name, $errors);
return new InvalidArgumentException($msg, 400);
} | [
"private",
"function",
"failureException",
"(",
"MethodInvocation",
"$",
"invocation",
",",
"FailureInterface",
"$",
"failure",
")",
"{",
"$",
"class",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"invocation",
"->",
"getThis",
"(",
")",
")",
";",
"$",
"className",
"=",
"$",
"class",
"->",
"implementsInterface",
"(",
"WeavedInterface",
"::",
"class",
")",
"?",
"$",
"class",
"->",
"getParentClass",
"(",
")",
"->",
"name",
":",
"$",
"class",
"->",
"name",
";",
"$",
"errors",
"=",
"json_encode",
"(",
"$",
"failure",
"->",
"getMessages",
"(",
")",
")",
";",
"$",
"msg",
"=",
"sprintf",
"(",
"'%s::%s() %s'",
",",
"$",
"className",
",",
"$",
"invocation",
"->",
"getMethod",
"(",
")",
"->",
"name",
",",
"$",
"errors",
")",
";",
"return",
"new",
"InvalidArgumentException",
"(",
"$",
"msg",
",",
"400",
")",
";",
"}"
]
| Return InvalidArgumentException exception
@param MethodInvocation $invocation
@param FailureInterface $failure
@return InvalidArgumentException | [
"Return",
"InvalidArgumentException",
"exception"
]
| 7e4e3c4a05e11dc989d689202ac6ae625695588e | https://github.com/ray-di/Ray.ValidateModule/blob/7e4e3c4a05e11dc989d689202ac6ae625695588e/src/ValidateInterceptor.php#L122-L130 |
19,623 | Lansoweb/LosReCaptcha | src/Form/View/Helper/Captcha/ReCaptcha.php | ReCaptcha.render | public function render(ElementInterface $element)
{
$attributes = $element->getAttributes();
$captcha = $element->getCaptcha();
if ($captcha === null || ! $captcha instanceof CaptchaAdapter) {
throw new Exception\DomainException(sprintf(
'%s requires that the element has a "captcha" is an instance of LosReCaptcha\Captcha\ReCaptcha',
__METHOD__
));
}
$name = $element->getName();
$id = isset($attributes['id']) ? $attributes['id'] : $name;
$responseName = empty($name) ? 'recaptcha_response_field' : $name . '[recaptcha_response_field]';
$responseId = $id . '-response';
$markup = $captcha->getService()->getHtml($name);
$hidden = $this->renderHiddenInput($responseName, $responseId);
$js = $this->renderJsEvents($responseId);
return $hidden . $markup . $js;
} | php | public function render(ElementInterface $element)
{
$attributes = $element->getAttributes();
$captcha = $element->getCaptcha();
if ($captcha === null || ! $captcha instanceof CaptchaAdapter) {
throw new Exception\DomainException(sprintf(
'%s requires that the element has a "captcha" is an instance of LosReCaptcha\Captcha\ReCaptcha',
__METHOD__
));
}
$name = $element->getName();
$id = isset($attributes['id']) ? $attributes['id'] : $name;
$responseName = empty($name) ? 'recaptcha_response_field' : $name . '[recaptcha_response_field]';
$responseId = $id . '-response';
$markup = $captcha->getService()->getHtml($name);
$hidden = $this->renderHiddenInput($responseName, $responseId);
$js = $this->renderJsEvents($responseId);
return $hidden . $markup . $js;
} | [
"public",
"function",
"render",
"(",
"ElementInterface",
"$",
"element",
")",
"{",
"$",
"attributes",
"=",
"$",
"element",
"->",
"getAttributes",
"(",
")",
";",
"$",
"captcha",
"=",
"$",
"element",
"->",
"getCaptcha",
"(",
")",
";",
"if",
"(",
"$",
"captcha",
"===",
"null",
"||",
"!",
"$",
"captcha",
"instanceof",
"CaptchaAdapter",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"DomainException",
"(",
"sprintf",
"(",
"'%s requires that the element has a \"captcha\" is an instance of LosReCaptcha\\Captcha\\ReCaptcha'",
",",
"__METHOD__",
")",
")",
";",
"}",
"$",
"name",
"=",
"$",
"element",
"->",
"getName",
"(",
")",
";",
"$",
"id",
"=",
"isset",
"(",
"$",
"attributes",
"[",
"'id'",
"]",
")",
"?",
"$",
"attributes",
"[",
"'id'",
"]",
":",
"$",
"name",
";",
"$",
"responseName",
"=",
"empty",
"(",
"$",
"name",
")",
"?",
"'recaptcha_response_field'",
":",
"$",
"name",
".",
"'[recaptcha_response_field]'",
";",
"$",
"responseId",
"=",
"$",
"id",
".",
"'-response'",
";",
"$",
"markup",
"=",
"$",
"captcha",
"->",
"getService",
"(",
")",
"->",
"getHtml",
"(",
"$",
"name",
")",
";",
"$",
"hidden",
"=",
"$",
"this",
"->",
"renderHiddenInput",
"(",
"$",
"responseName",
",",
"$",
"responseId",
")",
";",
"$",
"js",
"=",
"$",
"this",
"->",
"renderJsEvents",
"(",
"$",
"responseId",
")",
";",
"return",
"$",
"hidden",
".",
"$",
"markup",
".",
"$",
"js",
";",
"}"
]
| Render ReCaptcha form elements
@param ElementInterface $element
@throws Exception\DomainException
@return string | [
"Render",
"ReCaptcha",
"form",
"elements"
]
| 8df866995501db087c3850f97fd2b6547632e6ed | https://github.com/Lansoweb/LosReCaptcha/blob/8df866995501db087c3850f97fd2b6547632e6ed/src/Form/View/Helper/Captcha/ReCaptcha.php#L43-L65 |
19,624 | CakeCMS/Core | src/Controller/Component/AppComponent.php | AppComponent.redirect | public function redirect(array $options = [])
{
$plugin = $this->_request->getParam('plugin');
$controller = $this->_request->getParam('controller');
$_options = [
'apply' => [],
'savenew' => [
'plugin' => $plugin,
'controller' => $controller,
'action' => 'add'
],
'save' => [
'plugin' => $plugin,
'controller' => $controller,
'action' => 'index',
]
];
$options = Hash::merge($_options, $options);
$url = $options['save'];
if ($rAction = $this->_request->getData('action')) {
list(, $action) = pluginSplit($rAction);
$action = Str::low($action);
if (Arr::key($action, $options)) {
$url = $options[$action];
}
}
return $this->_controller->redirect($url);
} | php | public function redirect(array $options = [])
{
$plugin = $this->_request->getParam('plugin');
$controller = $this->_request->getParam('controller');
$_options = [
'apply' => [],
'savenew' => [
'plugin' => $plugin,
'controller' => $controller,
'action' => 'add'
],
'save' => [
'plugin' => $plugin,
'controller' => $controller,
'action' => 'index',
]
];
$options = Hash::merge($_options, $options);
$url = $options['save'];
if ($rAction = $this->_request->getData('action')) {
list(, $action) = pluginSplit($rAction);
$action = Str::low($action);
if (Arr::key($action, $options)) {
$url = $options[$action];
}
}
return $this->_controller->redirect($url);
} | [
"public",
"function",
"redirect",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"plugin",
"=",
"$",
"this",
"->",
"_request",
"->",
"getParam",
"(",
"'plugin'",
")",
";",
"$",
"controller",
"=",
"$",
"this",
"->",
"_request",
"->",
"getParam",
"(",
"'controller'",
")",
";",
"$",
"_options",
"=",
"[",
"'apply'",
"=>",
"[",
"]",
",",
"'savenew'",
"=>",
"[",
"'plugin'",
"=>",
"$",
"plugin",
",",
"'controller'",
"=>",
"$",
"controller",
",",
"'action'",
"=>",
"'add'",
"]",
",",
"'save'",
"=>",
"[",
"'plugin'",
"=>",
"$",
"plugin",
",",
"'controller'",
"=>",
"$",
"controller",
",",
"'action'",
"=>",
"'index'",
",",
"]",
"]",
";",
"$",
"options",
"=",
"Hash",
"::",
"merge",
"(",
"$",
"_options",
",",
"$",
"options",
")",
";",
"$",
"url",
"=",
"$",
"options",
"[",
"'save'",
"]",
";",
"if",
"(",
"$",
"rAction",
"=",
"$",
"this",
"->",
"_request",
"->",
"getData",
"(",
"'action'",
")",
")",
"{",
"list",
"(",
",",
"$",
"action",
")",
"=",
"pluginSplit",
"(",
"$",
"rAction",
")",
";",
"$",
"action",
"=",
"Str",
"::",
"low",
"(",
"$",
"action",
")",
";",
"if",
"(",
"Arr",
"::",
"key",
"(",
"$",
"action",
",",
"$",
"options",
")",
")",
"{",
"$",
"url",
"=",
"$",
"options",
"[",
"$",
"action",
"]",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_controller",
"->",
"redirect",
"(",
"$",
"url",
")",
";",
"}"
]
| Redirect by request data.
@param array $options
@return \Cake\Http\Response|null | [
"Redirect",
"by",
"request",
"data",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/AppComponent.php#L69-L100 |
19,625 | CakeCMS/Core | src/Controller/Component/AppComponent.php | AppComponent.toggleField | public function toggleField(Table $table, $id, $value, $field = 'status')
{
$this->checkIsAjax();
$this->_checkToggleData($id, $value);
$this->_controller->viewBuilder()
->setLayout('ajax')
->setTemplate('toggle')
->setTemplatePath('Common');
$entity = $table->get($id);
$entity->set($field, !(int) $value);
if ($result = $table->save($entity)) {
$this->_controller->set('entity', $result);
$this->_controller->render('toggle');
} else {
throw new \RuntimeException(__d('core', 'Failed toggling field {0} to {1}', $field, $entity->get($field)));
}
} | php | public function toggleField(Table $table, $id, $value, $field = 'status')
{
$this->checkIsAjax();
$this->_checkToggleData($id, $value);
$this->_controller->viewBuilder()
->setLayout('ajax')
->setTemplate('toggle')
->setTemplatePath('Common');
$entity = $table->get($id);
$entity->set($field, !(int) $value);
if ($result = $table->save($entity)) {
$this->_controller->set('entity', $result);
$this->_controller->render('toggle');
} else {
throw new \RuntimeException(__d('core', 'Failed toggling field {0} to {1}', $field, $entity->get($field)));
}
} | [
"public",
"function",
"toggleField",
"(",
"Table",
"$",
"table",
",",
"$",
"id",
",",
"$",
"value",
",",
"$",
"field",
"=",
"'status'",
")",
"{",
"$",
"this",
"->",
"checkIsAjax",
"(",
")",
";",
"$",
"this",
"->",
"_checkToggleData",
"(",
"$",
"id",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"_controller",
"->",
"viewBuilder",
"(",
")",
"->",
"setLayout",
"(",
"'ajax'",
")",
"->",
"setTemplate",
"(",
"'toggle'",
")",
"->",
"setTemplatePath",
"(",
"'Common'",
")",
";",
"$",
"entity",
"=",
"$",
"table",
"->",
"get",
"(",
"$",
"id",
")",
";",
"$",
"entity",
"->",
"set",
"(",
"$",
"field",
",",
"!",
"(",
"int",
")",
"$",
"value",
")",
";",
"if",
"(",
"$",
"result",
"=",
"$",
"table",
"->",
"save",
"(",
"$",
"entity",
")",
")",
"{",
"$",
"this",
"->",
"_controller",
"->",
"set",
"(",
"'entity'",
",",
"$",
"result",
")",
";",
"$",
"this",
"->",
"_controller",
"->",
"render",
"(",
"'toggle'",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"__d",
"(",
"'core'",
",",
"'Failed toggling field {0} to {1}'",
",",
"$",
"field",
",",
"$",
"entity",
"->",
"get",
"(",
"$",
"field",
")",
")",
")",
";",
"}",
"}"
]
| Toggle table field value.
@param Table $table
@param int $id
@param string|int $value
@param string $field
@throws \RuntimeException
@throws \Aura\Intl\Exception | [
"Toggle",
"table",
"field",
"value",
"."
]
| f9cba7aa0043a10e5c35bd45fbad158688a09a96 | https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/Component/AppComponent.php#L113-L132 |
19,626 | teneleven/GeolocatorBundle | Extractor/AddressExtractorRegistry.php | AddressExtractorRegistry.getExtractor | public function getExtractor($key)
{
if (!$this->hasExtractor($key)) {
throw new \InvalidArgumentException(sprintf('Address extractor with key "%s" does not exist', $key));
}
return $this->extractors[$key];
} | php | public function getExtractor($key)
{
if (!$this->hasExtractor($key)) {
throw new \InvalidArgumentException(sprintf('Address extractor with key "%s" does not exist', $key));
}
return $this->extractors[$key];
} | [
"public",
"function",
"getExtractor",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasExtractor",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Address extractor with key \"%s\" does not exist'",
",",
"$",
"key",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"extractors",
"[",
"$",
"key",
"]",
";",
"}"
]
| Get the extractor for the specified key
@param string $key
@return AddressExtractorInterface
@throws \InvalidArgumentException | [
"Get",
"the",
"extractor",
"for",
"the",
"specified",
"key"
]
| 4ead8e783a91577f2a67aa302b79641d4b9e99ad | https://github.com/teneleven/GeolocatorBundle/blob/4ead8e783a91577f2a67aa302b79641d4b9e99ad/Extractor/AddressExtractorRegistry.php#L63-L70 |
19,627 | jenwachter/html-form | src/Utility/Validator.php | Validator.validate | public function validate($addable)
{
foreach ($addable->elements as $element) {
$classes = class_parents($element);
// no validation needed
if (in_array("HtmlForm\Elements\Parents\Html", $classes)) {
continue;
}
if (in_array("HtmlForm\Abstracts\Addable", $classes)) {
// validate this addable (fieldset)
$moreErrors = $this->validate($element);
} else {
$class = $this->findclass($element);
if ($class == "honeypot") {
$value = $element->getRawValue();
$this->honeypot($value);
continue;
}
// validate this element
$elementErrors = $element->validate();
// add new errors to the list
$this->errors = array_merge($this->errors, $elementErrors);
}
}
return empty($this->errors);
} | php | public function validate($addable)
{
foreach ($addable->elements as $element) {
$classes = class_parents($element);
// no validation needed
if (in_array("HtmlForm\Elements\Parents\Html", $classes)) {
continue;
}
if (in_array("HtmlForm\Abstracts\Addable", $classes)) {
// validate this addable (fieldset)
$moreErrors = $this->validate($element);
} else {
$class = $this->findclass($element);
if ($class == "honeypot") {
$value = $element->getRawValue();
$this->honeypot($value);
continue;
}
// validate this element
$elementErrors = $element->validate();
// add new errors to the list
$this->errors = array_merge($this->errors, $elementErrors);
}
}
return empty($this->errors);
} | [
"public",
"function",
"validate",
"(",
"$",
"addable",
")",
"{",
"foreach",
"(",
"$",
"addable",
"->",
"elements",
"as",
"$",
"element",
")",
"{",
"$",
"classes",
"=",
"class_parents",
"(",
"$",
"element",
")",
";",
"// no validation needed",
"if",
"(",
"in_array",
"(",
"\"HtmlForm\\Elements\\Parents\\Html\"",
",",
"$",
"classes",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"in_array",
"(",
"\"HtmlForm\\Abstracts\\Addable\"",
",",
"$",
"classes",
")",
")",
"{",
"// validate this addable (fieldset)",
"$",
"moreErrors",
"=",
"$",
"this",
"->",
"validate",
"(",
"$",
"element",
")",
";",
"}",
"else",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"findclass",
"(",
"$",
"element",
")",
";",
"if",
"(",
"$",
"class",
"==",
"\"honeypot\"",
")",
"{",
"$",
"value",
"=",
"$",
"element",
"->",
"getRawValue",
"(",
")",
";",
"$",
"this",
"->",
"honeypot",
"(",
"$",
"value",
")",
";",
"continue",
";",
"}",
"// validate this element",
"$",
"elementErrors",
"=",
"$",
"element",
"->",
"validate",
"(",
")",
";",
"// add new errors to the list",
"$",
"this",
"->",
"errors",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"errors",
",",
"$",
"elementErrors",
")",
";",
"}",
"}",
"return",
"empty",
"(",
"$",
"this",
"->",
"errors",
")",
";",
"}"
]
| Runs through the validation required by
each form element.
@param object $addable Object that extends from \HtmlForm\Abstracts\Addable
@return array Found errors | [
"Runs",
"through",
"the",
"validation",
"required",
"by",
"each",
"form",
"element",
"."
]
| eaece87d474f7da5c25679548fb8f1608a94303c | https://github.com/jenwachter/html-form/blob/eaece87d474f7da5c25679548fb8f1608a94303c/src/Utility/Validator.php#L30-L67 |
19,628 | ClanCats/Core | src/classes/CCColor.php | CCColor.create | public static function create( $color )
{
// our return
$rgb = array();
if ( is_array( $color ) )
{
$color = array_values( $color );
$rgb[0] = $color[0];
$rgb[1] = $color[1];
$rgb[2] = $color[2];
}
// parse hex color
elseif ( is_string( $color ) && substr( $color, 0, 1 ) == '#' )
{
$color = substr( $color, 1 );
if( strlen( $color ) == 3 )
{
$rgb[0] = hexdec( substr( $color, 0, 1 ) . substr( $color, 0, 1 ) );
$rgb[1] = hexdec( substr( $color, 1, 1 ) . substr( $color, 1, 1 ) );
$rgb[2] = hexdec( substr( $color, 2, 1 ) . substr( $color, 2, 1 ) );
}
elseif( strlen( $color ) == 6 )
{
$rgb[0] = hexdec( substr( $color, 0, 2 ) );
$rgb[1] = hexdec( substr( $color, 2, 2 ) );
$rgb[2] = hexdec( substr( $color, 4, 2 ) );
}
}
// could not be parsed
else
{
return false;
}
return new static( $rgb );
} | php | public static function create( $color )
{
// our return
$rgb = array();
if ( is_array( $color ) )
{
$color = array_values( $color );
$rgb[0] = $color[0];
$rgb[1] = $color[1];
$rgb[2] = $color[2];
}
// parse hex color
elseif ( is_string( $color ) && substr( $color, 0, 1 ) == '#' )
{
$color = substr( $color, 1 );
if( strlen( $color ) == 3 )
{
$rgb[0] = hexdec( substr( $color, 0, 1 ) . substr( $color, 0, 1 ) );
$rgb[1] = hexdec( substr( $color, 1, 1 ) . substr( $color, 1, 1 ) );
$rgb[2] = hexdec( substr( $color, 2, 1 ) . substr( $color, 2, 1 ) );
}
elseif( strlen( $color ) == 6 )
{
$rgb[0] = hexdec( substr( $color, 0, 2 ) );
$rgb[1] = hexdec( substr( $color, 2, 2 ) );
$rgb[2] = hexdec( substr( $color, 4, 2 ) );
}
}
// could not be parsed
else
{
return false;
}
return new static( $rgb );
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"color",
")",
"{",
"// our return",
"$",
"rgb",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"color",
")",
")",
"{",
"$",
"color",
"=",
"array_values",
"(",
"$",
"color",
")",
";",
"$",
"rgb",
"[",
"0",
"]",
"=",
"$",
"color",
"[",
"0",
"]",
";",
"$",
"rgb",
"[",
"1",
"]",
"=",
"$",
"color",
"[",
"1",
"]",
";",
"$",
"rgb",
"[",
"2",
"]",
"=",
"$",
"color",
"[",
"2",
"]",
";",
"}",
"// parse hex color ",
"elseif",
"(",
"is_string",
"(",
"$",
"color",
")",
"&&",
"substr",
"(",
"$",
"color",
",",
"0",
",",
"1",
")",
"==",
"'#'",
")",
"{",
"$",
"color",
"=",
"substr",
"(",
"$",
"color",
",",
"1",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"color",
")",
"==",
"3",
")",
"{",
"$",
"rgb",
"[",
"0",
"]",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"color",
",",
"0",
",",
"1",
")",
".",
"substr",
"(",
"$",
"color",
",",
"0",
",",
"1",
")",
")",
";",
"$",
"rgb",
"[",
"1",
"]",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"color",
",",
"1",
",",
"1",
")",
".",
"substr",
"(",
"$",
"color",
",",
"1",
",",
"1",
")",
")",
";",
"$",
"rgb",
"[",
"2",
"]",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"color",
",",
"2",
",",
"1",
")",
".",
"substr",
"(",
"$",
"color",
",",
"2",
",",
"1",
")",
")",
";",
"}",
"elseif",
"(",
"strlen",
"(",
"$",
"color",
")",
"==",
"6",
")",
"{",
"$",
"rgb",
"[",
"0",
"]",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"color",
",",
"0",
",",
"2",
")",
")",
";",
"$",
"rgb",
"[",
"1",
"]",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"color",
",",
"2",
",",
"2",
")",
")",
";",
"$",
"rgb",
"[",
"2",
"]",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"color",
",",
"4",
",",
"2",
")",
")",
";",
"}",
"}",
"// could not be parsed ",
"else",
"{",
"return",
"false",
";",
"}",
"return",
"new",
"static",
"(",
"$",
"rgb",
")",
";",
"}"
]
| parse an color
@param mixed $color | [
"parse",
"an",
"color"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCColor.php#L18-L55 |
19,629 | webforge-labs/psc-cms | lib/Psc/Net/ServiceErrorPackage.php | ServiceErrorPackage.validationResponse | public function validationResponse(\Psc\Form\ValidatorExceptionList $list, $format = ServiceResponse::JSON, MetadataGenerator $metadataGenerator = NULL) {
if ($format === ServiceResponse::JSON) {
$body = (object) array('errors'=>array());
foreach ($list->getExceptions() as $validatorException) {
$body->errors[$validatorException->field] = $validatorException->getMessage();
}
return HTTPResponseException::BadRequest(json_encode($body), NULL, array('Content-Type'=>'application/json'));
} else {
$metadataGenerator = $metadataGenerator ?: new MetadataGenerator();
return HTTPException::BadRequest(
$list->getMessage(),
$list,
array_merge(
array('Content-Type'=>'text/html'),
$metadataGenerator->validationList($list)->toHeaders()
)
);
}
} | php | public function validationResponse(\Psc\Form\ValidatorExceptionList $list, $format = ServiceResponse::JSON, MetadataGenerator $metadataGenerator = NULL) {
if ($format === ServiceResponse::JSON) {
$body = (object) array('errors'=>array());
foreach ($list->getExceptions() as $validatorException) {
$body->errors[$validatorException->field] = $validatorException->getMessage();
}
return HTTPResponseException::BadRequest(json_encode($body), NULL, array('Content-Type'=>'application/json'));
} else {
$metadataGenerator = $metadataGenerator ?: new MetadataGenerator();
return HTTPException::BadRequest(
$list->getMessage(),
$list,
array_merge(
array('Content-Type'=>'text/html'),
$metadataGenerator->validationList($list)->toHeaders()
)
);
}
} | [
"public",
"function",
"validationResponse",
"(",
"\\",
"Psc",
"\\",
"Form",
"\\",
"ValidatorExceptionList",
"$",
"list",
",",
"$",
"format",
"=",
"ServiceResponse",
"::",
"JSON",
",",
"MetadataGenerator",
"$",
"metadataGenerator",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"format",
"===",
"ServiceResponse",
"::",
"JSON",
")",
"{",
"$",
"body",
"=",
"(",
"object",
")",
"array",
"(",
"'errors'",
"=>",
"array",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"list",
"->",
"getExceptions",
"(",
")",
"as",
"$",
"validatorException",
")",
"{",
"$",
"body",
"->",
"errors",
"[",
"$",
"validatorException",
"->",
"field",
"]",
"=",
"$",
"validatorException",
"->",
"getMessage",
"(",
")",
";",
"}",
"return",
"HTTPResponseException",
"::",
"BadRequest",
"(",
"json_encode",
"(",
"$",
"body",
")",
",",
"NULL",
",",
"array",
"(",
"'Content-Type'",
"=>",
"'application/json'",
")",
")",
";",
"}",
"else",
"{",
"$",
"metadataGenerator",
"=",
"$",
"metadataGenerator",
"?",
":",
"new",
"MetadataGenerator",
"(",
")",
";",
"return",
"HTTPException",
"::",
"BadRequest",
"(",
"$",
"list",
"->",
"getMessage",
"(",
")",
",",
"$",
"list",
",",
"array_merge",
"(",
"array",
"(",
"'Content-Type'",
"=>",
"'text/html'",
")",
",",
"$",
"metadataGenerator",
"->",
"validationList",
"(",
"$",
"list",
")",
"->",
"toHeaders",
"(",
")",
")",
")",
";",
"}",
"}"
]
| Throws an ValidationResponse
it handles the JSON case and the HTML case
@param ValidatorException[]
@param const $format im moment nur JSON oder HTML
@return HTTPException | [
"Throws",
"an",
"ValidationResponse"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Net/ServiceErrorPackage.php#L58-L79 |
19,630 | jfusion/org.jfusion.framework | src/Plugin/User.php | User.findUser | final public function findUser(Userinfo $userinfo)
{
$userloopup = $this->lookupUser($userinfo);
if ($userloopup instanceof Userinfo) {
$user = $this->getUser($userloopup);
} else {
$user = $this->getUser($userinfo);
if ($user instanceof Userinfo) {
/**
* TODO: determine if the update lookup should really be here or not.
*/
$this->updateLookup($user, $userinfo);
}
}
return $user;
} | php | final public function findUser(Userinfo $userinfo)
{
$userloopup = $this->lookupUser($userinfo);
if ($userloopup instanceof Userinfo) {
$user = $this->getUser($userloopup);
} else {
$user = $this->getUser($userinfo);
if ($user instanceof Userinfo) {
/**
* TODO: determine if the update lookup should really be here or not.
*/
$this->updateLookup($user, $userinfo);
}
}
return $user;
} | [
"final",
"public",
"function",
"findUser",
"(",
"Userinfo",
"$",
"userinfo",
")",
"{",
"$",
"userloopup",
"=",
"$",
"this",
"->",
"lookupUser",
"(",
"$",
"userinfo",
")",
";",
"if",
"(",
"$",
"userloopup",
"instanceof",
"Userinfo",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"userloopup",
")",
";",
"}",
"else",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"getUser",
"(",
"$",
"userinfo",
")",
";",
"if",
"(",
"$",
"user",
"instanceof",
"Userinfo",
")",
"{",
"/**\n\t\t\t\t * TODO: determine if the update lookup should really be here or not.\n\t\t\t\t */",
"$",
"this",
"->",
"updateLookup",
"(",
"$",
"user",
",",
"$",
"userinfo",
")",
";",
"}",
"}",
"return",
"$",
"user",
";",
"}"
]
| Gets the userinfo from the JFusion integrated software. it uses the lookup function
@param Userinfo $userinfo contains the object of the user
@return null|Userinfo Userinfo containing the user information | [
"Gets",
"the",
"userinfo",
"from",
"the",
"JFusion",
"integrated",
"software",
".",
"it",
"uses",
"the",
"lookup",
"function"
]
| 65771963f23ccabcf1f867eb17c9452299cfe683 | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/User.php#L74-L89 |
19,631 | jfusion/org.jfusion.framework | src/Plugin/User.php | User.getUserIdentifier | public final function getUserIdentifier(Userinfo &$userinfo, $username_col, $email_col, $userid_col, $lowerEmail = true)
{
$login_identifier = $this->params->get('login_identifier', 1);
if ($this->getJname() == $userinfo->getJname() && $userinfo->userid != null) {
$login_identifier = 4;
} elseif ($username_col == null) {
$login_identifier = 2;
}
switch ($login_identifier) {
default:
case 1:
// username
$identifier = $userinfo->username;
$identifier_type = $username_col;
break;
case 2:
// email
$identifier = $userinfo->email;
$identifier_type = $email_col;
break;
case 3:
// username or email
$pattern = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i';
if (preg_match($pattern, $userinfo->username)) {
$identifier_type = $email_col;
$identifier = $userinfo->email;
} else {
$identifier_type = $username_col;
$identifier = $userinfo->username;
}
break;
case 4:
// userid
$identifier_type = $userid_col;
$identifier = $userinfo->userid;
break;
}
if ($lowerEmail && $identifier_type == $email_col) {
$identifier_type = 'LOWER(' . $identifier_type . ')';
$identifier = strtolower($identifier);
}
return array($identifier_type, $identifier);
} | php | public final function getUserIdentifier(Userinfo &$userinfo, $username_col, $email_col, $userid_col, $lowerEmail = true)
{
$login_identifier = $this->params->get('login_identifier', 1);
if ($this->getJname() == $userinfo->getJname() && $userinfo->userid != null) {
$login_identifier = 4;
} elseif ($username_col == null) {
$login_identifier = 2;
}
switch ($login_identifier) {
default:
case 1:
// username
$identifier = $userinfo->username;
$identifier_type = $username_col;
break;
case 2:
// email
$identifier = $userinfo->email;
$identifier_type = $email_col;
break;
case 3:
// username or email
$pattern = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i';
if (preg_match($pattern, $userinfo->username)) {
$identifier_type = $email_col;
$identifier = $userinfo->email;
} else {
$identifier_type = $username_col;
$identifier = $userinfo->username;
}
break;
case 4:
// userid
$identifier_type = $userid_col;
$identifier = $userinfo->userid;
break;
}
if ($lowerEmail && $identifier_type == $email_col) {
$identifier_type = 'LOWER(' . $identifier_type . ')';
$identifier = strtolower($identifier);
}
return array($identifier_type, $identifier);
} | [
"public",
"final",
"function",
"getUserIdentifier",
"(",
"Userinfo",
"&",
"$",
"userinfo",
",",
"$",
"username_col",
",",
"$",
"email_col",
",",
"$",
"userid_col",
",",
"$",
"lowerEmail",
"=",
"true",
")",
"{",
"$",
"login_identifier",
"=",
"$",
"this",
"->",
"params",
"->",
"get",
"(",
"'login_identifier'",
",",
"1",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getJname",
"(",
")",
"==",
"$",
"userinfo",
"->",
"getJname",
"(",
")",
"&&",
"$",
"userinfo",
"->",
"userid",
"!=",
"null",
")",
"{",
"$",
"login_identifier",
"=",
"4",
";",
"}",
"elseif",
"(",
"$",
"username_col",
"==",
"null",
")",
"{",
"$",
"login_identifier",
"=",
"2",
";",
"}",
"switch",
"(",
"$",
"login_identifier",
")",
"{",
"default",
":",
"case",
"1",
":",
"// username",
"$",
"identifier",
"=",
"$",
"userinfo",
"->",
"username",
";",
"$",
"identifier_type",
"=",
"$",
"username_col",
";",
"break",
";",
"case",
"2",
":",
"// email",
"$",
"identifier",
"=",
"$",
"userinfo",
"->",
"email",
";",
"$",
"identifier_type",
"=",
"$",
"email_col",
";",
"break",
";",
"case",
"3",
":",
"// username or email",
"$",
"pattern",
"=",
"'/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$/i'",
";",
"if",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"userinfo",
"->",
"username",
")",
")",
"{",
"$",
"identifier_type",
"=",
"$",
"email_col",
";",
"$",
"identifier",
"=",
"$",
"userinfo",
"->",
"email",
";",
"}",
"else",
"{",
"$",
"identifier_type",
"=",
"$",
"username_col",
";",
"$",
"identifier",
"=",
"$",
"userinfo",
"->",
"username",
";",
"}",
"break",
";",
"case",
"4",
":",
"// userid",
"$",
"identifier_type",
"=",
"$",
"userid_col",
";",
"$",
"identifier",
"=",
"$",
"userinfo",
"->",
"userid",
";",
"break",
";",
"}",
"if",
"(",
"$",
"lowerEmail",
"&&",
"$",
"identifier_type",
"==",
"$",
"email_col",
")",
"{",
"$",
"identifier_type",
"=",
"'LOWER('",
".",
"$",
"identifier_type",
".",
"')'",
";",
"$",
"identifier",
"=",
"strtolower",
"(",
"$",
"identifier",
")",
";",
"}",
"return",
"array",
"(",
"$",
"identifier_type",
",",
"$",
"identifier",
")",
";",
"}"
]
| Returns the identifier and identifier_type for getUser
@param Userinfo &$userinfo object with user identifying information
@param string $username_col Database column for username
@param string $email_col Database column for email
@param string $userid_col Database column for userid
@param bool $lowerEmail Boolean to lowercase emails for comparison
@return array array($identifier, $identifier_type) | [
"Returns",
"the",
"identifier",
"and",
"identifier_type",
"for",
"getUser"
]
| 65771963f23ccabcf1f867eb17c9452299cfe683 | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/User.php#L102-L145 |
19,632 | jfusion/org.jfusion.framework | src/Plugin/User.php | User.executeUpdateUsergroup | function executeUpdateUsergroup(Userinfo $userinfo, Userinfo &$existinguser)
{
$changed = false;
$usergroups = $this->getCorrectUserGroups($userinfo);
if (!$this->compareUserGroups($existinguser, $usergroups)) {
$this->updateUsergroup($userinfo, $existinguser);
$changed = true;
}
return $changed;
} | php | function executeUpdateUsergroup(Userinfo $userinfo, Userinfo &$existinguser)
{
$changed = false;
$usergroups = $this->getCorrectUserGroups($userinfo);
if (!$this->compareUserGroups($existinguser, $usergroups)) {
$this->updateUsergroup($userinfo, $existinguser);
$changed = true;
}
return $changed;
} | [
"function",
"executeUpdateUsergroup",
"(",
"Userinfo",
"$",
"userinfo",
",",
"Userinfo",
"&",
"$",
"existinguser",
")",
"{",
"$",
"changed",
"=",
"false",
";",
"$",
"usergroups",
"=",
"$",
"this",
"->",
"getCorrectUserGroups",
"(",
"$",
"userinfo",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"compareUserGroups",
"(",
"$",
"existinguser",
",",
"$",
"usergroups",
")",
")",
"{",
"$",
"this",
"->",
"updateUsergroup",
"(",
"$",
"userinfo",
",",
"$",
"existinguser",
")",
";",
"$",
"changed",
"=",
"true",
";",
"}",
"return",
"$",
"changed",
";",
"}"
]
| Function that determines if the usergroup needs to be updated and executes updateUsergroup if it does
@param Userinfo $userinfo Object containing the new userinfo
@param Userinfo &$existinguser Object containing the old userinfo
@throws RuntimeException
@return boolean Whether updateUsergroup was executed or not | [
"Function",
"that",
"determines",
"if",
"the",
"usergroup",
"needs",
"to",
"be",
"updated",
"and",
"executes",
"updateUsergroup",
"if",
"it",
"does"
]
| 65771963f23ccabcf1f867eb17c9452299cfe683 | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/User.php#L302-L311 |
19,633 | jfusion/org.jfusion.framework | src/Plugin/User.php | User.compareUserGroups | public function compareUserGroups(Userinfo $userinfo, $usergroups) {
if (!is_array($usergroups)) {
$usergroups = array($usergroups);
}
$correct = false;
$count = 0;
if (count($usergroups) == count($userinfo->groups)) {
foreach ($usergroups as $group) {
if (in_array($group, $userinfo->groups, true)) {
$count++;
}
}
if (count($userinfo->groups) == $count) {
$correct = true;
}
}
return $correct;
} | php | public function compareUserGroups(Userinfo $userinfo, $usergroups) {
if (!is_array($usergroups)) {
$usergroups = array($usergroups);
}
$correct = false;
$count = 0;
if (count($usergroups) == count($userinfo->groups)) {
foreach ($usergroups as $group) {
if (in_array($group, $userinfo->groups, true)) {
$count++;
}
}
if (count($userinfo->groups) == $count) {
$correct = true;
}
}
return $correct;
} | [
"public",
"function",
"compareUserGroups",
"(",
"Userinfo",
"$",
"userinfo",
",",
"$",
"usergroups",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"usergroups",
")",
")",
"{",
"$",
"usergroups",
"=",
"array",
"(",
"$",
"usergroups",
")",
";",
"}",
"$",
"correct",
"=",
"false",
";",
"$",
"count",
"=",
"0",
";",
"if",
"(",
"count",
"(",
"$",
"usergroups",
")",
"==",
"count",
"(",
"$",
"userinfo",
"->",
"groups",
")",
")",
"{",
"foreach",
"(",
"$",
"usergroups",
"as",
"$",
"group",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"group",
",",
"$",
"userinfo",
"->",
"groups",
",",
"true",
")",
")",
"{",
"$",
"count",
"++",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"userinfo",
"->",
"groups",
")",
"==",
"$",
"count",
")",
"{",
"$",
"correct",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"correct",
";",
"}"
]
| compare set of usergroup with a user returns true if the usergroups are correct
@param Userinfo $userinfo user with current usergroups
@param array $usergroups array with the correct usergroups
@return boolean | [
"compare",
"set",
"of",
"usergroup",
"with",
"a",
"user",
"returns",
"true",
"if",
"the",
"usergroups",
"are",
"correct"
]
| 65771963f23ccabcf1f867eb17c9452299cfe683 | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/User.php#L682-L701 |
19,634 | jfusion/org.jfusion.framework | src/Plugin/User.php | User.getUserGroupIndex | function getUserGroupIndex(Userinfo $userinfo)
{
$index = 0;
$master = Framework::getMaster();
if ($master) {
$mastergroups = Groups::get($master->name);
foreach ($mastergroups as $key => $mastergroup) {
if ($mastergroup) {
if (count($mastergroup) == count($userinfo->groups)) {
$count = 0;
foreach ($mastergroup as $value) {
if (in_array($value, $userinfo->groups, true)) {
$count++;
}
}
if (count($userinfo->groups) == $count) {
$index = $key;
break;
}
}
}
}
}
return $index;
} | php | function getUserGroupIndex(Userinfo $userinfo)
{
$index = 0;
$master = Framework::getMaster();
if ($master) {
$mastergroups = Groups::get($master->name);
foreach ($mastergroups as $key => $mastergroup) {
if ($mastergroup) {
if (count($mastergroup) == count($userinfo->groups)) {
$count = 0;
foreach ($mastergroup as $value) {
if (in_array($value, $userinfo->groups, true)) {
$count++;
}
}
if (count($userinfo->groups) == $count) {
$index = $key;
break;
}
}
}
}
}
return $index;
} | [
"function",
"getUserGroupIndex",
"(",
"Userinfo",
"$",
"userinfo",
")",
"{",
"$",
"index",
"=",
"0",
";",
"$",
"master",
"=",
"Framework",
"::",
"getMaster",
"(",
")",
";",
"if",
"(",
"$",
"master",
")",
"{",
"$",
"mastergroups",
"=",
"Groups",
"::",
"get",
"(",
"$",
"master",
"->",
"name",
")",
";",
"foreach",
"(",
"$",
"mastergroups",
"as",
"$",
"key",
"=>",
"$",
"mastergroup",
")",
"{",
"if",
"(",
"$",
"mastergroup",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"mastergroup",
")",
"==",
"count",
"(",
"$",
"userinfo",
"->",
"groups",
")",
")",
"{",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
"$",
"mastergroup",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"value",
",",
"$",
"userinfo",
"->",
"groups",
",",
"true",
")",
")",
"{",
"$",
"count",
"++",
";",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"userinfo",
"->",
"groups",
")",
"==",
"$",
"count",
")",
"{",
"$",
"index",
"=",
"$",
"key",
";",
"break",
";",
"}",
"}",
"}",
"}",
"}",
"return",
"$",
"index",
";",
"}"
]
| Function That find the correct user group index
@param Userinfo $userinfo
@return int | [
"Function",
"That",
"find",
"the",
"correct",
"user",
"group",
"index"
]
| 65771963f23ccabcf1f867eb17c9452299cfe683 | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/User.php#L710-L736 |
19,635 | jfusion/org.jfusion.framework | src/Plugin/User.php | User.getCorrectUserGroups | final public function getCorrectUserGroups(Userinfo $userinfo)
{
$jname = $this->getJname();
$group = array();
$master = Framework::getMaster();
if ($master) {
if ($master->name == $jname) {
$group = Groups::get($master->name, true);
} else {
$slavegroups = Groups::get($jname);
$user = Factory::getUser($master->name);
$index = $user->getUserGroupIndex($userinfo);
if (isset($slavegroups[$index])) {
$group = $slavegroups[$index];
}
if ($group === null && isset($slavegroups[0])) {
$group = $slavegroups[0];
}
}
}
if (!is_array($group)) {
if ($group !== null) {
$group = array($group);
} else {
$group = array();
}
}
return $group;
} | php | final public function getCorrectUserGroups(Userinfo $userinfo)
{
$jname = $this->getJname();
$group = array();
$master = Framework::getMaster();
if ($master) {
if ($master->name == $jname) {
$group = Groups::get($master->name, true);
} else {
$slavegroups = Groups::get($jname);
$user = Factory::getUser($master->name);
$index = $user->getUserGroupIndex($userinfo);
if (isset($slavegroups[$index])) {
$group = $slavegroups[$index];
}
if ($group === null && isset($slavegroups[0])) {
$group = $slavegroups[0];
}
}
}
if (!is_array($group)) {
if ($group !== null) {
$group = array($group);
} else {
$group = array();
}
}
return $group;
} | [
"final",
"public",
"function",
"getCorrectUserGroups",
"(",
"Userinfo",
"$",
"userinfo",
")",
"{",
"$",
"jname",
"=",
"$",
"this",
"->",
"getJname",
"(",
")",
";",
"$",
"group",
"=",
"array",
"(",
")",
";",
"$",
"master",
"=",
"Framework",
"::",
"getMaster",
"(",
")",
";",
"if",
"(",
"$",
"master",
")",
"{",
"if",
"(",
"$",
"master",
"->",
"name",
"==",
"$",
"jname",
")",
"{",
"$",
"group",
"=",
"Groups",
"::",
"get",
"(",
"$",
"master",
"->",
"name",
",",
"true",
")",
";",
"}",
"else",
"{",
"$",
"slavegroups",
"=",
"Groups",
"::",
"get",
"(",
"$",
"jname",
")",
";",
"$",
"user",
"=",
"Factory",
"::",
"getUser",
"(",
"$",
"master",
"->",
"name",
")",
";",
"$",
"index",
"=",
"$",
"user",
"->",
"getUserGroupIndex",
"(",
"$",
"userinfo",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"slavegroups",
"[",
"$",
"index",
"]",
")",
")",
"{",
"$",
"group",
"=",
"$",
"slavegroups",
"[",
"$",
"index",
"]",
";",
"}",
"if",
"(",
"$",
"group",
"===",
"null",
"&&",
"isset",
"(",
"$",
"slavegroups",
"[",
"0",
"]",
")",
")",
"{",
"$",
"group",
"=",
"$",
"slavegroups",
"[",
"0",
"]",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"group",
")",
")",
"{",
"if",
"(",
"$",
"group",
"!==",
"null",
")",
"{",
"$",
"group",
"=",
"array",
"(",
"$",
"group",
")",
";",
"}",
"else",
"{",
"$",
"group",
"=",
"array",
"(",
")",
";",
"}",
"}",
"return",
"$",
"group",
";",
"}"
]
| return the correct usergroups for a given user
@param Userinfo|null $userinfo user with correct usergroups, if null it will return the usergroup for new users
@return array | [
"return",
"the",
"correct",
"usergroups",
"for",
"a",
"given",
"user"
]
| 65771963f23ccabcf1f867eb17c9452299cfe683 | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/User.php#L1054-L1087 |
19,636 | jfusion/org.jfusion.framework | src/Plugin/User.php | User.lookupUser | final public function lookupUser(Userinfo $exsistinginfo)
{
$user = null;
if ($exsistinginfo) {
//initialise some vars
$db = Factory::getDBO();
$query = $db->getQuery(true)
->select('b.userid, b.username, b.email')
->from('#__jfusion_users AS a')
->innerJoin('#__jfusion_users AS b ON a.id = b.id')
->where('b.jname = ' . $db->quote($this->getJname()))
->where('a.jname = ' . $db->quote($exsistinginfo->getJname()));
$search = array();
if (isset($exsistinginfo->userid)) {
$search[] = 'a.userid = ' . $db->quote($exsistinginfo->userid);
}
if (isset($exsistinginfo->username)) {
$search[] = 'a.username = ' . $db->quote($exsistinginfo->username);
}
if (isset($exsistinginfo->email)) {
$search[] = 'a.email = ' . $db->quote($exsistinginfo->email);
}
if (!empty($search)) {
$query->where('( ' . implode(' OR ', $search) . ' )');
$db->setQuery($query);
$result = $db->loadObject();
if ($result) {
$user = new Userinfo($this->getJname());
$user->bind($result);
}
}
}
return $user;
} | php | final public function lookupUser(Userinfo $exsistinginfo)
{
$user = null;
if ($exsistinginfo) {
//initialise some vars
$db = Factory::getDBO();
$query = $db->getQuery(true)
->select('b.userid, b.username, b.email')
->from('#__jfusion_users AS a')
->innerJoin('#__jfusion_users AS b ON a.id = b.id')
->where('b.jname = ' . $db->quote($this->getJname()))
->where('a.jname = ' . $db->quote($exsistinginfo->getJname()));
$search = array();
if (isset($exsistinginfo->userid)) {
$search[] = 'a.userid = ' . $db->quote($exsistinginfo->userid);
}
if (isset($exsistinginfo->username)) {
$search[] = 'a.username = ' . $db->quote($exsistinginfo->username);
}
if (isset($exsistinginfo->email)) {
$search[] = 'a.email = ' . $db->quote($exsistinginfo->email);
}
if (!empty($search)) {
$query->where('( ' . implode(' OR ', $search) . ' )');
$db->setQuery($query);
$result = $db->loadObject();
if ($result) {
$user = new Userinfo($this->getJname());
$user->bind($result);
}
}
}
return $user;
} | [
"final",
"public",
"function",
"lookupUser",
"(",
"Userinfo",
"$",
"exsistinginfo",
")",
"{",
"$",
"user",
"=",
"null",
";",
"if",
"(",
"$",
"exsistinginfo",
")",
"{",
"//initialise some vars",
"$",
"db",
"=",
"Factory",
"::",
"getDBO",
"(",
")",
";",
"$",
"query",
"=",
"$",
"db",
"->",
"getQuery",
"(",
"true",
")",
"->",
"select",
"(",
"'b.userid, b.username, b.email'",
")",
"->",
"from",
"(",
"'#__jfusion_users AS a'",
")",
"->",
"innerJoin",
"(",
"'#__jfusion_users AS b ON a.id = b.id'",
")",
"->",
"where",
"(",
"'b.jname = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"this",
"->",
"getJname",
"(",
")",
")",
")",
"->",
"where",
"(",
"'a.jname = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"exsistinginfo",
"->",
"getJname",
"(",
")",
")",
")",
";",
"$",
"search",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"exsistinginfo",
"->",
"userid",
")",
")",
"{",
"$",
"search",
"[",
"]",
"=",
"'a.userid = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"exsistinginfo",
"->",
"userid",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"exsistinginfo",
"->",
"username",
")",
")",
"{",
"$",
"search",
"[",
"]",
"=",
"'a.username = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"exsistinginfo",
"->",
"username",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"exsistinginfo",
"->",
"email",
")",
")",
"{",
"$",
"search",
"[",
"]",
"=",
"'a.email = '",
".",
"$",
"db",
"->",
"quote",
"(",
"$",
"exsistinginfo",
"->",
"email",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"search",
")",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'( '",
".",
"implode",
"(",
"' OR '",
",",
"$",
"search",
")",
".",
"' )'",
")",
";",
"$",
"db",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"result",
"=",
"$",
"db",
"->",
"loadObject",
"(",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"user",
"=",
"new",
"Userinfo",
"(",
"$",
"this",
"->",
"getJname",
"(",
")",
")",
";",
"$",
"user",
"->",
"bind",
"(",
"$",
"result",
")",
";",
"}",
"}",
"}",
"return",
"$",
"user",
";",
"}"
]
| Returns the userinfo data for JFusion plugin based on the userid
@param Userinfo $exsistinginfo user info
@return Userinfo|null returns user login info from the requester software or null | [
"Returns",
"the",
"userinfo",
"data",
"for",
"JFusion",
"plugin",
"based",
"on",
"the",
"userid"
]
| 65771963f23ccabcf1f867eb17c9452299cfe683 | https://github.com/jfusion/org.jfusion.framework/blob/65771963f23ccabcf1f867eb17c9452299cfe683/src/Plugin/User.php#L1117-L1153 |
19,637 | yuncms/framework | src/mq/BaseMessage.php | BaseMessage.send | public function send(MessageQueueInterface $messageQueue = null)
{
if ($messageQueue === null && $this->messageQueue === null) {
$messageQueue = Yii::$app->getMessageQueue();
} elseif ($messageQueue === null) {
$messageQueue = $this->messageQueue;
}
return $messageQueue->send($this);
} | php | public function send(MessageQueueInterface $messageQueue = null)
{
if ($messageQueue === null && $this->messageQueue === null) {
$messageQueue = Yii::$app->getMessageQueue();
} elseif ($messageQueue === null) {
$messageQueue = $this->messageQueue;
}
return $messageQueue->send($this);
} | [
"public",
"function",
"send",
"(",
"MessageQueueInterface",
"$",
"messageQueue",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"messageQueue",
"===",
"null",
"&&",
"$",
"this",
"->",
"messageQueue",
"===",
"null",
")",
"{",
"$",
"messageQueue",
"=",
"Yii",
"::",
"$",
"app",
"->",
"getMessageQueue",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"messageQueue",
"===",
"null",
")",
"{",
"$",
"messageQueue",
"=",
"$",
"this",
"->",
"messageQueue",
";",
"}",
"return",
"$",
"messageQueue",
"->",
"send",
"(",
"$",
"this",
")",
";",
"}"
]
| Sends this message queue message.
@param MessageQueueInterface $messageQueue the message queue that should be used to send this message.
If no message queue is given it will first check if [[messageQueue]] is set and if not,
the "messageQueue" application component will be used instead.
@return bool whether this message is sent successfully. | [
"Sends",
"this",
"message",
"queue",
"message",
"."
]
| af42e28ea4ae15ab8eead3f6d119f93863b94154 | https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/mq/BaseMessage.php#L110-L118 |
19,638 | php-rise/rise | src/Session.php | Session.getFlash | public function getFlash($key) {
return $this->started && isset($_SESSION[$this->flashSessionKey][$key])
? $_SESSION[$this->flashSessionKey][$key]
: null;
} | php | public function getFlash($key) {
return $this->started && isset($_SESSION[$this->flashSessionKey][$key])
? $_SESSION[$this->flashSessionKey][$key]
: null;
} | [
"public",
"function",
"getFlash",
"(",
"$",
"key",
")",
"{",
"return",
"$",
"this",
"->",
"started",
"&&",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"flashSessionKey",
"]",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"flashSessionKey",
"]",
"[",
"$",
"key",
"]",
":",
"null",
";",
"}"
]
| Get data from the current flash messages bag.
@param string $key
@return mixed | [
"Get",
"data",
"from",
"the",
"current",
"flash",
"messages",
"bag",
"."
]
| cd14ef9956f1b6875b7bcd642545dcef6a9152b7 | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Session.php#L116-L120 |
19,639 | php-rise/rise | src/Session.php | Session.setFlash | public function setFlash($key, $value) {
if (!$this->started) {
return $this;
}
$_SESSION[$this->nextFlashSessionKey][$key] = $value;
return $this;
} | php | public function setFlash($key, $value) {
if (!$this->started) {
return $this;
}
$_SESSION[$this->nextFlashSessionKey][$key] = $value;
return $this;
} | [
"public",
"function",
"setFlash",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"started",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"nextFlashSessionKey",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
]
| Set data to the flash messages bag for the next request.
@param string $key
@param mixed $value
@return self | [
"Set",
"data",
"to",
"the",
"flash",
"messages",
"bag",
"for",
"the",
"next",
"request",
"."
]
| cd14ef9956f1b6875b7bcd642545dcef6a9152b7 | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Session.php#L129-L136 |
19,640 | php-rise/rise | src/Session.php | Session.toNextFlash | public function toNextFlash() {
if (!$this->started) {
return $this;
}
$_SESSION[$this->flashSessionKey] =
isset($_SESSION[$this->nextFlashSessionKey])
? $_SESSION[$this->nextFlashSessionKey]
: [];
$_SESSION[$this->nextFlashSessionKey] = [];
return $this;
} | php | public function toNextFlash() {
if (!$this->started) {
return $this;
}
$_SESSION[$this->flashSessionKey] =
isset($_SESSION[$this->nextFlashSessionKey])
? $_SESSION[$this->nextFlashSessionKey]
: [];
$_SESSION[$this->nextFlashSessionKey] = [];
return $this;
} | [
"public",
"function",
"toNextFlash",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"started",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"flashSessionKey",
"]",
"=",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"nextFlashSessionKey",
"]",
")",
"?",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"nextFlashSessionKey",
"]",
":",
"[",
"]",
";",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"nextFlashSessionKey",
"]",
"=",
"[",
"]",
";",
"return",
"$",
"this",
";",
"}"
]
| Copy the next flash data to current flash. This should be done in the end of request.
@return self | [
"Copy",
"the",
"next",
"flash",
"data",
"to",
"current",
"flash",
".",
"This",
"should",
"be",
"done",
"in",
"the",
"end",
"of",
"request",
"."
]
| cd14ef9956f1b6875b7bcd642545dcef6a9152b7 | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Session.php#L153-L165 |
19,641 | php-rise/rise | src/Session.php | Session.generateCsrfToken | public function generateCsrfToken() {
$token = hash("sha512", mt_rand(0, mt_getrandmax()));
$_SESSION[$this->csrfTokenSessionKey] = $token;
return $token;
} | php | public function generateCsrfToken() {
$token = hash("sha512", mt_rand(0, mt_getrandmax()));
$_SESSION[$this->csrfTokenSessionKey] = $token;
return $token;
} | [
"public",
"function",
"generateCsrfToken",
"(",
")",
"{",
"$",
"token",
"=",
"hash",
"(",
"\"sha512\"",
",",
"mt_rand",
"(",
"0",
",",
"mt_getrandmax",
"(",
")",
")",
")",
";",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"csrfTokenSessionKey",
"]",
"=",
"$",
"token",
";",
"return",
"$",
"token",
";",
"}"
]
| Generate CSRF token.
@return string | [
"Generate",
"CSRF",
"token",
"."
]
| cd14ef9956f1b6875b7bcd642545dcef6a9152b7 | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Session.php#L172-L176 |
19,642 | php-rise/rise | src/Session.php | Session.validateCsrfToken | public function validateCsrfToken($token) {
return (
isset($_SESSION[$this->csrfTokenSessionKey])
&& $_SESSION[$this->csrfTokenSessionKey] === $token
);
} | php | public function validateCsrfToken($token) {
return (
isset($_SESSION[$this->csrfTokenSessionKey])
&& $_SESSION[$this->csrfTokenSessionKey] === $token
);
} | [
"public",
"function",
"validateCsrfToken",
"(",
"$",
"token",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"csrfTokenSessionKey",
"]",
")",
"&&",
"$",
"_SESSION",
"[",
"$",
"this",
"->",
"csrfTokenSessionKey",
"]",
"===",
"$",
"token",
")",
";",
"}"
]
| Validate with the token stored in session.
@param string $token
@return bool | [
"Validate",
"with",
"the",
"token",
"stored",
"in",
"session",
"."
]
| cd14ef9956f1b6875b7bcd642545dcef6a9152b7 | https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Session.php#L214-L219 |
19,643 | nyeholt/silverstripe-external-content | code/pages/ExternalContentPage.php | ExternalContentPage.RelativeLink | public function RelativeLink($action = null) {
$remoteObject = $this->ContentItem();
if (!is_string($action)) {
$action = null;
}
if ($remoteObject) {
return $this->LinkFor($remoteObject, $action ? $action : 'view');
}
return parent::RelativeLink($action);
} | php | public function RelativeLink($action = null) {
$remoteObject = $this->ContentItem();
if (!is_string($action)) {
$action = null;
}
if ($remoteObject) {
return $this->LinkFor($remoteObject, $action ? $action : 'view');
}
return parent::RelativeLink($action);
} | [
"public",
"function",
"RelativeLink",
"(",
"$",
"action",
"=",
"null",
")",
"{",
"$",
"remoteObject",
"=",
"$",
"this",
"->",
"ContentItem",
"(",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"action",
")",
")",
"{",
"$",
"action",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"remoteObject",
")",
"{",
"return",
"$",
"this",
"->",
"LinkFor",
"(",
"$",
"remoteObject",
",",
"$",
"action",
"?",
"$",
"action",
":",
"'view'",
")",
";",
"}",
"return",
"parent",
"::",
"RelativeLink",
"(",
"$",
"action",
")",
";",
"}"
]
| When linking to this external content page, return a URL that'll let
you view the external content item directly
(non-PHPdoc)
@see sapphire/core/model/SiteTree#Link($action) | [
"When",
"linking",
"to",
"this",
"external",
"content",
"page",
"return",
"a",
"URL",
"that",
"ll",
"let",
"you",
"view",
"the",
"external",
"content",
"item",
"directly"
]
| 1c6da8c56ef717225ff904e1522aff94ed051601 | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/pages/ExternalContentPage.php#L36-L45 |
19,644 | nyeholt/silverstripe-external-content | code/pages/ExternalContentPage.php | ExternalContentPage.ContentItem | public function ContentItem($what='k') {
if ($this->requestedItem) {
return $this->requestedItem;
}
if (!$this->ExternalContentRoot) {
return null;
}
// See if an item was requested in the url directly
$id = isset($_REQUEST['item']) ? $_REQUEST['item'] : null;
if (!$id) {
$id = $this->ExternalContentRoot;
}
$remoteObject = ExternalContent::getDataObjectFor($id);
if ($remoteObject) {
$this->requestedItem = $remoteObject;
return $this->requestedItem;
}
return null;
} | php | public function ContentItem($what='k') {
if ($this->requestedItem) {
return $this->requestedItem;
}
if (!$this->ExternalContentRoot) {
return null;
}
// See if an item was requested in the url directly
$id = isset($_REQUEST['item']) ? $_REQUEST['item'] : null;
if (!$id) {
$id = $this->ExternalContentRoot;
}
$remoteObject = ExternalContent::getDataObjectFor($id);
if ($remoteObject) {
$this->requestedItem = $remoteObject;
return $this->requestedItem;
}
return null;
} | [
"public",
"function",
"ContentItem",
"(",
"$",
"what",
"=",
"'k'",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"requestedItem",
")",
"{",
"return",
"$",
"this",
"->",
"requestedItem",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"ExternalContentRoot",
")",
"{",
"return",
"null",
";",
"}",
"// See if an item was requested in the url directly",
"$",
"id",
"=",
"isset",
"(",
"$",
"_REQUEST",
"[",
"'item'",
"]",
")",
"?",
"$",
"_REQUEST",
"[",
"'item'",
"]",
":",
"null",
";",
"if",
"(",
"!",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"ExternalContentRoot",
";",
"}",
"$",
"remoteObject",
"=",
"ExternalContent",
"::",
"getDataObjectFor",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"remoteObject",
")",
"{",
"$",
"this",
"->",
"requestedItem",
"=",
"$",
"remoteObject",
";",
"return",
"$",
"this",
"->",
"requestedItem",
";",
"}",
"return",
"null",
";",
"}"
]
| Get the external content item
@return DataObject | [
"Get",
"the",
"external",
"content",
"item"
]
| 1c6da8c56ef717225ff904e1522aff94ed051601 | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/pages/ExternalContentPage.php#L71-L95 |
19,645 | nyeholt/silverstripe-external-content | code/pages/ExternalContentPage.php | ExternalContentPage_Controller.view | public function view($request) {
$object = null;
if ($id = $request->param('ID')) {
$object = ExternalContent::getDataObjectFor($id);
if ($object instanceof ExternalContentSource) {
$object = $object->getRoot();
}
if ($object && ($object instanceof ExternalContentItem || $object instanceof ExternalContentSource)) {
$this->data()->setRequestedItem($object);
$type = $object instanceof ExternalContentItem ? $object->getType() : 'source';
$template = 'ExternalContent_' . get_class($object) . '_' . $type;
$viewer = new SSViewer(array($template, 'ExternalContent_' . get_class($object), 'ExternalContent', 'Page'));
$action = 'view';
$this->extend('updateViewer', $action, $viewer);
return $this->customise($object)->renderWith($viewer);
}
}
echo "Template not found for " . ($object ? get_class($object) . ' #' . $object->ID : '');
} | php | public function view($request) {
$object = null;
if ($id = $request->param('ID')) {
$object = ExternalContent::getDataObjectFor($id);
if ($object instanceof ExternalContentSource) {
$object = $object->getRoot();
}
if ($object && ($object instanceof ExternalContentItem || $object instanceof ExternalContentSource)) {
$this->data()->setRequestedItem($object);
$type = $object instanceof ExternalContentItem ? $object->getType() : 'source';
$template = 'ExternalContent_' . get_class($object) . '_' . $type;
$viewer = new SSViewer(array($template, 'ExternalContent_' . get_class($object), 'ExternalContent', 'Page'));
$action = 'view';
$this->extend('updateViewer', $action, $viewer);
return $this->customise($object)->renderWith($viewer);
}
}
echo "Template not found for " . ($object ? get_class($object) . ' #' . $object->ID : '');
} | [
"public",
"function",
"view",
"(",
"$",
"request",
")",
"{",
"$",
"object",
"=",
"null",
";",
"if",
"(",
"$",
"id",
"=",
"$",
"request",
"->",
"param",
"(",
"'ID'",
")",
")",
"{",
"$",
"object",
"=",
"ExternalContent",
"::",
"getDataObjectFor",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"object",
"instanceof",
"ExternalContentSource",
")",
"{",
"$",
"object",
"=",
"$",
"object",
"->",
"getRoot",
"(",
")",
";",
"}",
"if",
"(",
"$",
"object",
"&&",
"(",
"$",
"object",
"instanceof",
"ExternalContentItem",
"||",
"$",
"object",
"instanceof",
"ExternalContentSource",
")",
")",
"{",
"$",
"this",
"->",
"data",
"(",
")",
"->",
"setRequestedItem",
"(",
"$",
"object",
")",
";",
"$",
"type",
"=",
"$",
"object",
"instanceof",
"ExternalContentItem",
"?",
"$",
"object",
"->",
"getType",
"(",
")",
":",
"'source'",
";",
"$",
"template",
"=",
"'ExternalContent_'",
".",
"get_class",
"(",
"$",
"object",
")",
".",
"'_'",
".",
"$",
"type",
";",
"$",
"viewer",
"=",
"new",
"SSViewer",
"(",
"array",
"(",
"$",
"template",
",",
"'ExternalContent_'",
".",
"get_class",
"(",
"$",
"object",
")",
",",
"'ExternalContent'",
",",
"'Page'",
")",
")",
";",
"$",
"action",
"=",
"'view'",
";",
"$",
"this",
"->",
"extend",
"(",
"'updateViewer'",
",",
"$",
"action",
",",
"$",
"viewer",
")",
";",
"return",
"$",
"this",
"->",
"customise",
"(",
"$",
"object",
")",
"->",
"renderWith",
"(",
"$",
"viewer",
")",
";",
"}",
"}",
"echo",
"\"Template not found for \"",
".",
"(",
"$",
"object",
"?",
"get_class",
"(",
"$",
"object",
")",
".",
"' #'",
".",
"$",
"object",
"->",
"ID",
":",
"''",
")",
";",
"}"
]
| Display an item.
@param HTTP_Request $request
@return String | [
"Display",
"an",
"item",
"."
]
| 1c6da8c56ef717225ff904e1522aff94ed051601 | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/pages/ExternalContentPage.php#L133-L155 |
19,646 | nyeholt/silverstripe-external-content | code/pages/ExternalContentPage.php | ExternalContentPage_Controller.download | public function download($request) {
if ($request->param('ID')) {
$object = ExternalContent::getDataObjectFor($request->param('ID'));
if ($object && $object instanceof ExternalContentItem) {
$object->streamContent();
}
}
} | php | public function download($request) {
if ($request->param('ID')) {
$object = ExternalContent::getDataObjectFor($request->param('ID'));
if ($object && $object instanceof ExternalContentItem) {
$object->streamContent();
}
}
} | [
"public",
"function",
"download",
"(",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"param",
"(",
"'ID'",
")",
")",
"{",
"$",
"object",
"=",
"ExternalContent",
"::",
"getDataObjectFor",
"(",
"$",
"request",
"->",
"param",
"(",
"'ID'",
")",
")",
";",
"if",
"(",
"$",
"object",
"&&",
"$",
"object",
"instanceof",
"ExternalContentItem",
")",
"{",
"$",
"object",
"->",
"streamContent",
"(",
")",
";",
"}",
"}",
"}"
]
| Called to download this content item and stream it directly to the browser
@param HTTP_Request $request | [
"Called",
"to",
"download",
"this",
"content",
"item",
"and",
"stream",
"it",
"directly",
"to",
"the",
"browser"
]
| 1c6da8c56ef717225ff904e1522aff94ed051601 | https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/pages/ExternalContentPage.php#L162-L169 |
19,647 | joseph-walker/vector | src/Core/Module.php | Module.memoize | protected static function memoize(Callable $f)
{
return function(...$args) use ($f) {
static $cache;
if ($cache === null)
$cache = [];
$key = serialize($args);
if (array_key_exists($key, $cache)) {
return $cache[$key];
} else {
$result = call_user_func_array($f, $args);
$cache[$key] = $result;
return $result;
}
};
} | php | protected static function memoize(Callable $f)
{
return function(...$args) use ($f) {
static $cache;
if ($cache === null)
$cache = [];
$key = serialize($args);
if (array_key_exists($key, $cache)) {
return $cache[$key];
} else {
$result = call_user_func_array($f, $args);
$cache[$key] = $result;
return $result;
}
};
} | [
"protected",
"static",
"function",
"memoize",
"(",
"Callable",
"$",
"f",
")",
"{",
"return",
"function",
"(",
"...",
"$",
"args",
")",
"use",
"(",
"$",
"f",
")",
"{",
"static",
"$",
"cache",
";",
"if",
"(",
"$",
"cache",
"===",
"null",
")",
"$",
"cache",
"=",
"[",
"]",
";",
"$",
"key",
"=",
"serialize",
"(",
"$",
"args",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"cache",
")",
")",
"{",
"return",
"$",
"cache",
"[",
"$",
"key",
"]",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"call_user_func_array",
"(",
"$",
"f",
",",
"$",
"args",
")",
";",
"$",
"cache",
"[",
"$",
"key",
"]",
"=",
"$",
"result",
";",
"return",
"$",
"result",
";",
"}",
"}",
";",
"}"
]
| Memoize a Function
Provided a function $f, return a new function that keeps track of all calls to
$f and caches their responses. Good for functions that have long-running execution times.
Bad for functions that have side effects. But you don't write those now do you?
```
$myFastFunction = $memoize($myBigFunction);
$myFastFunction(1, 2); // Really long wait
$myFastFunction(1, 2); // Instantaneous response
```
@type (* -> *) -> * -> *
@param Callable $f Function to memoize
@return Callable Memoized funciton $f | [
"Memoize",
"a",
"Function"
]
| e349aa2e9e0535b1993f9fffc0476e7fd8e113fc | https://github.com/joseph-walker/vector/blob/e349aa2e9e0535b1993f9fffc0476e7fd8e113fc/src/Core/Module.php#L136-L155 |
19,648 | ClanCats/Core | src/classes/CCConfig/File.php | CCConfig_File.read | public function read( $name )
{
// check for absolut path
if ( substr( $name, 0, 1 ) == '/' && file_exists( $name ) )
{
return $this->read_file( $name );
}
$in_namespace = false;
// split the namespace
if ( strpos( $name, '::' ) !== false )
{
$conf = explode( '::', $name );
$in_namespace = $conf[0];
$name = $conf[1];
unset( $conf );
}
// the two holders
$main = $default = array();
/*
* App config
* if app config try to load the equal core config as defaults
*/
if ( !$in_namespace )
{
$core_conf = $this->path( CCCORE_NAMESPACE.'::'.$name, true );
$app_conf = $this->path( $name, true );
if ( file_exists( $core_conf ) )
{
$default = $this->read_file( $core_conf );
}
if ( file_exists( $app_conf ) )
{
$main = $this->read_file( $app_conf );
}
}
/*
* Namespaced config
* means use the namespaced config as default also try to load the app implementation
*/
elseif ( $in_namespace )
{
$main_conf = $this->path( $in_namespace.'::'.$name, true );
$app_conf = $this->path( $name, true );
if ( file_exists( $main_conf ) )
{
$default = $this->read_file( $main_conf );
}
if ( file_exists( $app_conf ) )
{
$main = $this->read_file( $app_conf );
}
}
// finally return the data
return CCArr::merge( $default, $main );
} | php | public function read( $name )
{
// check for absolut path
if ( substr( $name, 0, 1 ) == '/' && file_exists( $name ) )
{
return $this->read_file( $name );
}
$in_namespace = false;
// split the namespace
if ( strpos( $name, '::' ) !== false )
{
$conf = explode( '::', $name );
$in_namespace = $conf[0];
$name = $conf[1];
unset( $conf );
}
// the two holders
$main = $default = array();
/*
* App config
* if app config try to load the equal core config as defaults
*/
if ( !$in_namespace )
{
$core_conf = $this->path( CCCORE_NAMESPACE.'::'.$name, true );
$app_conf = $this->path( $name, true );
if ( file_exists( $core_conf ) )
{
$default = $this->read_file( $core_conf );
}
if ( file_exists( $app_conf ) )
{
$main = $this->read_file( $app_conf );
}
}
/*
* Namespaced config
* means use the namespaced config as default also try to load the app implementation
*/
elseif ( $in_namespace )
{
$main_conf = $this->path( $in_namespace.'::'.$name, true );
$app_conf = $this->path( $name, true );
if ( file_exists( $main_conf ) )
{
$default = $this->read_file( $main_conf );
}
if ( file_exists( $app_conf ) )
{
$main = $this->read_file( $app_conf );
}
}
// finally return the data
return CCArr::merge( $default, $main );
} | [
"public",
"function",
"read",
"(",
"$",
"name",
")",
"{",
"// check for absolut path",
"if",
"(",
"substr",
"(",
"$",
"name",
",",
"0",
",",
"1",
")",
"==",
"'/'",
"&&",
"file_exists",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"read_file",
"(",
"$",
"name",
")",
";",
"}",
"$",
"in_namespace",
"=",
"false",
";",
"// split the namespace",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"'::'",
")",
"!==",
"false",
")",
"{",
"$",
"conf",
"=",
"explode",
"(",
"'::'",
",",
"$",
"name",
")",
";",
"$",
"in_namespace",
"=",
"$",
"conf",
"[",
"0",
"]",
";",
"$",
"name",
"=",
"$",
"conf",
"[",
"1",
"]",
";",
"unset",
"(",
"$",
"conf",
")",
";",
"}",
"// the two holders",
"$",
"main",
"=",
"$",
"default",
"=",
"array",
"(",
")",
";",
"/*\n\t\t * App config\n\t\t * if app config try to load the equal core config as defaults\n\t\t */",
"if",
"(",
"!",
"$",
"in_namespace",
")",
"{",
"$",
"core_conf",
"=",
"$",
"this",
"->",
"path",
"(",
"CCCORE_NAMESPACE",
".",
"'::'",
".",
"$",
"name",
",",
"true",
")",
";",
"$",
"app_conf",
"=",
"$",
"this",
"->",
"path",
"(",
"$",
"name",
",",
"true",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"core_conf",
")",
")",
"{",
"$",
"default",
"=",
"$",
"this",
"->",
"read_file",
"(",
"$",
"core_conf",
")",
";",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"app_conf",
")",
")",
"{",
"$",
"main",
"=",
"$",
"this",
"->",
"read_file",
"(",
"$",
"app_conf",
")",
";",
"}",
"}",
"/*\n\t\t * Namespaced config\n\t\t * means use the namespaced config as default also try to load the app implementation\n\t\t */",
"elseif",
"(",
"$",
"in_namespace",
")",
"{",
"$",
"main_conf",
"=",
"$",
"this",
"->",
"path",
"(",
"$",
"in_namespace",
".",
"'::'",
".",
"$",
"name",
",",
"true",
")",
";",
"$",
"app_conf",
"=",
"$",
"this",
"->",
"path",
"(",
"$",
"name",
",",
"true",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"main_conf",
")",
")",
"{",
"$",
"default",
"=",
"$",
"this",
"->",
"read_file",
"(",
"$",
"main_conf",
")",
";",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"app_conf",
")",
")",
"{",
"$",
"main",
"=",
"$",
"this",
"->",
"read_file",
"(",
"$",
"app_conf",
")",
";",
"}",
"}",
"// finally return the data",
"return",
"CCArr",
"::",
"merge",
"(",
"$",
"default",
",",
"$",
"main",
")",
";",
"}"
]
| Read the configuration data
Get the configuration data and return them as array
@param string $name
@return array | [
"Read",
"the",
"configuration",
"data",
"Get",
"the",
"configuration",
"data",
"and",
"return",
"them",
"as",
"array"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConfig/File.php#L26-L90 |
19,649 | ClanCats/Core | src/classes/CCConfig/File.php | CCConfig_File.write | public function write( $file, $data )
{
// check for absolut path
if ( substr( $file, 0, 1 ) == '/' )
{
return $this->write_file( $file, $data );
}
$this->write_file( $this->path( $file ), $data );
} | php | public function write( $file, $data )
{
// check for absolut path
if ( substr( $file, 0, 1 ) == '/' )
{
return $this->write_file( $file, $data );
}
$this->write_file( $this->path( $file ), $data );
} | [
"public",
"function",
"write",
"(",
"$",
"file",
",",
"$",
"data",
")",
"{",
"// check for absolut path",
"if",
"(",
"substr",
"(",
"$",
"file",
",",
"0",
",",
"1",
")",
"==",
"'/'",
")",
"{",
"return",
"$",
"this",
"->",
"write_file",
"(",
"$",
"file",
",",
"$",
"data",
")",
";",
"}",
"$",
"this",
"->",
"write_file",
"(",
"$",
"this",
"->",
"path",
"(",
"$",
"file",
")",
",",
"$",
"data",
")",
";",
"}"
]
| Write the configuration data
@param string $file
@return void | [
"Write",
"the",
"configuration",
"data"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConfig/File.php#L98-L107 |
19,650 | ClanCats/Core | src/classes/CCConfig/File.php | CCConfig_File.delete | public function delete( $file )
{
// check for absolut path
if ( substr( $file, 0, 1 ) == '/' )
{
return CCFile::delete( $file );
}
return CCFile::delete( $this->path( $file ) );
} | php | public function delete( $file )
{
// check for absolut path
if ( substr( $file, 0, 1 ) == '/' )
{
return CCFile::delete( $file );
}
return CCFile::delete( $this->path( $file ) );
} | [
"public",
"function",
"delete",
"(",
"$",
"file",
")",
"{",
"// check for absolut path",
"if",
"(",
"substr",
"(",
"$",
"file",
",",
"0",
",",
"1",
")",
"==",
"'/'",
")",
"{",
"return",
"CCFile",
"::",
"delete",
"(",
"$",
"file",
")",
";",
"}",
"return",
"CCFile",
"::",
"delete",
"(",
"$",
"this",
"->",
"path",
"(",
"$",
"file",
")",
")",
";",
"}"
]
| delete the configuration data
@param string $file
@return void | [
"delete",
"the",
"configuration",
"data"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConfig/File.php#L115-L124 |
19,651 | ClanCats/Core | src/classes/CCConfig/File.php | CCConfig_File.path | protected function path( $name, $env = false )
{
$conf = CCPath::get( $name, \CCDIR_CONFIG, static::EXT );
if ( !$env )
{
return $conf;
}
$env_conf = CCPath::get( $name, \CCDIR_CONFIG.ClanCats::environment().'/', static::EXT );
if ( file_exists( $env_conf ) )
{
return $env_conf;
}
return $conf;
} | php | protected function path( $name, $env = false )
{
$conf = CCPath::get( $name, \CCDIR_CONFIG, static::EXT );
if ( !$env )
{
return $conf;
}
$env_conf = CCPath::get( $name, \CCDIR_CONFIG.ClanCats::environment().'/', static::EXT );
if ( file_exists( $env_conf ) )
{
return $env_conf;
}
return $conf;
} | [
"protected",
"function",
"path",
"(",
"$",
"name",
",",
"$",
"env",
"=",
"false",
")",
"{",
"$",
"conf",
"=",
"CCPath",
"::",
"get",
"(",
"$",
"name",
",",
"\\",
"CCDIR_CONFIG",
",",
"static",
"::",
"EXT",
")",
";",
"if",
"(",
"!",
"$",
"env",
")",
"{",
"return",
"$",
"conf",
";",
"}",
"$",
"env_conf",
"=",
"CCPath",
"::",
"get",
"(",
"$",
"name",
",",
"\\",
"CCDIR_CONFIG",
".",
"ClanCats",
"::",
"environment",
"(",
")",
".",
"'/'",
",",
"static",
"::",
"EXT",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"env_conf",
")",
")",
"{",
"return",
"$",
"env_conf",
";",
"}",
"return",
"$",
"conf",
";",
"}"
]
| generates a path for a config name
@param string $name
@param bool $env | [
"generates",
"a",
"path",
"for",
"a",
"config",
"name"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConfig/File.php#L152-L169 |
19,652 | tbreuss/pvc | src/View/ViewHelpers.php | ViewHelpers.add | public function add(string $name, callable $callback): self
{
if ($this->exists($name)) {
throw new LogicException(
'The helper function name "' . $name . '" is already registered.'
);
}
$this->helpers[$name] = $callback;
return $this;
} | php | public function add(string $name, callable $callback): self
{
if ($this->exists($name)) {
throw new LogicException(
'The helper function name "' . $name . '" is already registered.'
);
}
$this->helpers[$name] = $callback;
return $this;
} | [
"public",
"function",
"add",
"(",
"string",
"$",
"name",
",",
"callable",
"$",
"callback",
")",
":",
"self",
"{",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'The helper function name \"'",
".",
"$",
"name",
".",
"'\" is already registered.'",
")",
";",
"}",
"$",
"this",
"->",
"helpers",
"[",
"$",
"name",
"]",
"=",
"$",
"callback",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a new template function.
@param string $name
@param callback $callback
@return ViewHelpers | [
"Add",
"a",
"new",
"template",
"function",
"."
]
| ae100351010a8c9f645ccb918f70a26e167de7a7 | https://github.com/tbreuss/pvc/blob/ae100351010a8c9f645ccb918f70a26e167de7a7/src/View/ViewHelpers.php#L26-L37 |
19,653 | tbreuss/pvc | src/View/ViewHelpers.php | ViewHelpers.remove | public function remove(string $name): self
{
if (!$this->exists($name)) {
throw new LogicException(
'The template function "' . $name . '" was not found.'
);
}
unset($this->helpers[$name]);
return $this;
} | php | public function remove(string $name): self
{
if (!$this->exists($name)) {
throw new LogicException(
'The template function "' . $name . '" was not found.'
);
}
unset($this->helpers[$name]);
return $this;
} | [
"public",
"function",
"remove",
"(",
"string",
"$",
"name",
")",
":",
"self",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'The template function \"'",
".",
"$",
"name",
".",
"'\" was not found.'",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"helpers",
"[",
"$",
"name",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Remove a template function.
@param string $name
@return ViewHelpers | [
"Remove",
"a",
"template",
"function",
"."
]
| ae100351010a8c9f645ccb918f70a26e167de7a7 | https://github.com/tbreuss/pvc/blob/ae100351010a8c9f645ccb918f70a26e167de7a7/src/View/ViewHelpers.php#L44-L55 |
19,654 | Chill-project/Main | Entity/PermissionsGroup.php | PermissionsGroup.isRoleScopePresentOnce | public function isRoleScopePresentOnce(ExecutionContextInterface $context)
{
$roleScopesId = array_map(function(RoleScope $roleScope) {
return $roleScope->getId();
},
$this->getRoleScopes()->toArray());
$countedIds = array_count_values($roleScopesId);
foreach ($countedIds as $id => $nb) {
if ($nb > 1) {
$context->buildViolation("A permission is already present "
. "for the same role and scope")
->addViolation();
}
}
} | php | public function isRoleScopePresentOnce(ExecutionContextInterface $context)
{
$roleScopesId = array_map(function(RoleScope $roleScope) {
return $roleScope->getId();
},
$this->getRoleScopes()->toArray());
$countedIds = array_count_values($roleScopesId);
foreach ($countedIds as $id => $nb) {
if ($nb > 1) {
$context->buildViolation("A permission is already present "
. "for the same role and scope")
->addViolation();
}
}
} | [
"public",
"function",
"isRoleScopePresentOnce",
"(",
"ExecutionContextInterface",
"$",
"context",
")",
"{",
"$",
"roleScopesId",
"=",
"array_map",
"(",
"function",
"(",
"RoleScope",
"$",
"roleScope",
")",
"{",
"return",
"$",
"roleScope",
"->",
"getId",
"(",
")",
";",
"}",
",",
"$",
"this",
"->",
"getRoleScopes",
"(",
")",
"->",
"toArray",
"(",
")",
")",
";",
"$",
"countedIds",
"=",
"array_count_values",
"(",
"$",
"roleScopesId",
")",
";",
"foreach",
"(",
"$",
"countedIds",
"as",
"$",
"id",
"=>",
"$",
"nb",
")",
"{",
"if",
"(",
"$",
"nb",
">",
"1",
")",
"{",
"$",
"context",
"->",
"buildViolation",
"(",
"\"A permission is already present \"",
".",
"\"for the same role and scope\"",
")",
"->",
"addViolation",
"(",
")",
";",
"}",
"}",
"}"
]
| Test that a role scope is associated only once with the permission group
@param ExecutionContextInterface $context | [
"Test",
"that",
"a",
"role",
"scope",
"is",
"associated",
"only",
"once",
"with",
"the",
"permission",
"group"
]
| 384cb6c793072a4f1047dc5cafc2157ee2419f60 | https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Entity/PermissionsGroup.php#L110-L125 |
19,655 | ClanCats/Core | src/classes/CCAsset.php | CCAsset.macro_og | protected static function macro_og( $tags, $content = null )
{
if ( !is_array( $tags ) )
{
$tags = array( $tags => $content );
}
$buffer = "";
foreach( $tags as $key => $content )
{
$buffer .= '<meta property="og:'.$key.'" content="'.$content.'" />';
}
return $buffer;
} | php | protected static function macro_og( $tags, $content = null )
{
if ( !is_array( $tags ) )
{
$tags = array( $tags => $content );
}
$buffer = "";
foreach( $tags as $key => $content )
{
$buffer .= '<meta property="og:'.$key.'" content="'.$content.'" />';
}
return $buffer;
} | [
"protected",
"static",
"function",
"macro_og",
"(",
"$",
"tags",
",",
"$",
"content",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"tags",
")",
")",
"{",
"$",
"tags",
"=",
"array",
"(",
"$",
"tags",
"=>",
"$",
"content",
")",
";",
"}",
"$",
"buffer",
"=",
"\"\"",
";",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"key",
"=>",
"$",
"content",
")",
"{",
"$",
"buffer",
".=",
"'<meta property=\"og:'",
".",
"$",
"key",
".",
"'\" content=\"'",
".",
"$",
"content",
".",
"'\" />'",
";",
"}",
"return",
"$",
"buffer",
";",
"}"
]
| OG Macro - Generates open grapth tags
// <meta property="og:type" content="video" />
CCAsset::og( 'type', 'video' );
// <meta property="og:type" content="video" />
// <meta property="og:res" content="1080p" />
CCAsset::og( array( 'type' => 'video', 'res' => '1080p' ));
@param array|string $tags
@param string $content
@return string | [
"OG",
"Macro",
"-",
"Generates",
"open",
"grapth",
"tags"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCAsset.php#L109-L124 |
19,656 | ClanCats/Core | src/classes/CCAsset.php | CCAsset.uri | public static function uri( $uri, $name = null )
{
// when the uri conains a protocol we just return
// the given uri.
if ( strpos( $uri, '://' ) === false )
{
// If the path is relative and not absolute
// we prefix the holder path.
if ( substr( $uri, 0, 1 ) != '/' )
{
$uri = CCUrl::to( static::holder( $name )->path.$uri );
}
// When the given uri is absolute we remove the first
// slash and let CCUrl do the job.
else
{
$uri = CCUrl::to( substr( $uri, 1 ) );
}
}
return $uri;
} | php | public static function uri( $uri, $name = null )
{
// when the uri conains a protocol we just return
// the given uri.
if ( strpos( $uri, '://' ) === false )
{
// If the path is relative and not absolute
// we prefix the holder path.
if ( substr( $uri, 0, 1 ) != '/' )
{
$uri = CCUrl::to( static::holder( $name )->path.$uri );
}
// When the given uri is absolute we remove the first
// slash and let CCUrl do the job.
else
{
$uri = CCUrl::to( substr( $uri, 1 ) );
}
}
return $uri;
} | [
"public",
"static",
"function",
"uri",
"(",
"$",
"uri",
",",
"$",
"name",
"=",
"null",
")",
"{",
"// when the uri conains a protocol we just return ",
"// the given uri.",
"if",
"(",
"strpos",
"(",
"$",
"uri",
",",
"'://'",
")",
"===",
"false",
")",
"{",
"// If the path is relative and not absolute",
"// we prefix the holder path.",
"if",
"(",
"substr",
"(",
"$",
"uri",
",",
"0",
",",
"1",
")",
"!=",
"'/'",
")",
"{",
"$",
"uri",
"=",
"CCUrl",
"::",
"to",
"(",
"static",
"::",
"holder",
"(",
"$",
"name",
")",
"->",
"path",
".",
"$",
"uri",
")",
";",
"}",
"// When the given uri is absolute we remove the first",
"// slash and let CCUrl do the job.",
"else",
"{",
"$",
"uri",
"=",
"CCUrl",
"::",
"to",
"(",
"substr",
"(",
"$",
"uri",
",",
"1",
")",
")",
";",
"}",
"}",
"return",
"$",
"uri",
";",
"}"
]
| Get the uri to an asset
// /assets/images/something.jpg
CCAsset::uri( 'images/something.jpg' );
// /assets/MyTheme/images/something.jpg
CCAsset::uri( 'images/logo.png', 'theme' );
// will not modify the given url
CCAsset::uri( 'http://example.com/images/logo.jpg' );
@param string $uri
@param string $name
@return string | [
"Get",
"the",
"uri",
"to",
"an",
"asset"
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCAsset.php#L188-L209 |
19,657 | ClanCats/Core | src/classes/CCAsset.php | CCAsset.holder | public static function holder( $name = null )
{
if ( !isset( $name ) )
{
$name = static::$_default;
}
if ( !isset( static::$instances[$name] ) )
{
static::$instances[$name] = new CCAsset_Holder();
}
return static::$instances[$name];
} | php | public static function holder( $name = null )
{
if ( !isset( $name ) )
{
$name = static::$_default;
}
if ( !isset( static::$instances[$name] ) )
{
static::$instances[$name] = new CCAsset_Holder();
}
return static::$instances[$name];
} | [
"public",
"static",
"function",
"holder",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"static",
"::",
"$",
"_default",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"instances",
"[",
"$",
"name",
"]",
")",
")",
"{",
"static",
"::",
"$",
"instances",
"[",
"$",
"name",
"]",
"=",
"new",
"CCAsset_Holder",
"(",
")",
";",
"}",
"return",
"static",
"::",
"$",
"instances",
"[",
"$",
"name",
"]",
";",
"}"
]
| Get an asset holder instance.
$holder = CCAsset::holder();
$holder = CCAsset::holder( 'footer' );
@param string $name
@return CCAsset | [
"Get",
"an",
"asset",
"holder",
"instance",
"."
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCAsset.php#L220-L233 |
19,658 | ClanCats/Core | src/classes/CCAsset.php | CCAsset.code | public static function code( $type, $name = null )
{
$buffer = "";
foreach( static::holder( $name )->get( $type ) as $item )
{
$buffer .= call_user_func( array( '\\CCAsset', $type ), $item, $name );
}
return $buffer;
} | php | public static function code( $type, $name = null )
{
$buffer = "";
foreach( static::holder( $name )->get( $type ) as $item )
{
$buffer .= call_user_func( array( '\\CCAsset', $type ), $item, $name );
}
return $buffer;
} | [
"public",
"static",
"function",
"code",
"(",
"$",
"type",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"buffer",
"=",
"\"\"",
";",
"foreach",
"(",
"static",
"::",
"holder",
"(",
"$",
"name",
")",
"->",
"get",
"(",
"$",
"type",
")",
"as",
"$",
"item",
")",
"{",
"$",
"buffer",
".=",
"call_user_func",
"(",
"array",
"(",
"'\\\\CCAsset'",
",",
"$",
"type",
")",
",",
"$",
"item",
",",
"$",
"name",
")",
";",
"}",
"return",
"$",
"buffer",
";",
"}"
]
| Get all assets of a specific type in a holder and run them
trough the maching macros.
CCAsset::code( 'css' );
CCAsset::code( 'js', 'footer' );
@param string $type
@param string $name | [
"Get",
"all",
"assets",
"of",
"a",
"specific",
"type",
"in",
"a",
"holder",
"and",
"run",
"them",
"trough",
"the",
"maching",
"macros",
"."
]
| 9f6ec72c1a439de4b253d0223f1029f7f85b6ef8 | https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCAsset.php#L245-L255 |
19,659 | arsengoian/viper-framework | src/Viper/Daemon/QueueRouter.php | QueueRouter.add | public function add(Task $task) : void
{
$this->index++;
Util::put($this -> storage().$this->index.'.queue', serialize($task));
$this -> updateIterator();
Util::put($this -> storage().'_index', $this -> index);
} | php | public function add(Task $task) : void
{
$this->index++;
Util::put($this -> storage().$this->index.'.queue', serialize($task));
$this -> updateIterator();
Util::put($this -> storage().'_index', $this -> index);
} | [
"public",
"function",
"add",
"(",
"Task",
"$",
"task",
")",
":",
"void",
"{",
"$",
"this",
"->",
"index",
"++",
";",
"Util",
"::",
"put",
"(",
"$",
"this",
"->",
"storage",
"(",
")",
".",
"$",
"this",
"->",
"index",
".",
"'.queue'",
",",
"serialize",
"(",
"$",
"task",
")",
")",
";",
"$",
"this",
"->",
"updateIterator",
"(",
")",
";",
"Util",
"::",
"put",
"(",
"$",
"this",
"->",
"storage",
"(",
")",
".",
"'_index'",
",",
"$",
"this",
"->",
"index",
")",
";",
"}"
]
| Add new task to queue top
@param Task $task | [
"Add",
"new",
"task",
"to",
"queue",
"top"
]
| 22796c5cc219cae3ca0b4af370a347ba2acab0f2 | https://github.com/arsengoian/viper-framework/blob/22796c5cc219cae3ca0b4af370a347ba2acab0f2/src/Viper/Daemon/QueueRouter.php#L52-L58 |
19,660 | arsengoian/viper-framework | src/Viper/Daemon/QueueRouter.php | QueueRouter.pop | public function pop(int $num) : Collection
{
$ret = new Collection();
foreach ($this -> iterator as $item) {
if (!$num--)
return $ret;
$ret[] = unserialize(file_get_contents($item));
unlink($item);
}
$this -> updateIterator();
return $ret;
} | php | public function pop(int $num) : Collection
{
$ret = new Collection();
foreach ($this -> iterator as $item) {
if (!$num--)
return $ret;
$ret[] = unserialize(file_get_contents($item));
unlink($item);
}
$this -> updateIterator();
return $ret;
} | [
"public",
"function",
"pop",
"(",
"int",
"$",
"num",
")",
":",
"Collection",
"{",
"$",
"ret",
"=",
"new",
"Collection",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"iterator",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"$",
"num",
"--",
")",
"return",
"$",
"ret",
";",
"$",
"ret",
"[",
"]",
"=",
"unserialize",
"(",
"file_get_contents",
"(",
"$",
"item",
")",
")",
";",
"unlink",
"(",
"$",
"item",
")",
";",
"}",
"$",
"this",
"->",
"updateIterator",
"(",
")",
";",
"return",
"$",
"ret",
";",
"}"
]
| Get the oldest items from the queue
@param int $num the number of items to pop
@return Collection
TODO fix situation when crash is immediately after pop; | [
"Get",
"the",
"oldest",
"items",
"from",
"the",
"queue"
]
| 22796c5cc219cae3ca0b4af370a347ba2acab0f2 | https://github.com/arsengoian/viper-framework/blob/22796c5cc219cae3ca0b4af370a347ba2acab0f2/src/Viper/Daemon/QueueRouter.php#L66-L77 |
19,661 | slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php | BaseRemoteAppPeer.getValueSet | public static function getValueSet($colname)
{
$valueSets = RemoteAppPeer::getValueSets();
if (!isset($valueSets[$colname])) {
throw new PropelException(sprintf('Column "%s" has no ValueSet.', $colname));
}
return $valueSets[$colname];
} | php | public static function getValueSet($colname)
{
$valueSets = RemoteAppPeer::getValueSets();
if (!isset($valueSets[$colname])) {
throw new PropelException(sprintf('Column "%s" has no ValueSet.', $colname));
}
return $valueSets[$colname];
} | [
"public",
"static",
"function",
"getValueSet",
"(",
"$",
"colname",
")",
"{",
"$",
"valueSets",
"=",
"RemoteAppPeer",
"::",
"getValueSets",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"valueSets",
"[",
"$",
"colname",
"]",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"sprintf",
"(",
"'Column \"%s\" has no ValueSet.'",
",",
"$",
"colname",
")",
")",
";",
"}",
"return",
"$",
"valueSets",
"[",
"$",
"colname",
"]",
";",
"}"
]
| Gets the list of values for an ENUM column
@param string $colname The ENUM column name.
@return array list of possible values for the column | [
"Gets",
"the",
"list",
"of",
"values",
"for",
"an",
"ENUM",
"column"
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php#L237-L246 |
19,662 | slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php | BaseRemoteAppPeer.getSqlValueForEnum | public static function getSqlValueForEnum($colname, $enumVal)
{
$values = RemoteAppPeer::getValueSet($colname);
if (!in_array($enumVal, $values)) {
throw new PropelException(sprintf('Value "%s" is not accepted in this enumerated column', $colname));
}
return array_search($enumVal, $values);
} | php | public static function getSqlValueForEnum($colname, $enumVal)
{
$values = RemoteAppPeer::getValueSet($colname);
if (!in_array($enumVal, $values)) {
throw new PropelException(sprintf('Value "%s" is not accepted in this enumerated column', $colname));
}
return array_search($enumVal, $values);
} | [
"public",
"static",
"function",
"getSqlValueForEnum",
"(",
"$",
"colname",
",",
"$",
"enumVal",
")",
"{",
"$",
"values",
"=",
"RemoteAppPeer",
"::",
"getValueSet",
"(",
"$",
"colname",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"enumVal",
",",
"$",
"values",
")",
")",
"{",
"throw",
"new",
"PropelException",
"(",
"sprintf",
"(",
"'Value \"%s\" is not accepted in this enumerated column'",
",",
"$",
"colname",
")",
")",
";",
"}",
"return",
"array_search",
"(",
"$",
"enumVal",
",",
"$",
"values",
")",
";",
"}"
]
| Gets the SQL value for the ENUM column value
@param string $colname ENUM column name.
@param string $enumVal ENUM value.
@return int SQL value | [
"Gets",
"the",
"SQL",
"value",
"for",
"the",
"ENUM",
"column",
"value"
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php#L256-L264 |
19,663 | slashworks/control-bundle | src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php | BaseRemoteAppPeer.clearInstancePool | public static function clearInstancePool($and_clear_all_references = false)
{
if ($and_clear_all_references) {
foreach (RemoteAppPeer::$instances as $instance) {
$instance->clearAllReferences(true);
}
}
RemoteAppPeer::$instances = array();
} | php | public static function clearInstancePool($and_clear_all_references = false)
{
if ($and_clear_all_references) {
foreach (RemoteAppPeer::$instances as $instance) {
$instance->clearAllReferences(true);
}
}
RemoteAppPeer::$instances = array();
} | [
"public",
"static",
"function",
"clearInstancePool",
"(",
"$",
"and_clear_all_references",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"and_clear_all_references",
")",
"{",
"foreach",
"(",
"RemoteAppPeer",
"::",
"$",
"instances",
"as",
"$",
"instance",
")",
"{",
"$",
"instance",
"->",
"clearAllReferences",
"(",
"true",
")",
";",
"}",
"}",
"RemoteAppPeer",
"::",
"$",
"instances",
"=",
"array",
"(",
")",
";",
"}"
]
| Clear the instance pool.
@return void | [
"Clear",
"the",
"instance",
"pool",
"."
]
| 2ba86d96f1f41f9424e2229c4e2b13017e973f89 | https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseRemoteAppPeer.php#L537-L545 |
19,664 | jpcercal/resource-query-language | src/Processor/DoctrineOrmProcessor.php | DoctrineOrmProcessor.getParamKeyByExpr | protected function getParamKeyByExpr(ExprInterface $expr)
{
return str_replace('.', '', $expr->getField()) . ucfirst($expr->getExpression()) . uniqid();
} | php | protected function getParamKeyByExpr(ExprInterface $expr)
{
return str_replace('.', '', $expr->getField()) . ucfirst($expr->getExpression()) . uniqid();
} | [
"protected",
"function",
"getParamKeyByExpr",
"(",
"ExprInterface",
"$",
"expr",
")",
"{",
"return",
"str_replace",
"(",
"'.'",
",",
"''",
",",
"$",
"expr",
"->",
"getField",
"(",
")",
")",
".",
"ucfirst",
"(",
"$",
"expr",
"->",
"getExpression",
"(",
")",
")",
".",
"uniqid",
"(",
")",
";",
"}"
]
| Get the parameter key that is used by doctrine to put the query parameter identifier.
@param ExprInterface $expr
@return string | [
"Get",
"the",
"parameter",
"key",
"that",
"is",
"used",
"by",
"doctrine",
"to",
"put",
"the",
"query",
"parameter",
"identifier",
"."
]
| 2a1520198c717a8199cd8d3d85ca2557e24cb7f5 | https://github.com/jpcercal/resource-query-language/blob/2a1520198c717a8199cd8d3d85ca2557e24cb7f5/src/Processor/DoctrineOrmProcessor.php#L113-L116 |
19,665 | steeffeen/FancyManiaLinks | FML/Script/Features/Preload.php | Preload.addImageUrl | public function addImageUrl($imageUrl)
{
if (!in_array($imageUrl, $this->imageUrls)) {
array_push($this->imageUrls, $imageUrl);
}
return $this;
} | php | public function addImageUrl($imageUrl)
{
if (!in_array($imageUrl, $this->imageUrls)) {
array_push($this->imageUrls, $imageUrl);
}
return $this;
} | [
"public",
"function",
"addImageUrl",
"(",
"$",
"imageUrl",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"imageUrl",
",",
"$",
"this",
"->",
"imageUrls",
")",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"imageUrls",
",",
"$",
"imageUrl",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add an Image Url to preload
@api
@param string $imageUrl Image Url
@return static | [
"Add",
"an",
"Image",
"Url",
"to",
"preload"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/Preload.php#L55-L61 |
19,666 | TypistTech/wp-kses-view | src/View.php | View.toHtml | public function toHtml($context = null): string
{
return wp_kses(
$this->unsafeRender($context),
$this->allowedHtml
);
} | php | public function toHtml($context = null): string
{
return wp_kses(
$this->unsafeRender($context),
$this->allowedHtml
);
} | [
"public",
"function",
"toHtml",
"(",
"$",
"context",
"=",
"null",
")",
":",
"string",
"{",
"return",
"wp_kses",
"(",
"$",
"this",
"->",
"unsafeRender",
"(",
"$",
"context",
")",
",",
"$",
"this",
"->",
"allowedHtml",
")",
";",
"}"
]
| Convert the view to safe HTML.
@param mixed $context Optional. Context object for which to render the view.
@return string | [
"Convert",
"the",
"view",
"to",
"safe",
"HTML",
"."
]
| 6a5e5a34b81c6387d1c5356c9e42166daec9225f | https://github.com/TypistTech/wp-kses-view/blob/6a5e5a34b81c6387d1c5356c9e42166daec9225f/src/View.php#L80-L86 |
19,667 | Sedona-Solutions/sedona-sbo | src/Sedona/SBOGeneratorBundle/Command/GenerateDoctrineCrudCommand.php | GenerateDoctrineCrudCommand.generateTranslations | protected function generateTranslations($bundle, $entity, $metadata, $forceOverwrite)
{
try {
$this->getTranslationsGenerator($bundle)->generate($bundle, $entity, $metadata[0], $forceOverwrite);
} catch (\RuntimeException $e) {
// form already exists
}
} | php | protected function generateTranslations($bundle, $entity, $metadata, $forceOverwrite)
{
try {
$this->getTranslationsGenerator($bundle)->generate($bundle, $entity, $metadata[0], $forceOverwrite);
} catch (\RuntimeException $e) {
// form already exists
}
} | [
"protected",
"function",
"generateTranslations",
"(",
"$",
"bundle",
",",
"$",
"entity",
",",
"$",
"metadata",
",",
"$",
"forceOverwrite",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"getTranslationsGenerator",
"(",
"$",
"bundle",
")",
"->",
"generate",
"(",
"$",
"bundle",
",",
"$",
"entity",
",",
"$",
"metadata",
"[",
"0",
"]",
",",
"$",
"forceOverwrite",
")",
";",
"}",
"catch",
"(",
"\\",
"RuntimeException",
"$",
"e",
")",
"{",
"// form already exists",
"}",
"}"
]
| Tries to generate translations if they don't exist yet and if we need write operations on entities. | [
"Tries",
"to",
"generate",
"translations",
"if",
"they",
"don",
"t",
"exist",
"yet",
"and",
"if",
"we",
"need",
"write",
"operations",
"on",
"entities",
"."
]
| 8548be4170d191cb1a3e263577aaaab49f04d5ce | https://github.com/Sedona-Solutions/sedona-sbo/blob/8548be4170d191cb1a3e263577aaaab49f04d5ce/src/Sedona/SBOGeneratorBundle/Command/GenerateDoctrineCrudCommand.php#L242-L249 |
19,668 | webforge-labs/psc-cms | lib/Psc/Code/Generate/ClassBuilder.php | ClassBuilder.createMethod | public function createMethod($name, $params = array(), $body = NULL, $modifiers = 256) {
$method = $this->class->createMethod($name, $params, $body, $modifiers);
$method->setClassBuilder($this);
return $method;
} | php | public function createMethod($name, $params = array(), $body = NULL, $modifiers = 256) {
$method = $this->class->createMethod($name, $params, $body, $modifiers);
$method->setClassBuilder($this);
return $method;
} | [
"public",
"function",
"createMethod",
"(",
"$",
"name",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"body",
"=",
"NULL",
",",
"$",
"modifiers",
"=",
"256",
")",
"{",
"$",
"method",
"=",
"$",
"this",
"->",
"class",
"->",
"createMethod",
"(",
"$",
"name",
",",
"$",
"params",
",",
"$",
"body",
",",
"$",
"modifiers",
")",
";",
"$",
"method",
"->",
"setClassBuilder",
"(",
"$",
"this",
")",
";",
"return",
"$",
"method",
";",
"}"
]
| Erstellt eine neue Methode
@return GMethod | [
"Erstellt",
"eine",
"neue",
"Methode"
]
| 467bfa2547e6b4fa487d2d7f35fa6cc618dbc763 | https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Code/Generate/ClassBuilder.php#L109-L113 |
19,669 | bdunogier/iftttbundle | IFTTT/RequestParser.php | RequestParser.getRequest | public function getRequest( array $requestPostData )
{
$requestProperties = array(
'username' => $requestPostData[1],
'password' => $requestPostData[2],
'title' => $requestPostData[3]['title'],
'description' => $requestPostData[3]['description'],
'keywords' => $requestPostData[3]['mt_keywords'],
'status' => $requestPostData[3]['post_status'],
);
return new Request( $requestProperties );
} | php | public function getRequest( array $requestPostData )
{
$requestProperties = array(
'username' => $requestPostData[1],
'password' => $requestPostData[2],
'title' => $requestPostData[3]['title'],
'description' => $requestPostData[3]['description'],
'keywords' => $requestPostData[3]['mt_keywords'],
'status' => $requestPostData[3]['post_status'],
);
return new Request( $requestProperties );
} | [
"public",
"function",
"getRequest",
"(",
"array",
"$",
"requestPostData",
")",
"{",
"$",
"requestProperties",
"=",
"array",
"(",
"'username'",
"=>",
"$",
"requestPostData",
"[",
"1",
"]",
",",
"'password'",
"=>",
"$",
"requestPostData",
"[",
"2",
"]",
",",
"'title'",
"=>",
"$",
"requestPostData",
"[",
"3",
"]",
"[",
"'title'",
"]",
",",
"'description'",
"=>",
"$",
"requestPostData",
"[",
"3",
"]",
"[",
"'description'",
"]",
",",
"'keywords'",
"=>",
"$",
"requestPostData",
"[",
"3",
"]",
"[",
"'mt_keywords'",
"]",
",",
"'status'",
"=>",
"$",
"requestPostData",
"[",
"3",
"]",
"[",
"'post_status'",
"]",
",",
")",
";",
"return",
"new",
"Request",
"(",
"$",
"requestProperties",
")",
";",
"}"
]
| Creates an IFTTT Request from XML RPC post data
@param array $requestPostData
@return \BD\Bundle\IFTTTBundle\IFTTT\Request | [
"Creates",
"an",
"IFTTT",
"Request",
"from",
"XML",
"RPC",
"post",
"data"
]
| b3232a9f49cc6cc8bfc86e92eaf961d8c59021fa | https://github.com/bdunogier/iftttbundle/blob/b3232a9f49cc6cc8bfc86e92eaf961d8c59021fa/IFTTT/RequestParser.php#L21-L33 |
19,670 | steeffeen/FancyManiaLinks | FML/Form/Parameters.php | Parameters.getValue | public static function getValue($name)
{
if (array_key_exists($name, $_GET)) {
return $_GET[$name];
}
if (array_key_exists($name, $_POST)) {
return $_POST[$name];
}
return null;
} | php | public static function getValue($name)
{
if (array_key_exists($name, $_GET)) {
return $_GET[$name];
}
if (array_key_exists($name, $_POST)) {
return $_POST[$name];
}
return null;
} | [
"public",
"static",
"function",
"getValue",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"_GET",
")",
")",
"{",
"return",
"$",
"_GET",
"[",
"$",
"name",
"]",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"_POST",
")",
")",
"{",
"return",
"$",
"_POST",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"null",
";",
"}"
]
| Get the submitted form value
@param string $name Value name
@return string | [
"Get",
"the",
"submitted",
"form",
"value"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Form/Parameters.php#L21-L30 |
19,671 | prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/TimeUnit.php | TimeUnit.toNanos | public function toNanos($d)
{
$v = $this->getValue();
return $this->x($d, $this->{'c'.$v}/$this->c0, PHP_INT_MAX/($this->{'c'.$v}/$this->c0));
} | php | public function toNanos($d)
{
$v = $this->getValue();
return $this->x($d, $this->{'c'.$v}/$this->c0, PHP_INT_MAX/($this->{'c'.$v}/$this->c0));
} | [
"public",
"function",
"toNanos",
"(",
"$",
"d",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"return",
"$",
"this",
"->",
"x",
"(",
"$",
"d",
",",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c0",
",",
"PHP_INT_MAX",
"/",
"(",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c0",
")",
")",
";",
"}"
]
| Convert to nanos
@param int $d
@return int | [
"Convert",
"to",
"nanos"
]
| 771b55b3ef79d9a7443c4f6d95373f41b9f34c4a | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/TimeUnit.php#L52-L56 |
19,672 | prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/TimeUnit.php | TimeUnit.toMicros | public function toMicros($d)
{
$v = $this->getValue();
if ($v < self::MICROSECONDS) {
return $d/($this->c1/$this->c0);
} else {
return $this->x($d, $this->{'c'.$v}/$this->c1, PHP_INT_MAX/($this->{'c'.$v})/$this->c1);
}
} | php | public function toMicros($d)
{
$v = $this->getValue();
if ($v < self::MICROSECONDS) {
return $d/($this->c1/$this->c0);
} else {
return $this->x($d, $this->{'c'.$v}/$this->c1, PHP_INT_MAX/($this->{'c'.$v})/$this->c1);
}
} | [
"public",
"function",
"toMicros",
"(",
"$",
"d",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"$",
"v",
"<",
"self",
"::",
"MICROSECONDS",
")",
"{",
"return",
"$",
"d",
"/",
"(",
"$",
"this",
"->",
"c1",
"/",
"$",
"this",
"->",
"c0",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"x",
"(",
"$",
"d",
",",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c1",
",",
"PHP_INT_MAX",
"/",
"(",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
")",
"/",
"$",
"this",
"->",
"c1",
")",
";",
"}",
"}"
]
| Convert to micros
@param int $d
@return float|int | [
"Convert",
"to",
"micros"
]
| 771b55b3ef79d9a7443c4f6d95373f41b9f34c4a | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/TimeUnit.php#L64-L72 |
19,673 | prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/TimeUnit.php | TimeUnit.toMillis | public function toMillis($d)
{
$v = $this->getValue();
if ($v < self::MILLISECONDS) {
return $d/($this->c2/$this->{'c'.$v});
} else {
return $this->x($d, $this->{'c'.$v}/$this->c2, PHP_INT_MAX/($this->{'c'.$v}/$this->c2));
}
} | php | public function toMillis($d)
{
$v = $this->getValue();
if ($v < self::MILLISECONDS) {
return $d/($this->c2/$this->{'c'.$v});
} else {
return $this->x($d, $this->{'c'.$v}/$this->c2, PHP_INT_MAX/($this->{'c'.$v}/$this->c2));
}
} | [
"public",
"function",
"toMillis",
"(",
"$",
"d",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"$",
"v",
"<",
"self",
"::",
"MILLISECONDS",
")",
"{",
"return",
"$",
"d",
"/",
"(",
"$",
"this",
"->",
"c2",
"/",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"x",
"(",
"$",
"d",
",",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c2",
",",
"PHP_INT_MAX",
"/",
"(",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c2",
")",
")",
";",
"}",
"}"
]
| Convert to millies
@param int $d
@return float|int | [
"Convert",
"to",
"millies"
]
| 771b55b3ef79d9a7443c4f6d95373f41b9f34c4a | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/TimeUnit.php#L80-L88 |
19,674 | prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/TimeUnit.php | TimeUnit.toSeconds | public function toSeconds($d)
{
$v = $this->getValue();
if ($v < self::SECONDS) {
return $d/($this->c3/$this->{'c'.$v});
} else {
return $this->x($d, $this->{'c'.$v}/$this->c3, PHP_INT_MAX/($this->{'c'.$v}/$this->c3));
}
} | php | public function toSeconds($d)
{
$v = $this->getValue();
if ($v < self::SECONDS) {
return $d/($this->c3/$this->{'c'.$v});
} else {
return $this->x($d, $this->{'c'.$v}/$this->c3, PHP_INT_MAX/($this->{'c'.$v}/$this->c3));
}
} | [
"public",
"function",
"toSeconds",
"(",
"$",
"d",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"$",
"v",
"<",
"self",
"::",
"SECONDS",
")",
"{",
"return",
"$",
"d",
"/",
"(",
"$",
"this",
"->",
"c3",
"/",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"x",
"(",
"$",
"d",
",",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c3",
",",
"PHP_INT_MAX",
"/",
"(",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c3",
")",
")",
";",
"}",
"}"
]
| Convert to seconds
@param int $d
@return float|int | [
"Convert",
"to",
"seconds"
]
| 771b55b3ef79d9a7443c4f6d95373f41b9f34c4a | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/TimeUnit.php#L96-L104 |
19,675 | prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/TimeUnit.php | TimeUnit.toMinutes | public function toMinutes($d)
{
$v = $this->getValue();
if ($v < self::MINUTES) {
return $d/($this->c4/$this->{'c'.$v});
} else {
return $this->x($d, $this->{'c'.$v}/$this->c4, PHP_INT_MAX/($this->{'c'.$v}/$this->c4));
}
} | php | public function toMinutes($d)
{
$v = $this->getValue();
if ($v < self::MINUTES) {
return $d/($this->c4/$this->{'c'.$v});
} else {
return $this->x($d, $this->{'c'.$v}/$this->c4, PHP_INT_MAX/($this->{'c'.$v}/$this->c4));
}
} | [
"public",
"function",
"toMinutes",
"(",
"$",
"d",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"$",
"v",
"<",
"self",
"::",
"MINUTES",
")",
"{",
"return",
"$",
"d",
"/",
"(",
"$",
"this",
"->",
"c4",
"/",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"x",
"(",
"$",
"d",
",",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c4",
",",
"PHP_INT_MAX",
"/",
"(",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c4",
")",
")",
";",
"}",
"}"
]
| Convert to minutes
@param int $d
@return float|int | [
"Convert",
"to",
"minutes"
]
| 771b55b3ef79d9a7443c4f6d95373f41b9f34c4a | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/TimeUnit.php#L112-L120 |
19,676 | prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/TimeUnit.php | TimeUnit.toHours | public function toHours($d)
{
$v = $this->getValue();
if ($v < self::HOURS) {
return $d/($this->c5/$this->{'c'.$v});
} else {
return $this->x($d, $this->{'c'.$v}/$this->c5, PHP_INT_MAX/($this->{'c'.$v}/$this->c5));
}
} | php | public function toHours($d)
{
$v = $this->getValue();
if ($v < self::HOURS) {
return $d/($this->c5/$this->{'c'.$v});
} else {
return $this->x($d, $this->{'c'.$v}/$this->c5, PHP_INT_MAX/($this->{'c'.$v}/$this->c5));
}
} | [
"public",
"function",
"toHours",
"(",
"$",
"d",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"$",
"v",
"<",
"self",
"::",
"HOURS",
")",
"{",
"return",
"$",
"d",
"/",
"(",
"$",
"this",
"->",
"c5",
"/",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"x",
"(",
"$",
"d",
",",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c5",
",",
"PHP_INT_MAX",
"/",
"(",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
"/",
"$",
"this",
"->",
"c5",
")",
")",
";",
"}",
"}"
]
| Convert to hours
@param int $d
@return float|int | [
"Convert",
"to",
"hours"
]
| 771b55b3ef79d9a7443c4f6d95373f41b9f34c4a | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/TimeUnit.php#L128-L136 |
19,677 | prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/TimeUnit.php | TimeUnit.toDays | public function toDays($d)
{
$v = $this->getValue();
return $d/($this->c6/$this->{'c'.$v});
} | php | public function toDays($d)
{
$v = $this->getValue();
return $d/($this->c6/$this->{'c'.$v});
} | [
"public",
"function",
"toDays",
"(",
"$",
"d",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"return",
"$",
"d",
"/",
"(",
"$",
"this",
"->",
"c6",
"/",
"$",
"this",
"->",
"{",
"'c'",
".",
"$",
"v",
"}",
")",
";",
"}"
]
| Convert to days
@param int $d
@return float | [
"Convert",
"to",
"days"
]
| 771b55b3ef79d9a7443c4f6d95373f41b9f34c4a | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/TimeUnit.php#L144-L148 |
19,678 | prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/TimeUnit.php | TimeUnit.convert | public function convert($sourceDuration, TimeUnit $sourceUnit)
{
switch ($this->getValue()) {
case self::NANOSECONDS:
return $sourceUnit->toNanos($sourceDuration);
case self::MICROSECONDS:
return $sourceUnit->toMicros($sourceDuration);
case self::MILLISECONDS:
return $sourceUnit->toMillis($sourceDuration);
case self::SECONDS:
return $sourceUnit->toSeconds($sourceDuration);
case self::MINUTES;
return $sourceUnit->toMinutes($sourceDuration);
case self::HOURS;
return $sourceUnit->toHours($sourceDuration);
case self::DAYS:
return $sourceUnit->toDays($sourceDuration);
}
} | php | public function convert($sourceDuration, TimeUnit $sourceUnit)
{
switch ($this->getValue()) {
case self::NANOSECONDS:
return $sourceUnit->toNanos($sourceDuration);
case self::MICROSECONDS:
return $sourceUnit->toMicros($sourceDuration);
case self::MILLISECONDS:
return $sourceUnit->toMillis($sourceDuration);
case self::SECONDS:
return $sourceUnit->toSeconds($sourceDuration);
case self::MINUTES;
return $sourceUnit->toMinutes($sourceDuration);
case self::HOURS;
return $sourceUnit->toHours($sourceDuration);
case self::DAYS:
return $sourceUnit->toDays($sourceDuration);
}
} | [
"public",
"function",
"convert",
"(",
"$",
"sourceDuration",
",",
"TimeUnit",
"$",
"sourceUnit",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"getValue",
"(",
")",
")",
"{",
"case",
"self",
"::",
"NANOSECONDS",
":",
"return",
"$",
"sourceUnit",
"->",
"toNanos",
"(",
"$",
"sourceDuration",
")",
";",
"case",
"self",
"::",
"MICROSECONDS",
":",
"return",
"$",
"sourceUnit",
"->",
"toMicros",
"(",
"$",
"sourceDuration",
")",
";",
"case",
"self",
"::",
"MILLISECONDS",
":",
"return",
"$",
"sourceUnit",
"->",
"toMillis",
"(",
"$",
"sourceDuration",
")",
";",
"case",
"self",
"::",
"SECONDS",
":",
"return",
"$",
"sourceUnit",
"->",
"toSeconds",
"(",
"$",
"sourceDuration",
")",
";",
"case",
"self",
"::",
"MINUTES",
";",
"return",
"$",
"sourceUnit",
"->",
"toMinutes",
"(",
"$",
"sourceDuration",
")",
";",
"case",
"self",
"::",
"HOURS",
";",
"return",
"$",
"sourceUnit",
"->",
"toHours",
"(",
"$",
"sourceDuration",
")",
";",
"case",
"self",
"::",
"DAYS",
":",
"return",
"$",
"sourceUnit",
"->",
"toDays",
"(",
"$",
"sourceDuration",
")",
";",
"}",
"}"
]
| Convert the given time duration in the given unit to this
unit. Conversions from finer to coarser granularities
truncate, so lose precision. For example converting
999 milliseconds to seconds results in
0. Conversions from coarser to finer granularities
with arguments that would numerically overflow saturate to
"-PHP_INT_MAX -1" if negative or "PHP_INT_MAX"
if positive.
For example, to convert 10 minutes to milliseconds, use:
TimeUnit::MILLISECONDS()->convert(10, TimeUnit::MINUTES);
@param int $sourceDuration the time duration in the given source unit
@param TimeUnit $sourceUnit the unit of the source duration argument
@return float|int | [
"Convert",
"the",
"given",
"time",
"duration",
"in",
"the",
"given",
"unit",
"to",
"this",
"unit",
".",
"Conversions",
"from",
"finer",
"to",
"coarser",
"granularities",
"truncate",
"so",
"lose",
"precision",
".",
"For",
"example",
"converting",
"999",
"milliseconds",
"to",
"seconds",
"results",
"in",
"0",
".",
"Conversions",
"from",
"coarser",
"to",
"finer",
"granularities",
"with",
"arguments",
"that",
"would",
"numerically",
"overflow",
"saturate",
"to",
"-",
"PHP_INT_MAX",
"-",
"1",
"if",
"negative",
"or",
"PHP_INT_MAX",
"if",
"positive",
"."
]
| 771b55b3ef79d9a7443c4f6d95373f41b9f34c4a | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/TimeUnit.php#L167-L185 |
19,679 | prolic/Concurrent-PHP-Utils | src/ConcurrentPhpUtils/TimeUnit.php | TimeUnit.x | private function x($d, $m, $over)
{
if ($d > $over) {
return PHP_INT_MAX;
}
if ($d < -$over) {
return -PHP_INT_MAX -1;
}
return $d * $m;
} | php | private function x($d, $m, $over)
{
if ($d > $over) {
return PHP_INT_MAX;
}
if ($d < -$over) {
return -PHP_INT_MAX -1;
}
return $d * $m;
} | [
"private",
"function",
"x",
"(",
"$",
"d",
",",
"$",
"m",
",",
"$",
"over",
")",
"{",
"if",
"(",
"$",
"d",
">",
"$",
"over",
")",
"{",
"return",
"PHP_INT_MAX",
";",
"}",
"if",
"(",
"$",
"d",
"<",
"-",
"$",
"over",
")",
"{",
"return",
"-",
"PHP_INT_MAX",
"-",
"1",
";",
"}",
"return",
"$",
"d",
"*",
"$",
"m",
";",
"}"
]
| Scale d by m, checking for overflow.
This has a short name to make code more readable.
@param int $d
@param int $m
@param int $over
@return int | [
"Scale",
"d",
"by",
"m",
"checking",
"for",
"overflow",
".",
"This",
"has",
"a",
"short",
"name",
"to",
"make",
"code",
"more",
"readable",
"."
]
| 771b55b3ef79d9a7443c4f6d95373f41b9f34c4a | https://github.com/prolic/Concurrent-PHP-Utils/blob/771b55b3ef79d9a7443c4f6d95373f41b9f34c4a/src/ConcurrentPhpUtils/TimeUnit.php#L196-L205 |
19,680 | webtorque7/link-field | code/WTLink.php | WTLink.Link | public function Link()
{
$link = '';
switch ($this->type) {
case 'Internal' :
if ($this->internal && ($page = SiteTree::get()->byID($this->internal))) {
$link = $page->Link();
}
break;
case 'External' :
$link = $this->external;
break;
case 'Email' :
$link = $this->email ? 'mailto:' . $this->email : '';
break;
case 'File' :
if ($this->file) {
$link = File::get()->byID($this->file)->Filename;
}
break;
case 'DataObject':
if ($do = $this->getDO()) {
$link = $do->Link();
}
break;
}
if ($this->extra) {
//added a query string, but no ? to start it
if (strpos($this->extra, '=' !== false && strpos($this->extra, '?' === false))) {
$link .= '?';
}
$link .= $this->extra;
}
if ($this->anchor) {
$link .= '#' . $this->anchor;
}
return $link;
} | php | public function Link()
{
$link = '';
switch ($this->type) {
case 'Internal' :
if ($this->internal && ($page = SiteTree::get()->byID($this->internal))) {
$link = $page->Link();
}
break;
case 'External' :
$link = $this->external;
break;
case 'Email' :
$link = $this->email ? 'mailto:' . $this->email : '';
break;
case 'File' :
if ($this->file) {
$link = File::get()->byID($this->file)->Filename;
}
break;
case 'DataObject':
if ($do = $this->getDO()) {
$link = $do->Link();
}
break;
}
if ($this->extra) {
//added a query string, but no ? to start it
if (strpos($this->extra, '=' !== false && strpos($this->extra, '?' === false))) {
$link .= '?';
}
$link .= $this->extra;
}
if ($this->anchor) {
$link .= '#' . $this->anchor;
}
return $link;
} | [
"public",
"function",
"Link",
"(",
")",
"{",
"$",
"link",
"=",
"''",
";",
"switch",
"(",
"$",
"this",
"->",
"type",
")",
"{",
"case",
"'Internal'",
":",
"if",
"(",
"$",
"this",
"->",
"internal",
"&&",
"(",
"$",
"page",
"=",
"SiteTree",
"::",
"get",
"(",
")",
"->",
"byID",
"(",
"$",
"this",
"->",
"internal",
")",
")",
")",
"{",
"$",
"link",
"=",
"$",
"page",
"->",
"Link",
"(",
")",
";",
"}",
"break",
";",
"case",
"'External'",
":",
"$",
"link",
"=",
"$",
"this",
"->",
"external",
";",
"break",
";",
"case",
"'Email'",
":",
"$",
"link",
"=",
"$",
"this",
"->",
"email",
"?",
"'mailto:'",
".",
"$",
"this",
"->",
"email",
":",
"''",
";",
"break",
";",
"case",
"'File'",
":",
"if",
"(",
"$",
"this",
"->",
"file",
")",
"{",
"$",
"link",
"=",
"File",
"::",
"get",
"(",
")",
"->",
"byID",
"(",
"$",
"this",
"->",
"file",
")",
"->",
"Filename",
";",
"}",
"break",
";",
"case",
"'DataObject'",
":",
"if",
"(",
"$",
"do",
"=",
"$",
"this",
"->",
"getDO",
"(",
")",
")",
"{",
"$",
"link",
"=",
"$",
"do",
"->",
"Link",
"(",
")",
";",
"}",
"break",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"extra",
")",
"{",
"//added a query string, but no ? to start it",
"if",
"(",
"strpos",
"(",
"$",
"this",
"->",
"extra",
",",
"'='",
"!==",
"false",
"&&",
"strpos",
"(",
"$",
"this",
"->",
"extra",
",",
"'?'",
"===",
"false",
")",
")",
")",
"{",
"$",
"link",
".=",
"'?'",
";",
"}",
"$",
"link",
".=",
"$",
"this",
"->",
"extra",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"anchor",
")",
"{",
"$",
"link",
".=",
"'#'",
".",
"$",
"this",
"->",
"anchor",
";",
"}",
"return",
"$",
"link",
";",
"}"
]
| Determines the link by the type and what is set
@return mixed|string | [
"Determines",
"the",
"link",
"by",
"the",
"type",
"and",
"what",
"is",
"set"
]
| b846644e1d35676419e71f3127cfc8f150aff081 | https://github.com/webtorque7/link-field/blob/b846644e1d35676419e71f3127cfc8f150aff081/code/WTLink.php#L389-L430 |
19,681 | webtorque7/link-field | code/WTLink.php | WTLink.getDO | public function getDO()
{
if (!empty($this->dataObject)) {
list($className, $ID) = explode('-', $this->dataObject);
return DataList::create($className)->byID($ID);
}
return null;
} | php | public function getDO()
{
if (!empty($this->dataObject)) {
list($className, $ID) = explode('-', $this->dataObject);
return DataList::create($className)->byID($ID);
}
return null;
} | [
"public",
"function",
"getDO",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"dataObject",
")",
")",
"{",
"list",
"(",
"$",
"className",
",",
"$",
"ID",
")",
"=",
"explode",
"(",
"'-'",
",",
"$",
"this",
"->",
"dataObject",
")",
";",
"return",
"DataList",
"::",
"create",
"(",
"$",
"className",
")",
"->",
"byID",
"(",
"$",
"ID",
")",
";",
"}",
"return",
"null",
";",
"}"
]
| Get the DataObject instance
@return DataObject|null | [
"Get",
"the",
"DataObject",
"instance"
]
| b846644e1d35676419e71f3127cfc8f150aff081 | https://github.com/webtorque7/link-field/blob/b846644e1d35676419e71f3127cfc8f150aff081/code/WTLink.php#L459-L468 |
19,682 | transfer-framework/ezplatform | src/Transfer/EzPlatform/Repository/Values/ContentObject.php | ContentObject.addParentLocation | public function addParentLocation($parentLocation)
{
$locationObject = $this->convertToLocationObject($parentLocation);
if (!isset($locationObject->data['parent_location_id']) || (int) $locationObject->data['parent_location_id'] < 1) {
throw new InvalidDataStructureException('Parent location id must be an integer of 2 or above.');
}
if (!isset($locationObject->data['content_id'])) {
if ($this->getProperty('id')) {
$locationObject->data['content_id'] = $this->getProperty('id');
}
}
$this->properties['parent_locations'][$locationObject->data['parent_location_id']] = $locationObject;
} | php | public function addParentLocation($parentLocation)
{
$locationObject = $this->convertToLocationObject($parentLocation);
if (!isset($locationObject->data['parent_location_id']) || (int) $locationObject->data['parent_location_id'] < 1) {
throw new InvalidDataStructureException('Parent location id must be an integer of 2 or above.');
}
if (!isset($locationObject->data['content_id'])) {
if ($this->getProperty('id')) {
$locationObject->data['content_id'] = $this->getProperty('id');
}
}
$this->properties['parent_locations'][$locationObject->data['parent_location_id']] = $locationObject;
} | [
"public",
"function",
"addParentLocation",
"(",
"$",
"parentLocation",
")",
"{",
"$",
"locationObject",
"=",
"$",
"this",
"->",
"convertToLocationObject",
"(",
"$",
"parentLocation",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"locationObject",
"->",
"data",
"[",
"'parent_location_id'",
"]",
")",
"||",
"(",
"int",
")",
"$",
"locationObject",
"->",
"data",
"[",
"'parent_location_id'",
"]",
"<",
"1",
")",
"{",
"throw",
"new",
"InvalidDataStructureException",
"(",
"'Parent location id must be an integer of 2 or above.'",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"locationObject",
"->",
"data",
"[",
"'content_id'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getProperty",
"(",
"'id'",
")",
")",
"{",
"$",
"locationObject",
"->",
"data",
"[",
"'content_id'",
"]",
"=",
"$",
"this",
"->",
"getProperty",
"(",
"'id'",
")",
";",
"}",
"}",
"$",
"this",
"->",
"properties",
"[",
"'parent_locations'",
"]",
"[",
"$",
"locationObject",
"->",
"data",
"[",
"'parent_location_id'",
"]",
"]",
"=",
"$",
"locationObject",
";",
"}"
]
| Convert parameters to LocationCreateStruct and stores it on the ContentObject.
@param Location|LocationObject|int $parentLocation
@throws InvalidDataStructureException | [
"Convert",
"parameters",
"to",
"LocationCreateStruct",
"and",
"stores",
"it",
"on",
"the",
"ContentObject",
"."
]
| 1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f | https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Values/ContentObject.php#L96-L111 |
19,683 | steeffeen/FancyManiaLinks | FML/CustomUI.php | CustomUI.renderStandalone | public function renderStandalone()
{
$domDocument = new \DOMDocument("1.0", "utf-8");
$domDocument->xmlStandalone = true;
$domElement = $this->render($domDocument);
$domDocument->appendChild($domElement);
return $domDocument;
} | php | public function renderStandalone()
{
$domDocument = new \DOMDocument("1.0", "utf-8");
$domDocument->xmlStandalone = true;
$domElement = $this->render($domDocument);
$domDocument->appendChild($domElement);
return $domDocument;
} | [
"public",
"function",
"renderStandalone",
"(",
")",
"{",
"$",
"domDocument",
"=",
"new",
"\\",
"DOMDocument",
"(",
"\"1.0\"",
",",
"\"utf-8\"",
")",
";",
"$",
"domDocument",
"->",
"xmlStandalone",
"=",
"true",
";",
"$",
"domElement",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"domDocument",
")",
";",
"$",
"domDocument",
"->",
"appendChild",
"(",
"$",
"domElement",
")",
";",
"return",
"$",
"domDocument",
";",
"}"
]
| Render the Custom UI standalone
@return \DOMDocument | [
"Render",
"the",
"Custom",
"UI",
"standalone"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/CustomUI.php#L263-L272 |
19,684 | steeffeen/FancyManiaLinks | FML/CustomUI.php | CustomUI.render | public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("custom_ui");
$settings = $this->getSettings();
foreach ($settings as $setting => $value) {
if ($value === null) {
continue;
}
$settingDomElement = $domDocument->createElement($setting);
$settingDomElement->setAttribute("visible", ($value ? 1 : 0));
$domElement->appendChild($settingDomElement);
}
return $domElement;
} | php | public function render(\DOMDocument $domDocument)
{
$domElement = $domDocument->createElement("custom_ui");
$settings = $this->getSettings();
foreach ($settings as $setting => $value) {
if ($value === null) {
continue;
}
$settingDomElement = $domDocument->createElement($setting);
$settingDomElement->setAttribute("visible", ($value ? 1 : 0));
$domElement->appendChild($settingDomElement);
}
return $domElement;
} | [
"public",
"function",
"render",
"(",
"\\",
"DOMDocument",
"$",
"domDocument",
")",
"{",
"$",
"domElement",
"=",
"$",
"domDocument",
"->",
"createElement",
"(",
"\"custom_ui\"",
")",
";",
"$",
"settings",
"=",
"$",
"this",
"->",
"getSettings",
"(",
")",
";",
"foreach",
"(",
"$",
"settings",
"as",
"$",
"setting",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"continue",
";",
"}",
"$",
"settingDomElement",
"=",
"$",
"domDocument",
"->",
"createElement",
"(",
"$",
"setting",
")",
";",
"$",
"settingDomElement",
"->",
"setAttribute",
"(",
"\"visible\"",
",",
"(",
"$",
"value",
"?",
"1",
":",
"0",
")",
")",
";",
"$",
"domElement",
"->",
"appendChild",
"(",
"$",
"settingDomElement",
")",
";",
"}",
"return",
"$",
"domElement",
";",
"}"
]
| Render the Custom UI
@param \DOMDocument $domDocument DOMDocument for which the Custom UI should be rendered
@return \DOMElement | [
"Render",
"the",
"Custom",
"UI"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/CustomUI.php#L280-L296 |
19,685 | steeffeen/FancyManiaLinks | FML/CustomUI.php | CustomUI.getSettings | protected function getSettings()
{
return array(
"global" => $this->globalVisible,
"challenge_info" => $this->challengeInfoVisible,
"chat" => $this->chatVisible,
"checkpoint_list" => $this->checkpointListVisible,
"net_infos" => $this->netInfosVisible,
"notice" => $this->noticeVisible,
"round_scores" => $this->roundScoresVisible,
"scoretable" => $this->scoretableVisible
);
} | php | protected function getSettings()
{
return array(
"global" => $this->globalVisible,
"challenge_info" => $this->challengeInfoVisible,
"chat" => $this->chatVisible,
"checkpoint_list" => $this->checkpointListVisible,
"net_infos" => $this->netInfosVisible,
"notice" => $this->noticeVisible,
"round_scores" => $this->roundScoresVisible,
"scoretable" => $this->scoretableVisible
);
} | [
"protected",
"function",
"getSettings",
"(",
")",
"{",
"return",
"array",
"(",
"\"global\"",
"=>",
"$",
"this",
"->",
"globalVisible",
",",
"\"challenge_info\"",
"=>",
"$",
"this",
"->",
"challengeInfoVisible",
",",
"\"chat\"",
"=>",
"$",
"this",
"->",
"chatVisible",
",",
"\"checkpoint_list\"",
"=>",
"$",
"this",
"->",
"checkpointListVisible",
",",
"\"net_infos\"",
"=>",
"$",
"this",
"->",
"netInfosVisible",
",",
"\"notice\"",
"=>",
"$",
"this",
"->",
"noticeVisible",
",",
"\"round_scores\"",
"=>",
"$",
"this",
"->",
"roundScoresVisible",
",",
"\"scoretable\"",
"=>",
"$",
"this",
"->",
"scoretableVisible",
")",
";",
"}"
]
| Get associative array of all Custom UI settings
@return array | [
"Get",
"associative",
"array",
"of",
"all",
"Custom",
"UI",
"settings"
]
| 227b0759306f0a3c75873ba50276e4163a93bfa6 | https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/CustomUI.php#L314-L326 |
19,686 | accgit/single-web | src/Single/Latte.php | Latte.createLatteEngine | private function createLatteEngine()
{
$latte = new LatteEngine\Engine;
$latte->setTempDirectory($this->temp);
// Form macro.
$latte->onCompile[] = function($latte) {
Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
};
return $latte;
} | php | private function createLatteEngine()
{
$latte = new LatteEngine\Engine;
$latte->setTempDirectory($this->temp);
// Form macro.
$latte->onCompile[] = function($latte) {
Bridges\FormsLatte\FormMacros::install($latte->getCompiler());
};
return $latte;
} | [
"private",
"function",
"createLatteEngine",
"(",
")",
"{",
"$",
"latte",
"=",
"new",
"LatteEngine",
"\\",
"Engine",
";",
"$",
"latte",
"->",
"setTempDirectory",
"(",
"$",
"this",
"->",
"temp",
")",
";",
"// Form macro.\r",
"$",
"latte",
"->",
"onCompile",
"[",
"]",
"=",
"function",
"(",
"$",
"latte",
")",
"{",
"Bridges",
"\\",
"FormsLatte",
"\\",
"FormMacros",
"::",
"install",
"(",
"$",
"latte",
"->",
"getCompiler",
"(",
")",
")",
";",
"}",
";",
"return",
"$",
"latte",
";",
"}"
]
| Latte engine settings.
@return LatteEngine\Engine | [
"Latte",
"engine",
"settings",
"."
]
| 5d0dce3313df9e22ab60749bcf01f1753de8c143 | https://github.com/accgit/single-web/blob/5d0dce3313df9e22ab60749bcf01f1753de8c143/src/Single/Latte.php#L41-L51 |
19,687 | accgit/single-web | src/Single/Latte.php | Latte.getBasePath | private function getBasePath()
{
$pathInfo = new Http\RequestFactory;
$basePath = rtrim($pathInfo->createHttpRequest()->url->basePath, '/');
return $basePath;
} | php | private function getBasePath()
{
$pathInfo = new Http\RequestFactory;
$basePath = rtrim($pathInfo->createHttpRequest()->url->basePath, '/');
return $basePath;
} | [
"private",
"function",
"getBasePath",
"(",
")",
"{",
"$",
"pathInfo",
"=",
"new",
"Http",
"\\",
"RequestFactory",
";",
"$",
"basePath",
"=",
"rtrim",
"(",
"$",
"pathInfo",
"->",
"createHttpRequest",
"(",
")",
"->",
"url",
"->",
"basePath",
",",
"'/'",
")",
";",
"return",
"$",
"basePath",
";",
"}"
]
| Path to root.
@return string | [
"Path",
"to",
"root",
"."
]
| 5d0dce3313df9e22ab60749bcf01f1753de8c143 | https://github.com/accgit/single-web/blob/5d0dce3313df9e22ab60749bcf01f1753de8c143/src/Single/Latte.php#L57-L62 |
19,688 | accgit/single-web | src/Single/Latte.php | Latte.render | public function render($name, array $params = [])
{
$latte = $this->createLatteEngine();
$basePath = ['basePath' => $this->getBasePath()] ;
$latte->render($name, $params + $basePath);
return $latte;
} | php | public function render($name, array $params = [])
{
$latte = $this->createLatteEngine();
$basePath = ['basePath' => $this->getBasePath()] ;
$latte->render($name, $params + $basePath);
return $latte;
} | [
"public",
"function",
"render",
"(",
"$",
"name",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"latte",
"=",
"$",
"this",
"->",
"createLatteEngine",
"(",
")",
";",
"$",
"basePath",
"=",
"[",
"'basePath'",
"=>",
"$",
"this",
"->",
"getBasePath",
"(",
")",
"]",
";",
"$",
"latte",
"->",
"render",
"(",
"$",
"name",
",",
"$",
"params",
"+",
"$",
"basePath",
")",
";",
"return",
"$",
"latte",
";",
"}"
]
| Create a template and insert parameters.
@param string $name
@return self | [
"Create",
"a",
"template",
"and",
"insert",
"parameters",
"."
]
| 5d0dce3313df9e22ab60749bcf01f1753de8c143 | https://github.com/accgit/single-web/blob/5d0dce3313df9e22ab60749bcf01f1753de8c143/src/Single/Latte.php#L69-L75 |
19,689 | titon/db | src/Titon/Db/Query.php | Query.bindCallback | public function bindCallback($callback, $argument = null) {
if ($callback instanceof Closure) {
call_user_func_array($callback, [$this, $argument]);
}
return $this;
} | php | public function bindCallback($callback, $argument = null) {
if ($callback instanceof Closure) {
call_user_func_array($callback, [$this, $argument]);
}
return $this;
} | [
"public",
"function",
"bindCallback",
"(",
"$",
"callback",
",",
"$",
"argument",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"callback",
"instanceof",
"Closure",
")",
"{",
"call_user_func_array",
"(",
"$",
"callback",
",",
"[",
"$",
"this",
",",
"$",
"argument",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Bind a Closure callback to this query and execute it.
@param \Closure $callback
@param mixed $argument
@return $this | [
"Bind",
"a",
"Closure",
"callback",
"to",
"this",
"query",
"and",
"execute",
"it",
"."
]
| fbc5159d1ce9d2139759c9367565986981485604 | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L251-L257 |
19,690 | titon/db | src/Titon/Db/Query.php | Query.cache | public function cache($key, $expires = null) {
if ($this->getType() !== self::SELECT) {
return $this;
}
$this->_cacheKey = $key;
$this->_cacheLength = $expires;
return $this;
} | php | public function cache($key, $expires = null) {
if ($this->getType() !== self::SELECT) {
return $this;
}
$this->_cacheKey = $key;
$this->_cacheLength = $expires;
return $this;
} | [
"public",
"function",
"cache",
"(",
"$",
"key",
",",
"$",
"expires",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
"!==",
"self",
"::",
"SELECT",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"_cacheKey",
"=",
"$",
"key",
";",
"$",
"this",
"->",
"_cacheLength",
"=",
"$",
"expires",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the cache key and duration length.
@param mixed $key
@param mixed $expires
@return $this | [
"Set",
"the",
"cache",
"key",
"and",
"duration",
"length",
"."
]
| fbc5159d1ce9d2139759c9367565986981485604 | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L266-L275 |
19,691 | titon/db | src/Titon/Db/Query.php | Query.count | public function count() {
$repo = $this->getRepository();
return $repo->aggregate($this->limit(0), __FUNCTION__, $repo->getPrimaryKey());
} | php | public function count() {
$repo = $this->getRepository();
return $repo->aggregate($this->limit(0), __FUNCTION__, $repo->getPrimaryKey());
} | [
"public",
"function",
"count",
"(",
")",
"{",
"$",
"repo",
"=",
"$",
"this",
"->",
"getRepository",
"(",
")",
";",
"return",
"$",
"repo",
"->",
"aggregate",
"(",
"$",
"this",
"->",
"limit",
"(",
"0",
")",
",",
"__FUNCTION__",
",",
"$",
"repo",
"->",
"getPrimaryKey",
"(",
")",
")",
";",
"}"
]
| Pass the query to the repository to interact with the database.
Return the count of how many records exist.
@return int | [
"Pass",
"the",
"query",
"to",
"the",
"repository",
"to",
"interact",
"with",
"the",
"database",
".",
"Return",
"the",
"count",
"of",
"how",
"many",
"records",
"exist",
"."
]
| fbc5159d1ce9d2139759c9367565986981485604 | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L283-L287 |
19,692 | titon/db | src/Titon/Db/Query.php | Query.data | public function data($data) {
if ($data instanceof Arrayable) {
$data = $data->toArray();
} else if (!is_array($data)) {
throw new InvalidArgumentException('Data passed must be an array or extend the Titon\Type\Contract\Arrayable interface');
}
$type = $this->getType();
// Only set binds for queries with dynamic data
if (in_array($type, [self::INSERT, self::UPDATE, self::MULTI_INSERT], true)) {
$binds = [];
$rows = $data;
if ($type !== self::MULTI_INSERT) {
$rows = [$rows];
}
foreach ($rows as $row) {
foreach ($row as $field => $value) {
$binds[] = [
'field' => $field,
'value' => $value
];
}
}
$this->setBindings($binds);
}
$this->_data = $data;
return $this;
} | php | public function data($data) {
if ($data instanceof Arrayable) {
$data = $data->toArray();
} else if (!is_array($data)) {
throw new InvalidArgumentException('Data passed must be an array or extend the Titon\Type\Contract\Arrayable interface');
}
$type = $this->getType();
// Only set binds for queries with dynamic data
if (in_array($type, [self::INSERT, self::UPDATE, self::MULTI_INSERT], true)) {
$binds = [];
$rows = $data;
if ($type !== self::MULTI_INSERT) {
$rows = [$rows];
}
foreach ($rows as $row) {
foreach ($row as $field => $value) {
$binds[] = [
'field' => $field,
'value' => $value
];
}
}
$this->setBindings($binds);
}
$this->_data = $data;
return $this;
} | [
"public",
"function",
"data",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"data",
"instanceof",
"Arrayable",
")",
"{",
"$",
"data",
"=",
"$",
"data",
"->",
"toArray",
"(",
")",
";",
"}",
"else",
"if",
"(",
"!",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Data passed must be an array or extend the Titon\\Type\\Contract\\Arrayable interface'",
")",
";",
"}",
"$",
"type",
"=",
"$",
"this",
"->",
"getType",
"(",
")",
";",
"// Only set binds for queries with dynamic data",
"if",
"(",
"in_array",
"(",
"$",
"type",
",",
"[",
"self",
"::",
"INSERT",
",",
"self",
"::",
"UPDATE",
",",
"self",
"::",
"MULTI_INSERT",
"]",
",",
"true",
")",
")",
"{",
"$",
"binds",
"=",
"[",
"]",
";",
"$",
"rows",
"=",
"$",
"data",
";",
"if",
"(",
"$",
"type",
"!==",
"self",
"::",
"MULTI_INSERT",
")",
"{",
"$",
"rows",
"=",
"[",
"$",
"rows",
"]",
";",
"}",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"row",
")",
"{",
"foreach",
"(",
"$",
"row",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"$",
"binds",
"[",
"]",
"=",
"[",
"'field'",
"=>",
"$",
"field",
",",
"'value'",
"=>",
"$",
"value",
"]",
";",
"}",
"}",
"$",
"this",
"->",
"setBindings",
"(",
"$",
"binds",
")",
";",
"}",
"$",
"this",
"->",
"_data",
"=",
"$",
"data",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the data to use in an update, insert, or create index statement.
We should also extract data to later bind during a prepared statement.
@param array|\Titon\Type\Contract\Arrayable $data
@return $this
@throws \Titon\Db\Exception\InvalidArgumentException | [
"Set",
"the",
"data",
"to",
"use",
"in",
"an",
"update",
"insert",
"or",
"create",
"index",
"statement",
".",
"We",
"should",
"also",
"extract",
"data",
"to",
"later",
"bind",
"during",
"a",
"prepared",
"statement",
"."
]
| fbc5159d1ce9d2139759c9367565986981485604 | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L297-L331 |
19,693 | titon/db | src/Titon/Db/Query.php | Query.except | public function except(Query $query, $flag = null) {
if ($flag === Dialect::ALL) {
$query->attribute('flag', $flag);
}
return $this->_addCompound(Dialect::EXCEPT, $query);
} | php | public function except(Query $query, $flag = null) {
if ($flag === Dialect::ALL) {
$query->attribute('flag', $flag);
}
return $this->_addCompound(Dialect::EXCEPT, $query);
} | [
"public",
"function",
"except",
"(",
"Query",
"$",
"query",
",",
"$",
"flag",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"flag",
"===",
"Dialect",
"::",
"ALL",
")",
"{",
"$",
"query",
"->",
"attribute",
"(",
"'flag'",
",",
"$",
"flag",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_addCompound",
"(",
"Dialect",
"::",
"EXCEPT",
",",
"$",
"query",
")",
";",
"}"
]
| Add a select query as an except.
@param \Titon\Db\Query $query
@param string $flag
@return $this | [
"Add",
"a",
"select",
"query",
"as",
"an",
"except",
"."
]
| fbc5159d1ce9d2139759c9367565986981485604 | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L349-L355 |
19,694 | titon/db | src/Titon/Db/Query.php | Query.getAlias | public function getAlias() {
if ($this->getJoins() || $this instanceof SubQuery || in_array($this->getType(), [self::CREATE_INDEX, self::DROP_INDEX])) {
return $this->_alias;
}
return null;
} | php | public function getAlias() {
if ($this->getJoins() || $this instanceof SubQuery || in_array($this->getType(), [self::CREATE_INDEX, self::DROP_INDEX])) {
return $this->_alias;
}
return null;
} | [
"public",
"function",
"getAlias",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getJoins",
"(",
")",
"||",
"$",
"this",
"instanceof",
"SubQuery",
"||",
"in_array",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
",",
"[",
"self",
"::",
"CREATE_INDEX",
",",
"self",
"::",
"DROP_INDEX",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_alias",
";",
"}",
"return",
"null",
";",
"}"
]
| Only return the alias if joins have been set or this is a sub-query.
@return string | [
"Only",
"return",
"the",
"alias",
"if",
"joins",
"have",
"been",
"set",
"or",
"this",
"is",
"a",
"sub",
"-",
"query",
"."
]
| fbc5159d1ce9d2139759c9367565986981485604 | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L424-L430 |
19,695 | titon/db | src/Titon/Db/Query.php | Query.getFields | public function getFields() {
$fields = $this->_fields;
if ($this->getJoins() && !$fields && $this->getType() === self::SELECT) {
return array_keys($this->getRepository()->getSchema()->getColumns());
}
return $fields;
} | php | public function getFields() {
$fields = $this->_fields;
if ($this->getJoins() && !$fields && $this->getType() === self::SELECT) {
return array_keys($this->getRepository()->getSchema()->getColumns());
}
return $fields;
} | [
"public",
"function",
"getFields",
"(",
")",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"_fields",
";",
"if",
"(",
"$",
"this",
"->",
"getJoins",
"(",
")",
"&&",
"!",
"$",
"fields",
"&&",
"$",
"this",
"->",
"getType",
"(",
")",
"===",
"self",
"::",
"SELECT",
")",
"{",
"return",
"array_keys",
"(",
"$",
"this",
"->",
"getRepository",
"(",
")",
"->",
"getSchema",
"(",
")",
"->",
"getColumns",
"(",
")",
")",
";",
"}",
"return",
"$",
"fields",
";",
"}"
]
| Return the list of fields and or values.
Return all table fields if a join exists and no fields were whitelisted.
@return string[] | [
"Return",
"the",
"list",
"of",
"fields",
"and",
"or",
"values",
".",
"Return",
"all",
"table",
"fields",
"if",
"a",
"join",
"exists",
"and",
"no",
"fields",
"were",
"whitelisted",
"."
]
| fbc5159d1ce9d2139759c9367565986981485604 | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L483-L491 |
19,696 | titon/db | src/Titon/Db/Query.php | Query.groupBy | public function groupBy() {
$fields = func_get_args();
if (is_array($fields[0])) {
$fields = $fields[0];
}
$this->_groupBy = array_unique(array_merge($this->_groupBy, $fields));
return $this;
} | php | public function groupBy() {
$fields = func_get_args();
if (is_array($fields[0])) {
$fields = $fields[0];
}
$this->_groupBy = array_unique(array_merge($this->_groupBy, $fields));
return $this;
} | [
"public",
"function",
"groupBy",
"(",
")",
"{",
"$",
"fields",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"fields",
"[",
"0",
"]",
")",
")",
"{",
"$",
"fields",
"=",
"$",
"fields",
"[",
"0",
"]",
";",
"}",
"$",
"this",
"->",
"_groupBy",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"_groupBy",
",",
"$",
"fields",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set what fields to group on.
@return $this | [
"Set",
"what",
"fields",
"to",
"group",
"on",
"."
]
| fbc5159d1ce9d2139759c9367565986981485604 | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L601-L611 |
19,697 | titon/db | src/Titon/Db/Query.php | Query.having | public function having($field, $op = null, $value = null) {
return $this->_modifyPredicate($this->_having, Predicate::ALSO, $field, $op, $value);
} | php | public function having($field, $op = null, $value = null) {
return $this->_modifyPredicate($this->_having, Predicate::ALSO, $field, $op, $value);
} | [
"public",
"function",
"having",
"(",
"$",
"field",
",",
"$",
"op",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"_modifyPredicate",
"(",
"$",
"this",
"->",
"_having",
",",
"Predicate",
"::",
"ALSO",
",",
"$",
"field",
",",
"$",
"op",
",",
"$",
"value",
")",
";",
"}"
]
| Will modify or create a having predicate using the AND conjunction.
@param string $field
@param string $op
@param mixed $value
@return $this | [
"Will",
"modify",
"or",
"create",
"a",
"having",
"predicate",
"using",
"the",
"AND",
"conjunction",
"."
]
| fbc5159d1ce9d2139759c9367565986981485604 | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L621-L623 |
19,698 | titon/db | src/Titon/Db/Query.php | Query.innerJoin | public function innerJoin($table, array $fields = [], array $on = []) {
return $this->_addJoin(Join::INNER, $table, $fields, $on);
} | php | public function innerJoin($table, array $fields = [], array $on = []) {
return $this->_addJoin(Join::INNER, $table, $fields, $on);
} | [
"public",
"function",
"innerJoin",
"(",
"$",
"table",
",",
"array",
"$",
"fields",
"=",
"[",
"]",
",",
"array",
"$",
"on",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_addJoin",
"(",
"Join",
"::",
"INNER",
",",
"$",
"table",
",",
"$",
"fields",
",",
"$",
"on",
")",
";",
"}"
]
| Add a new INNER join.
@param string|array $table
@param array $fields
@param array $on
@return $this | [
"Add",
"a",
"new",
"INNER",
"join",
"."
]
| fbc5159d1ce9d2139759c9367565986981485604 | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L633-L635 |
19,699 | titon/db | src/Titon/Db/Query.php | Query.intersect | public function intersect(Query $query, $flag = null) {
if ($flag === Dialect::ALL) {
$query->attribute('flag', $flag);
}
return $this->_addCompound(Dialect::INTERSECT, $query);
} | php | public function intersect(Query $query, $flag = null) {
if ($flag === Dialect::ALL) {
$query->attribute('flag', $flag);
}
return $this->_addCompound(Dialect::INTERSECT, $query);
} | [
"public",
"function",
"intersect",
"(",
"Query",
"$",
"query",
",",
"$",
"flag",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"flag",
"===",
"Dialect",
"::",
"ALL",
")",
"{",
"$",
"query",
"->",
"attribute",
"(",
"'flag'",
",",
"$",
"flag",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_addCompound",
"(",
"Dialect",
"::",
"INTERSECT",
",",
"$",
"query",
")",
";",
"}"
]
| Add a select query as an intersect.
@param \Titon\Db\Query $query
@param string $flag
@return $this | [
"Add",
"a",
"select",
"query",
"as",
"an",
"intersect",
"."
]
| fbc5159d1ce9d2139759c9367565986981485604 | https://github.com/titon/db/blob/fbc5159d1ce9d2139759c9367565986981485604/src/Titon/Db/Query.php#L644-L650 |
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.