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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
24,400
|
Xety/Breadcrumbs
|
src/BreadcrumbsTrait.php
|
BreadcrumbsTrait.setListElement
|
public function setListElement(string $element): Breadcrumbs
{
$this->validateElement('allowedListElement', $element);
$this->setOption('listElement', $element);
return $this;
}
|
php
|
public function setListElement(string $element): Breadcrumbs
{
$this->validateElement('allowedListElement', $element);
$this->setOption('listElement', $element);
return $this;
}
|
[
"public",
"function",
"setListElement",
"(",
"string",
"$",
"element",
")",
":",
"Breadcrumbs",
"{",
"$",
"this",
"->",
"validateElement",
"(",
"'allowedListElement'",
",",
"$",
"element",
")",
";",
"$",
"this",
"->",
"setOption",
"(",
"'listElement'",
",",
"$",
"element",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the container list DOM Element.
@param string $element The Element to set.
@return \Xety\Breadcrumbs\Breadcrumbs
|
[
"Set",
"the",
"container",
"list",
"DOM",
"Element",
"."
] |
aded39bdbf4f6e857f0154a810339d71897a94b0
|
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L152-L159
|
24,401
|
Xety/Breadcrumbs
|
src/BreadcrumbsTrait.php
|
BreadcrumbsTrait.setListItemElement
|
public function setListItemElement(string $element): Breadcrumbs
{
$this->validateElement('allowedListItemElement', $element);
$this->setOption('listItemElement', $element);
return $this;
}
|
php
|
public function setListItemElement(string $element): Breadcrumbs
{
$this->validateElement('allowedListItemElement', $element);
$this->setOption('listItemElement', $element);
return $this;
}
|
[
"public",
"function",
"setListItemElement",
"(",
"string",
"$",
"element",
")",
":",
"Breadcrumbs",
"{",
"$",
"this",
"->",
"validateElement",
"(",
"'allowedListItemElement'",
",",
"$",
"element",
")",
";",
"$",
"this",
"->",
"setOption",
"(",
"'listItemElement'",
",",
"$",
"element",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the item DOM Element.
@param string $element The Element to set.
@return \Xety\Breadcrumbs\Breadcrumbs
|
[
"Set",
"the",
"item",
"DOM",
"Element",
"."
] |
aded39bdbf4f6e857f0154a810339d71897a94b0
|
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L224-L231
|
24,402
|
Xety/Breadcrumbs
|
src/BreadcrumbsTrait.php
|
BreadcrumbsTrait.setListActiveElement
|
public function setListActiveElement(string $element): Breadcrumbs
{
$this->validateElement('allowedListActiveElement', $element);
$this->setOption('listActiveElement', $element);
return $this;
}
|
php
|
public function setListActiveElement(string $element): Breadcrumbs
{
$this->validateElement('allowedListActiveElement', $element);
$this->setOption('listActiveElement', $element);
return $this;
}
|
[
"public",
"function",
"setListActiveElement",
"(",
"string",
"$",
"element",
")",
":",
"Breadcrumbs",
"{",
"$",
"this",
"->",
"validateElement",
"(",
"'allowedListActiveElement'",
",",
"$",
"element",
")",
";",
"$",
"this",
"->",
"setOption",
"(",
"'listActiveElement'",
",",
"$",
"element",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the active DOM Element.
@param string $element The Element to set.
@return \Xety\Breadcrumbs\Breadcrumbs
|
[
"Set",
"the",
"active",
"DOM",
"Element",
"."
] |
aded39bdbf4f6e857f0154a810339d71897a94b0
|
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L296-L303
|
24,403
|
Xety/Breadcrumbs
|
src/BreadcrumbsTrait.php
|
BreadcrumbsTrait.setElementClasses
|
protected function setElementClasses(string $option, $classes): Breadcrumbs
{
if (is_string($classes)) {
$classes = explode(' ', $classes);
}
$this->validateClasses($classes);
$this->setOption($option, array_unique($classes));
return $this;
}
|
php
|
protected function setElementClasses(string $option, $classes): Breadcrumbs
{
if (is_string($classes)) {
$classes = explode(' ', $classes);
}
$this->validateClasses($classes);
$this->setOption($option, array_unique($classes));
return $this;
}
|
[
"protected",
"function",
"setElementClasses",
"(",
"string",
"$",
"option",
",",
"$",
"classes",
")",
":",
"Breadcrumbs",
"{",
"if",
"(",
"is_string",
"(",
"$",
"classes",
")",
")",
"{",
"$",
"classes",
"=",
"explode",
"(",
"' '",
",",
"$",
"classes",
")",
";",
"}",
"$",
"this",
"->",
"validateClasses",
"(",
"$",
"classes",
")",
";",
"$",
"this",
"->",
"setOption",
"(",
"$",
"option",
",",
"array_unique",
"(",
"$",
"classes",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the classes to the given option type.
@param string $option The option from where we must set the classes.
@param string|array $classes The classes to set.
@return \Xety\Breadcrumbs\Breadcrumbs
|
[
"Set",
"the",
"classes",
"to",
"the",
"given",
"option",
"type",
"."
] |
aded39bdbf4f6e857f0154a810339d71897a94b0
|
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L369-L379
|
24,404
|
Xety/Breadcrumbs
|
src/BreadcrumbsTrait.php
|
BreadcrumbsTrait.addElementClasses
|
protected function addElementClasses(string $option, $classes): Breadcrumbs
{
if (is_string($classes)) {
$classes = explode(' ', $classes);
}
$this->validateClasses($classes);
$classes = array_merge(
$this->getOption($option),
$classes
);
$this->setOption($option, array_unique($classes));
return $this;
}
|
php
|
protected function addElementClasses(string $option, $classes): Breadcrumbs
{
if (is_string($classes)) {
$classes = explode(' ', $classes);
}
$this->validateClasses($classes);
$classes = array_merge(
$this->getOption($option),
$classes
);
$this->setOption($option, array_unique($classes));
return $this;
}
|
[
"protected",
"function",
"addElementClasses",
"(",
"string",
"$",
"option",
",",
"$",
"classes",
")",
":",
"Breadcrumbs",
"{",
"if",
"(",
"is_string",
"(",
"$",
"classes",
")",
")",
"{",
"$",
"classes",
"=",
"explode",
"(",
"' '",
",",
"$",
"classes",
")",
";",
"}",
"$",
"this",
"->",
"validateClasses",
"(",
"$",
"classes",
")",
";",
"$",
"classes",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"getOption",
"(",
"$",
"option",
")",
",",
"$",
"classes",
")",
";",
"$",
"this",
"->",
"setOption",
"(",
"$",
"option",
",",
"array_unique",
"(",
"$",
"classes",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add one or more CSS classes related to the option type.
@param string $option The option from where we must add the classes.
@param string|array $classes The classes to add.
@return \Xety\Breadcrumbs\Breadcrumbs
|
[
"Add",
"one",
"or",
"more",
"CSS",
"classes",
"related",
"to",
"the",
"option",
"type",
"."
] |
aded39bdbf4f6e857f0154a810339d71897a94b0
|
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L405-L419
|
24,405
|
Xety/Breadcrumbs
|
src/BreadcrumbsTrait.php
|
BreadcrumbsTrait.removeElementClasses
|
protected function removeElementClasses(string $option, $classes): Breadcrumbs
{
if (is_string($classes)) {
$classes = explode(' ', $classes);
}
$this->validateClasses($classes);
$classes = array_diff(
$this->getOption($option),
$classes
);
$this->setOption($option, array_unique($classes));
return $this;
}
|
php
|
protected function removeElementClasses(string $option, $classes): Breadcrumbs
{
if (is_string($classes)) {
$classes = explode(' ', $classes);
}
$this->validateClasses($classes);
$classes = array_diff(
$this->getOption($option),
$classes
);
$this->setOption($option, array_unique($classes));
return $this;
}
|
[
"protected",
"function",
"removeElementClasses",
"(",
"string",
"$",
"option",
",",
"$",
"classes",
")",
":",
"Breadcrumbs",
"{",
"if",
"(",
"is_string",
"(",
"$",
"classes",
")",
")",
"{",
"$",
"classes",
"=",
"explode",
"(",
"' '",
",",
"$",
"classes",
")",
";",
"}",
"$",
"this",
"->",
"validateClasses",
"(",
"$",
"classes",
")",
";",
"$",
"classes",
"=",
"array_diff",
"(",
"$",
"this",
"->",
"getOption",
"(",
"$",
"option",
")",
",",
"$",
"classes",
")",
";",
"$",
"this",
"->",
"setOption",
"(",
"$",
"option",
",",
"array_unique",
"(",
"$",
"classes",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Remove one or more CSS classes related to the option type.
@param string $option The option from where we must remove the classes.
@param string|array $classes The classes to remove.
@return \Xety\Breadcrumbs\Breadcrumbs
|
[
"Remove",
"one",
"or",
"more",
"CSS",
"classes",
"related",
"to",
"the",
"option",
"type",
"."
] |
aded39bdbf4f6e857f0154a810339d71897a94b0
|
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L429-L443
|
24,406
|
Xety/Breadcrumbs
|
src/BreadcrumbsTrait.php
|
BreadcrumbsTrait.validateElement
|
protected function validateElement(string $type, string $element)
{
if (!in_array($element, $this->{$type})) {
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['function'];
throw new InvalidArgumentException("Breadcrumbs::{$trace} was passed \"$element\", but " .
"this is not a valid element. Allowed list : " . implode(' ', $this->{$type}));
}
}
|
php
|
protected function validateElement(string $type, string $element)
{
if (!in_array($element, $this->{$type})) {
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2)[1]['function'];
throw new InvalidArgumentException("Breadcrumbs::{$trace} was passed \"$element\", but " .
"this is not a valid element. Allowed list : " . implode(' ', $this->{$type}));
}
}
|
[
"protected",
"function",
"validateElement",
"(",
"string",
"$",
"type",
",",
"string",
"$",
"element",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"element",
",",
"$",
"this",
"->",
"{",
"$",
"type",
"}",
")",
")",
"{",
"$",
"trace",
"=",
"debug_backtrace",
"(",
"DEBUG_BACKTRACE_IGNORE_ARGS",
",",
"2",
")",
"[",
"1",
"]",
"[",
"'function'",
"]",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Breadcrumbs::{$trace} was passed \\\"$element\\\", but \"",
".",
"\"this is not a valid element. Allowed list : \"",
".",
"implode",
"(",
"' '",
",",
"$",
"this",
"->",
"{",
"$",
"type",
"}",
")",
")",
";",
"}",
"}"
] |
Validate an Element before saving it.
@param string $type The type from where we must validate the Element.
@param string $element The Element to validate.
@throws \InvalidArgumentException When the validation fail.
@return void
|
[
"Validate",
"an",
"Element",
"before",
"saving",
"it",
"."
] |
aded39bdbf4f6e857f0154a810339d71897a94b0
|
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L455-L463
|
24,407
|
Xety/Breadcrumbs
|
src/BreadcrumbsTrait.php
|
BreadcrumbsTrait.validateClasses
|
protected function validateClasses($classes)
{
if (!is_array($classes)) {
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2]['function'];
throw new InvalidArgumentException("Breadcrumbs::{$trace}() only accepts strings or arrays.");
}
foreach ($classes as $key => $class) {
if (!is_string($class)) {
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2]['function'];
throw new InvalidArgumentException(
"Breadcrumbs::{$trace}() was passed an array, but at least one of the values " .
"was not a string: \$classes['{$key}'] = " . print_r($class, true)
);
}
}
}
|
php
|
protected function validateClasses($classes)
{
if (!is_array($classes)) {
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2]['function'];
throw new InvalidArgumentException("Breadcrumbs::{$trace}() only accepts strings or arrays.");
}
foreach ($classes as $key => $class) {
if (!is_string($class)) {
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2]['function'];
throw new InvalidArgumentException(
"Breadcrumbs::{$trace}() was passed an array, but at least one of the values " .
"was not a string: \$classes['{$key}'] = " . print_r($class, true)
);
}
}
}
|
[
"protected",
"function",
"validateClasses",
"(",
"$",
"classes",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"classes",
")",
")",
"{",
"$",
"trace",
"=",
"debug_backtrace",
"(",
"DEBUG_BACKTRACE_IGNORE_ARGS",
",",
"3",
")",
"[",
"2",
"]",
"[",
"'function'",
"]",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Breadcrumbs::{$trace}() only accepts strings or arrays.\"",
")",
";",
"}",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"key",
"=>",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"class",
")",
")",
"{",
"$",
"trace",
"=",
"debug_backtrace",
"(",
"DEBUG_BACKTRACE_IGNORE_ARGS",
",",
"3",
")",
"[",
"2",
"]",
"[",
"'function'",
"]",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Breadcrumbs::{$trace}() was passed an array, but at least one of the values \"",
".",
"\"was not a string: \\$classes['{$key}'] = \"",
".",
"print_r",
"(",
"$",
"class",
",",
"true",
")",
")",
";",
"}",
"}",
"}"
] |
Validate the classes to ensure they have the right format.
@param array $classes The classes to validate.
@throws \InvalidArgumentException When the classes is not an array or a string.
Or when the class name is not a string.
@return void
|
[
"Validate",
"the",
"classes",
"to",
"ensure",
"they",
"have",
"the",
"right",
"format",
"."
] |
aded39bdbf4f6e857f0154a810339d71897a94b0
|
https://github.com/Xety/Breadcrumbs/blob/aded39bdbf4f6e857f0154a810339d71897a94b0/src/BreadcrumbsTrait.php#L475-L493
|
24,408
|
i-lateral/silverstripe-users
|
code/forms/Users_EditAccountForm.php
|
Users_EditAccountForm.doUpdate
|
public function doUpdate($data)
{
$filter = array();
$member = Member::get()->byID($data["ID"]);
$this->extend("onBeforeUpdate", $data);
// Check that a member isn't trying to mess up another users profile
if (Member::currentUserID() && $member->canEdit(Member::currentUser())) {
try {
// Save member
$this->saveInto($member);
$member->write();
$this->sessionMessage(
_t("Users.DETAILSUPDATED", "Account details updated"),
"success"
);
} catch (Exception $e) {
$this->sessionMessage(
$e->getMessage(),
"warning"
);
}
} else {
$this->sessionMessage(
_t("Users.CANNOTEDIT", "You cannot edit this account"),
"warning"
);
}
$this->extend("onAfterUpdate", $data);
return $this->controller->redirectBack();
}
|
php
|
public function doUpdate($data)
{
$filter = array();
$member = Member::get()->byID($data["ID"]);
$this->extend("onBeforeUpdate", $data);
// Check that a member isn't trying to mess up another users profile
if (Member::currentUserID() && $member->canEdit(Member::currentUser())) {
try {
// Save member
$this->saveInto($member);
$member->write();
$this->sessionMessage(
_t("Users.DETAILSUPDATED", "Account details updated"),
"success"
);
} catch (Exception $e) {
$this->sessionMessage(
$e->getMessage(),
"warning"
);
}
} else {
$this->sessionMessage(
_t("Users.CANNOTEDIT", "You cannot edit this account"),
"warning"
);
}
$this->extend("onAfterUpdate", $data);
return $this->controller->redirectBack();
}
|
[
"public",
"function",
"doUpdate",
"(",
"$",
"data",
")",
"{",
"$",
"filter",
"=",
"array",
"(",
")",
";",
"$",
"member",
"=",
"Member",
"::",
"get",
"(",
")",
"->",
"byID",
"(",
"$",
"data",
"[",
"\"ID\"",
"]",
")",
";",
"$",
"this",
"->",
"extend",
"(",
"\"onBeforeUpdate\"",
",",
"$",
"data",
")",
";",
"// Check that a member isn't trying to mess up another users profile",
"if",
"(",
"Member",
"::",
"currentUserID",
"(",
")",
"&&",
"$",
"member",
"->",
"canEdit",
"(",
"Member",
"::",
"currentUser",
"(",
")",
")",
")",
"{",
"try",
"{",
"// Save member",
"$",
"this",
"->",
"saveInto",
"(",
"$",
"member",
")",
";",
"$",
"member",
"->",
"write",
"(",
")",
";",
"$",
"this",
"->",
"sessionMessage",
"(",
"_t",
"(",
"\"Users.DETAILSUPDATED\"",
",",
"\"Account details updated\"",
")",
",",
"\"success\"",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"sessionMessage",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"\"warning\"",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"sessionMessage",
"(",
"_t",
"(",
"\"Users.CANNOTEDIT\"",
",",
"\"You cannot edit this account\"",
")",
",",
"\"warning\"",
")",
";",
"}",
"$",
"this",
"->",
"extend",
"(",
"\"onAfterUpdate\"",
",",
"$",
"data",
")",
";",
"return",
"$",
"this",
"->",
"controller",
"->",
"redirectBack",
"(",
")",
";",
"}"
] |
Register a new member
@param array $data User submitted data
@return SS_HTTPResponse
|
[
"Register",
"a",
"new",
"member"
] |
27ddc38890fa2709ac419eccf854ab6b439f0d9a
|
https://github.com/i-lateral/silverstripe-users/blob/27ddc38890fa2709ac419eccf854ab6b439f0d9a/code/forms/Users_EditAccountForm.php#L107-L141
|
24,409
|
titledk/silverstripe-uploaddirrules
|
code/rules/SubsiteUploadDirRules.php
|
SubsiteUploadDirRules.get_directory_for_current_subsite
|
public static function get_directory_for_current_subsite()
{
$subsite = Subsite::currentSubsite();
if ($subsite) {
if ((int) $subsite->AssetsFolderID > 0) {
$dirObj = $subsite->AssetsFolder();
$dirName = str_replace('assets/', '', $dirObj->Filename);
//make sure we've got no trailing slashes
$dirName = str_replace('/', '', $dirName);
return $dirName;
}
} else {
return false;
}
}
|
php
|
public static function get_directory_for_current_subsite()
{
$subsite = Subsite::currentSubsite();
if ($subsite) {
if ((int) $subsite->AssetsFolderID > 0) {
$dirObj = $subsite->AssetsFolder();
$dirName = str_replace('assets/', '', $dirObj->Filename);
//make sure we've got no trailing slashes
$dirName = str_replace('/', '', $dirName);
return $dirName;
}
} else {
return false;
}
}
|
[
"public",
"static",
"function",
"get_directory_for_current_subsite",
"(",
")",
"{",
"$",
"subsite",
"=",
"Subsite",
"::",
"currentSubsite",
"(",
")",
";",
"if",
"(",
"$",
"subsite",
")",
"{",
"if",
"(",
"(",
"int",
")",
"$",
"subsite",
"->",
"AssetsFolderID",
">",
"0",
")",
"{",
"$",
"dirObj",
"=",
"$",
"subsite",
"->",
"AssetsFolder",
"(",
")",
";",
"$",
"dirName",
"=",
"str_replace",
"(",
"'assets/'",
",",
"''",
",",
"$",
"dirObj",
"->",
"Filename",
")",
";",
"//make sure we've got no trailing slashes",
"$",
"dirName",
"=",
"str_replace",
"(",
"'/'",
",",
"''",
",",
"$",
"dirName",
")",
";",
"return",
"$",
"dirName",
";",
"}",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Getting subsite directory based on it's assets folder.
@return bool|mixed
|
[
"Getting",
"subsite",
"directory",
"based",
"on",
"it",
"s",
"assets",
"folder",
"."
] |
ed8ece7b6a4ca86dcb5dc16ee10ff339f629de3c
|
https://github.com/titledk/silverstripe-uploaddirrules/blob/ed8ece7b6a4ca86dcb5dc16ee10ff339f629de3c/code/rules/SubsiteUploadDirRules.php#L34-L51
|
24,410
|
titledk/silverstripe-uploaddirrules
|
code/rules/SubsiteUploadDirRules.php
|
SubsiteUploadDirRules.calc_full_directory_for_object
|
public static function calc_full_directory_for_object(DataObject $do)
{
if ($do->ClassName == 'Subsite') {
//This is the subsite creation
//we only want the subsite part
return self::calc_directory_for_subsite($do);
} else {
//If we're dealing with a path inside of a subsites,
//we need at least be sure that the subsite is having an asset directory
//NOTE: this only works when on the actual subsite
$subsite_dir = self::get_directory_for_current_subsite();
if ($subsite_dir) {
$str = parent::calc_full_directory_for_object($do);
$str = "$subsite_dir/$str";
return $str;
} else {
return false;
}
}
}
|
php
|
public static function calc_full_directory_for_object(DataObject $do)
{
if ($do->ClassName == 'Subsite') {
//This is the subsite creation
//we only want the subsite part
return self::calc_directory_for_subsite($do);
} else {
//If we're dealing with a path inside of a subsites,
//we need at least be sure that the subsite is having an asset directory
//NOTE: this only works when on the actual subsite
$subsite_dir = self::get_directory_for_current_subsite();
if ($subsite_dir) {
$str = parent::calc_full_directory_for_object($do);
$str = "$subsite_dir/$str";
return $str;
} else {
return false;
}
}
}
|
[
"public",
"static",
"function",
"calc_full_directory_for_object",
"(",
"DataObject",
"$",
"do",
")",
"{",
"if",
"(",
"$",
"do",
"->",
"ClassName",
"==",
"'Subsite'",
")",
"{",
"//This is the subsite creation",
"//we only want the subsite part",
"return",
"self",
"::",
"calc_directory_for_subsite",
"(",
"$",
"do",
")",
";",
"}",
"else",
"{",
"//If we're dealing with a path inside of a subsites,",
"//we need at least be sure that the subsite is having an asset directory",
"//NOTE: this only works when on the actual subsite",
"$",
"subsite_dir",
"=",
"self",
"::",
"get_directory_for_current_subsite",
"(",
")",
";",
"if",
"(",
"$",
"subsite_dir",
")",
"{",
"$",
"str",
"=",
"parent",
"::",
"calc_full_directory_for_object",
"(",
"$",
"do",
")",
";",
"$",
"str",
"=",
"\"$subsite_dir/$str\"",
";",
"return",
"$",
"str",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"}"
] |
Full subsite directory.
@param DataObject $do
@return bool|string
|
[
"Full",
"subsite",
"directory",
"."
] |
ed8ece7b6a4ca86dcb5dc16ee10ff339f629de3c
|
https://github.com/titledk/silverstripe-uploaddirrules/blob/ed8ece7b6a4ca86dcb5dc16ee10ff339f629de3c/code/rules/SubsiteUploadDirRules.php#L69-L90
|
24,411
|
DevGroup-ru/yii2-measure
|
src/models/Measure.php
|
Measure.validateConverterClass
|
public function validateConverterClass($attribute, $params)
{
$className = $this->$attribute;
if (class_exists($className) === true) {
if (new $className instanceof MeasureConverterInterface === false) {
$this->addError($attribute, MeasureHelper::t('Class does not implement `DevGroup\Measure\converters\MeasureConverterInterface` interface'));
}
} else {
$this->addError($attribute, MeasureHelper::t('Class not found'));
}
}
|
php
|
public function validateConverterClass($attribute, $params)
{
$className = $this->$attribute;
if (class_exists($className) === true) {
if (new $className instanceof MeasureConverterInterface === false) {
$this->addError($attribute, MeasureHelper::t('Class does not implement `DevGroup\Measure\converters\MeasureConverterInterface` interface'));
}
} else {
$this->addError($attribute, MeasureHelper::t('Class not found'));
}
}
|
[
"public",
"function",
"validateConverterClass",
"(",
"$",
"attribute",
",",
"$",
"params",
")",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"$",
"attribute",
";",
"if",
"(",
"class_exists",
"(",
"$",
"className",
")",
"===",
"true",
")",
"{",
"if",
"(",
"new",
"$",
"className",
"instanceof",
"MeasureConverterInterface",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"$",
"attribute",
",",
"MeasureHelper",
"::",
"t",
"(",
"'Class does not implement `DevGroup\\Measure\\converters\\MeasureConverterInterface` interface'",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"addError",
"(",
"$",
"attribute",
",",
"MeasureHelper",
"::",
"t",
"(",
"'Class not found'",
")",
")",
";",
"}",
"}"
] |
Validate the converter class name
@param string $attribute
@param array $params
|
[
"Validate",
"the",
"converter",
"class",
"name"
] |
1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c
|
https://github.com/DevGroup-ru/yii2-measure/blob/1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c/src/models/Measure.php#L44-L54
|
24,412
|
DevGroup-ru/yii2-measure
|
src/models/Measure.php
|
Measure.getTypes
|
public static function getTypes()
{
$typesList = [];
foreach (Yii::$app->db->getTableSchema(static::tableName())->columns['type']->enumValues as $type) {
$typesList[$type] = MeasureHelper::t($type);
}
return $typesList;
}
|
php
|
public static function getTypes()
{
$typesList = [];
foreach (Yii::$app->db->getTableSchema(static::tableName())->columns['type']->enumValues as $type) {
$typesList[$type] = MeasureHelper::t($type);
}
return $typesList;
}
|
[
"public",
"static",
"function",
"getTypes",
"(",
")",
"{",
"$",
"typesList",
"=",
"[",
"]",
";",
"foreach",
"(",
"Yii",
"::",
"$",
"app",
"->",
"db",
"->",
"getTableSchema",
"(",
"static",
"::",
"tableName",
"(",
")",
")",
"->",
"columns",
"[",
"'type'",
"]",
"->",
"enumValues",
"as",
"$",
"type",
")",
"{",
"$",
"typesList",
"[",
"$",
"type",
"]",
"=",
"MeasureHelper",
"::",
"t",
"(",
"$",
"type",
")",
";",
"}",
"return",
"$",
"typesList",
";",
"}"
] |
Get list of measure types.
@return array of types in the next format `'TypeName' => 'Translated type name'`
|
[
"Get",
"list",
"of",
"measure",
"types",
"."
] |
1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c
|
https://github.com/DevGroup-ru/yii2-measure/blob/1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c/src/models/Measure.php#L60-L67
|
24,413
|
DevGroup-ru/yii2-measure
|
src/models/Measure.php
|
Measure.getFormatter
|
public function getFormatter()
{
if ($this->formatterInstance === null) {
$this->formatterInstance = Yii::createObject(
[
'class' => '\yii\i18n\Formatter',
'decimalSeparator' => $this->decimal_separator,
'thousandSeparator' => $this->thousand_separator,
'numberFormatterOptions' => [
\NumberFormatter::MIN_FRACTION_DIGITS => $this->min_fraction_digits,
\NumberFormatter::MAX_FRACTION_DIGITS => $this->max_fraction_digits,
]
]
);
}
return $this->formatterInstance;
}
|
php
|
public function getFormatter()
{
if ($this->formatterInstance === null) {
$this->formatterInstance = Yii::createObject(
[
'class' => '\yii\i18n\Formatter',
'decimalSeparator' => $this->decimal_separator,
'thousandSeparator' => $this->thousand_separator,
'numberFormatterOptions' => [
\NumberFormatter::MIN_FRACTION_DIGITS => $this->min_fraction_digits,
\NumberFormatter::MAX_FRACTION_DIGITS => $this->max_fraction_digits,
]
]
);
}
return $this->formatterInstance;
}
|
[
"public",
"function",
"getFormatter",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"formatterInstance",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"formatterInstance",
"=",
"Yii",
"::",
"createObject",
"(",
"[",
"'class'",
"=>",
"'\\yii\\i18n\\Formatter'",
",",
"'decimalSeparator'",
"=>",
"$",
"this",
"->",
"decimal_separator",
",",
"'thousandSeparator'",
"=>",
"$",
"this",
"->",
"thousand_separator",
",",
"'numberFormatterOptions'",
"=>",
"[",
"\\",
"NumberFormatter",
"::",
"MIN_FRACTION_DIGITS",
"=>",
"$",
"this",
"->",
"min_fraction_digits",
",",
"\\",
"NumberFormatter",
"::",
"MAX_FRACTION_DIGITS",
"=>",
"$",
"this",
"->",
"max_fraction_digits",
",",
"]",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"formatterInstance",
";",
"}"
] |
Returns \yii\i18n\Formatter instance for current Currency instance
@return \yii\i18n\Formatter
@throws InvalidConfigException
|
[
"Returns",
"\\",
"yii",
"\\",
"i18n",
"\\",
"Formatter",
"instance",
"for",
"current",
"Currency",
"instance"
] |
1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c
|
https://github.com/DevGroup-ru/yii2-measure/blob/1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c/src/models/Measure.php#L119-L135
|
24,414
|
DevGroup-ru/yii2-measure
|
src/models/Measure.php
|
Measure.getMeasures
|
public static function getMeasures($type)
{
/** @var ActiveQuery $query */
$query = static::find()->select(['name', 'id'])->indexBy('id');
if (empty($type) === false) {
$query->where(['type' => $type]);
}
return $query->column();
}
|
php
|
public static function getMeasures($type)
{
/** @var ActiveQuery $query */
$query = static::find()->select(['name', 'id'])->indexBy('id');
if (empty($type) === false) {
$query->where(['type' => $type]);
}
return $query->column();
}
|
[
"public",
"static",
"function",
"getMeasures",
"(",
"$",
"type",
")",
"{",
"/** @var ActiveQuery $query */",
"$",
"query",
"=",
"static",
"::",
"find",
"(",
")",
"->",
"select",
"(",
"[",
"'name'",
",",
"'id'",
"]",
")",
"->",
"indexBy",
"(",
"'id'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"type",
")",
"===",
"false",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"[",
"'type'",
"=>",
"$",
"type",
"]",
")",
";",
"}",
"return",
"$",
"query",
"->",
"column",
"(",
")",
";",
"}"
] |
Get measures by type name.
@param string $type
@return array of measures in the next format `measure_id => 'Measure name'`
|
[
"Get",
"measures",
"by",
"type",
"name",
"."
] |
1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c
|
https://github.com/DevGroup-ru/yii2-measure/blob/1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c/src/models/Measure.php#L152-L160
|
24,415
|
skmetaly/laravel-twitch-restful-api
|
src/API/Authentication.php
|
Authentication.authenticationURL
|
public function authenticationURL()
{
$clientId = config('twitch-api.client_id');
$scopes = implode('+', config('twitch-api.scopes'));
$redirectURL = config('twitch-api.redirect_url');
return config('twitch-api.api_url') . '/kraken/oauth2/authorize?response_type=code&client_id=' . $clientId . '&redirect_uri=' . $redirectURL . '&scope=' . $scopes;
}
|
php
|
public function authenticationURL()
{
$clientId = config('twitch-api.client_id');
$scopes = implode('+', config('twitch-api.scopes'));
$redirectURL = config('twitch-api.redirect_url');
return config('twitch-api.api_url') . '/kraken/oauth2/authorize?response_type=code&client_id=' . $clientId . '&redirect_uri=' . $redirectURL . '&scope=' . $scopes;
}
|
[
"public",
"function",
"authenticationURL",
"(",
")",
"{",
"$",
"clientId",
"=",
"config",
"(",
"'twitch-api.client_id'",
")",
";",
"$",
"scopes",
"=",
"implode",
"(",
"'+'",
",",
"config",
"(",
"'twitch-api.scopes'",
")",
")",
";",
"$",
"redirectURL",
"=",
"config",
"(",
"'twitch-api.redirect_url'",
")",
";",
"return",
"config",
"(",
"'twitch-api.api_url'",
")",
".",
"'/kraken/oauth2/authorize?response_type=code&client_id='",
".",
"$",
"clientId",
".",
"'&redirect_uri='",
".",
"$",
"redirectURL",
".",
"'&scope='",
".",
"$",
"scopes",
";",
"}"
] |
Returns the authentication URL where the user needs to be redirected to
@return string
|
[
"Returns",
"the",
"authentication",
"URL",
"where",
"the",
"user",
"needs",
"to",
"be",
"redirected",
"to"
] |
70c83e441deb411ade2e343ad5cb0339c90dc6c2
|
https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Authentication.php#L22-L29
|
24,416
|
skmetaly/laravel-twitch-restful-api
|
src/API/Authentication.php
|
Authentication.requestToken
|
public function requestToken($code)
{
$parameters = [
'client_id' => config('twitch-api.client_id'),
'client_secret' => config('twitch-api.client_secret'),
'redirect_uri' => config('twitch-api.redirect_url'),
'code' => $code,
'grant_type' => 'authorization_code'
];
try {
$client = new Client();
$response = $client->post(config('twitch-api.api_url') . '/kraken/oauth2/token', ['body' => $parameters]);
$response = $response->json();
if (isset($response[ 'access_token' ])) {
return $response[ 'access_token' ];
}
} catch (\Exception $e) {
throw $e;
}
}
|
php
|
public function requestToken($code)
{
$parameters = [
'client_id' => config('twitch-api.client_id'),
'client_secret' => config('twitch-api.client_secret'),
'redirect_uri' => config('twitch-api.redirect_url'),
'code' => $code,
'grant_type' => 'authorization_code'
];
try {
$client = new Client();
$response = $client->post(config('twitch-api.api_url') . '/kraken/oauth2/token', ['body' => $parameters]);
$response = $response->json();
if (isset($response[ 'access_token' ])) {
return $response[ 'access_token' ];
}
} catch (\Exception $e) {
throw $e;
}
}
|
[
"public",
"function",
"requestToken",
"(",
"$",
"code",
")",
"{",
"$",
"parameters",
"=",
"[",
"'client_id'",
"=>",
"config",
"(",
"'twitch-api.client_id'",
")",
",",
"'client_secret'",
"=>",
"config",
"(",
"'twitch-api.client_secret'",
")",
",",
"'redirect_uri'",
"=>",
"config",
"(",
"'twitch-api.redirect_url'",
")",
",",
"'code'",
"=>",
"$",
"code",
",",
"'grant_type'",
"=>",
"'authorization_code'",
"]",
";",
"try",
"{",
"$",
"client",
"=",
"new",
"Client",
"(",
")",
";",
"$",
"response",
"=",
"$",
"client",
"->",
"post",
"(",
"config",
"(",
"'twitch-api.api_url'",
")",
".",
"'/kraken/oauth2/token'",
",",
"[",
"'body'",
"=>",
"$",
"parameters",
"]",
")",
";",
"$",
"response",
"=",
"$",
"response",
"->",
"json",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"response",
"[",
"'access_token'",
"]",
")",
")",
"{",
"return",
"$",
"response",
"[",
"'access_token'",
"]",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"}"
] |
Requests a token for a given code
@param $code
@return mixed
@throws \Exception
|
[
"Requests",
"a",
"token",
"for",
"a",
"given",
"code"
] |
70c83e441deb411ade2e343ad5cb0339c90dc6c2
|
https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Authentication.php#L39-L65
|
24,417
|
wenbinye/PhalconX
|
src/Db/Schema/Index.php
|
Index.fromIndex
|
public static function fromIndex(Db\Index $index)
{
return new self([
'name' => $index->getName(),
'columns' => $index->getColumns(),
'type' => $index->getType()
]);
}
|
php
|
public static function fromIndex(Db\Index $index)
{
return new self([
'name' => $index->getName(),
'columns' => $index->getColumns(),
'type' => $index->getType()
]);
}
|
[
"public",
"static",
"function",
"fromIndex",
"(",
"Db",
"\\",
"Index",
"$",
"index",
")",
"{",
"return",
"new",
"self",
"(",
"[",
"'name'",
"=>",
"$",
"index",
"->",
"getName",
"(",
")",
",",
"'columns'",
"=>",
"$",
"index",
"->",
"getColumns",
"(",
")",
",",
"'type'",
"=>",
"$",
"index",
"->",
"getType",
"(",
")",
"]",
")",
";",
"}"
] |
convert from Phalcon\Db\Index object
|
[
"convert",
"from",
"Phalcon",
"\\",
"Db",
"\\",
"Index",
"object"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Db/Schema/Index.php#L34-L41
|
24,418
|
wenbinye/PhalconX
|
src/Db/Schema/Index.php
|
Index.isSame
|
public function isSame(Index $other, $renamedColumns = null)
{
if ($renamedColumns) {
$columns = [];
foreach ($this->columns as $col) {
$columns[] = isset($renamedColumns[$col]) ? $renamedColumns[$col]->name : $col;
}
} else {
$columns = $this->columns;
}
if ($columns != $other->columns) {
return false;
}
if ($this->name == self::PRIMARY || $other->name == self::PRIMARY) {
return $this->name == $other->name;
} else {
return $this->type == $other->type;
}
}
|
php
|
public function isSame(Index $other, $renamedColumns = null)
{
if ($renamedColumns) {
$columns = [];
foreach ($this->columns as $col) {
$columns[] = isset($renamedColumns[$col]) ? $renamedColumns[$col]->name : $col;
}
} else {
$columns = $this->columns;
}
if ($columns != $other->columns) {
return false;
}
if ($this->name == self::PRIMARY || $other->name == self::PRIMARY) {
return $this->name == $other->name;
} else {
return $this->type == $other->type;
}
}
|
[
"public",
"function",
"isSame",
"(",
"Index",
"$",
"other",
",",
"$",
"renamedColumns",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"renamedColumns",
")",
"{",
"$",
"columns",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"col",
")",
"{",
"$",
"columns",
"[",
"]",
"=",
"isset",
"(",
"$",
"renamedColumns",
"[",
"$",
"col",
"]",
")",
"?",
"$",
"renamedColumns",
"[",
"$",
"col",
"]",
"->",
"name",
":",
"$",
"col",
";",
"}",
"}",
"else",
"{",
"$",
"columns",
"=",
"$",
"this",
"->",
"columns",
";",
"}",
"if",
"(",
"$",
"columns",
"!=",
"$",
"other",
"->",
"columns",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"name",
"==",
"self",
"::",
"PRIMARY",
"||",
"$",
"other",
"->",
"name",
"==",
"self",
"::",
"PRIMARY",
")",
"{",
"return",
"$",
"this",
"->",
"name",
"==",
"$",
"other",
"->",
"name",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"type",
"==",
"$",
"other",
"->",
"type",
";",
"}",
"}"
] |
compare with index
@param Index $other
@param array $renamedColumns
@return boolean
|
[
"compare",
"with",
"index"
] |
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
|
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Db/Schema/Index.php#L100-L118
|
24,419
|
surebert/surebert-framework
|
src/sb/Email/Writer.php
|
Writer.addEmailToOutbox
|
public function addEmailToOutbox(\sb\Email $email)
{
if ($this->checkHeadersForInjection($email)) {
return 0;
} else {
$this->emails[] = $email;
return true;
}
}
|
php
|
public function addEmailToOutbox(\sb\Email $email)
{
if ($this->checkHeadersForInjection($email)) {
return 0;
} else {
$this->emails[] = $email;
return true;
}
}
|
[
"public",
"function",
"addEmailToOutbox",
"(",
"\\",
"sb",
"\\",
"Email",
"$",
"email",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"checkHeadersForInjection",
"(",
"$",
"email",
")",
")",
"{",
"return",
"0",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"emails",
"[",
"]",
"=",
"$",
"email",
";",
"return",
"true",
";",
"}",
"}"
] |
Adds an email to the outbox which is sent with the send method
@param \sb\Email $email
@return boolean false if it has injectors, true if added to outbox
|
[
"Adds",
"an",
"email",
"to",
"the",
"outbox",
"which",
"is",
"sent",
"with",
"the",
"send",
"method"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email/Writer.php#L167-L178
|
24,420
|
surebert/surebert-framework
|
src/sb/Email/Writer.php
|
Writer.logEmail
|
private function logEmail($email, $sent)
{
$message = "\nEmail sent at " . date('m/d/y h:i:s');
$message .= "\nFrom:" . $email->from . '@' . $this->remote_addr;
$message .= "\nTo: " . $email->to;
foreach ($email->cc as $cc) {
$message .="\nCc:" . $cc;
}
foreach ($email->bcc as $bcc) {
$message .="\nBcc:" . $bcc;
}
$message .= "\nSubject: " . $email->subject;
$message .= "\nAttachments: " . count($email->attachments) . ' ';
if ($this->log_body) {
$message .= "\nBody: " . $email->body;
$message .= "\nBody_HTML: " . $email->body_HTML;
}
$names = Array();
foreach ($email->attachments as $attachment) {
$names[] = $attachment->name;
}
$message .= "(" . \implode(",", $names) . ")";
if ($sent) {
return $this->logger->sbEmailWriterSent($message);
} else {
return $this->logger->sbEmailWriterError($message);
}
}
|
php
|
private function logEmail($email, $sent)
{
$message = "\nEmail sent at " . date('m/d/y h:i:s');
$message .= "\nFrom:" . $email->from . '@' . $this->remote_addr;
$message .= "\nTo: " . $email->to;
foreach ($email->cc as $cc) {
$message .="\nCc:" . $cc;
}
foreach ($email->bcc as $bcc) {
$message .="\nBcc:" . $bcc;
}
$message .= "\nSubject: " . $email->subject;
$message .= "\nAttachments: " . count($email->attachments) . ' ';
if ($this->log_body) {
$message .= "\nBody: " . $email->body;
$message .= "\nBody_HTML: " . $email->body_HTML;
}
$names = Array();
foreach ($email->attachments as $attachment) {
$names[] = $attachment->name;
}
$message .= "(" . \implode(",", $names) . ")";
if ($sent) {
return $this->logger->sbEmailWriterSent($message);
} else {
return $this->logger->sbEmailWriterError($message);
}
}
|
[
"private",
"function",
"logEmail",
"(",
"$",
"email",
",",
"$",
"sent",
")",
"{",
"$",
"message",
"=",
"\"\\nEmail sent at \"",
".",
"date",
"(",
"'m/d/y h:i:s'",
")",
";",
"$",
"message",
".=",
"\"\\nFrom:\"",
".",
"$",
"email",
"->",
"from",
".",
"'@'",
".",
"$",
"this",
"->",
"remote_addr",
";",
"$",
"message",
".=",
"\"\\nTo: \"",
".",
"$",
"email",
"->",
"to",
";",
"foreach",
"(",
"$",
"email",
"->",
"cc",
"as",
"$",
"cc",
")",
"{",
"$",
"message",
".=",
"\"\\nCc:\"",
".",
"$",
"cc",
";",
"}",
"foreach",
"(",
"$",
"email",
"->",
"bcc",
"as",
"$",
"bcc",
")",
"{",
"$",
"message",
".=",
"\"\\nBcc:\"",
".",
"$",
"bcc",
";",
"}",
"$",
"message",
".=",
"\"\\nSubject: \"",
".",
"$",
"email",
"->",
"subject",
";",
"$",
"message",
".=",
"\"\\nAttachments: \"",
".",
"count",
"(",
"$",
"email",
"->",
"attachments",
")",
".",
"' '",
";",
"if",
"(",
"$",
"this",
"->",
"log_body",
")",
"{",
"$",
"message",
".=",
"\"\\nBody: \"",
".",
"$",
"email",
"->",
"body",
";",
"$",
"message",
".=",
"\"\\nBody_HTML: \"",
".",
"$",
"email",
"->",
"body_HTML",
";",
"}",
"$",
"names",
"=",
"Array",
"(",
")",
";",
"foreach",
"(",
"$",
"email",
"->",
"attachments",
"as",
"$",
"attachment",
")",
"{",
"$",
"names",
"[",
"]",
"=",
"$",
"attachment",
"->",
"name",
";",
"}",
"$",
"message",
".=",
"\"(\"",
".",
"\\",
"implode",
"(",
"\",\"",
",",
"$",
"names",
")",
".",
"\")\"",
";",
"if",
"(",
"$",
"sent",
")",
"{",
"return",
"$",
"this",
"->",
"logger",
"->",
"sbEmailWriterSent",
"(",
"$",
"message",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"logger",
"->",
"sbEmailWriterError",
"(",
"$",
"message",
")",
";",
"}",
"}"
] |
Logs the sending of emails if logging is enable by specifying the log_file property
@param $email \sb\Email
@param $sent Boolean, was the email sent or not
|
[
"Logs",
"the",
"sending",
"of",
"emails",
"if",
"logging",
"is",
"enable",
"by",
"specifying",
"the",
"log_file",
"property"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email/Writer.php#L186-L217
|
24,421
|
surebert/surebert-framework
|
src/sb/Email/Writer.php
|
Writer.checkHeadersForInjection
|
private function checkHeadersForInjection(\sb\Email $email)
{
if (\preg_match("~\r|:~i", $email->to) || preg_match("~\r|:~i", $email->from)) {
return true;
}
return false;
}
|
php
|
private function checkHeadersForInjection(\sb\Email $email)
{
if (\preg_match("~\r|:~i", $email->to) || preg_match("~\r|:~i", $email->from)) {
return true;
}
return false;
}
|
[
"private",
"function",
"checkHeadersForInjection",
"(",
"\\",
"sb",
"\\",
"Email",
"$",
"email",
")",
"{",
"if",
"(",
"\\",
"preg_match",
"(",
"\"~\\r|:~i\"",
",",
"$",
"email",
"->",
"to",
")",
"||",
"preg_match",
"(",
"\"~\\r|:~i\"",
",",
"$",
"email",
"->",
"from",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks email for injections in from and to addr
@param \sb\Email $email
@return boolean
|
[
"Checks",
"email",
"for",
"injections",
"in",
"from",
"and",
"to",
"addr"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email/Writer.php#L225-L233
|
24,422
|
ArrowSphere/Client
|
src/xAC/Cursor.php
|
Cursor.get
|
public function get()
{
$uri = null;
if ($this->context) {
$uri = $this->context->getBaseUri() . '/';
}
$uri .= $this->params['endpoint'];
$uri .= sprintf("?page=%d&perpage=%d"
, $this->page
, $this->perpage
);
// add filter if value is not empty
foreach ($this->filters as $filter) {
if (! empty($filter['value'])) {
$uri .= sprintf("&%s=%s"
, $filter['field']
, rawurlencode($filter['value'])
);
}
}
$res = $this->client->call($uri);
// get and preserve pagination
$lr = Client::getLastResponse();
$this->pagination = isset($lr['body']) && isset($lr['body']['pagination']) ? $lr['body']['pagination'] : [];
// convert array to Entities collection
$this->data = [];
foreach ($res as $data) {
$this->data[] = (new Entity([], $this->client))->setData($data);
}
$this->current = 0;
return $this->data;
}
|
php
|
public function get()
{
$uri = null;
if ($this->context) {
$uri = $this->context->getBaseUri() . '/';
}
$uri .= $this->params['endpoint'];
$uri .= sprintf("?page=%d&perpage=%d"
, $this->page
, $this->perpage
);
// add filter if value is not empty
foreach ($this->filters as $filter) {
if (! empty($filter['value'])) {
$uri .= sprintf("&%s=%s"
, $filter['field']
, rawurlencode($filter['value'])
);
}
}
$res = $this->client->call($uri);
// get and preserve pagination
$lr = Client::getLastResponse();
$this->pagination = isset($lr['body']) && isset($lr['body']['pagination']) ? $lr['body']['pagination'] : [];
// convert array to Entities collection
$this->data = [];
foreach ($res as $data) {
$this->data[] = (new Entity([], $this->client))->setData($data);
}
$this->current = 0;
return $this->data;
}
|
[
"public",
"function",
"get",
"(",
")",
"{",
"$",
"uri",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"context",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"context",
"->",
"getBaseUri",
"(",
")",
".",
"'/'",
";",
"}",
"$",
"uri",
".=",
"$",
"this",
"->",
"params",
"[",
"'endpoint'",
"]",
";",
"$",
"uri",
".=",
"sprintf",
"(",
"\"?page=%d&perpage=%d\"",
",",
"$",
"this",
"->",
"page",
",",
"$",
"this",
"->",
"perpage",
")",
";",
"// add filter if value is not empty",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"as",
"$",
"filter",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"filter",
"[",
"'value'",
"]",
")",
")",
"{",
"$",
"uri",
".=",
"sprintf",
"(",
"\"&%s=%s\"",
",",
"$",
"filter",
"[",
"'field'",
"]",
",",
"rawurlencode",
"(",
"$",
"filter",
"[",
"'value'",
"]",
")",
")",
";",
"}",
"}",
"$",
"res",
"=",
"$",
"this",
"->",
"client",
"->",
"call",
"(",
"$",
"uri",
")",
";",
"// get and preserve pagination",
"$",
"lr",
"=",
"Client",
"::",
"getLastResponse",
"(",
")",
";",
"$",
"this",
"->",
"pagination",
"=",
"isset",
"(",
"$",
"lr",
"[",
"'body'",
"]",
")",
"&&",
"isset",
"(",
"$",
"lr",
"[",
"'body'",
"]",
"[",
"'pagination'",
"]",
")",
"?",
"$",
"lr",
"[",
"'body'",
"]",
"[",
"'pagination'",
"]",
":",
"[",
"]",
";",
"// convert array to Entities collection",
"$",
"this",
"->",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"res",
"as",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"]",
"=",
"(",
"new",
"Entity",
"(",
"[",
"]",
",",
"$",
"this",
"->",
"client",
")",
")",
"->",
"setData",
"(",
"$",
"data",
")",
";",
"}",
"$",
"this",
"->",
"current",
"=",
"0",
";",
"return",
"$",
"this",
"->",
"data",
";",
"}"
] |
Get current data
@return array
|
[
"Get",
"current",
"data"
] |
6608f8257060375e7d3a27c485b23268b73f6ef7
|
https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC/Cursor.php#L86-L123
|
24,423
|
ArrowSphere/Client
|
src/xAC/Cursor.php
|
Cursor.getNext
|
public function getNext()
{
if (count($this->pagination) == 0) {
$this->get();
}
if ($this->page < $this->pagination['total_pages']) {
$this->page++;
return $this->get();
}
return false;
}
|
php
|
public function getNext()
{
if (count($this->pagination) == 0) {
$this->get();
}
if ($this->page < $this->pagination['total_pages']) {
$this->page++;
return $this->get();
}
return false;
}
|
[
"public",
"function",
"getNext",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"pagination",
")",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"get",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"page",
"<",
"$",
"this",
"->",
"pagination",
"[",
"'total_pages'",
"]",
")",
"{",
"$",
"this",
"->",
"page",
"++",
";",
"return",
"$",
"this",
"->",
"get",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Increase page number and get next results batch
return array
|
[
"Increase",
"page",
"number",
"and",
"get",
"next",
"results",
"batch",
"return",
"array"
] |
6608f8257060375e7d3a27c485b23268b73f6ef7
|
https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC/Cursor.php#L129-L141
|
24,424
|
ArrowSphere/Client
|
src/xAC/Cursor.php
|
Cursor.setPerPage
|
public function setPerPage($perpage)
{
if ($perpage > 0) {
$this->perpage = (int) $perpage;
$this->page = 1;
}
return $this;
}
|
php
|
public function setPerPage($perpage)
{
if ($perpage > 0) {
$this->perpage = (int) $perpage;
$this->page = 1;
}
return $this;
}
|
[
"public",
"function",
"setPerPage",
"(",
"$",
"perpage",
")",
"{",
"if",
"(",
"$",
"perpage",
">",
"0",
")",
"{",
"$",
"this",
"->",
"perpage",
"=",
"(",
"int",
")",
"$",
"perpage",
";",
"$",
"this",
"->",
"page",
"=",
"1",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set per page value, reset page value to 1
@param integer $perpage
@return \Arrowsphere\Client\xAC\Cursor
|
[
"Set",
"per",
"page",
"value",
"reset",
"page",
"value",
"to",
"1"
] |
6608f8257060375e7d3a27c485b23268b73f6ef7
|
https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC/Cursor.php#L173-L181
|
24,425
|
ArrowSphere/Client
|
src/xAC/Cursor.php
|
Cursor.addFilter
|
public function addFilter($field, $value, $operator= '=')
{
$this->filter[] = [
'field' => $field,
'value' => $value,
'operator' => $operator,
];
return $this;
}
|
php
|
public function addFilter($field, $value, $operator= '=')
{
$this->filter[] = [
'field' => $field,
'value' => $value,
'operator' => $operator,
];
return $this;
}
|
[
"public",
"function",
"addFilter",
"(",
"$",
"field",
",",
"$",
"value",
",",
"$",
"operator",
"=",
"'='",
")",
"{",
"$",
"this",
"->",
"filter",
"[",
"]",
"=",
"[",
"'field'",
"=>",
"$",
"field",
",",
"'value'",
"=>",
"$",
"value",
",",
"'operator'",
"=>",
"$",
"operator",
",",
"]",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a filter that will be passed to the API query
@param string $field
@param string $value
@param string $operator
@return \Arrowsphere\Client\xAC\Cursor
|
[
"Add",
"a",
"filter",
"that",
"will",
"be",
"passed",
"to",
"the",
"API",
"query"
] |
6608f8257060375e7d3a27c485b23268b73f6ef7
|
https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC/Cursor.php#L200-L209
|
24,426
|
ArrowSphere/Client
|
src/xAC/Cursor.php
|
Cursor.resetFilters
|
public function resetFilters($field = null)
{
if (is_null($field)) {
$this->filters = [];
} else {
if (isset($this->filters[$field])) {
unset($this->filters[$field]);
}
}
return $this;
}
|
php
|
public function resetFilters($field = null)
{
if (is_null($field)) {
$this->filters = [];
} else {
if (isset($this->filters[$field])) {
unset($this->filters[$field]);
}
}
return $this;
}
|
[
"public",
"function",
"resetFilters",
"(",
"$",
"field",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"field",
")",
")",
"{",
"$",
"this",
"->",
"filters",
"=",
"[",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"field",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"filters",
"[",
"$",
"field",
"]",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Remove filter matching given identifier or all filters if empty
@param string $field
@return \Arrowsphere\Client\xAC\Cursor
|
[
"Remove",
"filter",
"matching",
"given",
"identifier",
"or",
"all",
"filters",
"if",
"empty"
] |
6608f8257060375e7d3a27c485b23268b73f6ef7
|
https://github.com/ArrowSphere/Client/blob/6608f8257060375e7d3a27c485b23268b73f6ef7/src/xAC/Cursor.php#L216-L227
|
24,427
|
znck/countries
|
src/FileLoader.php
|
FileLoader.load
|
public function load(string $locale):array
{
$filename = "{$this->path}/{$locale}.php";
try {
$loaded = $this->files->getRequire($filename);
if (!is_array($loaded)) {
throw new InvalidResourceException();
}
return $loaded;
} catch (FileNotFoundException $e) {
throw new NotFoundResourceException("$filename not found.", 0, $e);
} catch (\Throwable $e) {
throw new InvalidResourceException("$filename has invalid resources.", 0, $e);
}
}
|
php
|
public function load(string $locale):array
{
$filename = "{$this->path}/{$locale}.php";
try {
$loaded = $this->files->getRequire($filename);
if (!is_array($loaded)) {
throw new InvalidResourceException();
}
return $loaded;
} catch (FileNotFoundException $e) {
throw new NotFoundResourceException("$filename not found.", 0, $e);
} catch (\Throwable $e) {
throw new InvalidResourceException("$filename has invalid resources.", 0, $e);
}
}
|
[
"public",
"function",
"load",
"(",
"string",
"$",
"locale",
")",
":",
"array",
"{",
"$",
"filename",
"=",
"\"{$this->path}/{$locale}.php\"",
";",
"try",
"{",
"$",
"loaded",
"=",
"$",
"this",
"->",
"files",
"->",
"getRequire",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"loaded",
")",
")",
"{",
"throw",
"new",
"InvalidResourceException",
"(",
")",
";",
"}",
"return",
"$",
"loaded",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"$",
"e",
")",
"{",
"throw",
"new",
"NotFoundResourceException",
"(",
"\"$filename not found.\"",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"e",
")",
"{",
"throw",
"new",
"InvalidResourceException",
"(",
"\"$filename has invalid resources.\"",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Loads a locale.
@param string $locale A locale
@throws NotFoundResourceException when the resource cannot be found
@throws InvalidResourceException when the resource cannot be loaded
@return array
|
[
"Loads",
"a",
"locale",
"."
] |
a78a2b302dfa8eacab8fe0c06127dbb37fa98fd3
|
https://github.com/znck/countries/blob/a78a2b302dfa8eacab8fe0c06127dbb37fa98fd3/src/FileLoader.php#L43-L58
|
24,428
|
odiaseo/pagebuilder
|
src/PageBuilder/Controller/TemplateController.php
|
TemplateController.get
|
public function get($id)
{
return $this->_sendPayload(
$this->_getService($this->_pageServiceKey)->getTemplateLayout($id)
);
}
|
php
|
public function get($id)
{
return $this->_sendPayload(
$this->_getService($this->_pageServiceKey)->getTemplateLayout($id)
);
}
|
[
"public",
"function",
"get",
"(",
"$",
"id",
")",
"{",
"return",
"$",
"this",
"->",
"_sendPayload",
"(",
"$",
"this",
"->",
"_getService",
"(",
"$",
"this",
"->",
"_pageServiceKey",
")",
"->",
"getTemplateLayout",
"(",
"$",
"id",
")",
")",
";",
"}"
] |
Get template details
@param mixed $id
@return mixed|\Zend\View\Model\ModelInterface
|
[
"Get",
"template",
"details"
] |
88ef7cccf305368561307efe4ca07fac8e5774f3
|
https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Controller/TemplateController.php#L18-L23
|
24,429
|
GrupaZero/api
|
src/Gzero/Api/Transformer/WidgetTransformer.php
|
WidgetTransformer.transform
|
public function transform($widget)
{
$widget = $this->entityToArray(Widget::class, $widget);
return [
'id' => (int) $widget['id'],
'name' => $widget['name'],
'args' => array_camel_case_keys($widget['args']),
'isActive' => (bool) $widget['is_active'],
'isCacheable' => (bool) $widget['is_cacheable'],
'createdAt' => $widget['created_at'],
'updatedAt' => $widget['updated_at'],
];
}
|
php
|
public function transform($widget)
{
$widget = $this->entityToArray(Widget::class, $widget);
return [
'id' => (int) $widget['id'],
'name' => $widget['name'],
'args' => array_camel_case_keys($widget['args']),
'isActive' => (bool) $widget['is_active'],
'isCacheable' => (bool) $widget['is_cacheable'],
'createdAt' => $widget['created_at'],
'updatedAt' => $widget['updated_at'],
];
}
|
[
"public",
"function",
"transform",
"(",
"$",
"widget",
")",
"{",
"$",
"widget",
"=",
"$",
"this",
"->",
"entityToArray",
"(",
"Widget",
"::",
"class",
",",
"$",
"widget",
")",
";",
"return",
"[",
"'id'",
"=>",
"(",
"int",
")",
"$",
"widget",
"[",
"'id'",
"]",
",",
"'name'",
"=>",
"$",
"widget",
"[",
"'name'",
"]",
",",
"'args'",
"=>",
"array_camel_case_keys",
"(",
"$",
"widget",
"[",
"'args'",
"]",
")",
",",
"'isActive'",
"=>",
"(",
"bool",
")",
"$",
"widget",
"[",
"'is_active'",
"]",
",",
"'isCacheable'",
"=>",
"(",
"bool",
")",
"$",
"widget",
"[",
"'is_cacheable'",
"]",
",",
"'createdAt'",
"=>",
"$",
"widget",
"[",
"'created_at'",
"]",
",",
"'updatedAt'",
"=>",
"$",
"widget",
"[",
"'updated_at'",
"]",
",",
"]",
";",
"}"
] |
Transforms widget entity
@param Widget|array $widget Widget entity
@return array
|
[
"Transforms",
"widget",
"entity"
] |
fc544bb6057274e9d5e7b617346c3f854ea5effd
|
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Transformer/WidgetTransformer.php#L26-L38
|
24,430
|
SergioMadness/query-builder
|
src/traits/Conditional.php
|
Conditional.setConditionBuilder
|
public function setConditionBuilder(\pwf\components\querybuilder\interfaces\ConditionBuilder $builder)
{
$this->conditionBuilder = $builder;
return $this;
}
|
php
|
public function setConditionBuilder(\pwf\components\querybuilder\interfaces\ConditionBuilder $builder)
{
$this->conditionBuilder = $builder;
return $this;
}
|
[
"public",
"function",
"setConditionBuilder",
"(",
"\\",
"pwf",
"\\",
"components",
"\\",
"querybuilder",
"\\",
"interfaces",
"\\",
"ConditionBuilder",
"$",
"builder",
")",
"{",
"$",
"this",
"->",
"conditionBuilder",
"=",
"$",
"builder",
";",
"return",
"$",
"this",
";",
"}"
] |
Set condition builder
@param \pwf\components\querybuilder\interfaces\ConditionBuilder $builder
@return $this
|
[
"Set",
"condition",
"builder"
] |
95b7a46bba4c4d369101c6f0d37f133fecb3956d
|
https://github.com/SergioMadness/query-builder/blob/95b7a46bba4c4d369101c6f0d37f133fecb3956d/src/traits/Conditional.php#L27-L31
|
24,431
|
comodojo/daemon
|
src/Comodojo/Daemon/Console/LogHandler.php
|
LogHandler.write
|
protected function write(array $record) {
$level = $record['level'];
$message = $record['formatted'];
$context = empty($record['context']) ? null : $record['context'];
$time = $record['datetime']->format('c');
$this->toConsole($time, $level, $message, $context);
}
|
php
|
protected function write(array $record) {
$level = $record['level'];
$message = $record['formatted'];
$context = empty($record['context']) ? null : $record['context'];
$time = $record['datetime']->format('c');
$this->toConsole($time, $level, $message, $context);
}
|
[
"protected",
"function",
"write",
"(",
"array",
"$",
"record",
")",
"{",
"$",
"level",
"=",
"$",
"record",
"[",
"'level'",
"]",
";",
"$",
"message",
"=",
"$",
"record",
"[",
"'formatted'",
"]",
";",
"$",
"context",
"=",
"empty",
"(",
"$",
"record",
"[",
"'context'",
"]",
")",
"?",
"null",
":",
"$",
"record",
"[",
"'context'",
"]",
";",
"$",
"time",
"=",
"$",
"record",
"[",
"'datetime'",
"]",
"->",
"format",
"(",
"'c'",
")",
";",
"$",
"this",
"->",
"toConsole",
"(",
"$",
"time",
",",
"$",
"level",
",",
"$",
"message",
",",
"$",
"context",
")",
";",
"}"
] |
Record's writer
|
[
"Record",
"s",
"writer"
] |
361b0a3a91dc7720dd3bec448bb4ca47d0ef0292
|
https://github.com/comodojo/daemon/blob/361b0a3a91dc7720dd3bec448bb4ca47d0ef0292/src/Comodojo/Daemon/Console/LogHandler.php#L91-L103
|
24,432
|
comodojo/daemon
|
src/Comodojo/Daemon/Console/LogHandler.php
|
LogHandler.toConsole
|
private function toConsole($time, $level, $message, $context) {
$color = static::$colors[$level];
$pattern = "<%s>%s</%s>";
$message = sprintf($pattern, $color, $message, $color);
$this->outputcontroller->out($message);
if ( !empty($context) && $this->include_context ) {
$this->outputcontroller->out(sprintf($pattern, $color, var_export($context, true), $color));
}
}
|
php
|
private function toConsole($time, $level, $message, $context) {
$color = static::$colors[$level];
$pattern = "<%s>%s</%s>";
$message = sprintf($pattern, $color, $message, $color);
$this->outputcontroller->out($message);
if ( !empty($context) && $this->include_context ) {
$this->outputcontroller->out(sprintf($pattern, $color, var_export($context, true), $color));
}
}
|
[
"private",
"function",
"toConsole",
"(",
"$",
"time",
",",
"$",
"level",
",",
"$",
"message",
",",
"$",
"context",
")",
"{",
"$",
"color",
"=",
"static",
"::",
"$",
"colors",
"[",
"$",
"level",
"]",
";",
"$",
"pattern",
"=",
"\"<%s>%s</%s>\"",
";",
"$",
"message",
"=",
"sprintf",
"(",
"$",
"pattern",
",",
"$",
"color",
",",
"$",
"message",
",",
"$",
"color",
")",
";",
"$",
"this",
"->",
"outputcontroller",
"->",
"out",
"(",
"$",
"message",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"context",
")",
"&&",
"$",
"this",
"->",
"include_context",
")",
"{",
"$",
"this",
"->",
"outputcontroller",
"->",
"out",
"(",
"sprintf",
"(",
"$",
"pattern",
",",
"$",
"color",
",",
"var_export",
"(",
"$",
"context",
",",
"true",
")",
",",
"$",
"color",
")",
")",
";",
"}",
"}"
] |
Send record to console formatting it
|
[
"Send",
"record",
"to",
"console",
"formatting",
"it"
] |
361b0a3a91dc7720dd3bec448bb4ca47d0ef0292
|
https://github.com/comodojo/daemon/blob/361b0a3a91dc7720dd3bec448bb4ca47d0ef0292/src/Comodojo/Daemon/Console/LogHandler.php#L108-L124
|
24,433
|
surebert/surebert-framework
|
src/sb/Controller/REST.php
|
REST.render
|
public function render()
{
if ($this->onBeforeRender() === false) {
return $this->notFound();
}
$method = \sb\Gateway::$request->method;
if (method_exists($this, $method)) {
$reflection = new \ReflectionMethod($this, $method);
//check for phpdocs
$docs = $reflection->getDocComment();
$servable = false;
if (!empty($docs)) {
if (preg_match("~@servable (true|false)~", $docs, $match)) {
$servable = $match[1] == 'true' ? true : false;
}
}
if ($servable) {
return $this->filterOutput($this->$method());
} else {
return $this->filterOutput($this->notFound($method));
}
} else {
return $this->filterOutput($this->notFound($method));
}
}
|
php
|
public function render()
{
if ($this->onBeforeRender() === false) {
return $this->notFound();
}
$method = \sb\Gateway::$request->method;
if (method_exists($this, $method)) {
$reflection = new \ReflectionMethod($this, $method);
//check for phpdocs
$docs = $reflection->getDocComment();
$servable = false;
if (!empty($docs)) {
if (preg_match("~@servable (true|false)~", $docs, $match)) {
$servable = $match[1] == 'true' ? true : false;
}
}
if ($servable) {
return $this->filterOutput($this->$method());
} else {
return $this->filterOutput($this->notFound($method));
}
} else {
return $this->filterOutput($this->notFound($method));
}
}
|
[
"public",
"function",
"render",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"onBeforeRender",
"(",
")",
"===",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"notFound",
"(",
")",
";",
"}",
"$",
"method",
"=",
"\\",
"sb",
"\\",
"Gateway",
"::",
"$",
"request",
"->",
"method",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"this",
",",
"$",
"method",
")",
";",
"//check for phpdocs",
"$",
"docs",
"=",
"$",
"reflection",
"->",
"getDocComment",
"(",
")",
";",
"$",
"servable",
"=",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"docs",
")",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"~@servable (true|false)~\"",
",",
"$",
"docs",
",",
"$",
"match",
")",
")",
"{",
"$",
"servable",
"=",
"$",
"match",
"[",
"1",
"]",
"==",
"'true'",
"?",
"true",
":",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"servable",
")",
"{",
"return",
"$",
"this",
"->",
"filterOutput",
"(",
"$",
"this",
"->",
"$",
"method",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"filterOutput",
"(",
"$",
"this",
"->",
"notFound",
"(",
"$",
"method",
")",
")",
";",
"}",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"filterOutput",
"(",
"$",
"this",
"->",
"notFound",
"(",
"$",
"method",
")",
")",
";",
"}",
"}"
] |
Used to render the output through the filterOutput method by calling the
handler appropriate to the HTTP request
@return string
|
[
"Used",
"to",
"render",
"the",
"output",
"through",
"the",
"filterOutput",
"method",
"by",
"calling",
"the",
"handler",
"appropriate",
"to",
"the",
"HTTP",
"request"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Controller/REST.php#L66-L93
|
24,434
|
surebert/surebert-framework
|
src/sb/Gitlab/User.php
|
User.getByEmail
|
protected function getByEmail($email) {
$users = $this->_client->get('/users?search='.urlencode($email));
return isset($users[0]) ? $users[0] : false;
}
|
php
|
protected function getByEmail($email) {
$users = $this->_client->get('/users?search='.urlencode($email));
return isset($users[0]) ? $users[0] : false;
}
|
[
"protected",
"function",
"getByEmail",
"(",
"$",
"email",
")",
"{",
"$",
"users",
"=",
"$",
"this",
"->",
"_client",
"->",
"get",
"(",
"'/users?search='",
".",
"urlencode",
"(",
"$",
"email",
")",
")",
";",
"return",
"isset",
"(",
"$",
"users",
"[",
"0",
"]",
")",
"?",
"$",
"users",
"[",
"0",
"]",
":",
"false",
";",
"}"
] |
Loads a user by email
@param string $email
@return \stdClass
|
[
"Loads",
"a",
"user",
"by",
"email"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Gitlab/User.php#L88-L91
|
24,435
|
f3ath/lazypdo
|
src/PDODecorator.php
|
PDODecorator.query
|
public function query($statement)
{
if (1 == func_num_args()) {
return $this->getPDO()->query($statement);
}
// this way is much slower but supports overloading
// http://php.net/manual/en/pdo.query.php
return call_user_func_array(array($this->getPDO(), __FUNCTION__), func_get_args());
}
|
php
|
public function query($statement)
{
if (1 == func_num_args()) {
return $this->getPDO()->query($statement);
}
// this way is much slower but supports overloading
// http://php.net/manual/en/pdo.query.php
return call_user_func_array(array($this->getPDO(), __FUNCTION__), func_get_args());
}
|
[
"public",
"function",
"query",
"(",
"$",
"statement",
")",
"{",
"if",
"(",
"1",
"==",
"func_num_args",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getPDO",
"(",
")",
"->",
"query",
"(",
"$",
"statement",
")",
";",
"}",
"// this way is much slower but supports overloading",
"// http://php.net/manual/en/pdo.query.php",
"return",
"call_user_func_array",
"(",
"array",
"(",
"$",
"this",
"->",
"getPDO",
"(",
")",
",",
"__FUNCTION__",
")",
",",
"func_get_args",
"(",
")",
")",
";",
"}"
] |
Executes an SQL statement, returning a result set as a PDOStatement object,
overloading is supported
@param string $statement
@return PDOStatement
|
[
"Executes",
"an",
"SQL",
"statement",
"returning",
"a",
"result",
"set",
"as",
"a",
"PDOStatement",
"object",
"overloading",
"is",
"supported"
] |
0ebdb3bc87d327d68a322d5fca049f4c21865928
|
https://github.com/f3ath/lazypdo/blob/0ebdb3bc87d327d68a322d5fca049f4c21865928/src/PDODecorator.php#L167-L175
|
24,436
|
ezsystems/ezdfs-fsbackend-dispatcher
|
classes/ezdfsfilehandlerdfsdispatcher.php
|
eZDFSFileHandlerDFSDispatcher.getFilesList
|
public function getFilesList( $basePath )
{
$iterator = new AppendIterator();
foreach ( $this->getAllHandlers() as $handler )
{
$iterator->append( $handler->getFilesList( $basePath ) );
}
return $iterator;
}
|
php
|
public function getFilesList( $basePath )
{
$iterator = new AppendIterator();
foreach ( $this->getAllHandlers() as $handler )
{
$iterator->append( $handler->getFilesList( $basePath ) );
}
return $iterator;
}
|
[
"public",
"function",
"getFilesList",
"(",
"$",
"basePath",
")",
"{",
"$",
"iterator",
"=",
"new",
"AppendIterator",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getAllHandlers",
"(",
")",
"as",
"$",
"handler",
")",
"{",
"$",
"iterator",
"->",
"append",
"(",
"$",
"handler",
"->",
"getFilesList",
"(",
"$",
"basePath",
")",
")",
";",
"}",
"return",
"$",
"iterator",
";",
"}"
] |
Returns an AppendIterator with every handler's iterator
@param string $basePath
@return Iterator
|
[
"Returns",
"an",
"AppendIterator",
"with",
"every",
"handler",
"s",
"iterator"
] |
e12c51e58ad452b2376bb6e0ec6deb8be5d8e036
|
https://github.com/ezsystems/ezdfs-fsbackend-dispatcher/blob/e12c51e58ad452b2376bb6e0ec6deb8be5d8e036/classes/ezdfsfilehandlerdfsdispatcher.php#L225-L233
|
24,437
|
alevilar/ristorantino-vendor
|
Compras/Model/PedidoMercaderia.php
|
PedidoMercaderia.getProveedoresInvolucrados
|
public function getProveedoresInvolucrados( $pedidoMercaderias ) {
$provs = [];
foreach ($pedidoMercaderias as $pm) {
if ( !empty($pm['Mercaderia']['Proveedor']['id']) ) {
$provs[] = $pm['Mercaderia']['Proveedor']['id'];
}
if ( !empty($pm['Mercaderia']['Rubro']['Proveedor']) ) {
foreach ($pm['Mercaderia']['Rubro']['Proveedor'] as $rubro) {
$provs[] = $rubro['id'];
}
}
}
return $provs;
}
|
php
|
public function getProveedoresInvolucrados( $pedidoMercaderias ) {
$provs = [];
foreach ($pedidoMercaderias as $pm) {
if ( !empty($pm['Mercaderia']['Proveedor']['id']) ) {
$provs[] = $pm['Mercaderia']['Proveedor']['id'];
}
if ( !empty($pm['Mercaderia']['Rubro']['Proveedor']) ) {
foreach ($pm['Mercaderia']['Rubro']['Proveedor'] as $rubro) {
$provs[] = $rubro['id'];
}
}
}
return $provs;
}
|
[
"public",
"function",
"getProveedoresInvolucrados",
"(",
"$",
"pedidoMercaderias",
")",
"{",
"$",
"provs",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"pedidoMercaderias",
"as",
"$",
"pm",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"pm",
"[",
"'Mercaderia'",
"]",
"[",
"'Proveedor'",
"]",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"provs",
"[",
"]",
"=",
"$",
"pm",
"[",
"'Mercaderia'",
"]",
"[",
"'Proveedor'",
"]",
"[",
"'id'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"pm",
"[",
"'Mercaderia'",
"]",
"[",
"'Rubro'",
"]",
"[",
"'Proveedor'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"pm",
"[",
"'Mercaderia'",
"]",
"[",
"'Rubro'",
"]",
"[",
"'Proveedor'",
"]",
"as",
"$",
"rubro",
")",
"{",
"$",
"provs",
"[",
"]",
"=",
"$",
"rubro",
"[",
"'id'",
"]",
";",
"}",
"}",
"}",
"return",
"$",
"provs",
";",
"}"
] |
filtrar los proveedores involucrados retornando un listado de ID's
@param array $pedidoMercaderias array del find de PedidoMercaderia
@return array con un list de id's de proveedores
|
[
"filtrar",
"los",
"proveedores",
"involucrados",
"retornando",
"un",
"listado",
"de",
"ID",
"s"
] |
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
|
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Compras/Model/PedidoMercaderia.php#L153-L167
|
24,438
|
K-Phoen/DoctrineStateMachineBehavior
|
src/StateMachine/StateMachineExtension.php
|
StateMachineExtension.canJumpToState
|
public function canJumpToState($state)
{
if ($state instanceof StateInterface) {
$state = $state->getName();
}
// assert that the given state exists
$this->getState($state);
return in_array($this->currentState->getName(), $this->statePrecedence[$state], true);
}
|
php
|
public function canJumpToState($state)
{
if ($state instanceof StateInterface) {
$state = $state->getName();
}
// assert that the given state exists
$this->getState($state);
return in_array($this->currentState->getName(), $this->statePrecedence[$state], true);
}
|
[
"public",
"function",
"canJumpToState",
"(",
"$",
"state",
")",
"{",
"if",
"(",
"$",
"state",
"instanceof",
"StateInterface",
")",
"{",
"$",
"state",
"=",
"$",
"state",
"->",
"getName",
"(",
")",
";",
"}",
"// assert that the given state exists",
"$",
"this",
"->",
"getState",
"(",
"$",
"state",
")",
";",
"return",
"in_array",
"(",
"$",
"this",
"->",
"currentState",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"statePrecedence",
"[",
"$",
"state",
"]",
",",
"true",
")",
";",
"}"
] |
Tells if moving to the given state is allowed.
@param string|StateInterface $state
@return bool
|
[
"Tells",
"if",
"moving",
"to",
"the",
"given",
"state",
"is",
"allowed",
"."
] |
699880fed03dd777ddae6cd8cec4b3d61853d4d7
|
https://github.com/K-Phoen/DoctrineStateMachineBehavior/blob/699880fed03dd777ddae6cd8cec4b3d61853d4d7/src/StateMachine/StateMachineExtension.php#L64-L74
|
24,439
|
K-Phoen/DoctrineStateMachineBehavior
|
src/StateMachine/StateMachineExtension.php
|
StateMachineExtension.jumpToState
|
public function jumpToState($state)
{
if (!$state instanceof StateInterface) {
$state = $this->getState($state);
}
if (!$this->canJumpToState($state)) {
throw new StateException(sprintf('Can not jump from state "%s" to "%s".',$this->currentState->getName(), $state->getName()));
}
$this->object->setFiniteState($state->getName());
$this->currentState = $state;
}
|
php
|
public function jumpToState($state)
{
if (!$state instanceof StateInterface) {
$state = $this->getState($state);
}
if (!$this->canJumpToState($state)) {
throw new StateException(sprintf('Can not jump from state "%s" to "%s".',$this->currentState->getName(), $state->getName()));
}
$this->object->setFiniteState($state->getName());
$this->currentState = $state;
}
|
[
"public",
"function",
"jumpToState",
"(",
"$",
"state",
")",
"{",
"if",
"(",
"!",
"$",
"state",
"instanceof",
"StateInterface",
")",
"{",
"$",
"state",
"=",
"$",
"this",
"->",
"getState",
"(",
"$",
"state",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"canJumpToState",
"(",
"$",
"state",
")",
")",
"{",
"throw",
"new",
"StateException",
"(",
"sprintf",
"(",
"'Can not jump from state \"%s\" to \"%s\".'",
",",
"$",
"this",
"->",
"currentState",
"->",
"getName",
"(",
")",
",",
"$",
"state",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"object",
"->",
"setFiniteState",
"(",
"$",
"state",
"->",
"getName",
"(",
")",
")",
";",
"$",
"this",
"->",
"currentState",
"=",
"$",
"state",
";",
"}"
] |
Moves to the given state if allowed.
@param string|StateInterface $state
@return bool
|
[
"Moves",
"to",
"the",
"given",
"state",
"if",
"allowed",
"."
] |
699880fed03dd777ddae6cd8cec4b3d61853d4d7
|
https://github.com/K-Phoen/DoctrineStateMachineBehavior/blob/699880fed03dd777ddae6cd8cec4b3d61853d4d7/src/StateMachine/StateMachineExtension.php#L83-L95
|
24,440
|
zhouyl/mellivora
|
Mellivora/Console/Parser.php
|
Parser.extractDescription
|
protected static function extractDescription($token)
{
$parts = preg_split('/\s+:\s+/', trim($token), 2);
return count($parts) === 2 ? $parts : [$token, null];
}
|
php
|
protected static function extractDescription($token)
{
$parts = preg_split('/\s+:\s+/', trim($token), 2);
return count($parts) === 2 ? $parts : [$token, null];
}
|
[
"protected",
"static",
"function",
"extractDescription",
"(",
"$",
"token",
")",
"{",
"$",
"parts",
"=",
"preg_split",
"(",
"'/\\s+:\\s+/'",
",",
"trim",
"(",
"$",
"token",
")",
",",
"2",
")",
";",
"return",
"count",
"(",
"$",
"parts",
")",
"===",
"2",
"?",
"$",
"parts",
":",
"[",
"$",
"token",
",",
"null",
"]",
";",
"}"
] |
Parse the token into its token and description segments.
@param string $token
@return array
|
[
"Parse",
"the",
"token",
"into",
"its",
"token",
"and",
"description",
"segments",
"."
] |
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
|
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Console/Parser.php#L142-L147
|
24,441
|
oroinc/OroLayoutComponent
|
RawLayout.php
|
RawLayout.getParentId
|
public function getParentId($id)
{
$path = $this->getProperty($id, self::PATH);
array_pop($path);
return empty($path)
? null // the given item is the root
: array_pop($path);
}
|
php
|
public function getParentId($id)
{
$path = $this->getProperty($id, self::PATH);
array_pop($path);
return empty($path)
? null // the given item is the root
: array_pop($path);
}
|
[
"public",
"function",
"getParentId",
"(",
"$",
"id",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getProperty",
"(",
"$",
"id",
",",
"self",
"::",
"PATH",
")",
";",
"array_pop",
"(",
"$",
"path",
")",
";",
"return",
"empty",
"(",
"$",
"path",
")",
"?",
"null",
"// the given item is the root",
":",
"array_pop",
"(",
"$",
"path",
")",
";",
"}"
] |
Returns the id of the parent layout item
@param string $id The id or alias of the layout item
@return string|null The id of the parent layout item or null if the given item is the root
|
[
"Returns",
"the",
"id",
"of",
"the",
"parent",
"layout",
"item"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L87-L95
|
24,442
|
oroinc/OroLayoutComponent
|
RawLayout.php
|
RawLayout.resolveId
|
public function resolveId($id)
{
return $this->aliases->has($id)
? $this->aliases->getId($id)
: $id;
}
|
php
|
public function resolveId($id)
{
return $this->aliases->has($id)
? $this->aliases->getId($id)
: $id;
}
|
[
"public",
"function",
"resolveId",
"(",
"$",
"id",
")",
"{",
"return",
"$",
"this",
"->",
"aliases",
"->",
"has",
"(",
"$",
"id",
")",
"?",
"$",
"this",
"->",
"aliases",
"->",
"getId",
"(",
"$",
"id",
")",
":",
"$",
"id",
";",
"}"
] |
Returns real id of the layout item
@param string $id The id or alias of the layout item
@return string The layout item id
|
[
"Returns",
"real",
"id",
"of",
"the",
"layout",
"item"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L104-L109
|
24,443
|
oroinc/OroLayoutComponent
|
RawLayout.php
|
RawLayout.has
|
public function has($id)
{
$id = $this->resolveId($id);
return isset($this->items[$id]);
}
|
php
|
public function has($id)
{
$id = $this->resolveId($id);
return isset($this->items[$id]);
}
|
[
"public",
"function",
"has",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"resolveId",
"(",
"$",
"id",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
")",
";",
"}"
] |
Checks if the layout item with the given id exists
@param string $id The id or alias of the layout item
@return bool
|
[
"Checks",
"if",
"the",
"layout",
"item",
"with",
"the",
"given",
"id",
"exists"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L118-L123
|
24,444
|
oroinc/OroLayoutComponent
|
RawLayout.php
|
RawLayout.add
|
public function add(
$id,
$parentId,
$blockType,
array $options = [],
$siblingId = null,
$prepend = null
) {
$this->validateId($id, true);
if (isset($this->items[$id])) {
throw new Exception\ItemAlreadyExistsException(
sprintf(
'The "%s" item already exists.'
. ' Remove existing item before add the new item with the same id.',
$id
)
);
}
if (!$parentId && !$this->hierarchy->isEmpty()) {
throw new Exception\LogicException(
sprintf(
'The "%s" item cannot be the root item'
. ' because another root item ("%s") already exists.',
$id,
$this->hierarchy->getRootId()
)
);
}
if ($parentId) {
$parentId = $this->validateAndResolveId($parentId);
}
if ($siblingId) {
$siblingId = $this->resolveId($siblingId);
if (!isset($this->items[$siblingId])) {
throw new Exception\ItemNotFoundException(sprintf('The "%s" sibling item does not exist.', $siblingId));
}
if ($parentId && $siblingId === $parentId) {
throw new Exception\LogicException('The sibling item cannot be the same as the parent item.');
}
}
$path = $parentId
? $this->getProperty($parentId, self::PATH, true)
: [];
$this->hierarchy->add($path, $id, $siblingId, $prepend);
$path[] = $id;
$this->items[$id] = [
self::PATH => $path,
self::BLOCK_TYPE => $blockType,
self::OPTIONS => $options
];
}
|
php
|
public function add(
$id,
$parentId,
$blockType,
array $options = [],
$siblingId = null,
$prepend = null
) {
$this->validateId($id, true);
if (isset($this->items[$id])) {
throw new Exception\ItemAlreadyExistsException(
sprintf(
'The "%s" item already exists.'
. ' Remove existing item before add the new item with the same id.',
$id
)
);
}
if (!$parentId && !$this->hierarchy->isEmpty()) {
throw new Exception\LogicException(
sprintf(
'The "%s" item cannot be the root item'
. ' because another root item ("%s") already exists.',
$id,
$this->hierarchy->getRootId()
)
);
}
if ($parentId) {
$parentId = $this->validateAndResolveId($parentId);
}
if ($siblingId) {
$siblingId = $this->resolveId($siblingId);
if (!isset($this->items[$siblingId])) {
throw new Exception\ItemNotFoundException(sprintf('The "%s" sibling item does not exist.', $siblingId));
}
if ($parentId && $siblingId === $parentId) {
throw new Exception\LogicException('The sibling item cannot be the same as the parent item.');
}
}
$path = $parentId
? $this->getProperty($parentId, self::PATH, true)
: [];
$this->hierarchy->add($path, $id, $siblingId, $prepend);
$path[] = $id;
$this->items[$id] = [
self::PATH => $path,
self::BLOCK_TYPE => $blockType,
self::OPTIONS => $options
];
}
|
[
"public",
"function",
"add",
"(",
"$",
"id",
",",
"$",
"parentId",
",",
"$",
"blockType",
",",
"array",
"$",
"options",
"=",
"[",
"]",
",",
"$",
"siblingId",
"=",
"null",
",",
"$",
"prepend",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"validateId",
"(",
"$",
"id",
",",
"true",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"ItemAlreadyExistsException",
"(",
"sprintf",
"(",
"'The \"%s\" item already exists.'",
".",
"' Remove existing item before add the new item with the same id.'",
",",
"$",
"id",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"parentId",
"&&",
"!",
"$",
"this",
"->",
"hierarchy",
"->",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'The \"%s\" item cannot be the root item'",
".",
"' because another root item (\"%s\") already exists.'",
",",
"$",
"id",
",",
"$",
"this",
"->",
"hierarchy",
"->",
"getRootId",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"parentId",
")",
"{",
"$",
"parentId",
"=",
"$",
"this",
"->",
"validateAndResolveId",
"(",
"$",
"parentId",
")",
";",
"}",
"if",
"(",
"$",
"siblingId",
")",
"{",
"$",
"siblingId",
"=",
"$",
"this",
"->",
"resolveId",
"(",
"$",
"siblingId",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"siblingId",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"ItemNotFoundException",
"(",
"sprintf",
"(",
"'The \"%s\" sibling item does not exist.'",
",",
"$",
"siblingId",
")",
")",
";",
"}",
"if",
"(",
"$",
"parentId",
"&&",
"$",
"siblingId",
"===",
"$",
"parentId",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"'The sibling item cannot be the same as the parent item.'",
")",
";",
"}",
"}",
"$",
"path",
"=",
"$",
"parentId",
"?",
"$",
"this",
"->",
"getProperty",
"(",
"$",
"parentId",
",",
"self",
"::",
"PATH",
",",
"true",
")",
":",
"[",
"]",
";",
"$",
"this",
"->",
"hierarchy",
"->",
"add",
"(",
"$",
"path",
",",
"$",
"id",
",",
"$",
"siblingId",
",",
"$",
"prepend",
")",
";",
"$",
"path",
"[",
"]",
"=",
"$",
"id",
";",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
"=",
"[",
"self",
"::",
"PATH",
"=>",
"$",
"path",
",",
"self",
"::",
"BLOCK_TYPE",
"=>",
"$",
"blockType",
",",
"self",
"::",
"OPTIONS",
"=>",
"$",
"options",
"]",
";",
"}"
] |
Adds a new item to the layout
@param string $id The layout item id
@param string $parentId The id or alias of parent item. Set null to add the root item
@param mixed $blockType The block type associated with the layout item
@param array $options The layout item options
@param string|null $siblingId The id or alias of an item which should be nearest neighbor
@param bool $prepend Determines whether the moving item should be located before or after
the specified sibling item
@throws Exception\InvalidArgumentException if the id or parent id are empty or invalid
@throws Exception\ItemAlreadyExistsException if the layout item with the same id already exists
@throws Exception\ItemNotFoundException if the parent layout item does not exist
@throws Exception\LogicException if the layout item cannot be added by other reasons
@SuppressWarnings(PHPMD.NPathComplexity)
|
[
"Adds",
"a",
"new",
"item",
"to",
"the",
"layout"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L143-L194
|
24,445
|
oroinc/OroLayoutComponent
|
RawLayout.php
|
RawLayout.remove
|
public function remove($id)
{
$id = $this->validateAndResolveId($id);
$path = $this->items[$id][self::PATH];
// remove item from hierarchy
$this->hierarchy->remove($path);
// remove item
unset($this->items[$id]);
$this->aliases->removeById($id);
unset($this->blockThemes[$id]);
// remove all children
$pathLength = count($path);
$pathLastIndex = $pathLength - 1;
$ids = array_keys($this->items);
foreach ($ids as $itemId) {
$currentPath = $this->items[$itemId][self::PATH];
if (count($currentPath) > $pathLength && $currentPath[$pathLastIndex] === $id) {
unset($this->items[$itemId]);
$this->aliases->removeById($itemId);
unset($this->blockThemes[$itemId]);
}
}
}
|
php
|
public function remove($id)
{
$id = $this->validateAndResolveId($id);
$path = $this->items[$id][self::PATH];
// remove item from hierarchy
$this->hierarchy->remove($path);
// remove item
unset($this->items[$id]);
$this->aliases->removeById($id);
unset($this->blockThemes[$id]);
// remove all children
$pathLength = count($path);
$pathLastIndex = $pathLength - 1;
$ids = array_keys($this->items);
foreach ($ids as $itemId) {
$currentPath = $this->items[$itemId][self::PATH];
if (count($currentPath) > $pathLength && $currentPath[$pathLastIndex] === $id) {
unset($this->items[$itemId]);
$this->aliases->removeById($itemId);
unset($this->blockThemes[$itemId]);
}
}
}
|
[
"public",
"function",
"remove",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"validateAndResolveId",
"(",
"$",
"id",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
"[",
"self",
"::",
"PATH",
"]",
";",
"// remove item from hierarchy",
"$",
"this",
"->",
"hierarchy",
"->",
"remove",
"(",
"$",
"path",
")",
";",
"// remove item",
"unset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
")",
";",
"$",
"this",
"->",
"aliases",
"->",
"removeById",
"(",
"$",
"id",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"blockThemes",
"[",
"$",
"id",
"]",
")",
";",
"// remove all children",
"$",
"pathLength",
"=",
"count",
"(",
"$",
"path",
")",
";",
"$",
"pathLastIndex",
"=",
"$",
"pathLength",
"-",
"1",
";",
"$",
"ids",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"items",
")",
";",
"foreach",
"(",
"$",
"ids",
"as",
"$",
"itemId",
")",
"{",
"$",
"currentPath",
"=",
"$",
"this",
"->",
"items",
"[",
"$",
"itemId",
"]",
"[",
"self",
"::",
"PATH",
"]",
";",
"if",
"(",
"count",
"(",
"$",
"currentPath",
")",
">",
"$",
"pathLength",
"&&",
"$",
"currentPath",
"[",
"$",
"pathLastIndex",
"]",
"===",
"$",
"id",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"itemId",
"]",
")",
";",
"$",
"this",
"->",
"aliases",
"->",
"removeById",
"(",
"$",
"itemId",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"blockThemes",
"[",
"$",
"itemId",
"]",
")",
";",
"}",
"}",
"}"
] |
Removes the given item from the layout
@param string $id The id of the layout item to be removed
@throws Exception\InvalidArgumentException if the id is empty
@throws Exception\ItemNotFoundException if the layout item does not exist
|
[
"Removes",
"the",
"given",
"item",
"from",
"the",
"layout"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L204-L227
|
24,446
|
oroinc/OroLayoutComponent
|
RawLayout.php
|
RawLayout.hasProperty
|
public function hasProperty($id, $name, $directAccess = false)
{
if (!$directAccess) {
$id = $this->validateAndResolveId($id);
}
return isset($this->items[$id][$name]) || array_key_exists($name, $this->items[$id]);
}
|
php
|
public function hasProperty($id, $name, $directAccess = false)
{
if (!$directAccess) {
$id = $this->validateAndResolveId($id);
}
return isset($this->items[$id][$name]) || array_key_exists($name, $this->items[$id]);
}
|
[
"public",
"function",
"hasProperty",
"(",
"$",
"id",
",",
"$",
"name",
",",
"$",
"directAccess",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"directAccess",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"validateAndResolveId",
"(",
"$",
"id",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
"[",
"$",
"name",
"]",
")",
"||",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
")",
";",
"}"
] |
Checks if the layout item has the given additional property
@param string $id The id or alias of the layout item
@param string $name The property name
@param bool $directAccess Indicated whether the item id validation should be skipped.
This flag can be used to increase performance of get operation,
but use it carefully and only when you absolutely sure that
the value passed as the item id is not an alias
@return bool
@throws Exception\InvalidArgumentException if the id is empty
@throws Exception\ItemNotFoundException if the layout item does not exist
|
[
"Checks",
"if",
"the",
"layout",
"item",
"has",
"the",
"given",
"additional",
"property"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L325-L332
|
24,447
|
oroinc/OroLayoutComponent
|
RawLayout.php
|
RawLayout.getProperty
|
public function getProperty($id, $name, $directAccess = false)
{
if ($directAccess) {
if (!isset($this->items[$id][$name])) {
return null;
}
return $this->items[$id][$name];
}
$id = $this->validateAndResolveId($id);
if (!isset($this->items[$id][$name]) && !array_key_exists($name, $this->items[$id])) {
throw new Exception\LogicException(
sprintf('The "%s" item does not have "%s" property.', $id, $name)
);
}
return $this->items[$id][$name];
}
|
php
|
public function getProperty($id, $name, $directAccess = false)
{
if ($directAccess) {
if (!isset($this->items[$id][$name])) {
return null;
}
return $this->items[$id][$name];
}
$id = $this->validateAndResolveId($id);
if (!isset($this->items[$id][$name]) && !array_key_exists($name, $this->items[$id])) {
throw new Exception\LogicException(
sprintf('The "%s" item does not have "%s" property.', $id, $name)
);
}
return $this->items[$id][$name];
}
|
[
"public",
"function",
"getProperty",
"(",
"$",
"id",
",",
"$",
"name",
",",
"$",
"directAccess",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"directAccess",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
"[",
"$",
"name",
"]",
";",
"}",
"$",
"id",
"=",
"$",
"this",
"->",
"validateAndResolveId",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
"[",
"$",
"name",
"]",
")",
"&&",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'The \"%s\" item does not have \"%s\" property.'",
",",
"$",
"id",
",",
"$",
"name",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
"[",
"$",
"name",
"]",
";",
"}"
] |
Gets a value of an additional property for the layout item
@param string $id The id or alias of the layout item
@param string $name The property name
@param bool $directAccess Indicated whether the item id and property name validation should be skipped.
This flag can be used to increase performance of get operation,
but use it carefully and only when you absolutely sure that:
* the item with the specified id exists
* the value passed as the item id is not an alias
* the property with the specified name exists
@return mixed
@throws Exception\InvalidArgumentException if the id is empty
@throws Exception\ItemNotFoundException if the layout item does not exist
@throws Exception\LogicException if the layout item does not have the requested property
|
[
"Gets",
"a",
"value",
"of",
"an",
"additional",
"property",
"for",
"the",
"layout",
"item"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L352-L370
|
24,448
|
oroinc/OroLayoutComponent
|
RawLayout.php
|
RawLayout.setProperty
|
public function setProperty($id, $name, $value)
{
$id = $this->validateAndResolveId($id);
$this->items[$id][$name] = $value;
}
|
php
|
public function setProperty($id, $name, $value)
{
$id = $this->validateAndResolveId($id);
$this->items[$id][$name] = $value;
}
|
[
"public",
"function",
"setProperty",
"(",
"$",
"id",
",",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"validateAndResolveId",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}"
] |
Sets a value of an additional property for the layout item
@param string $id The id or alias of the layout item
@param string $name The property name
@param mixed $value The property value
@throws Exception\InvalidArgumentException if the id is empty
@throws Exception\ItemNotFoundException if the layout item does not exist
|
[
"Sets",
"a",
"value",
"of",
"an",
"additional",
"property",
"for",
"the",
"layout",
"item"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L382-L387
|
24,449
|
oroinc/OroLayoutComponent
|
RawLayout.php
|
RawLayout.addAlias
|
public function addAlias($alias, $id)
{
$this->validateAlias($alias, true);
$this->validateId($id, true);
// perform additional validations
if ($alias === $id) {
throw new Exception\LogicException(
sprintf(
'The "%s" sting cannot be used as an alias for "%s" item'
. ' because an alias cannot be equal to the item id.',
$alias,
$id
)
);
}
if (isset($this->items[$alias])) {
throw new Exception\LogicException(
sprintf(
'The "%s" sting cannot be used as an alias for "%s" item'
. ' because another item with the same id exists.',
$alias,
$id
)
);
}
if (!isset($this->items[$this->resolveId($id)])) {
throw new Exception\ItemNotFoundException(sprintf('The "%s" item does not exist.', $id));
}
$this->aliases->add($alias, $id);
}
|
php
|
public function addAlias($alias, $id)
{
$this->validateAlias($alias, true);
$this->validateId($id, true);
// perform additional validations
if ($alias === $id) {
throw new Exception\LogicException(
sprintf(
'The "%s" sting cannot be used as an alias for "%s" item'
. ' because an alias cannot be equal to the item id.',
$alias,
$id
)
);
}
if (isset($this->items[$alias])) {
throw new Exception\LogicException(
sprintf(
'The "%s" sting cannot be used as an alias for "%s" item'
. ' because another item with the same id exists.',
$alias,
$id
)
);
}
if (!isset($this->items[$this->resolveId($id)])) {
throw new Exception\ItemNotFoundException(sprintf('The "%s" item does not exist.', $id));
}
$this->aliases->add($alias, $id);
}
|
[
"public",
"function",
"addAlias",
"(",
"$",
"alias",
",",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"validateAlias",
"(",
"$",
"alias",
",",
"true",
")",
";",
"$",
"this",
"->",
"validateId",
"(",
"$",
"id",
",",
"true",
")",
";",
"// perform additional validations",
"if",
"(",
"$",
"alias",
"===",
"$",
"id",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'The \"%s\" sting cannot be used as an alias for \"%s\" item'",
".",
"' because an alias cannot be equal to the item id.'",
",",
"$",
"alias",
",",
"$",
"id",
")",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"alias",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'The \"%s\" sting cannot be used as an alias for \"%s\" item'",
".",
"' because another item with the same id exists.'",
",",
"$",
"alias",
",",
"$",
"id",
")",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"this",
"->",
"resolveId",
"(",
"$",
"id",
")",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"ItemNotFoundException",
"(",
"sprintf",
"(",
"'The \"%s\" item does not exist.'",
",",
"$",
"id",
")",
")",
";",
"}",
"$",
"this",
"->",
"aliases",
"->",
"add",
"(",
"$",
"alias",
",",
"$",
"id",
")",
";",
"}"
] |
Creates an alias for the specified layout item
@param string $alias A string that can be used to access to the layout item instead of its id
@param string $id The layout item id
@throws Exception\InvalidArgumentException if the alias or id are empty or invalid
@throws Exception\ItemNotFoundException if the layout item with the given id does not exist
@throws Exception\AliasAlreadyExistsException if the alias is used for another layout item
@throws Exception\LogicException if the alias cannot be added by other reasons
|
[
"Creates",
"an",
"alias",
"for",
"the",
"specified",
"layout",
"item"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L412-L442
|
24,450
|
oroinc/OroLayoutComponent
|
RawLayout.php
|
RawLayout.removeAlias
|
public function removeAlias($alias)
{
$this->validateAlias($alias);
if (!$this->aliases->has($alias)) {
throw new Exception\AliasNotFoundException(sprintf('The "%s" item alias does not exist.', $alias));
}
$this->aliases->remove($alias);
}
|
php
|
public function removeAlias($alias)
{
$this->validateAlias($alias);
if (!$this->aliases->has($alias)) {
throw new Exception\AliasNotFoundException(sprintf('The "%s" item alias does not exist.', $alias));
}
$this->aliases->remove($alias);
}
|
[
"public",
"function",
"removeAlias",
"(",
"$",
"alias",
")",
"{",
"$",
"this",
"->",
"validateAlias",
"(",
"$",
"alias",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"aliases",
"->",
"has",
"(",
"$",
"alias",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"AliasNotFoundException",
"(",
"sprintf",
"(",
"'The \"%s\" item alias does not exist.'",
",",
"$",
"alias",
")",
")",
";",
"}",
"$",
"this",
"->",
"aliases",
"->",
"remove",
"(",
"$",
"alias",
")",
";",
"}"
] |
Removes the layout item alias
@param string $alias The layout item alias
@throws Exception\InvalidArgumentException if the alias is empty
@throws Exception\AliasNotFoundException if the alias does not exist
|
[
"Removes",
"the",
"layout",
"item",
"alias"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L452-L460
|
24,451
|
oroinc/OroLayoutComponent
|
RawLayout.php
|
RawLayout.getHierarchy
|
public function getHierarchy($id)
{
$path = $this->getProperty($id, self::PATH);
return $this->hierarchy->get($path);
}
|
php
|
public function getHierarchy($id)
{
$path = $this->getProperty($id, self::PATH);
return $this->hierarchy->get($path);
}
|
[
"public",
"function",
"getHierarchy",
"(",
"$",
"id",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getProperty",
"(",
"$",
"id",
",",
"self",
"::",
"PATH",
")",
";",
"return",
"$",
"this",
"->",
"hierarchy",
"->",
"get",
"(",
"$",
"path",
")",
";",
"}"
] |
Returns the layout items hierarchy from the given path
@param string $id The id or alias of the layout item
@return array
@throws Exception\InvalidArgumentException if the id is empty
@throws Exception\ItemNotFoundException if the layout item does not exist
|
[
"Returns",
"the",
"layout",
"items",
"hierarchy",
"from",
"the",
"given",
"path"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L564-L569
|
24,452
|
oroinc/OroLayoutComponent
|
RawLayout.php
|
RawLayout.getHierarchyIterator
|
public function getHierarchyIterator($id)
{
$id = $this->validateAndResolveId($id);
$children = $this->hierarchy->get($this->getProperty($id, self::PATH, true));
return new HierarchyIterator($id, $children);
}
|
php
|
public function getHierarchyIterator($id)
{
$id = $this->validateAndResolveId($id);
$children = $this->hierarchy->get($this->getProperty($id, self::PATH, true));
return new HierarchyIterator($id, $children);
}
|
[
"public",
"function",
"getHierarchyIterator",
"(",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"validateAndResolveId",
"(",
"$",
"id",
")",
";",
"$",
"children",
"=",
"$",
"this",
"->",
"hierarchy",
"->",
"get",
"(",
"$",
"this",
"->",
"getProperty",
"(",
"$",
"id",
",",
"self",
"::",
"PATH",
",",
"true",
")",
")",
";",
"return",
"new",
"HierarchyIterator",
"(",
"$",
"id",
",",
"$",
"children",
")",
";",
"}"
] |
Returns an iterator which can be used to get ids of all children of the given item
The iteration is performed from parent to child
@param string $id The id or alias of the layout item
@return HierarchyIterator
@throws Exception\InvalidArgumentException if the id is empty
@throws Exception\ItemNotFoundException if the layout item does not exist
|
[
"Returns",
"an",
"iterator",
"which",
"can",
"be",
"used",
"to",
"get",
"ids",
"of",
"all",
"children",
"of",
"the",
"given",
"item",
"The",
"iteration",
"is",
"performed",
"from",
"parent",
"to",
"child"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L582-L588
|
24,453
|
oroinc/OroLayoutComponent
|
RawLayout.php
|
RawLayout.validateId
|
protected function validateId($id, $fullCheck = false)
{
if (!$id) {
throw new Exception\InvalidArgumentException('The item id must not be empty.');
}
if ($fullCheck) {
if (!is_string($id)) {
throw new Exception\UnexpectedTypeException($id, 'string', 'id');
}
if (!$this->isValidId($id)) {
throw new Exception\InvalidArgumentException(
sprintf(
'The "%s" string cannot be used as the item id because it contains illegal characters. '
. 'The valid item id should start with a letter and only contain '
. 'letters, numbers, underscores ("_"), hyphens ("-") and colons (":").',
$id
)
);
}
}
}
|
php
|
protected function validateId($id, $fullCheck = false)
{
if (!$id) {
throw new Exception\InvalidArgumentException('The item id must not be empty.');
}
if ($fullCheck) {
if (!is_string($id)) {
throw new Exception\UnexpectedTypeException($id, 'string', 'id');
}
if (!$this->isValidId($id)) {
throw new Exception\InvalidArgumentException(
sprintf(
'The "%s" string cannot be used as the item id because it contains illegal characters. '
. 'The valid item id should start with a letter and only contain '
. 'letters, numbers, underscores ("_"), hyphens ("-") and colons (":").',
$id
)
);
}
}
}
|
[
"protected",
"function",
"validateId",
"(",
"$",
"id",
",",
"$",
"fullCheck",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"id",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'The item id must not be empty.'",
")",
";",
"}",
"if",
"(",
"$",
"fullCheck",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"id",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UnexpectedTypeException",
"(",
"$",
"id",
",",
"'string'",
",",
"'id'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isValidId",
"(",
"$",
"id",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The \"%s\" string cannot be used as the item id because it contains illegal characters. '",
".",
"'The valid item id should start with a letter and only contain '",
".",
"'letters, numbers, underscores (\"_\"), hyphens (\"-\") and colons (\":\").'",
",",
"$",
"id",
")",
")",
";",
"}",
"}",
"}"
] |
Checks if the given value can be used as the layout item id
@param string $id The layout item id
@param bool $fullCheck Determines whether all validation rules should be applied
or it is required to validate for empty value only
@throws Exception\InvalidArgumentException if the id is not valid
|
[
"Checks",
"if",
"the",
"given",
"value",
"can",
"be",
"used",
"as",
"the",
"layout",
"item",
"id"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L636-L656
|
24,454
|
oroinc/OroLayoutComponent
|
RawLayout.php
|
RawLayout.validateAndResolveId
|
protected function validateAndResolveId($id)
{
$this->validateId($id);
$id = $this->resolveId($id);
if (!isset($this->items[$id])) {
throw new Exception\ItemNotFoundException(sprintf('The "%s" item does not exist.', $id));
}
return $id;
}
|
php
|
protected function validateAndResolveId($id)
{
$this->validateId($id);
$id = $this->resolveId($id);
if (!isset($this->items[$id])) {
throw new Exception\ItemNotFoundException(sprintf('The "%s" item does not exist.', $id));
}
return $id;
}
|
[
"protected",
"function",
"validateAndResolveId",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"validateId",
"(",
"$",
"id",
")",
";",
"$",
"id",
"=",
"$",
"this",
"->",
"resolveId",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"ItemNotFoundException",
"(",
"sprintf",
"(",
"'The \"%s\" item does not exist.'",
",",
"$",
"id",
")",
")",
";",
"}",
"return",
"$",
"id",
";",
"}"
] |
Checks the layout item id for empty and returns real id
Also this method raises an exception if the layout item does not exist
@param string $id The layout item id
@return string The resolved item id
@throws Exception\InvalidArgumentException if the id is empty
@throws Exception\ItemNotFoundException if the layout item does not exist
|
[
"Checks",
"the",
"layout",
"item",
"id",
"for",
"empty",
"and",
"returns",
"real",
"id",
"Also",
"this",
"method",
"raises",
"an",
"exception",
"if",
"the",
"layout",
"item",
"does",
"not",
"exist"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L669-L678
|
24,455
|
oroinc/OroLayoutComponent
|
RawLayout.php
|
RawLayout.validateAlias
|
protected function validateAlias($alias, $fullCheck = false)
{
if (!$alias) {
throw new Exception\InvalidArgumentException('The item alias must not be empty.');
}
if ($fullCheck) {
if (!is_string($alias)) {
throw new Exception\UnexpectedTypeException($alias, 'string', 'alias');
}
if (!$this->isValidId($alias)) {
throw new Exception\InvalidArgumentException(
sprintf(
'The "%s" string cannot be used as the item alias because it contains illegal characters. '
. 'The valid alias should start with a letter and only contain '
. 'letters, numbers, underscores ("_"), hyphens ("-") and colons (":").',
$alias
)
);
}
}
}
|
php
|
protected function validateAlias($alias, $fullCheck = false)
{
if (!$alias) {
throw new Exception\InvalidArgumentException('The item alias must not be empty.');
}
if ($fullCheck) {
if (!is_string($alias)) {
throw new Exception\UnexpectedTypeException($alias, 'string', 'alias');
}
if (!$this->isValidId($alias)) {
throw new Exception\InvalidArgumentException(
sprintf(
'The "%s" string cannot be used as the item alias because it contains illegal characters. '
. 'The valid alias should start with a letter and only contain '
. 'letters, numbers, underscores ("_"), hyphens ("-") and colons (":").',
$alias
)
);
}
}
}
|
[
"protected",
"function",
"validateAlias",
"(",
"$",
"alias",
",",
"$",
"fullCheck",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"alias",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'The item alias must not be empty.'",
")",
";",
"}",
"if",
"(",
"$",
"fullCheck",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"alias",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"UnexpectedTypeException",
"(",
"$",
"alias",
",",
"'string'",
",",
"'alias'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isValidId",
"(",
"$",
"alias",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The \"%s\" string cannot be used as the item alias because it contains illegal characters. '",
".",
"'The valid alias should start with a letter and only contain '",
".",
"'letters, numbers, underscores (\"_\"), hyphens (\"-\") and colons (\":\").'",
",",
"$",
"alias",
")",
")",
";",
"}",
"}",
"}"
] |
Checks if the given value can be used as an alias for the layout item
@param string $alias The layout item alias
@param bool $fullCheck Determines whether all validation rules should be applied
or it is required to validate for empty value only
@throws Exception\InvalidArgumentException if the alias is not valid
|
[
"Checks",
"if",
"the",
"given",
"value",
"can",
"be",
"used",
"as",
"an",
"alias",
"for",
"the",
"layout",
"item"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/RawLayout.php#L689-L709
|
24,456
|
GreenCape/joomla-cli
|
src/GreenCape/JoomlaCLI/Commands/Install.php
|
InstallCommand.execute
|
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setupEnvironment('administrator', $input, $output);
// Enable debug, so that JInstaller::install() throws exceptions on problems
$this->joomla->setCfg('debug', 1);
$installer = \JInstaller::getInstance();
if ($installer->install($this->handleExtension($input, $output)))
{
$output->writeln($this->getExtensionInfo($installer));
return 0;
}
else
{
$output->writeln('Installation failed due to unknown reason.');
return 1;
}
}
|
php
|
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setupEnvironment('administrator', $input, $output);
// Enable debug, so that JInstaller::install() throws exceptions on problems
$this->joomla->setCfg('debug', 1);
$installer = \JInstaller::getInstance();
if ($installer->install($this->handleExtension($input, $output)))
{
$output->writeln($this->getExtensionInfo($installer));
return 0;
}
else
{
$output->writeln('Installation failed due to unknown reason.');
return 1;
}
}
|
[
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"setupEnvironment",
"(",
"'administrator'",
",",
"$",
"input",
",",
"$",
"output",
")",
";",
"// Enable debug, so that JInstaller::install() throws exceptions on problems",
"$",
"this",
"->",
"joomla",
"->",
"setCfg",
"(",
"'debug'",
",",
"1",
")",
";",
"$",
"installer",
"=",
"\\",
"JInstaller",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"$",
"installer",
"->",
"install",
"(",
"$",
"this",
"->",
"handleExtension",
"(",
"$",
"input",
",",
"$",
"output",
")",
")",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"$",
"this",
"->",
"getExtensionInfo",
"(",
"$",
"installer",
")",
")",
";",
"return",
"0",
";",
"}",
"else",
"{",
"$",
"output",
"->",
"writeln",
"(",
"'Installation failed due to unknown reason.'",
")",
";",
"return",
"1",
";",
"}",
"}"
] |
Execute the install command
@param InputInterface $input An InputInterface instance
@param OutputInterface $output An OutputInterface instance
@return integer 0 if everything went fine, 1 on error
|
[
"Execute",
"the",
"install",
"command"
] |
74a6940f27b1f66c99330d4f9e2c5ac314cdd369
|
https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Commands/Install.php#L74-L95
|
24,457
|
GreenCape/joomla-cli
|
src/GreenCape/JoomlaCLI/Commands/Install.php
|
InstallCommand.handleExtension
|
protected function handleExtension(InputInterface $input, OutputInterface $output)
{
$source = $input->getArgument('extension');
if (strpos($source, '://'))
{
$tmpPath = $this->handleDownload($output, $source);
}
elseif (is_dir($source))
{
$tmpPath = $this->handleDirectory($output, $source);
}
else
{
$tmpPath = $this->handleArchive($output, $source);
}
return $tmpPath;
}
|
php
|
protected function handleExtension(InputInterface $input, OutputInterface $output)
{
$source = $input->getArgument('extension');
if (strpos($source, '://'))
{
$tmpPath = $this->handleDownload($output, $source);
}
elseif (is_dir($source))
{
$tmpPath = $this->handleDirectory($output, $source);
}
else
{
$tmpPath = $this->handleArchive($output, $source);
}
return $tmpPath;
}
|
[
"protected",
"function",
"handleExtension",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"source",
"=",
"$",
"input",
"->",
"getArgument",
"(",
"'extension'",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"source",
",",
"'://'",
")",
")",
"{",
"$",
"tmpPath",
"=",
"$",
"this",
"->",
"handleDownload",
"(",
"$",
"output",
",",
"$",
"source",
")",
";",
"}",
"elseif",
"(",
"is_dir",
"(",
"$",
"source",
")",
")",
"{",
"$",
"tmpPath",
"=",
"$",
"this",
"->",
"handleDirectory",
"(",
"$",
"output",
",",
"$",
"source",
")",
";",
"}",
"else",
"{",
"$",
"tmpPath",
"=",
"$",
"this",
"->",
"handleArchive",
"(",
"$",
"output",
",",
"$",
"source",
")",
";",
"}",
"return",
"$",
"tmpPath",
";",
"}"
] |
Handle the specified extension
An extension can be provided as a download, a directory, or an archive.
This method prepares the installation by providing the extension in a
temporary directory ready for install.
@param InputInterface $input An InputInterface instance
@param OutputInterface $output An OutputInterface instance
@return string The location of the prepared extension
|
[
"Handle",
"the",
"specified",
"extension",
"An",
"extension",
"can",
"be",
"provided",
"as",
"a",
"download",
"a",
"directory",
"or",
"an",
"archive",
".",
"This",
"method",
"prepares",
"the",
"installation",
"by",
"providing",
"the",
"extension",
"in",
"a",
"temporary",
"directory",
"ready",
"for",
"install",
"."
] |
74a6940f27b1f66c99330d4f9e2c5ac314cdd369
|
https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Commands/Install.php#L108-L126
|
24,458
|
GreenCape/joomla-cli
|
src/GreenCape/JoomlaCLI/Commands/Install.php
|
InstallCommand.getExtensionInfo
|
private function getExtensionInfo($installer)
{
$manifest = $installer->getManifest();
$data = $this->joomla->getExtensionInfo($manifest);
$message = array(
'Installed ' . $data['type'] . ' <info>' . $data['name'] . '</info> version <info>' . $data['version'] . '</info>',
'',
wordwrap($data['description'], 60),
''
);
return $message;
}
|
php
|
private function getExtensionInfo($installer)
{
$manifest = $installer->getManifest();
$data = $this->joomla->getExtensionInfo($manifest);
$message = array(
'Installed ' . $data['type'] . ' <info>' . $data['name'] . '</info> version <info>' . $data['version'] . '</info>',
'',
wordwrap($data['description'], 60),
''
);
return $message;
}
|
[
"private",
"function",
"getExtensionInfo",
"(",
"$",
"installer",
")",
"{",
"$",
"manifest",
"=",
"$",
"installer",
"->",
"getManifest",
"(",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"joomla",
"->",
"getExtensionInfo",
"(",
"$",
"manifest",
")",
";",
"$",
"message",
"=",
"array",
"(",
"'Installed '",
".",
"$",
"data",
"[",
"'type'",
"]",
".",
"' <info>'",
".",
"$",
"data",
"[",
"'name'",
"]",
".",
"'</info> version <info>'",
".",
"$",
"data",
"[",
"'version'",
"]",
".",
"'</info>'",
",",
"''",
",",
"wordwrap",
"(",
"$",
"data",
"[",
"'description'",
"]",
",",
"60",
")",
",",
"''",
")",
";",
"return",
"$",
"message",
";",
"}"
] |
Get information about the installed extension
@param \JInstaller $installer
@return array A message array suitable for OutputInterface::write[ln]
|
[
"Get",
"information",
"about",
"the",
"installed",
"extension"
] |
74a6940f27b1f66c99330d4f9e2c5ac314cdd369
|
https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Commands/Install.php#L135-L148
|
24,459
|
GreenCape/joomla-cli
|
src/GreenCape/JoomlaCLI/Commands/Install.php
|
InstallCommand.handleDownload
|
private function handleDownload(OutputInterface $output, $source)
{
$this->writeln($output, "Downloading $source", OutputInterface::VERBOSITY_VERBOSE);
return $this->unpack(\JInstallerHelper::downloadPackage($source));
}
|
php
|
private function handleDownload(OutputInterface $output, $source)
{
$this->writeln($output, "Downloading $source", OutputInterface::VERBOSITY_VERBOSE);
return $this->unpack(\JInstallerHelper::downloadPackage($source));
}
|
[
"private",
"function",
"handleDownload",
"(",
"OutputInterface",
"$",
"output",
",",
"$",
"source",
")",
"{",
"$",
"this",
"->",
"writeln",
"(",
"$",
"output",
",",
"\"Downloading $source\"",
",",
"OutputInterface",
"::",
"VERBOSITY_VERBOSE",
")",
";",
"return",
"$",
"this",
"->",
"unpack",
"(",
"\\",
"JInstallerHelper",
"::",
"downloadPackage",
"(",
"$",
"source",
")",
")",
";",
"}"
] |
Prepare the installation for an extension specified by a URL
@param OutputInterface $output An OutputInterface instance
@param string $source The extension source
@return string The location of the prepared extension
|
[
"Prepare",
"the",
"installation",
"for",
"an",
"extension",
"specified",
"by",
"a",
"URL"
] |
74a6940f27b1f66c99330d4f9e2c5ac314cdd369
|
https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Commands/Install.php#L158-L163
|
24,460
|
GreenCape/joomla-cli
|
src/GreenCape/JoomlaCLI/Commands/Install.php
|
InstallCommand.handleDirectory
|
private function handleDirectory(OutputInterface $output, $source)
{
$tmpDir = $this->joomla->getCfg('tmp_path');
$tmpPath = $tmpDir . '/' . uniqid('install_');
$this->writeln($output, "Copying $source", OutputInterface::VERBOSITY_VERBOSE);
mkdir($tmpPath);
copy($source, $tmpPath);
return $tmpPath;
}
|
php
|
private function handleDirectory(OutputInterface $output, $source)
{
$tmpDir = $this->joomla->getCfg('tmp_path');
$tmpPath = $tmpDir . '/' . uniqid('install_');
$this->writeln($output, "Copying $source", OutputInterface::VERBOSITY_VERBOSE);
mkdir($tmpPath);
copy($source, $tmpPath);
return $tmpPath;
}
|
[
"private",
"function",
"handleDirectory",
"(",
"OutputInterface",
"$",
"output",
",",
"$",
"source",
")",
"{",
"$",
"tmpDir",
"=",
"$",
"this",
"->",
"joomla",
"->",
"getCfg",
"(",
"'tmp_path'",
")",
";",
"$",
"tmpPath",
"=",
"$",
"tmpDir",
".",
"'/'",
".",
"uniqid",
"(",
"'install_'",
")",
";",
"$",
"this",
"->",
"writeln",
"(",
"$",
"output",
",",
"\"Copying $source\"",
",",
"OutputInterface",
"::",
"VERBOSITY_VERBOSE",
")",
";",
"mkdir",
"(",
"$",
"tmpPath",
")",
";",
"copy",
"(",
"$",
"source",
",",
"$",
"tmpPath",
")",
";",
"return",
"$",
"tmpPath",
";",
"}"
] |
Prepare the installation for an extension specified by a directory
@param OutputInterface $output An OutputInterface instance
@param string $source The extension source
@return string The location of the prepared extension
|
[
"Prepare",
"the",
"installation",
"for",
"an",
"extension",
"specified",
"by",
"a",
"directory"
] |
74a6940f27b1f66c99330d4f9e2c5ac314cdd369
|
https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Commands/Install.php#L173-L183
|
24,461
|
GreenCape/joomla-cli
|
src/GreenCape/JoomlaCLI/Commands/Install.php
|
InstallCommand.handleArchive
|
private function handleArchive(OutputInterface $output, $source)
{
$tmpDir = $this->joomla->getCfg('tmp_path');
$tmpPath = $tmpDir . '/' . basename($source);
$this->writeln($output, "Extracting $source", OutputInterface::VERBOSITY_VERBOSE);
copy($source, $tmpPath);
return $this->unpack($tmpPath);
}
|
php
|
private function handleArchive(OutputInterface $output, $source)
{
$tmpDir = $this->joomla->getCfg('tmp_path');
$tmpPath = $tmpDir . '/' . basename($source);
$this->writeln($output, "Extracting $source", OutputInterface::VERBOSITY_VERBOSE);
copy($source, $tmpPath);
return $this->unpack($tmpPath);
}
|
[
"private",
"function",
"handleArchive",
"(",
"OutputInterface",
"$",
"output",
",",
"$",
"source",
")",
"{",
"$",
"tmpDir",
"=",
"$",
"this",
"->",
"joomla",
"->",
"getCfg",
"(",
"'tmp_path'",
")",
";",
"$",
"tmpPath",
"=",
"$",
"tmpDir",
".",
"'/'",
".",
"basename",
"(",
"$",
"source",
")",
";",
"$",
"this",
"->",
"writeln",
"(",
"$",
"output",
",",
"\"Extracting $source\"",
",",
"OutputInterface",
"::",
"VERBOSITY_VERBOSE",
")",
";",
"copy",
"(",
"$",
"source",
",",
"$",
"tmpPath",
")",
";",
"return",
"$",
"this",
"->",
"unpack",
"(",
"$",
"tmpPath",
")",
";",
"}"
] |
Prepare the installation for an extension in an archive
@param OutputInterface $output An OutputInterface instance
@param string $source The extension source
@return string The location of the prepared extension
|
[
"Prepare",
"the",
"installation",
"for",
"an",
"extension",
"in",
"an",
"archive"
] |
74a6940f27b1f66c99330d4f9e2c5ac314cdd369
|
https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Commands/Install.php#L193-L202
|
24,462
|
thelia-modules/CustomerGroup
|
Model/Base/CustomerCustomerGroup.php
|
CustomerCustomerGroup.setCustomer
|
public function setCustomer(ChildCustomer $v = null)
{
if ($v === null) {
$this->setCustomerId(NULL);
} else {
$this->setCustomerId($v->getId());
}
$this->aCustomer = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildCustomer object, it will not be re-added.
if ($v !== null) {
$v->addCustomerCustomerGroup($this);
}
return $this;
}
|
php
|
public function setCustomer(ChildCustomer $v = null)
{
if ($v === null) {
$this->setCustomerId(NULL);
} else {
$this->setCustomerId($v->getId());
}
$this->aCustomer = $v;
// Add binding for other direction of this n:n relationship.
// If this object has already been added to the ChildCustomer object, it will not be re-added.
if ($v !== null) {
$v->addCustomerCustomerGroup($this);
}
return $this;
}
|
[
"public",
"function",
"setCustomer",
"(",
"ChildCustomer",
"$",
"v",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"v",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setCustomerId",
"(",
"NULL",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setCustomerId",
"(",
"$",
"v",
"->",
"getId",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"aCustomer",
"=",
"$",
"v",
";",
"// Add binding for other direction of this n:n relationship.",
"// If this object has already been added to the ChildCustomer object, it will not be re-added.",
"if",
"(",
"$",
"v",
"!==",
"null",
")",
"{",
"$",
"v",
"->",
"addCustomerCustomerGroup",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Declares an association between this object and a ChildCustomer object.
@param ChildCustomer $v
@return \CustomerGroup\Model\CustomerCustomerGroup The current object (for fluent API support)
@throws PropelException
|
[
"Declares",
"an",
"association",
"between",
"this",
"object",
"and",
"a",
"ChildCustomer",
"object",
"."
] |
672cc64c686812f6a95cf0d702111f93d8c0e850
|
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroup.php#L1013-L1031
|
24,463
|
thelia-modules/CustomerGroup
|
Model/Base/CustomerCustomerGroup.php
|
CustomerCustomerGroup.getCustomer
|
public function getCustomer(ConnectionInterface $con = null)
{
if ($this->aCustomer === null && ($this->customer_id !== null)) {
$this->aCustomer = CustomerQuery::create()->findPk($this->customer_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aCustomer->addCustomerCustomerGroups($this);
*/
}
return $this->aCustomer;
}
|
php
|
public function getCustomer(ConnectionInterface $con = null)
{
if ($this->aCustomer === null && ($this->customer_id !== null)) {
$this->aCustomer = CustomerQuery::create()->findPk($this->customer_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aCustomer->addCustomerCustomerGroups($this);
*/
}
return $this->aCustomer;
}
|
[
"public",
"function",
"getCustomer",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"aCustomer",
"===",
"null",
"&&",
"(",
"$",
"this",
"->",
"customer_id",
"!==",
"null",
")",
")",
"{",
"$",
"this",
"->",
"aCustomer",
"=",
"CustomerQuery",
"::",
"create",
"(",
")",
"->",
"findPk",
"(",
"$",
"this",
"->",
"customer_id",
",",
"$",
"con",
")",
";",
"/* The following can be used additionally to\n guarantee the related object contains a reference\n to this object. This level of coupling may, however, be\n undesirable since it could result in an only partially populated collection\n in the referenced object.\n $this->aCustomer->addCustomerCustomerGroups($this);\n */",
"}",
"return",
"$",
"this",
"->",
"aCustomer",
";",
"}"
] |
Get the associated ChildCustomer object
@param ConnectionInterface $con Optional Connection object.
@return ChildCustomer The associated ChildCustomer object.
@throws PropelException
|
[
"Get",
"the",
"associated",
"ChildCustomer",
"object"
] |
672cc64c686812f6a95cf0d702111f93d8c0e850
|
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerCustomerGroup.php#L1041-L1055
|
24,464
|
skmetaly/laravel-twitch-restful-api
|
src/API/Follow.php
|
Follow.userFollowsChannels
|
public function userFollowsChannels($user, $options = [])
{
$availableOptions = ['limit', 'offset', 'direction', 'sortby'];
// Filter the available options
foreach ($availableOptions as $option) {
if (isset($options[ $option ])) {
$options[ $option ] = $options[ $option ];
}
}
$url = 'kraken/users/' . $user . '/follows/channels';
$response = $this->client->get($url, ['body' => $options]);
return $response->json();
}
|
php
|
public function userFollowsChannels($user, $options = [])
{
$availableOptions = ['limit', 'offset', 'direction', 'sortby'];
// Filter the available options
foreach ($availableOptions as $option) {
if (isset($options[ $option ])) {
$options[ $option ] = $options[ $option ];
}
}
$url = 'kraken/users/' . $user . '/follows/channels';
$response = $this->client->get($url, ['body' => $options]);
return $response->json();
}
|
[
"public",
"function",
"userFollowsChannels",
"(",
"$",
"user",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"availableOptions",
"=",
"[",
"'limit'",
",",
"'offset'",
",",
"'direction'",
",",
"'sortby'",
"]",
";",
"// Filter the available options",
"foreach",
"(",
"$",
"availableOptions",
"as",
"$",
"option",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"$",
"option",
"]",
")",
")",
"{",
"$",
"options",
"[",
"$",
"option",
"]",
"=",
"$",
"options",
"[",
"$",
"option",
"]",
";",
"}",
"}",
"$",
"url",
"=",
"'kraken/users/'",
".",
"$",
"user",
".",
"'/follows/channels'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"url",
",",
"[",
"'body'",
"=>",
"$",
"options",
"]",
")",
";",
"return",
"$",
"response",
"->",
"json",
"(",
")",
";",
"}"
] |
Returns a list of follows objects.
Parameters
Name Required? Type Description
limit optional integer Maximum number of objects in array. Default is 25. Maximum is 100.
offset optional integer Object offset for pagination. Default is 0.
direction optional string Sorting direction. Default is desc. Valid values are asc and desc.
sortby optional string Sort key. Default is created_at. Valid values are created_at and last_broadcast.
@param $user
@param array $options
@return mixed
|
[
"Returns",
"a",
"list",
"of",
"follows",
"objects",
".",
"Parameters",
"Name",
"Required?",
"Type",
"Description",
"limit",
"optional",
"integer",
"Maximum",
"number",
"of",
"objects",
"in",
"array",
".",
"Default",
"is",
"25",
".",
"Maximum",
"is",
"100",
".",
"offset",
"optional",
"integer",
"Object",
"offset",
"for",
"pagination",
".",
"Default",
"is",
"0",
".",
"direction",
"optional",
"string",
"Sorting",
"direction",
".",
"Default",
"is",
"desc",
".",
"Valid",
"values",
"are",
"asc",
"and",
"desc",
".",
"sortby",
"optional",
"string",
"Sort",
"key",
".",
"Default",
"is",
"created_at",
".",
"Valid",
"values",
"are",
"created_at",
"and",
"last_broadcast",
"."
] |
70c83e441deb411ade2e343ad5cb0339c90dc6c2
|
https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Follow.php#L65-L83
|
24,465
|
GrupaZero/api
|
src/Gzero/Api/Controller/Admin/FileController.php
|
FileController.destroy
|
public function destroy($id)
{
$file = $this->fileRepo->getById($id);
if (!empty($file)) {
$this->authorize('delete', $file);
$this->fileRepo->delete($file);
return $this->respondWithSimpleSuccess(['success' => true]);
}
return $this->respondNotFound();
}
|
php
|
public function destroy($id)
{
$file = $this->fileRepo->getById($id);
if (!empty($file)) {
$this->authorize('delete', $file);
$this->fileRepo->delete($file);
return $this->respondWithSimpleSuccess(['success' => true]);
}
return $this->respondNotFound();
}
|
[
"public",
"function",
"destroy",
"(",
"$",
"id",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"fileRepo",
"->",
"getById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'delete'",
",",
"$",
"file",
")",
";",
"$",
"this",
"->",
"fileRepo",
"->",
"delete",
"(",
"$",
"file",
")",
";",
"return",
"$",
"this",
"->",
"respondWithSimpleSuccess",
"(",
"[",
"'success'",
"=>",
"true",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"respondNotFound",
"(",
")",
";",
"}"
] |
Remove the specified file from database.
@param int $id Id of the file
@return \Illuminate\Http\JsonResponse
|
[
"Remove",
"the",
"specified",
"file",
"from",
"database",
"."
] |
fc544bb6057274e9d5e7b617346c3f854ea5effd
|
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/FileController.php#L122-L132
|
24,466
|
wolfguarder/yii2-block
|
controllers/AdminController.php
|
AdminController.actionIndex
|
public function actionIndex()
{
$searchModel = $this->module->manager->createBlockSearch();
$dataProvider = $searchModel->search($_GET);
return $this->render('index', [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
]);
}
|
php
|
public function actionIndex()
{
$searchModel = $this->module->manager->createBlockSearch();
$dataProvider = $searchModel->search($_GET);
return $this->render('index', [
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
]);
}
|
[
"public",
"function",
"actionIndex",
"(",
")",
"{",
"$",
"searchModel",
"=",
"$",
"this",
"->",
"module",
"->",
"manager",
"->",
"createBlockSearch",
"(",
")",
";",
"$",
"dataProvider",
"=",
"$",
"searchModel",
"->",
"search",
"(",
"$",
"_GET",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"'index'",
",",
"[",
"'dataProvider'",
"=>",
"$",
"dataProvider",
",",
"'searchModel'",
"=>",
"$",
"searchModel",
",",
"]",
")",
";",
"}"
] |
Lists all Block models.
@return mixed
|
[
"Lists",
"all",
"Block",
"models",
"."
] |
b8f657a572eb5182584161acc2cfd77b20ab7680
|
https://github.com/wolfguarder/yii2-block/blob/b8f657a572eb5182584161acc2cfd77b20ab7680/controllers/AdminController.php#L48-L57
|
24,467
|
wolfguarder/yii2-block
|
controllers/AdminController.php
|
AdminController.actionCreate
|
public function actionCreate()
{
$model = $this->module->manager->createBlock(['scenario' => 'create']);
if ($model->load(\Yii::$app->request->post()) && $model->create()) {
\Yii::$app->getSession()->setFlash('block.success', \Yii::t('block', 'Block has been created'));
return $this->redirect(['index']);
}
return $this->render('create', [
'model' => $model
]);
}
|
php
|
public function actionCreate()
{
$model = $this->module->manager->createBlock(['scenario' => 'create']);
if ($model->load(\Yii::$app->request->post()) && $model->create()) {
\Yii::$app->getSession()->setFlash('block.success', \Yii::t('block', 'Block has been created'));
return $this->redirect(['index']);
}
return $this->render('create', [
'model' => $model
]);
}
|
[
"public",
"function",
"actionCreate",
"(",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"module",
"->",
"manager",
"->",
"createBlock",
"(",
"[",
"'scenario'",
"=>",
"'create'",
"]",
")",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"model",
"->",
"create",
"(",
")",
")",
"{",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"getSession",
"(",
")",
"->",
"setFlash",
"(",
"'block.success'",
",",
"\\",
"Yii",
"::",
"t",
"(",
"'block'",
",",
"'Block has been created'",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"[",
"'index'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'create'",
",",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}"
] |
Creates a new Block model.
If creation is successful, the browser will be redirected to the 'index' page.
@return mixed
|
[
"Creates",
"a",
"new",
"Block",
"model",
".",
"If",
"creation",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"index",
"page",
"."
] |
b8f657a572eb5182584161acc2cfd77b20ab7680
|
https://github.com/wolfguarder/yii2-block/blob/b8f657a572eb5182584161acc2cfd77b20ab7680/controllers/AdminController.php#L64-L76
|
24,468
|
wolfguarder/yii2-block
|
controllers/AdminController.php
|
AdminController.actionUpdate
|
public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->scenario = 'update';
if ($model->load(\Yii::$app->request->post()) && $model->save()) {
if(\Yii::$app->request->get('returnUrl')){
$back = urldecode(\Yii::$app->request->get('returnUrl'));
return $this->redirect($back);
}
\Yii::$app->getSession()->setFlash('block.success', \Yii::t('block', 'Block has been updated'));
return $this->refresh();
}
return $this->render('update', [
'model' => $model
]);
}
|
php
|
public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->scenario = 'update';
if ($model->load(\Yii::$app->request->post()) && $model->save()) {
if(\Yii::$app->request->get('returnUrl')){
$back = urldecode(\Yii::$app->request->get('returnUrl'));
return $this->redirect($back);
}
\Yii::$app->getSession()->setFlash('block.success', \Yii::t('block', 'Block has been updated'));
return $this->refresh();
}
return $this->render('update', [
'model' => $model
]);
}
|
[
"public",
"function",
"actionUpdate",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"findModel",
"(",
"$",
"id",
")",
";",
"$",
"model",
"->",
"scenario",
"=",
"'update'",
";",
"if",
"(",
"$",
"model",
"->",
"load",
"(",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"post",
"(",
")",
")",
"&&",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"if",
"(",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"get",
"(",
"'returnUrl'",
")",
")",
"{",
"$",
"back",
"=",
"urldecode",
"(",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"get",
"(",
"'returnUrl'",
")",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"back",
")",
";",
"}",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"getSession",
"(",
")",
"->",
"setFlash",
"(",
"'block.success'",
",",
"\\",
"Yii",
"::",
"t",
"(",
"'block'",
",",
"'Block has been updated'",
")",
")",
";",
"return",
"$",
"this",
"->",
"refresh",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"'update'",
",",
"[",
"'model'",
"=>",
"$",
"model",
"]",
")",
";",
"}"
] |
Updates an existing Block model.
If update is successful, the browser will be redirected to the 'index' page.
@param integer $id
@return mixed
|
[
"Updates",
"an",
"existing",
"Block",
"model",
".",
"If",
"update",
"is",
"successful",
"the",
"browser",
"will",
"be",
"redirected",
"to",
"the",
"index",
"page",
"."
] |
b8f657a572eb5182584161acc2cfd77b20ab7680
|
https://github.com/wolfguarder/yii2-block/blob/b8f657a572eb5182584161acc2cfd77b20ab7680/controllers/AdminController.php#L84-L102
|
24,469
|
thupan/framework
|
src/Service/PDF.php
|
PDF.array_sum_interval
|
function array_sum_interval($array_external, $interval){
$n_interval=explode(":", $interval);
$sum = 0;
for($i=$n_interval[0]; $i < ($n_interval[1]+1) ; $i++){
$sum += $array_external[$i];
}
return $sum;
}
|
php
|
function array_sum_interval($array_external, $interval){
$n_interval=explode(":", $interval);
$sum = 0;
for($i=$n_interval[0]; $i < ($n_interval[1]+1) ; $i++){
$sum += $array_external[$i];
}
return $sum;
}
|
[
"function",
"array_sum_interval",
"(",
"$",
"array_external",
",",
"$",
"interval",
")",
"{",
"$",
"n_interval",
"=",
"explode",
"(",
"\":\"",
",",
"$",
"interval",
")",
";",
"$",
"sum",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"n_interval",
"[",
"0",
"]",
";",
"$",
"i",
"<",
"(",
"$",
"n_interval",
"[",
"1",
"]",
"+",
"1",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"sum",
"+=",
"$",
"array_external",
"[",
"$",
"i",
"]",
";",
"}",
"return",
"$",
"sum",
";",
"}"
] |
Function for sum intervals of an array
|
[
"Function",
"for",
"sum",
"intervals",
"of",
"an",
"array"
] |
43193c67e87942930fb0cbc53aa069b60b27e749
|
https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/PDF.php#L531-L540
|
24,470
|
thupan/framework
|
src/Service/PDF.php
|
PDF.array_sum_intervals
|
function array_sum_intervals($array_external, $intervals){
$n_intervals=explode(";", $intervals);
$array_amount = count($n_intervals);
$result = 0;
for($i=0; $i < $array_amount ; $i++){
$result += $this->array_sum_interval($array_external, $n_intervals[$i]);
}
return $result;
}
|
php
|
function array_sum_intervals($array_external, $intervals){
$n_intervals=explode(";", $intervals);
$array_amount = count($n_intervals);
$result = 0;
for($i=0; $i < $array_amount ; $i++){
$result += $this->array_sum_interval($array_external, $n_intervals[$i]);
}
return $result;
}
|
[
"function",
"array_sum_intervals",
"(",
"$",
"array_external",
",",
"$",
"intervals",
")",
"{",
"$",
"n_intervals",
"=",
"explode",
"(",
"\";\"",
",",
"$",
"intervals",
")",
";",
"$",
"array_amount",
"=",
"count",
"(",
"$",
"n_intervals",
")",
";",
"$",
"result",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"array_amount",
";",
"$",
"i",
"++",
")",
"{",
"$",
"result",
"+=",
"$",
"this",
"->",
"array_sum_interval",
"(",
"$",
"array_external",
",",
"$",
"n_intervals",
"[",
"$",
"i",
"]",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Function for sum a interval of an array
|
[
"Function",
"for",
"sum",
"a",
"interval",
"of",
"an",
"array"
] |
43193c67e87942930fb0cbc53aa069b60b27e749
|
https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/PDF.php#L542-L552
|
24,471
|
thupan/framework
|
src/Service/PDF.php
|
PDF.flipDiagonally
|
function flipDiagonally($arr)
{
$out = array();
foreach ($arr as $key => $subarr) {
foreach ($subarr as $subkey => $subvalue) {
$out[$subkey][$key] = $subvalue;
}
}
return $out;
}
|
php
|
function flipDiagonally($arr)
{
$out = array();
foreach ($arr as $key => $subarr) {
foreach ($subarr as $subkey => $subvalue) {
$out[$subkey][$key] = $subvalue;
}
}
return $out;
}
|
[
"function",
"flipDiagonally",
"(",
"$",
"arr",
")",
"{",
"$",
"out",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"key",
"=>",
"$",
"subarr",
")",
"{",
"foreach",
"(",
"$",
"subarr",
"as",
"$",
"subkey",
"=>",
"$",
"subvalue",
")",
"{",
"$",
"out",
"[",
"$",
"subkey",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"subvalue",
";",
"}",
"}",
"return",
"$",
"out",
";",
"}"
] |
Matriz Transposta - transforma array dados de linhas em colunas
|
[
"Matriz",
"Transposta",
"-",
"transforma",
"array",
"dados",
"de",
"linhas",
"em",
"colunas"
] |
43193c67e87942930fb0cbc53aa069b60b27e749
|
https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/PDF.php#L555-L564
|
24,472
|
thupan/framework
|
src/Service/PDF.php
|
PDF.ImagePngWithAlpha
|
function ImagePngWithAlpha($file, $x, $y, $w=0, $h=0, $link='')
{
$tmp_alpha = tempnam('.', 'mska');
$this->tmpFiles[] = $tmp_alpha;
$tmp_plain = tempnam('.', 'mskp');
$this->tmpFiles[] = $tmp_plain;
list($wpx, $hpx) = getimagesize($file);
$img = imagecreatefrompng($file);
$alpha_img = imagecreate( $wpx, $hpx );
// generate gray scale pallete
for($c=0;$c<256;$c++) ImageColorAllocate($alpha_img, $c, $c, $c);
// extract alpha channel
$xpx=0;
while ($xpx<$wpx){
$ypx = 0;
while ($ypx<$hpx){
$color_index = imagecolorat($img, $xpx, $ypx);
$alpha = 255-($color_index>>24)*255/127; // GD alpha component: 7 bit only, 0..127!
imagesetpixel($alpha_img, $xpx, $ypx, $alpha);
++$ypx;
}
++$xpx;
}
imagepng($alpha_img, $tmp_alpha);
imagedestroy($alpha_img);
// extract image without alpha channel
$plain_img = imagecreatetruecolor ( $wpx, $hpx );
imagecopy ($plain_img, $img, 0, 0, 0, 0, $wpx, $hpx );
imagepng($plain_img, $tmp_plain);
imagedestroy($plain_img);
//first embed mask image (w, h, x, will be ignored)
$maskImg = $this->Image($tmp_alpha, 0, 0, 0, 0, 'PNG', '', true);
//embed image, masked with previously embedded mask
$this->Image($tmp_plain, $x, $y, $w, $h, 'PNG', $link, false, $maskImg);
}
|
php
|
function ImagePngWithAlpha($file, $x, $y, $w=0, $h=0, $link='')
{
$tmp_alpha = tempnam('.', 'mska');
$this->tmpFiles[] = $tmp_alpha;
$tmp_plain = tempnam('.', 'mskp');
$this->tmpFiles[] = $tmp_plain;
list($wpx, $hpx) = getimagesize($file);
$img = imagecreatefrompng($file);
$alpha_img = imagecreate( $wpx, $hpx );
// generate gray scale pallete
for($c=0;$c<256;$c++) ImageColorAllocate($alpha_img, $c, $c, $c);
// extract alpha channel
$xpx=0;
while ($xpx<$wpx){
$ypx = 0;
while ($ypx<$hpx){
$color_index = imagecolorat($img, $xpx, $ypx);
$alpha = 255-($color_index>>24)*255/127; // GD alpha component: 7 bit only, 0..127!
imagesetpixel($alpha_img, $xpx, $ypx, $alpha);
++$ypx;
}
++$xpx;
}
imagepng($alpha_img, $tmp_alpha);
imagedestroy($alpha_img);
// extract image without alpha channel
$plain_img = imagecreatetruecolor ( $wpx, $hpx );
imagecopy ($plain_img, $img, 0, 0, 0, 0, $wpx, $hpx );
imagepng($plain_img, $tmp_plain);
imagedestroy($plain_img);
//first embed mask image (w, h, x, will be ignored)
$maskImg = $this->Image($tmp_alpha, 0, 0, 0, 0, 'PNG', '', true);
//embed image, masked with previously embedded mask
$this->Image($tmp_plain, $x, $y, $w, $h, 'PNG', $link, false, $maskImg);
}
|
[
"function",
"ImagePngWithAlpha",
"(",
"$",
"file",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"w",
"=",
"0",
",",
"$",
"h",
"=",
"0",
",",
"$",
"link",
"=",
"''",
")",
"{",
"$",
"tmp_alpha",
"=",
"tempnam",
"(",
"'.'",
",",
"'mska'",
")",
";",
"$",
"this",
"->",
"tmpFiles",
"[",
"]",
"=",
"$",
"tmp_alpha",
";",
"$",
"tmp_plain",
"=",
"tempnam",
"(",
"'.'",
",",
"'mskp'",
")",
";",
"$",
"this",
"->",
"tmpFiles",
"[",
"]",
"=",
"$",
"tmp_plain",
";",
"list",
"(",
"$",
"wpx",
",",
"$",
"hpx",
")",
"=",
"getimagesize",
"(",
"$",
"file",
")",
";",
"$",
"img",
"=",
"imagecreatefrompng",
"(",
"$",
"file",
")",
";",
"$",
"alpha_img",
"=",
"imagecreate",
"(",
"$",
"wpx",
",",
"$",
"hpx",
")",
";",
"// generate gray scale pallete",
"for",
"(",
"$",
"c",
"=",
"0",
";",
"$",
"c",
"<",
"256",
";",
"$",
"c",
"++",
")",
"ImageColorAllocate",
"(",
"$",
"alpha_img",
",",
"$",
"c",
",",
"$",
"c",
",",
"$",
"c",
")",
";",
"// extract alpha channel",
"$",
"xpx",
"=",
"0",
";",
"while",
"(",
"$",
"xpx",
"<",
"$",
"wpx",
")",
"{",
"$",
"ypx",
"=",
"0",
";",
"while",
"(",
"$",
"ypx",
"<",
"$",
"hpx",
")",
"{",
"$",
"color_index",
"=",
"imagecolorat",
"(",
"$",
"img",
",",
"$",
"xpx",
",",
"$",
"ypx",
")",
";",
"$",
"alpha",
"=",
"255",
"-",
"(",
"$",
"color_index",
">>",
"24",
")",
"*",
"255",
"/",
"127",
";",
"// GD alpha component: 7 bit only, 0..127!",
"imagesetpixel",
"(",
"$",
"alpha_img",
",",
"$",
"xpx",
",",
"$",
"ypx",
",",
"$",
"alpha",
")",
";",
"++",
"$",
"ypx",
";",
"}",
"++",
"$",
"xpx",
";",
"}",
"imagepng",
"(",
"$",
"alpha_img",
",",
"$",
"tmp_alpha",
")",
";",
"imagedestroy",
"(",
"$",
"alpha_img",
")",
";",
"// extract image without alpha channel",
"$",
"plain_img",
"=",
"imagecreatetruecolor",
"(",
"$",
"wpx",
",",
"$",
"hpx",
")",
";",
"imagecopy",
"(",
"$",
"plain_img",
",",
"$",
"img",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"wpx",
",",
"$",
"hpx",
")",
";",
"imagepng",
"(",
"$",
"plain_img",
",",
"$",
"tmp_plain",
")",
";",
"imagedestroy",
"(",
"$",
"plain_img",
")",
";",
"//first embed mask image (w, h, x, will be ignored)",
"$",
"maskImg",
"=",
"$",
"this",
"->",
"Image",
"(",
"$",
"tmp_alpha",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"'PNG'",
",",
"''",
",",
"true",
")",
";",
"//embed image, masked with previously embedded mask",
"$",
"this",
"->",
"Image",
"(",
"$",
"tmp_plain",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"w",
",",
"$",
"h",
",",
"'PNG'",
",",
"$",
"link",
",",
"false",
",",
"$",
"maskImg",
")",
";",
"}"
] |
pixel-wise operation, not very fast
|
[
"pixel",
"-",
"wise",
"operation",
"not",
"very",
"fast"
] |
43193c67e87942930fb0cbc53aa069b60b27e749
|
https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Service/PDF.php#L674-L715
|
24,473
|
weew/http
|
src/Weew/Http/HttpResponse.php
|
HttpResponse.extend
|
public function extend(IHttpResponse $response) {
$this->setHeaders(clone($response->getHeaders()));
$this->setProtocol($response->getProtocol());
$this->setProtocolVersion($response->getProtocolVersion());
$this->setStatusCode($response->getStatusCode());
$this->setContent($response->getContent());
$this->setCookies(clone($response->getCookies()));
$this->setDefaultContentType();
}
|
php
|
public function extend(IHttpResponse $response) {
$this->setHeaders(clone($response->getHeaders()));
$this->setProtocol($response->getProtocol());
$this->setProtocolVersion($response->getProtocolVersion());
$this->setStatusCode($response->getStatusCode());
$this->setContent($response->getContent());
$this->setCookies(clone($response->getCookies()));
$this->setDefaultContentType();
}
|
[
"public",
"function",
"extend",
"(",
"IHttpResponse",
"$",
"response",
")",
"{",
"$",
"this",
"->",
"setHeaders",
"(",
"clone",
"(",
"$",
"response",
"->",
"getHeaders",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"setProtocol",
"(",
"$",
"response",
"->",
"getProtocol",
"(",
")",
")",
";",
"$",
"this",
"->",
"setProtocolVersion",
"(",
"$",
"response",
"->",
"getProtocolVersion",
"(",
")",
")",
";",
"$",
"this",
"->",
"setStatusCode",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
")",
";",
"$",
"this",
"->",
"setContent",
"(",
"$",
"response",
"->",
"getContent",
"(",
")",
")",
";",
"$",
"this",
"->",
"setCookies",
"(",
"clone",
"(",
"$",
"response",
"->",
"getCookies",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"setDefaultContentType",
"(",
")",
";",
"}"
] |
Extend current response with another.
@param IHttpResponse $response
|
[
"Extend",
"current",
"response",
"with",
"another",
"."
] |
fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d
|
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/HttpResponse.php#L311-L320
|
24,474
|
raideer/twitch-api
|
src/Resources/Search.php
|
Search.searchStreams
|
public function searchStreams($query, $params = [])
{
$defaults = [
'query' => urlencode($query),
'limit' => 25,
'offset' => 0,
'hls' => null,
];
return $this->wrapper->request('GET', 'search/streams', ['query' => $this->resolveOptions($params, $defaults)]);
}
|
php
|
public function searchStreams($query, $params = [])
{
$defaults = [
'query' => urlencode($query),
'limit' => 25,
'offset' => 0,
'hls' => null,
];
return $this->wrapper->request('GET', 'search/streams', ['query' => $this->resolveOptions($params, $defaults)]);
}
|
[
"public",
"function",
"searchStreams",
"(",
"$",
"query",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'query'",
"=>",
"urlencode",
"(",
"$",
"query",
")",
",",
"'limit'",
"=>",
"25",
",",
"'offset'",
"=>",
"0",
",",
"'hls'",
"=>",
"null",
",",
"]",
";",
"return",
"$",
"this",
"->",
"wrapper",
"->",
"request",
"(",
"'GET'",
",",
"'search/streams'",
",",
"[",
"'query'",
"=>",
"$",
"this",
"->",
"resolveOptions",
"(",
"$",
"params",
",",
"$",
"defaults",
")",
"]",
")",
";",
"}"
] |
Returns a list of stream objects matching the search query.
Learn more:
https://github.com/justintv/Twitch-API/blob/master/v3_resources/search.md#get-searchstreams
@param string $query Search query
@param array $params Optional params
@return array
|
[
"Returns",
"a",
"list",
"of",
"stream",
"objects",
"matching",
"the",
"search",
"query",
"."
] |
27ebf1dcb0315206300d507600b6a82ebe33d57e
|
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Search.php#L53-L63
|
24,475
|
raideer/twitch-api
|
src/Resources/Search.php
|
Search.searchGames
|
public function searchGames($query, $params = [])
{
$defaults = [
'query' => urlencode($query),
'limit' => 25,
'type' => 'suggest',
'live' => false,
];
return $this->wrapper->request('GET', 'search/games', ['query' => $this->resolveOptions($params, $defaults)]);
}
|
php
|
public function searchGames($query, $params = [])
{
$defaults = [
'query' => urlencode($query),
'limit' => 25,
'type' => 'suggest',
'live' => false,
];
return $this->wrapper->request('GET', 'search/games', ['query' => $this->resolveOptions($params, $defaults)]);
}
|
[
"public",
"function",
"searchGames",
"(",
"$",
"query",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'query'",
"=>",
"urlencode",
"(",
"$",
"query",
")",
",",
"'limit'",
"=>",
"25",
",",
"'type'",
"=>",
"'suggest'",
",",
"'live'",
"=>",
"false",
",",
"]",
";",
"return",
"$",
"this",
"->",
"wrapper",
"->",
"request",
"(",
"'GET'",
",",
"'search/games'",
",",
"[",
"'query'",
"=>",
"$",
"this",
"->",
"resolveOptions",
"(",
"$",
"params",
",",
"$",
"defaults",
")",
"]",
")",
";",
"}"
] |
Returns a list of game objects matching the search query.
Learn more:
https://github.com/justintv/Twitch-API/blob/master/v3_resources/search.md#get-searchgames
@param string $query Search query
@param array $params Optional params
@return array
|
[
"Returns",
"a",
"list",
"of",
"game",
"objects",
"matching",
"the",
"search",
"query",
"."
] |
27ebf1dcb0315206300d507600b6a82ebe33d57e
|
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Search.php#L76-L86
|
24,476
|
ekuiter/feature-php
|
FeaturePhp/Exporter/ZipExporter.php
|
ZipExporter.open
|
private function open() {
if (file_exists($this->target) && !unlink($this->target))
throw new ZipExporterException("could not remove existing zip archive at \"$this->target\"");
$zip = new \ZipArchive();
if (!$zip->open($this->target, \ZipArchive::CREATE))
throw new ZipExporterException("could not create zip archive at \"$this->target\"");
return $zip;
}
|
php
|
private function open() {
if (file_exists($this->target) && !unlink($this->target))
throw new ZipExporterException("could not remove existing zip archive at \"$this->target\"");
$zip = new \ZipArchive();
if (!$zip->open($this->target, \ZipArchive::CREATE))
throw new ZipExporterException("could not create zip archive at \"$this->target\"");
return $zip;
}
|
[
"private",
"function",
"open",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"target",
")",
"&&",
"!",
"unlink",
"(",
"$",
"this",
"->",
"target",
")",
")",
"throw",
"new",
"ZipExporterException",
"(",
"\"could not remove existing zip archive at \\\"$this->target\\\"\"",
")",
";",
"$",
"zip",
"=",
"new",
"\\",
"ZipArchive",
"(",
")",
";",
"if",
"(",
"!",
"$",
"zip",
"->",
"open",
"(",
"$",
"this",
"->",
"target",
",",
"\\",
"ZipArchive",
"::",
"CREATE",
")",
")",
"throw",
"new",
"ZipExporterException",
"(",
"\"could not create zip archive at \\\"$this->target\\\"\"",
")",
";",
"return",
"$",
"zip",
";",
"}"
] |
Opens and returns the targeted ZIP archive.
@return \ZipArchive
|
[
"Opens",
"and",
"returns",
"the",
"targeted",
"ZIP",
"archive",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Exporter/ZipExporter.php#L41-L49
|
24,477
|
ekuiter/feature-php
|
FeaturePhp/Exporter/ZipExporter.php
|
ZipExporter.export
|
public function export($product) {
$productLineName = $product->getProductLine()->getName();
$files = $product->generateFiles();
$zip = $this->open();
if (count($files) === 0)
$files[] = new fphp\File\TextFile("NOTICE", "No files were generated.");
foreach ($files as $file)
if (!$file->getContent()->addToZip($zip, fphp\Helper\Path::join($productLineName, $file->getTarget())))
throw new ZipExporterException("could not add file to zip archive at \"$this->target\"");
$this->close($zip);
}
|
php
|
public function export($product) {
$productLineName = $product->getProductLine()->getName();
$files = $product->generateFiles();
$zip = $this->open();
if (count($files) === 0)
$files[] = new fphp\File\TextFile("NOTICE", "No files were generated.");
foreach ($files as $file)
if (!$file->getContent()->addToZip($zip, fphp\Helper\Path::join($productLineName, $file->getTarget())))
throw new ZipExporterException("could not add file to zip archive at \"$this->target\"");
$this->close($zip);
}
|
[
"public",
"function",
"export",
"(",
"$",
"product",
")",
"{",
"$",
"productLineName",
"=",
"$",
"product",
"->",
"getProductLine",
"(",
")",
"->",
"getName",
"(",
")",
";",
"$",
"files",
"=",
"$",
"product",
"->",
"generateFiles",
"(",
")",
";",
"$",
"zip",
"=",
"$",
"this",
"->",
"open",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"files",
")",
"===",
"0",
")",
"$",
"files",
"[",
"]",
"=",
"new",
"fphp",
"\\",
"File",
"\\",
"TextFile",
"(",
"\"NOTICE\"",
",",
"\"No files were generated.\"",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"if",
"(",
"!",
"$",
"file",
"->",
"getContent",
"(",
")",
"->",
"addToZip",
"(",
"$",
"zip",
",",
"fphp",
"\\",
"Helper",
"\\",
"Path",
"::",
"join",
"(",
"$",
"productLineName",
",",
"$",
"file",
"->",
"getTarget",
"(",
")",
")",
")",
")",
"throw",
"new",
"ZipExporterException",
"(",
"\"could not add file to zip archive at \\\"$this->target\\\"\"",
")",
";",
"$",
"this",
"->",
"close",
"(",
"$",
"zip",
")",
";",
"}"
] |
Exports a product as a ZIP archive.
Every generated file is added to the archive at its target path. If there are no files,
a NOTICE file is generated because \ZipArchive does not support saving an empty ZIP archive.
The archive's root directory has the product line's name.
@param \FeaturePhp\ProductLine\Product $product
|
[
"Exports",
"a",
"product",
"as",
"a",
"ZIP",
"archive",
".",
"Every",
"generated",
"file",
"is",
"added",
"to",
"the",
"archive",
"at",
"its",
"target",
"path",
".",
"If",
"there",
"are",
"no",
"files",
"a",
"NOTICE",
"file",
"is",
"generated",
"because",
"\\",
"ZipArchive",
"does",
"not",
"support",
"saving",
"an",
"empty",
"ZIP",
"archive",
".",
"The",
"archive",
"s",
"root",
"directory",
"has",
"the",
"product",
"line",
"s",
"name",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Exporter/ZipExporter.php#L67-L80
|
24,478
|
frdl/webfan
|
.ApplicationComposer/lib/frdl/webfan/Autoloading/SourceLoader.php
|
SourceLoader.addPsr0
|
public function addPsr0($prefix, $base_dir, $prepend = false)
{
$prefix = trim($prefix, '\\') . '\\';
$base_dir = rtrim($base_dir, self::DS) . self::DS;
if(isset($this->autoloadersPsr0[$prefix]) === false) {
$this->autoloadersPsr0[$prefix] = array();
}
if($prepend) {
array_unshift($this->autoloadersPsr0[$prefix], $base_dir);
} else {
array_push($this->autoloadersPsr0[$prefix], $base_dir);
}
return $this;
}
|
php
|
public function addPsr0($prefix, $base_dir, $prepend = false)
{
$prefix = trim($prefix, '\\') . '\\';
$base_dir = rtrim($base_dir, self::DS) . self::DS;
if(isset($this->autoloadersPsr0[$prefix]) === false) {
$this->autoloadersPsr0[$prefix] = array();
}
if($prepend) {
array_unshift($this->autoloadersPsr0[$prefix], $base_dir);
} else {
array_push($this->autoloadersPsr0[$prefix], $base_dir);
}
return $this;
}
|
[
"public",
"function",
"addPsr0",
"(",
"$",
"prefix",
",",
"$",
"base_dir",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"$",
"prefix",
"=",
"trim",
"(",
"$",
"prefix",
",",
"'\\\\'",
")",
".",
"'\\\\'",
";",
"$",
"base_dir",
"=",
"rtrim",
"(",
"$",
"base_dir",
",",
"self",
"::",
"DS",
")",
".",
"self",
"::",
"DS",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"autoloadersPsr0",
"[",
"$",
"prefix",
"]",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"autoloadersPsr0",
"[",
"$",
"prefix",
"]",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"$",
"prepend",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"autoloadersPsr0",
"[",
"$",
"prefix",
"]",
",",
"$",
"base_dir",
")",
";",
"}",
"else",
"{",
"array_push",
"(",
"$",
"this",
"->",
"autoloadersPsr0",
"[",
"$",
"prefix",
"]",
",",
"$",
"base_dir",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Psr-0
|
[
"Psr",
"-",
"0"
] |
84d270377685224e891cd9d571b103b36f05b845
|
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/webfan/Autoloading/SourceLoader.php#L344-L359
|
24,479
|
frdl/webfan
|
.ApplicationComposer/lib/frdl/webfan/Autoloading/SourceLoader.php
|
SourceLoader.addNamespace
|
public function addNamespace($prefix, $base_dir, $prepend = false)
{
return $this->addPsr4($prefix, $base_dir, $prepend);
}
|
php
|
public function addNamespace($prefix, $base_dir, $prepend = false)
{
return $this->addPsr4($prefix, $base_dir, $prepend);
}
|
[
"public",
"function",
"addNamespace",
"(",
"$",
"prefix",
",",
"$",
"base_dir",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"addPsr4",
"(",
"$",
"prefix",
",",
"$",
"base_dir",
",",
"$",
"prepend",
")",
";",
"}"
] |
Psr-4
|
[
"Psr",
"-",
"4"
] |
84d270377685224e891cd9d571b103b36f05b845
|
https://github.com/frdl/webfan/blob/84d270377685224e891cd9d571b103b36f05b845/.ApplicationComposer/lib/frdl/webfan/Autoloading/SourceLoader.php#L364-L367
|
24,480
|
heidelpay/PhpDoc
|
src/phpDocumentor/Descriptor/Builder/Reflector/TraitAssembler.php
|
TraitAssembler.addMethods
|
protected function addMethods($methods, $traitDescriptor)
{
foreach ($methods as $method) {
$methodDescriptor = $this->getBuilder()->buildDescriptor($method);
if ($methodDescriptor) {
$methodDescriptor->setParent($traitDescriptor);
$traitDescriptor->getMethods()->set($methodDescriptor->getName(), $methodDescriptor);
}
}
}
|
php
|
protected function addMethods($methods, $traitDescriptor)
{
foreach ($methods as $method) {
$methodDescriptor = $this->getBuilder()->buildDescriptor($method);
if ($methodDescriptor) {
$methodDescriptor->setParent($traitDescriptor);
$traitDescriptor->getMethods()->set($methodDescriptor->getName(), $methodDescriptor);
}
}
}
|
[
"protected",
"function",
"addMethods",
"(",
"$",
"methods",
",",
"$",
"traitDescriptor",
")",
"{",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"method",
")",
"{",
"$",
"methodDescriptor",
"=",
"$",
"this",
"->",
"getBuilder",
"(",
")",
"->",
"buildDescriptor",
"(",
"$",
"method",
")",
";",
"if",
"(",
"$",
"methodDescriptor",
")",
"{",
"$",
"methodDescriptor",
"->",
"setParent",
"(",
"$",
"traitDescriptor",
")",
";",
"$",
"traitDescriptor",
"->",
"getMethods",
"(",
")",
"->",
"set",
"(",
"$",
"methodDescriptor",
"->",
"getName",
"(",
")",
",",
"$",
"methodDescriptor",
")",
";",
"}",
"}",
"}"
] |
Registers the child methods with the generated Trait Descriptor.
@param MethodReflector[] $methods
@param TraitDescriptor $traitDescriptor
@return void
|
[
"Registers",
"the",
"child",
"methods",
"with",
"the",
"generated",
"Trait",
"Descriptor",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/TraitAssembler.php#L80-L89
|
24,481
|
NuclearCMS/Hierarchy
|
src/NodeBag.php
|
NodeBag.getOrFind
|
public function getOrFind($id, $published = true)
{
$node = $this->get($id);
if (is_null($node))
{
$node = $published ?
PublishedNode::find($id) :
Node::find($id);
$this->put($id, $node);
}
return $node;
}
|
php
|
public function getOrFind($id, $published = true)
{
$node = $this->get($id);
if (is_null($node))
{
$node = $published ?
PublishedNode::find($id) :
Node::find($id);
$this->put($id, $node);
}
return $node;
}
|
[
"public",
"function",
"getOrFind",
"(",
"$",
"id",
",",
"$",
"published",
"=",
"true",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"id",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"node",
")",
")",
"{",
"$",
"node",
"=",
"$",
"published",
"?",
"PublishedNode",
"::",
"find",
"(",
"$",
"id",
")",
":",
"Node",
"::",
"find",
"(",
"$",
"id",
")",
";",
"$",
"this",
"->",
"put",
"(",
"$",
"id",
",",
"$",
"node",
")",
";",
"}",
"return",
"$",
"node",
";",
"}"
] |
Gets or finds the node and sets by id
@param int $id
@param bool $published
@return Node
|
[
"Gets",
"or",
"finds",
"the",
"node",
"and",
"sets",
"by",
"id"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeBag.php#L18-L32
|
24,482
|
hametuha/wpametu
|
src/WPametu/DB/Model.php
|
Model.get
|
public function get($id, $ignore_cache = false){
if( empty($this->primary_key) ){
return null;
}
$row = $this->where("{$this->table}.{$this->primary_key} = %d", $id)->get_row('', $ignore_cache);
if( $row && $this->result_class ){
return new $this->result_class($row);
}else{
return $row;
}
}
|
php
|
public function get($id, $ignore_cache = false){
if( empty($this->primary_key) ){
return null;
}
$row = $this->where("{$this->table}.{$this->primary_key} = %d", $id)->get_row('', $ignore_cache);
if( $row && $this->result_class ){
return new $this->result_class($row);
}else{
return $row;
}
}
|
[
"public",
"function",
"get",
"(",
"$",
"id",
",",
"$",
"ignore_cache",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"primary_key",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"row",
"=",
"$",
"this",
"->",
"where",
"(",
"\"{$this->table}.{$this->primary_key} = %d\"",
",",
"$",
"id",
")",
"->",
"get_row",
"(",
"''",
",",
"$",
"ignore_cache",
")",
";",
"if",
"(",
"$",
"row",
"&&",
"$",
"this",
"->",
"result_class",
")",
"{",
"return",
"new",
"$",
"this",
"->",
"result_class",
"(",
"$",
"row",
")",
";",
"}",
"else",
"{",
"return",
"$",
"row",
";",
"}",
"}"
] |
Get object with primary key
@param int $id
@param bool $ignore_cache
@return mixed|null
|
[
"Get",
"object",
"with",
"primary",
"key"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/Model.php#L69-L79
|
24,483
|
hametuha/wpametu
|
src/WPametu/DB/Model.php
|
Model.get_col
|
public function get_col($x = 0, $query = ''){
if( !$query ){
$query = $this->build_query();
}
$this->clear();
return $this->db->get_col($query, $x);
}
|
php
|
public function get_col($x = 0, $query = ''){
if( !$query ){
$query = $this->build_query();
}
$this->clear();
return $this->db->get_col($query, $x);
}
|
[
"public",
"function",
"get_col",
"(",
"$",
"x",
"=",
"0",
",",
"$",
"query",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"query",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"build_query",
"(",
")",
";",
"}",
"$",
"this",
"->",
"clear",
"(",
")",
";",
"return",
"$",
"this",
"->",
"db",
"->",
"get_col",
"(",
"$",
"query",
",",
"$",
"x",
")",
";",
"}"
] |
Returns specified column as array
@param int $x
@param string $query
@return array
|
[
"Returns",
"specified",
"column",
"as",
"array"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/Model.php#L115-L121
|
24,484
|
hametuha/wpametu
|
src/WPametu/DB/Model.php
|
Model.get_row
|
public function get_row($query = '', $ignore_cache = false){
if( empty($query) ){
$query = $this->build_query();
$this->clear();
}
if( $this->cache_exist($query) && !$ignore_cache ){
return $this->get_cache($query);
}else{
return $this->db->get_row($query);
}
}
|
php
|
public function get_row($query = '', $ignore_cache = false){
if( empty($query) ){
$query = $this->build_query();
$this->clear();
}
if( $this->cache_exist($query) && !$ignore_cache ){
return $this->get_cache($query);
}else{
return $this->db->get_row($query);
}
}
|
[
"public",
"function",
"get_row",
"(",
"$",
"query",
"=",
"''",
",",
"$",
"ignore_cache",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"query",
")",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"build_query",
"(",
")",
";",
"$",
"this",
"->",
"clear",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"cache_exist",
"(",
"$",
"query",
")",
"&&",
"!",
"$",
"ignore_cache",
")",
"{",
"return",
"$",
"this",
"->",
"get_cache",
"(",
"$",
"query",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"get_row",
"(",
"$",
"query",
")",
";",
"}",
"}"
] |
Returns row object
@param string $query
@param bool $ignore_cache
@return mixed|null
|
[
"Returns",
"row",
"object"
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/DB/Model.php#L130-L140
|
24,485
|
gedex/php-janrain-api
|
lib/Janrain/Api/Capture/Clients.php
|
Clients.getList
|
public function getList(array $hasFeatures = array())
{
$params = array();
if (!empty($hasFeatures)) {
$params['features'] = json_encode(array_values($hasFeatures));
}
return $this->post('clients/list', $params);
}
|
php
|
public function getList(array $hasFeatures = array())
{
$params = array();
if (!empty($hasFeatures)) {
$params['features'] = json_encode(array_values($hasFeatures));
}
return $this->post('clients/list', $params);
}
|
[
"public",
"function",
"getList",
"(",
"array",
"$",
"hasFeatures",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"hasFeatures",
")",
")",
"{",
"$",
"params",
"[",
"'features'",
"]",
"=",
"json_encode",
"(",
"array_values",
"(",
"$",
"hasFeatures",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"post",
"(",
"'clients/list'",
",",
"$",
"params",
")",
";",
"}"
] |
Since `list` is reserved keyword in PHP.
Get a list of the clients in your Capture application, optionally filtered
by client feature. Only the 'owner' client can make this API call.
@param array $hasFeatures Array features names; only clients which have at
least one of the features in the array will be
displayed
|
[
"Since",
"list",
"is",
"reserved",
"keyword",
"in",
"PHP",
"."
] |
6283f68454e0ad5211ac620f1d337df38cd49597
|
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Capture/Clients.php#L75-L83
|
24,486
|
gedex/php-janrain-api
|
lib/Janrain/Api/Capture/Clients.php
|
Clients.setDescription
|
public function setDescription($clientId, $description)
{
$params = array(
'for_client_id' => $clientId,
'description' => $description,
);
// If empty, description is set for the owner client.
if (!$params['for_client_id']) {
unset($params['for_client_id']);
}
return $this->post('clients/set_description', $params);
}
|
php
|
public function setDescription($clientId, $description)
{
$params = array(
'for_client_id' => $clientId,
'description' => $description,
);
// If empty, description is set for the owner client.
if (!$params['for_client_id']) {
unset($params['for_client_id']);
}
return $this->post('clients/set_description', $params);
}
|
[
"public",
"function",
"setDescription",
"(",
"$",
"clientId",
",",
"$",
"description",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"'for_client_id'",
"=>",
"$",
"clientId",
",",
"'description'",
"=>",
"$",
"description",
",",
")",
";",
"// If empty, description is set for the owner client.",
"if",
"(",
"!",
"$",
"params",
"[",
"'for_client_id'",
"]",
")",
"{",
"unset",
"(",
"$",
"params",
"[",
"'for_client_id'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"post",
"(",
"'clients/set_description'",
",",
"$",
"params",
")",
";",
"}"
] |
Change the description of a client. This can also be thought of as the
'name' of the client. This API call may only be made by the owner client.
@param string $clientId The client id of the client having it's
description changed
@param string $description The new description for the target client
|
[
"Change",
"the",
"description",
"of",
"a",
"client",
".",
"This",
"can",
"also",
"be",
"thought",
"of",
"as",
"the",
"name",
"of",
"the",
"client",
".",
"This",
"API",
"call",
"may",
"only",
"be",
"made",
"by",
"the",
"owner",
"client",
"."
] |
6283f68454e0ad5211ac620f1d337df38cd49597
|
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Capture/Clients.php#L119-L132
|
24,487
|
gedex/php-janrain-api
|
lib/Janrain/Api/Capture/Clients.php
|
Clients.setFeatures
|
public function setFeatures($clientId, array $features)
{
$params = array(
'for_client_id' => $clientId,
'features' => json_encode($features),
);
// If empty, features are set for the owner client.
if (!$params['for_client_id']) {
unset($params['for_client_id']);
}
return $this->post('clients/set_features', $params);
}
|
php
|
public function setFeatures($clientId, array $features)
{
$params = array(
'for_client_id' => $clientId,
'features' => json_encode($features),
);
// If empty, features are set for the owner client.
if (!$params['for_client_id']) {
unset($params['for_client_id']);
}
return $this->post('clients/set_features', $params);
}
|
[
"public",
"function",
"setFeatures",
"(",
"$",
"clientId",
",",
"array",
"$",
"features",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"'for_client_id'",
"=>",
"$",
"clientId",
",",
"'features'",
"=>",
"json_encode",
"(",
"$",
"features",
")",
",",
")",
";",
"// If empty, features are set for the owner client.",
"if",
"(",
"!",
"$",
"params",
"[",
"'for_client_id'",
"]",
")",
"{",
"unset",
"(",
"$",
"params",
"[",
"'for_client_id'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"post",
"(",
"'clients/set_features'",
",",
"$",
"params",
")",
";",
"}"
] |
Change the features that a target client has by overwriting the old feature
list. This API call may only be made by the 'owner' client. The owner client
may not remove the 'owner' feature from itself.
@param string $clientId The client id for which to set features
@param array $features Array of feature names to assign to the client
|
[
"Change",
"the",
"features",
"that",
"a",
"target",
"client",
"has",
"by",
"overwriting",
"the",
"old",
"feature",
"list",
".",
"This",
"API",
"call",
"may",
"only",
"be",
"made",
"by",
"the",
"owner",
"client",
".",
"The",
"owner",
"client",
"may",
"not",
"remove",
"the",
"owner",
"feature",
"from",
"itself",
"."
] |
6283f68454e0ad5211ac620f1d337df38cd49597
|
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Capture/Clients.php#L142-L155
|
24,488
|
gedex/php-janrain-api
|
lib/Janrain/Api/Capture/Clients.php
|
Clients.setWhiteList
|
public function setWhiteList($clientId, array $addresses)
{
$params = array(
'for_client_id' => $clientId,
'whitelist' => json_encode($addresses),
);
// If empty, features are set for the owner client.
if (!$params['for_client_id']) {
unset($params['for_client_id']);
}
return $this->post('clients/set_whitelist', $params);
}
|
php
|
public function setWhiteList($clientId, array $addresses)
{
$params = array(
'for_client_id' => $clientId,
'whitelist' => json_encode($addresses),
);
// If empty, features are set for the owner client.
if (!$params['for_client_id']) {
unset($params['for_client_id']);
}
return $this->post('clients/set_whitelist', $params);
}
|
[
"public",
"function",
"setWhiteList",
"(",
"$",
"clientId",
",",
"array",
"$",
"addresses",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"'for_client_id'",
"=>",
"$",
"clientId",
",",
"'whitelist'",
"=>",
"json_encode",
"(",
"$",
"addresses",
")",
",",
")",
";",
"// If empty, features are set for the owner client.",
"if",
"(",
"!",
"$",
"params",
"[",
"'for_client_id'",
"]",
")",
"{",
"unset",
"(",
"$",
"params",
"[",
"'for_client_id'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"post",
"(",
"'clients/set_whitelist'",
",",
"$",
"params",
")",
";",
"}"
] |
Change the IP whitelist for a target client, overwriting the previous whitelist.
@param string $clientId Client ID
@param array $addresses Array of CIDR addresses
|
[
"Change",
"the",
"IP",
"whitelist",
"for",
"a",
"target",
"client",
"overwriting",
"the",
"previous",
"whitelist",
"."
] |
6283f68454e0ad5211ac620f1d337df38cd49597
|
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Capture/Clients.php#L163-L176
|
24,489
|
heidelpay/PhpDoc
|
src/phpDocumentor/Command/Helper/LoggerHelper.php
|
LoggerHelper.connectOutputToLogging
|
public function connectOutputToLogging(OutputInterface $output, $command)
{
static $alreadyConnected = false;
$helper = $this;
// ignore any second or later invocations of this method
if ($alreadyConnected) {
return;
}
/** @var Dispatcher $eventDispatcher */
$eventDispatcher = $command->getService('event_dispatcher');
$eventDispatcher->addListener(
'parser.file.pre',
function (PreFileEvent $event) use ($output) {
$output->writeln('Parsing <info>'.$event->getFile().'</info>');
}
);
$eventDispatcher->addListener(
'system.log',
function (LogEvent $event) use ($command, $helper, $output) {
$helper->logEvent($output, $event, $command);
}
);
$alreadyConnected = true;
}
|
php
|
public function connectOutputToLogging(OutputInterface $output, $command)
{
static $alreadyConnected = false;
$helper = $this;
// ignore any second or later invocations of this method
if ($alreadyConnected) {
return;
}
/** @var Dispatcher $eventDispatcher */
$eventDispatcher = $command->getService('event_dispatcher');
$eventDispatcher->addListener(
'parser.file.pre',
function (PreFileEvent $event) use ($output) {
$output->writeln('Parsing <info>'.$event->getFile().'</info>');
}
);
$eventDispatcher->addListener(
'system.log',
function (LogEvent $event) use ($command, $helper, $output) {
$helper->logEvent($output, $event, $command);
}
);
$alreadyConnected = true;
}
|
[
"public",
"function",
"connectOutputToLogging",
"(",
"OutputInterface",
"$",
"output",
",",
"$",
"command",
")",
"{",
"static",
"$",
"alreadyConnected",
"=",
"false",
";",
"$",
"helper",
"=",
"$",
"this",
";",
"// ignore any second or later invocations of this method",
"if",
"(",
"$",
"alreadyConnected",
")",
"{",
"return",
";",
"}",
"/** @var Dispatcher $eventDispatcher */",
"$",
"eventDispatcher",
"=",
"$",
"command",
"->",
"getService",
"(",
"'event_dispatcher'",
")",
";",
"$",
"eventDispatcher",
"->",
"addListener",
"(",
"'parser.file.pre'",
",",
"function",
"(",
"PreFileEvent",
"$",
"event",
")",
"use",
"(",
"$",
"output",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"'Parsing <info>'",
".",
"$",
"event",
"->",
"getFile",
"(",
")",
".",
"'</info>'",
")",
";",
"}",
")",
";",
"$",
"eventDispatcher",
"->",
"addListener",
"(",
"'system.log'",
",",
"function",
"(",
"LogEvent",
"$",
"event",
")",
"use",
"(",
"$",
"command",
",",
"$",
"helper",
",",
"$",
"output",
")",
"{",
"$",
"helper",
"->",
"logEvent",
"(",
"$",
"output",
",",
"$",
"event",
",",
"$",
"command",
")",
";",
"}",
")",
";",
"$",
"alreadyConnected",
"=",
"true",
";",
"}"
] |
Connect the logging events to the output object of Symfony Console.
@param OutputInterface $output
@param Command $command
@return void
|
[
"Connect",
"the",
"logging",
"events",
"to",
"the",
"output",
"object",
"of",
"Symfony",
"Console",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Command/Helper/LoggerHelper.php#L64-L92
|
24,490
|
heidelpay/PhpDoc
|
src/phpDocumentor/Command/Helper/LoggerHelper.php
|
LoggerHelper.logEvent
|
public function logEvent(OutputInterface $output, LogEvent $event, Command $command)
{
$numericErrors = array(
LogLevel::DEBUG => 0,
LogLevel::NOTICE => 1,
LogLevel::INFO => 2,
LogLevel::WARNING => 3,
LogLevel::ERROR => 4,
LogLevel::ALERT => 5,
LogLevel::CRITICAL => 6,
LogLevel::EMERGENCY => 7,
);
$threshold = LogLevel::ERROR;
if ($output->getVerbosity() === OutputInterface::VERBOSITY_DEBUG) {
$threshold = LogLevel::DEBUG;
}
if ($numericErrors[$event->getPriority()] >= $numericErrors[$threshold]) {
/** @var Translator $translator */
$translator = $command->getContainer()->offsetGet('translator');
$message = vsprintf($translator->translate($event->getMessage()), $event->getContext());
switch ($event->getPriority()) {
case LogLevel::WARNING:
$message = '<comment>' . $message . '</comment>';
break;
case LogLevel::EMERGENCY:
case LogLevel::ALERT:
case LogLevel::CRITICAL:
case LogLevel::ERROR:
$message = '<error>' . $message . '</error>';
break;
}
$output->writeln(' ' . $message);
}
}
|
php
|
public function logEvent(OutputInterface $output, LogEvent $event, Command $command)
{
$numericErrors = array(
LogLevel::DEBUG => 0,
LogLevel::NOTICE => 1,
LogLevel::INFO => 2,
LogLevel::WARNING => 3,
LogLevel::ERROR => 4,
LogLevel::ALERT => 5,
LogLevel::CRITICAL => 6,
LogLevel::EMERGENCY => 7,
);
$threshold = LogLevel::ERROR;
if ($output->getVerbosity() === OutputInterface::VERBOSITY_DEBUG) {
$threshold = LogLevel::DEBUG;
}
if ($numericErrors[$event->getPriority()] >= $numericErrors[$threshold]) {
/** @var Translator $translator */
$translator = $command->getContainer()->offsetGet('translator');
$message = vsprintf($translator->translate($event->getMessage()), $event->getContext());
switch ($event->getPriority()) {
case LogLevel::WARNING:
$message = '<comment>' . $message . '</comment>';
break;
case LogLevel::EMERGENCY:
case LogLevel::ALERT:
case LogLevel::CRITICAL:
case LogLevel::ERROR:
$message = '<error>' . $message . '</error>';
break;
}
$output->writeln(' ' . $message);
}
}
|
[
"public",
"function",
"logEvent",
"(",
"OutputInterface",
"$",
"output",
",",
"LogEvent",
"$",
"event",
",",
"Command",
"$",
"command",
")",
"{",
"$",
"numericErrors",
"=",
"array",
"(",
"LogLevel",
"::",
"DEBUG",
"=>",
"0",
",",
"LogLevel",
"::",
"NOTICE",
"=>",
"1",
",",
"LogLevel",
"::",
"INFO",
"=>",
"2",
",",
"LogLevel",
"::",
"WARNING",
"=>",
"3",
",",
"LogLevel",
"::",
"ERROR",
"=>",
"4",
",",
"LogLevel",
"::",
"ALERT",
"=>",
"5",
",",
"LogLevel",
"::",
"CRITICAL",
"=>",
"6",
",",
"LogLevel",
"::",
"EMERGENCY",
"=>",
"7",
",",
")",
";",
"$",
"threshold",
"=",
"LogLevel",
"::",
"ERROR",
";",
"if",
"(",
"$",
"output",
"->",
"getVerbosity",
"(",
")",
"===",
"OutputInterface",
"::",
"VERBOSITY_DEBUG",
")",
"{",
"$",
"threshold",
"=",
"LogLevel",
"::",
"DEBUG",
";",
"}",
"if",
"(",
"$",
"numericErrors",
"[",
"$",
"event",
"->",
"getPriority",
"(",
")",
"]",
">=",
"$",
"numericErrors",
"[",
"$",
"threshold",
"]",
")",
"{",
"/** @var Translator $translator */",
"$",
"translator",
"=",
"$",
"command",
"->",
"getContainer",
"(",
")",
"->",
"offsetGet",
"(",
"'translator'",
")",
";",
"$",
"message",
"=",
"vsprintf",
"(",
"$",
"translator",
"->",
"translate",
"(",
"$",
"event",
"->",
"getMessage",
"(",
")",
")",
",",
"$",
"event",
"->",
"getContext",
"(",
")",
")",
";",
"switch",
"(",
"$",
"event",
"->",
"getPriority",
"(",
")",
")",
"{",
"case",
"LogLevel",
"::",
"WARNING",
":",
"$",
"message",
"=",
"'<comment>'",
".",
"$",
"message",
".",
"'</comment>'",
";",
"break",
";",
"case",
"LogLevel",
"::",
"EMERGENCY",
":",
"case",
"LogLevel",
"::",
"ALERT",
":",
"case",
"LogLevel",
"::",
"CRITICAL",
":",
"case",
"LogLevel",
"::",
"ERROR",
":",
"$",
"message",
"=",
"'<error>'",
".",
"$",
"message",
".",
"'</error>'",
";",
"break",
";",
"}",
"$",
"output",
"->",
"writeln",
"(",
"' '",
".",
"$",
"message",
")",
";",
"}",
"}"
] |
Logs an event with the output.
This method will also colorize the message based on priority and withhold
certain logging in case of verbosity or not.
@param OutputInterface $output
@param LogEvent $event
@param Command $command
@return void
|
[
"Logs",
"an",
"event",
"with",
"the",
"output",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Command/Helper/LoggerHelper.php#L106-L142
|
24,491
|
codezero-be/curl
|
src/Request.php
|
Request.put
|
public function put($url, array $data = [], array $headers = [])
{
$this->unsetOptions([CURLOPT_HTTPGET, CURLOPT_POST]);
$this->setOption(CURLOPT_CUSTOMREQUEST, 'PUT');
return $this->send($url, $data, $headers);
}
|
php
|
public function put($url, array $data = [], array $headers = [])
{
$this->unsetOptions([CURLOPT_HTTPGET, CURLOPT_POST]);
$this->setOption(CURLOPT_CUSTOMREQUEST, 'PUT');
return $this->send($url, $data, $headers);
}
|
[
"public",
"function",
"put",
"(",
"$",
"url",
",",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"unsetOptions",
"(",
"[",
"CURLOPT_HTTPGET",
",",
"CURLOPT_POST",
"]",
")",
";",
"$",
"this",
"->",
"setOption",
"(",
"CURLOPT_CUSTOMREQUEST",
",",
"'PUT'",
")",
";",
"return",
"$",
"this",
"->",
"send",
"(",
"$",
"url",
",",
"$",
"data",
",",
"$",
"headers",
")",
";",
"}"
] |
Send PUT request
@param string $url
@param array $data
@param array $headers
@return Response
|
[
"Send",
"PUT",
"request"
] |
c1385479886662b6276c18dd9140df529959d95c
|
https://github.com/codezero-be/curl/blob/c1385479886662b6276c18dd9140df529959d95c/src/Request.php#L102-L109
|
24,492
|
codezero-be/curl
|
src/Request.php
|
Request.setDefaultOptions
|
private function setDefaultOptions()
{
$this->setOptions([
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true, //=> return response instead of boolean
CURLOPT_FAILONERROR => false //=> also return an error when there is a http error >= 400
]);
}
|
php
|
private function setDefaultOptions()
{
$this->setOptions([
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true, //=> return response instead of boolean
CURLOPT_FAILONERROR => false //=> also return an error when there is a http error >= 400
]);
}
|
[
"private",
"function",
"setDefaultOptions",
"(",
")",
"{",
"$",
"this",
"->",
"setOptions",
"(",
"[",
"CURLOPT_SSL_VERIFYPEER",
"=>",
"true",
",",
"CURLOPT_HEADER",
"=>",
"false",
",",
"CURLOPT_RETURNTRANSFER",
"=>",
"true",
",",
"//=> return response instead of boolean",
"CURLOPT_FAILONERROR",
"=>",
"false",
"//=> also return an error when there is a http error >= 400",
"]",
")",
";",
"}"
] |
Set default cURL options
@return void
|
[
"Set",
"default",
"cURL",
"options"
] |
c1385479886662b6276c18dd9140df529959d95c
|
https://github.com/codezero-be/curl/blob/c1385479886662b6276c18dd9140df529959d95c/src/Request.php#L265-L273
|
24,493
|
codezero-be/curl
|
src/Request.php
|
Request.setData
|
private function setData(array $data)
{
if ( ! empty($data))
{
$this->setOption(CURLOPT_POSTFIELDS, $this->optionParser->parseData($data));
}
else
{
$this->unsetOption(CURLOPT_POSTFIELDS);
}
}
|
php
|
private function setData(array $data)
{
if ( ! empty($data))
{
$this->setOption(CURLOPT_POSTFIELDS, $this->optionParser->parseData($data));
}
else
{
$this->unsetOption(CURLOPT_POSTFIELDS);
}
}
|
[
"private",
"function",
"setData",
"(",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"$",
"this",
"->",
"setOption",
"(",
"CURLOPT_POSTFIELDS",
",",
"$",
"this",
"->",
"optionParser",
"->",
"parseData",
"(",
"$",
"data",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"unsetOption",
"(",
"CURLOPT_POSTFIELDS",
")",
";",
"}",
"}"
] |
Set request post fields
@param array $data
@return void
|
[
"Set",
"request",
"post",
"fields"
] |
c1385479886662b6276c18dd9140df529959d95c
|
https://github.com/codezero-be/curl/blob/c1385479886662b6276c18dd9140df529959d95c/src/Request.php#L294-L304
|
24,494
|
codezero-be/curl
|
src/Request.php
|
Request.setHeaders
|
private function setHeaders(array $headers)
{
if ( ! empty($headers))
{
$this->setOption(CURLOPT_HTTPHEADER, $this->optionParser->parseHeaders($headers));
}
else
{
$this->unsetOption(CURLOPT_HTTPHEADER);
}
}
|
php
|
private function setHeaders(array $headers)
{
if ( ! empty($headers))
{
$this->setOption(CURLOPT_HTTPHEADER, $this->optionParser->parseHeaders($headers));
}
else
{
$this->unsetOption(CURLOPT_HTTPHEADER);
}
}
|
[
"private",
"function",
"setHeaders",
"(",
"array",
"$",
"headers",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"headers",
")",
")",
"{",
"$",
"this",
"->",
"setOption",
"(",
"CURLOPT_HTTPHEADER",
",",
"$",
"this",
"->",
"optionParser",
"->",
"parseHeaders",
"(",
"$",
"headers",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"unsetOption",
"(",
"CURLOPT_HTTPHEADER",
")",
";",
"}",
"}"
] |
Set request headers
@param array $headers
@return void
|
[
"Set",
"request",
"headers"
] |
c1385479886662b6276c18dd9140df529959d95c
|
https://github.com/codezero-be/curl/blob/c1385479886662b6276c18dd9140df529959d95c/src/Request.php#L313-L323
|
24,495
|
Duffleman/json-client
|
src/JSONClient.php
|
JSONClient.get
|
public function get($url, $query = [], $headers = [])
{
$headers = array_merge($this->global_headers, $headers);
return $this->request('GET', $url, [], $query, $headers);
}
|
php
|
public function get($url, $query = [], $headers = [])
{
$headers = array_merge($this->global_headers, $headers);
return $this->request('GET', $url, [], $query, $headers);
}
|
[
"public",
"function",
"get",
"(",
"$",
"url",
",",
"$",
"query",
"=",
"[",
"]",
",",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"headers",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"global_headers",
",",
"$",
"headers",
")",
";",
"return",
"$",
"this",
"->",
"request",
"(",
"'GET'",
",",
"$",
"url",
",",
"[",
"]",
",",
"$",
"query",
",",
"$",
"headers",
")",
";",
"}"
] |
Special method for GET because we never pass in a body.
@param string $url
@param array $query
@param array $headers
@return Collections\Generic|\Illuminate\Support\Collection|void
|
[
"Special",
"method",
"for",
"GET",
"because",
"we",
"never",
"pass",
"in",
"a",
"body",
"."
] |
83432875a000e79243424a1e8676acb9969d0c18
|
https://github.com/Duffleman/json-client/blob/83432875a000e79243424a1e8676acb9969d0c18/src/JSONClient.php#L85-L90
|
24,496
|
Duffleman/json-client
|
src/JSONClient.php
|
JSONClient.request
|
public function request($method, $url, $body = [], $query = [], $headers = [])
{
list($body, $query, $headers) = $this->setupVariables($body, $query, $headers);
if (!empty($body)) {
$body = encode($body);
$headers['Content-Type'] = 'application/json';
} else {
$body = null;
}
$headers = array_merge($this->global_headers, $headers);
try {
$response = $this->client->request($method, $url, [
'query' => $query,
'body' => $body,
'headers' => $headers,
]);
$response_body = (string) $response->getBody();
} catch (BadResponseException $exception) {
self::handleError($exception);
}
switch ($this->mode) {
case -1:
return $response;
case 0:
return $response_body;
case 1:
if (!empty($response_body)) {
return decode($response_body);
}
return;
case 2:
if (!empty($response_body)) {
return CollectionManager::build(decode($response_body));
}
return;
default:
throw new JSONLibraryException('unknown_mode_set');
}
}
|
php
|
public function request($method, $url, $body = [], $query = [], $headers = [])
{
list($body, $query, $headers) = $this->setupVariables($body, $query, $headers);
if (!empty($body)) {
$body = encode($body);
$headers['Content-Type'] = 'application/json';
} else {
$body = null;
}
$headers = array_merge($this->global_headers, $headers);
try {
$response = $this->client->request($method, $url, [
'query' => $query,
'body' => $body,
'headers' => $headers,
]);
$response_body = (string) $response->getBody();
} catch (BadResponseException $exception) {
self::handleError($exception);
}
switch ($this->mode) {
case -1:
return $response;
case 0:
return $response_body;
case 1:
if (!empty($response_body)) {
return decode($response_body);
}
return;
case 2:
if (!empty($response_body)) {
return CollectionManager::build(decode($response_body));
}
return;
default:
throw new JSONLibraryException('unknown_mode_set');
}
}
|
[
"public",
"function",
"request",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"body",
"=",
"[",
"]",
",",
"$",
"query",
"=",
"[",
"]",
",",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"list",
"(",
"$",
"body",
",",
"$",
"query",
",",
"$",
"headers",
")",
"=",
"$",
"this",
"->",
"setupVariables",
"(",
"$",
"body",
",",
"$",
"query",
",",
"$",
"headers",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"body",
")",
")",
"{",
"$",
"body",
"=",
"encode",
"(",
"$",
"body",
")",
";",
"$",
"headers",
"[",
"'Content-Type'",
"]",
"=",
"'application/json'",
";",
"}",
"else",
"{",
"$",
"body",
"=",
"null",
";",
"}",
"$",
"headers",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"global_headers",
",",
"$",
"headers",
")",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"$",
"method",
",",
"$",
"url",
",",
"[",
"'query'",
"=>",
"$",
"query",
",",
"'body'",
"=>",
"$",
"body",
",",
"'headers'",
"=>",
"$",
"headers",
",",
"]",
")",
";",
"$",
"response_body",
"=",
"(",
"string",
")",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"}",
"catch",
"(",
"BadResponseException",
"$",
"exception",
")",
"{",
"self",
"::",
"handleError",
"(",
"$",
"exception",
")",
";",
"}",
"switch",
"(",
"$",
"this",
"->",
"mode",
")",
"{",
"case",
"-",
"1",
":",
"return",
"$",
"response",
";",
"case",
"0",
":",
"return",
"$",
"response_body",
";",
"case",
"1",
":",
"if",
"(",
"!",
"empty",
"(",
"$",
"response_body",
")",
")",
"{",
"return",
"decode",
"(",
"$",
"response_body",
")",
";",
"}",
"return",
";",
"case",
"2",
":",
"if",
"(",
"!",
"empty",
"(",
"$",
"response_body",
")",
")",
"{",
"return",
"CollectionManager",
"::",
"build",
"(",
"decode",
"(",
"$",
"response_body",
")",
")",
";",
"}",
"return",
";",
"default",
":",
"throw",
"new",
"JSONLibraryException",
"(",
"'unknown_mode_set'",
")",
";",
"}",
"}"
] |
The main meaty request method, handles
all outgoing requests and deals with responses.
@param string $method
@param string $url
@param array $body
@param array $query
@param array $headers
@throws JSONError
@throws JSONLibraryException
@return Collections\Generic|\Illuminate\Support\Collection|null|void
|
[
"The",
"main",
"meaty",
"request",
"method",
"handles",
"all",
"outgoing",
"requests",
"and",
"deals",
"with",
"responses",
"."
] |
83432875a000e79243424a1e8676acb9969d0c18
|
https://github.com/Duffleman/json-client/blob/83432875a000e79243424a1e8676acb9969d0c18/src/JSONClient.php#L107-L151
|
24,497
|
Duffleman/json-client
|
src/JSONClient.php
|
JSONClient.requestAsync
|
public function requestAsync($method, $url, $body = [], $query = [], $headers = [])
{
if (!empty($body)) {
$body = encode($body);
$headers['Content-Type'] = 'application/json';
} else {
$body = null;
}
$headers = array_merge($this->global_headers, $headers);
return $this->client->requestAsync($method, $url, [
'query' => $query,
'body' => $body,
'headers' => $headers,
]);
}
|
php
|
public function requestAsync($method, $url, $body = [], $query = [], $headers = [])
{
if (!empty($body)) {
$body = encode($body);
$headers['Content-Type'] = 'application/json';
} else {
$body = null;
}
$headers = array_merge($this->global_headers, $headers);
return $this->client->requestAsync($method, $url, [
'query' => $query,
'body' => $body,
'headers' => $headers,
]);
}
|
[
"public",
"function",
"requestAsync",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"body",
"=",
"[",
"]",
",",
"$",
"query",
"=",
"[",
"]",
",",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"body",
")",
")",
"{",
"$",
"body",
"=",
"encode",
"(",
"$",
"body",
")",
";",
"$",
"headers",
"[",
"'Content-Type'",
"]",
"=",
"'application/json'",
";",
"}",
"else",
"{",
"$",
"body",
"=",
"null",
";",
"}",
"$",
"headers",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"global_headers",
",",
"$",
"headers",
")",
";",
"return",
"$",
"this",
"->",
"client",
"->",
"requestAsync",
"(",
"$",
"method",
",",
"$",
"url",
",",
"[",
"'query'",
"=>",
"$",
"query",
",",
"'body'",
"=>",
"$",
"body",
",",
"'headers'",
"=>",
"$",
"headers",
",",
"]",
")",
";",
"}"
] |
Return a promise for async requests.
@param string $method
@param string $url
@param array $body
@param array $query
@param array $headers
@return \GuzzleHttp\Promise\PromiseInterface
|
[
"Return",
"a",
"promise",
"for",
"async",
"requests",
"."
] |
83432875a000e79243424a1e8676acb9969d0c18
|
https://github.com/Duffleman/json-client/blob/83432875a000e79243424a1e8676acb9969d0c18/src/JSONClient.php#L164-L180
|
24,498
|
Duffleman/json-client
|
src/JSONClient.php
|
JSONClient.handleError
|
public static function handleError(BadResponseException $exception)
{
$response_body = (string) $exception->getResponse()->getBody();
$array_body = decode($response_body);
$code = $exception->getResponse()->getStatusCode();
$lookForKeys = ['message', 'code', 'error'];
foreach ($lookForKeys as $key) {
if (isset($array_body[$key])) {
$message = $array_body[$key];
}
}
if (!$message) {
$message = 'unknown_error';
}
throw new JSONError($message, $code, $array_body);
}
|
php
|
public static function handleError(BadResponseException $exception)
{
$response_body = (string) $exception->getResponse()->getBody();
$array_body = decode($response_body);
$code = $exception->getResponse()->getStatusCode();
$lookForKeys = ['message', 'code', 'error'];
foreach ($lookForKeys as $key) {
if (isset($array_body[$key])) {
$message = $array_body[$key];
}
}
if (!$message) {
$message = 'unknown_error';
}
throw new JSONError($message, $code, $array_body);
}
|
[
"public",
"static",
"function",
"handleError",
"(",
"BadResponseException",
"$",
"exception",
")",
"{",
"$",
"response_body",
"=",
"(",
"string",
")",
"$",
"exception",
"->",
"getResponse",
"(",
")",
"->",
"getBody",
"(",
")",
";",
"$",
"array_body",
"=",
"decode",
"(",
"$",
"response_body",
")",
";",
"$",
"code",
"=",
"$",
"exception",
"->",
"getResponse",
"(",
")",
"->",
"getStatusCode",
"(",
")",
";",
"$",
"lookForKeys",
"=",
"[",
"'message'",
",",
"'code'",
",",
"'error'",
"]",
";",
"foreach",
"(",
"$",
"lookForKeys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"array_body",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"message",
"=",
"$",
"array_body",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"message",
")",
"{",
"$",
"message",
"=",
"'unknown_error'",
";",
"}",
"throw",
"new",
"JSONError",
"(",
"$",
"message",
",",
"$",
"code",
",",
"$",
"array_body",
")",
";",
"}"
] |
Handles the error for us, just a bit of code abstraction.
@param BadResponseException $exception
@throws JSONError
|
[
"Handles",
"the",
"error",
"for",
"us",
"just",
"a",
"bit",
"of",
"code",
"abstraction",
"."
] |
83432875a000e79243424a1e8676acb9969d0c18
|
https://github.com/Duffleman/json-client/blob/83432875a000e79243424a1e8676acb9969d0c18/src/JSONClient.php#L189-L209
|
24,499
|
Duffleman/json-client
|
src/JSONClient.php
|
JSONClient.mode
|
public function mode($mode)
{
$acceptable_modes = [-1, 0, 1, 2];
if (!in_array($mode, $acceptable_modes)) {
throw new JSONLibraryException('bad_mode_set');
}
$this->mode = $mode;
return $this;
}
|
php
|
public function mode($mode)
{
$acceptable_modes = [-1, 0, 1, 2];
if (!in_array($mode, $acceptable_modes)) {
throw new JSONLibraryException('bad_mode_set');
}
$this->mode = $mode;
return $this;
}
|
[
"public",
"function",
"mode",
"(",
"$",
"mode",
")",
"{",
"$",
"acceptable_modes",
"=",
"[",
"-",
"1",
",",
"0",
",",
"1",
",",
"2",
"]",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"mode",
",",
"$",
"acceptable_modes",
")",
")",
"{",
"throw",
"new",
"JSONLibraryException",
"(",
"'bad_mode_set'",
")",
";",
"}",
"$",
"this",
"->",
"mode",
"=",
"$",
"mode",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the mode fluently.
@param int $mode
@throws JSONLibraryException
@return $this
|
[
"Set",
"the",
"mode",
"fluently",
"."
] |
83432875a000e79243424a1e8676acb9969d0c18
|
https://github.com/Duffleman/json-client/blob/83432875a000e79243424a1e8676acb9969d0c18/src/JSONClient.php#L220-L229
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.