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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
225,500
|
jeffreyguo/SS-Behat-quicksetup
|
src/SilverStripe/BehatExtension/Context/BasicContext.php
|
BasicContext.cleanAssetsAfterScenario
|
public function cleanAssetsAfterScenario(ScenarioEvent $event) {
foreach(\File::get() as $file) {
if(file_exists($file->getFullPath())) $file->delete();
}
}
|
php
|
public function cleanAssetsAfterScenario(ScenarioEvent $event) {
foreach(\File::get() as $file) {
if(file_exists($file->getFullPath())) $file->delete();
}
}
|
[
"public",
"function",
"cleanAssetsAfterScenario",
"(",
"ScenarioEvent",
"$",
"event",
")",
"{",
"foreach",
"(",
"\\",
"File",
"::",
"get",
"(",
")",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"file",
"->",
"getFullPath",
"(",
")",
")",
")",
"$",
"file",
"->",
"delete",
"(",
")",
";",
"}",
"}"
] |
Delete any created files and folders from assets directory
@AfterScenario @assets
|
[
"Delete",
"any",
"created",
"files",
"and",
"folders",
"from",
"assets",
"directory"
] |
a5172f3a94dc2b364df5c2758a8a1df4f026168e
|
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Context/BasicContext.php#L269-L273
|
225,501
|
jeffreyguo/SS-Behat-quicksetup
|
src/SilverStripe/BehatExtension/Context/BasicContext.php
|
BasicContext.iSelectFromInputGroup
|
public function iSelectFromInputGroup($value, $labelText) {
$page = $this->getSession()->getPage();
$parent = null;
foreach($page->findAll('css', 'label') as $label) {
if($label->getText() == $labelText) {
$parent = $label->getParent();
}
}
if(!$parent) throw new \InvalidArgumentException(sprintf('Input group with label "%s" cannot be found', $labelText));
foreach($parent->findAll('css', 'label') as $option) {
if($option->getText() == $value) {
$for = $option->getAttribute('for');
$input = $parent->findById($for);
if(!$input) throw new \InvalidArgumentException(sprintf('Input "%s" cannot be found', $value));
$this->getSession()->getDriver()->click($input->getXPath());
}
}
}
|
php
|
public function iSelectFromInputGroup($value, $labelText) {
$page = $this->getSession()->getPage();
$parent = null;
foreach($page->findAll('css', 'label') as $label) {
if($label->getText() == $labelText) {
$parent = $label->getParent();
}
}
if(!$parent) throw new \InvalidArgumentException(sprintf('Input group with label "%s" cannot be found', $labelText));
foreach($parent->findAll('css', 'label') as $option) {
if($option->getText() == $value) {
$for = $option->getAttribute('for');
$input = $parent->findById($for);
if(!$input) throw new \InvalidArgumentException(sprintf('Input "%s" cannot be found', $value));
$this->getSession()->getDriver()->click($input->getXPath());
}
}
}
|
[
"public",
"function",
"iSelectFromInputGroup",
"(",
"$",
"value",
",",
"$",
"labelText",
")",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getPage",
"(",
")",
";",
"$",
"parent",
"=",
"null",
";",
"foreach",
"(",
"$",
"page",
"->",
"findAll",
"(",
"'css'",
",",
"'label'",
")",
"as",
"$",
"label",
")",
"{",
"if",
"(",
"$",
"label",
"->",
"getText",
"(",
")",
"==",
"$",
"labelText",
")",
"{",
"$",
"parent",
"=",
"$",
"label",
"->",
"getParent",
"(",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"parent",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Input group with label \"%s\" cannot be found'",
",",
"$",
"labelText",
")",
")",
";",
"foreach",
"(",
"$",
"parent",
"->",
"findAll",
"(",
"'css'",
",",
"'label'",
")",
"as",
"$",
"option",
")",
"{",
"if",
"(",
"$",
"option",
"->",
"getText",
"(",
")",
"==",
"$",
"value",
")",
"{",
"$",
"for",
"=",
"$",
"option",
"->",
"getAttribute",
"(",
"'for'",
")",
";",
"$",
"input",
"=",
"$",
"parent",
"->",
"findById",
"(",
"$",
"for",
")",
";",
"if",
"(",
"!",
"$",
"input",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Input \"%s\" cannot be found'",
",",
"$",
"value",
")",
")",
";",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getDriver",
"(",
")",
"->",
"click",
"(",
"$",
"input",
"->",
"getXPath",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Select an individual input from within a group, matched by the top-most label.
@Given /^I select "([^"]*)" from "([^"]*)" input group$/
|
[
"Select",
"an",
"individual",
"input",
"from",
"within",
"a",
"group",
"matched",
"by",
"the",
"top",
"-",
"most",
"label",
"."
] |
a5172f3a94dc2b364df5c2758a8a1df4f026168e
|
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Context/BasicContext.php#L449-L471
|
225,502
|
jeffreyguo/SS-Behat-quicksetup
|
src/SilverStripe/BehatExtension/Context/BasicContext.php
|
BasicContext.iSelectTheRadioButton
|
public function iSelectTheRadioButton($radioLabel) {
$session = $this->getSession();
$radioButton = $session->getPage()->find('named', array(
'radio', $this->getSession()->getSelectorsHandler()->xpathLiteral($radioLabel)
));
assertNotNull($radioButton);
$session->getDriver()->click($radioButton->getXPath());
}
|
php
|
public function iSelectTheRadioButton($radioLabel) {
$session = $this->getSession();
$radioButton = $session->getPage()->find('named', array(
'radio', $this->getSession()->getSelectorsHandler()->xpathLiteral($radioLabel)
));
assertNotNull($radioButton);
$session->getDriver()->click($radioButton->getXPath());
}
|
[
"public",
"function",
"iSelectTheRadioButton",
"(",
"$",
"radioLabel",
")",
"{",
"$",
"session",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
";",
"$",
"radioButton",
"=",
"$",
"session",
"->",
"getPage",
"(",
")",
"->",
"find",
"(",
"'named'",
",",
"array",
"(",
"'radio'",
",",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getSelectorsHandler",
"(",
")",
"->",
"xpathLiteral",
"(",
"$",
"radioLabel",
")",
")",
")",
";",
"assertNotNull",
"(",
"$",
"radioButton",
")",
";",
"$",
"session",
"->",
"getDriver",
"(",
")",
"->",
"click",
"(",
"$",
"radioButton",
"->",
"getXPath",
"(",
")",
")",
";",
"}"
] |
Selects the specified radio button
@Given /^I select the "([^"]*)" radio button$/
|
[
"Selects",
"the",
"specified",
"radio",
"button"
] |
a5172f3a94dc2b364df5c2758a8a1df4f026168e
|
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Context/BasicContext.php#L705-L712
|
225,503
|
jeffreyguo/SS-Behat-quicksetup
|
src/SilverStripe/BehatExtension/Context/BasicContext.php
|
BasicContext.iWaitXUntilISee
|
public function iWaitXUntilISee($wait, $selector) {
$page = $this->getSession()->getPage();
$this->spin(function($page) use ($page, $selector){
$element = $page->find('css', $selector);
if(empty($element)) {
return false;
} else {
return $element->isVisible();
}
});
}
|
php
|
public function iWaitXUntilISee($wait, $selector) {
$page = $this->getSession()->getPage();
$this->spin(function($page) use ($page, $selector){
$element = $page->find('css', $selector);
if(empty($element)) {
return false;
} else {
return $element->isVisible();
}
});
}
|
[
"public",
"function",
"iWaitXUntilISee",
"(",
"$",
"wait",
",",
"$",
"selector",
")",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getPage",
"(",
")",
";",
"$",
"this",
"->",
"spin",
"(",
"function",
"(",
"$",
"page",
")",
"use",
"(",
"$",
"page",
",",
"$",
"selector",
")",
"{",
"$",
"element",
"=",
"$",
"page",
"->",
"find",
"(",
"'css'",
",",
"$",
"selector",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"element",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"$",
"element",
"->",
"isVisible",
"(",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Wait until a certain amount of seconds till I see an element identified by a CSS selector.
Example: Given I wait for 10 seconds until I see the ".css_element" element
@Given /^I wait for (\d+) seconds until I see the "([^"]*)" element$/
|
[
"Wait",
"until",
"a",
"certain",
"amount",
"of",
"seconds",
"till",
"I",
"see",
"an",
"element",
"identified",
"by",
"a",
"CSS",
"selector",
"."
] |
a5172f3a94dc2b364df5c2758a8a1df4f026168e
|
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Context/BasicContext.php#L820-L832
|
225,504
|
jeffreyguo/SS-Behat-quicksetup
|
src/SilverStripe/BehatExtension/Context/BasicContext.php
|
BasicContext.iWaitUntilISee
|
public function iWaitUntilISee($selector) {
$page = $this->getSession()->getPage();
$this->spin(function($page) use ($page, $selector){
$element = $page->find('css', $selector);
if(empty($element)){
return false;
} else{
return ($element->isVisible());
}
});
}
|
php
|
public function iWaitUntilISee($selector) {
$page = $this->getSession()->getPage();
$this->spin(function($page) use ($page, $selector){
$element = $page->find('css', $selector);
if(empty($element)){
return false;
} else{
return ($element->isVisible());
}
});
}
|
[
"public",
"function",
"iWaitUntilISee",
"(",
"$",
"selector",
")",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getPage",
"(",
")",
";",
"$",
"this",
"->",
"spin",
"(",
"function",
"(",
"$",
"page",
")",
"use",
"(",
"$",
"page",
",",
"$",
"selector",
")",
"{",
"$",
"element",
"=",
"$",
"page",
"->",
"find",
"(",
"'css'",
",",
"$",
"selector",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"element",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"(",
"$",
"element",
"->",
"isVisible",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Wait until a particular element is visible, using a CSS selector. Useful for content loaded via AJAX, or only
populated after JS execution.
Example: Given I wait until I see the "header .login-form" element
@Given /^I wait until I see the "([^"]*)" element$/
|
[
"Wait",
"until",
"a",
"particular",
"element",
"is",
"visible",
"using",
"a",
"CSS",
"selector",
".",
"Useful",
"for",
"content",
"loaded",
"via",
"AJAX",
"or",
"only",
"populated",
"after",
"JS",
"execution",
"."
] |
a5172f3a94dc2b364df5c2758a8a1df4f026168e
|
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Context/BasicContext.php#L842-L852
|
225,505
|
jeffreyguo/SS-Behat-quicksetup
|
src/SilverStripe/BehatExtension/Context/BasicContext.php
|
BasicContext.iWaitUntilISeeText
|
public function iWaitUntilISeeText($text){
$page = $this->getSession()->getPage();
$session = $this->getSession();
$this->spin(function($page) use ($page, $session, $text) {
$element = $page->find(
'xpath',
$session->getSelectorsHandler()->selectorToXpath("xpath", ".//*[contains(text(), '$text')]")
);
if(empty($element)) {
return false;
} else {
return ($element->isVisible());
}
});
}
|
php
|
public function iWaitUntilISeeText($text){
$page = $this->getSession()->getPage();
$session = $this->getSession();
$this->spin(function($page) use ($page, $session, $text) {
$element = $page->find(
'xpath',
$session->getSelectorsHandler()->selectorToXpath("xpath", ".//*[contains(text(), '$text')]")
);
if(empty($element)) {
return false;
} else {
return ($element->isVisible());
}
});
}
|
[
"public",
"function",
"iWaitUntilISeeText",
"(",
"$",
"text",
")",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getPage",
"(",
")",
";",
"$",
"session",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
";",
"$",
"this",
"->",
"spin",
"(",
"function",
"(",
"$",
"page",
")",
"use",
"(",
"$",
"page",
",",
"$",
"session",
",",
"$",
"text",
")",
"{",
"$",
"element",
"=",
"$",
"page",
"->",
"find",
"(",
"'xpath'",
",",
"$",
"session",
"->",
"getSelectorsHandler",
"(",
")",
"->",
"selectorToXpath",
"(",
"\"xpath\"",
",",
"\".//*[contains(text(), '$text')]\"",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"element",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"(",
"$",
"element",
"->",
"isVisible",
"(",
")",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Wait until a particular string is found on the page. Useful for content loaded via AJAX, or only populated after
JS execution.
Example: Given I wait until I see the text "Welcome back, John!"
@Given /^I wait until I see the text "([^"]*)"$/
|
[
"Wait",
"until",
"a",
"particular",
"string",
"is",
"found",
"on",
"the",
"page",
".",
"Useful",
"for",
"content",
"loaded",
"via",
"AJAX",
"or",
"only",
"populated",
"after",
"JS",
"execution",
"."
] |
a5172f3a94dc2b364df5c2758a8a1df4f026168e
|
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Context/BasicContext.php#L862-L877
|
225,506
|
jeffreyguo/SS-Behat-quicksetup
|
src/SilverStripe/BehatExtension/Context/BasicContext.php
|
BasicContext.iScrollToField
|
public function iScrollToField($locator, $type) {
$page = $this->getSession()->getPage();
$el = $page->find('named', array($type, "'$locator'"));
assertNotNull($el, sprintf('%s element not found', $locator));
$id = $el->getAttribute('id');
if(empty($id)) {
throw new \InvalidArgumentException('Element requires an "id" attribute');
}
$js = sprintf("document.getElementById('%s').scrollIntoView(true);", $id);
$this->getSession()->executeScript($js);
}
|
php
|
public function iScrollToField($locator, $type) {
$page = $this->getSession()->getPage();
$el = $page->find('named', array($type, "'$locator'"));
assertNotNull($el, sprintf('%s element not found', $locator));
$id = $el->getAttribute('id');
if(empty($id)) {
throw new \InvalidArgumentException('Element requires an "id" attribute');
}
$js = sprintf("document.getElementById('%s').scrollIntoView(true);", $id);
$this->getSession()->executeScript($js);
}
|
[
"public",
"function",
"iScrollToField",
"(",
"$",
"locator",
",",
"$",
"type",
")",
"{",
"$",
"page",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getPage",
"(",
")",
";",
"$",
"el",
"=",
"$",
"page",
"->",
"find",
"(",
"'named'",
",",
"array",
"(",
"$",
"type",
",",
"\"'$locator'\"",
")",
")",
";",
"assertNotNull",
"(",
"$",
"el",
",",
"sprintf",
"(",
"'%s element not found'",
",",
"$",
"locator",
")",
")",
";",
"$",
"id",
"=",
"$",
"el",
"->",
"getAttribute",
"(",
"'id'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Element requires an \"id\" attribute'",
")",
";",
"}",
"$",
"js",
"=",
"sprintf",
"(",
"\"document.getElementById('%s').scrollIntoView(true);\"",
",",
"$",
"id",
")",
";",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"executeScript",
"(",
"$",
"js",
")",
";",
"}"
] |
Scroll to a certain element by label.
Requires an "id" attribute to uniquely identify the element in the document.
Example: Given I scroll to the "Submit" button
Example: Given I scroll to the "My Date" field
@Given /^I scroll to the "([^"]*)" (field|link|button)$/
|
[
"Scroll",
"to",
"a",
"certain",
"element",
"by",
"label",
".",
"Requires",
"an",
"id",
"attribute",
"to",
"uniquely",
"identify",
"the",
"element",
"in",
"the",
"document",
"."
] |
a5172f3a94dc2b364df5c2758a8a1df4f026168e
|
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Context/BasicContext.php#L903-L915
|
225,507
|
jeffreyguo/SS-Behat-quicksetup
|
src/SilverStripe/BehatExtension/Context/BasicContext.php
|
BasicContext.iScrollToElement
|
public function iScrollToElement($locator) {
$el = $this->getSession()->getPage()->find('css', $locator);
assertNotNull($el, sprintf('The element "%s" is not found', $locator));
$id = $el->getAttribute('id');
if(empty($id)) {
throw new \InvalidArgumentException('Element requires an "id" attribute');
}
$js = sprintf("document.getElementById('%s').scrollIntoView(true);", $id);
$this->getSession()->executeScript($js);
}
|
php
|
public function iScrollToElement($locator) {
$el = $this->getSession()->getPage()->find('css', $locator);
assertNotNull($el, sprintf('The element "%s" is not found', $locator));
$id = $el->getAttribute('id');
if(empty($id)) {
throw new \InvalidArgumentException('Element requires an "id" attribute');
}
$js = sprintf("document.getElementById('%s').scrollIntoView(true);", $id);
$this->getSession()->executeScript($js);
}
|
[
"public",
"function",
"iScrollToElement",
"(",
"$",
"locator",
")",
"{",
"$",
"el",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"find",
"(",
"'css'",
",",
"$",
"locator",
")",
";",
"assertNotNull",
"(",
"$",
"el",
",",
"sprintf",
"(",
"'The element \"%s\" is not found'",
",",
"$",
"locator",
")",
")",
";",
"$",
"id",
"=",
"$",
"el",
"->",
"getAttribute",
"(",
"'id'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Element requires an \"id\" attribute'",
")",
";",
"}",
"$",
"js",
"=",
"sprintf",
"(",
"\"document.getElementById('%s').scrollIntoView(true);\"",
",",
"$",
"id",
")",
";",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"executeScript",
"(",
"$",
"js",
")",
";",
"}"
] |
Scroll to a certain element by CSS selector.
Requires an "id" attribute to uniquely identify the element in the document.
Example: Given I scroll to the ".css_element" element
@Given /^I scroll to the "(?P<locator>(?:[^"]|\\")*)" element$/
|
[
"Scroll",
"to",
"a",
"certain",
"element",
"by",
"CSS",
"selector",
".",
"Requires",
"an",
"id",
"attribute",
"to",
"uniquely",
"identify",
"the",
"element",
"in",
"the",
"document",
"."
] |
a5172f3a94dc2b364df5c2758a8a1df4f026168e
|
https://github.com/jeffreyguo/SS-Behat-quicksetup/blob/a5172f3a94dc2b364df5c2758a8a1df4f026168e/src/SilverStripe/BehatExtension/Context/BasicContext.php#L925-L936
|
225,508
|
DarvinStudio/DarvinUserBundle
|
Repository/UserRepository.php
|
UserRepository.getByRegistrationToken
|
public function getByRegistrationToken($code)
{
$builder = $this->createQueryBuilder('u');
return $builder
->where('u.registrationConfirmToken.id=:code')
->andWhere($builder->expr()->isNotNull('u.registrationConfirmToken.id'))
->setParameter('code', $code)
->setMaxResults(1)
->getQuery()
->getOneOrNullResult()
;
}
|
php
|
public function getByRegistrationToken($code)
{
$builder = $this->createQueryBuilder('u');
return $builder
->where('u.registrationConfirmToken.id=:code')
->andWhere($builder->expr()->isNotNull('u.registrationConfirmToken.id'))
->setParameter('code', $code)
->setMaxResults(1)
->getQuery()
->getOneOrNullResult()
;
}
|
[
"public",
"function",
"getByRegistrationToken",
"(",
"$",
"code",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'u'",
")",
";",
"return",
"$",
"builder",
"->",
"where",
"(",
"'u.registrationConfirmToken.id=:code'",
")",
"->",
"andWhere",
"(",
"$",
"builder",
"->",
"expr",
"(",
")",
"->",
"isNotNull",
"(",
"'u.registrationConfirmToken.id'",
")",
")",
"->",
"setParameter",
"(",
"'code'",
",",
"$",
"code",
")",
"->",
"setMaxResults",
"(",
"1",
")",
"->",
"getQuery",
"(",
")",
"->",
"getOneOrNullResult",
"(",
")",
";",
"}"
] |
Find user by registration confirmation code
@param $code
@return BaseUser|null
|
[
"Find",
"user",
"by",
"registration",
"confirmation",
"code"
] |
da18cc7348f33ffa212e6646b7ef96a18ab3eff0
|
https://github.com/DarvinStudio/DarvinUserBundle/blob/da18cc7348f33ffa212e6646b7ef96a18ab3eff0/Repository/UserRepository.php#L36-L48
|
225,509
|
RevisionTen/cqrs
|
Services/EventStore.php
|
EventStore.find
|
public function find(string $uuid, int $max_version = null, int $min_version = null): array
{
return $this->findEventObjects(EventStreamObject::class, $uuid, $max_version, $min_version);
}
|
php
|
public function find(string $uuid, int $max_version = null, int $min_version = null): array
{
return $this->findEventObjects(EventStreamObject::class, $uuid, $max_version, $min_version);
}
|
[
"public",
"function",
"find",
"(",
"string",
"$",
"uuid",
",",
"int",
"$",
"max_version",
"=",
"null",
",",
"int",
"$",
"min_version",
"=",
"null",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"findEventObjects",
"(",
"EventStreamObject",
"::",
"class",
",",
"$",
"uuid",
",",
"$",
"max_version",
",",
"$",
"min_version",
")",
";",
"}"
] |
Returns Event Stream Objects for a given Uuid.
@param string $uuid
@param int|null $max_version
@param int|null $min_version
@return array
|
[
"Returns",
"Event",
"Stream",
"Objects",
"for",
"a",
"given",
"Uuid",
"."
] |
d94fdd86855a994c4662e24a6c3c08ef586e64f9
|
https://github.com/RevisionTen/cqrs/blob/d94fdd86855a994c4662e24a6c3c08ef586e64f9/Services/EventStore.php#L89-L92
|
225,510
|
RevisionTen/cqrs
|
Services/EventStore.php
|
EventStore.findQeued
|
public function findQeued(string $uuid, int $max_version = null, int $min_version = null, int $user): array
{
$eventQeueObjects = $this->findEventObjects(EventQeueObject::class, $uuid, $max_version, $min_version, $user);
return array_map(function ($eventQeueObject) {
/* @var EventQeueObject $eventQeueObject */
return $eventQeueObject->getEventStreamObject();
}, $eventQeueObjects);
}
|
php
|
public function findQeued(string $uuid, int $max_version = null, int $min_version = null, int $user): array
{
$eventQeueObjects = $this->findEventObjects(EventQeueObject::class, $uuid, $max_version, $min_version, $user);
return array_map(function ($eventQeueObject) {
/* @var EventQeueObject $eventQeueObject */
return $eventQeueObject->getEventStreamObject();
}, $eventQeueObjects);
}
|
[
"public",
"function",
"findQeued",
"(",
"string",
"$",
"uuid",
",",
"int",
"$",
"max_version",
"=",
"null",
",",
"int",
"$",
"min_version",
"=",
"null",
",",
"int",
"$",
"user",
")",
":",
"array",
"{",
"$",
"eventQeueObjects",
"=",
"$",
"this",
"->",
"findEventObjects",
"(",
"EventQeueObject",
"::",
"class",
",",
"$",
"uuid",
",",
"$",
"max_version",
",",
"$",
"min_version",
",",
"$",
"user",
")",
";",
"return",
"array_map",
"(",
"function",
"(",
"$",
"eventQeueObject",
")",
"{",
"/* @var EventQeueObject $eventQeueObject */",
"return",
"$",
"eventQeueObject",
"->",
"getEventStreamObject",
"(",
")",
";",
"}",
",",
"$",
"eventQeueObjects",
")",
";",
"}"
] |
Returns qeued Event Stream Objects for a given Uuid and User.
@param string $uuid
@param int|null $max_version
@param int|null $min_version
@param int $user
@return array
|
[
"Returns",
"qeued",
"Event",
"Stream",
"Objects",
"for",
"a",
"given",
"Uuid",
"and",
"User",
"."
] |
d94fdd86855a994c4662e24a6c3c08ef586e64f9
|
https://github.com/RevisionTen/cqrs/blob/d94fdd86855a994c4662e24a6c3c08ef586e64f9/Services/EventStore.php#L104-L112
|
225,511
|
RevisionTen/cqrs
|
Services/EventStore.php
|
EventStore.findEventObjects
|
public function findEventObjects(string $objectClass, string $uuid, int $max_version = null, int $min_version = null, int $user = null): array
{
$criteria = new Criteria();
$criteria->where(Criteria::expr()->eq('uuid', $uuid));
if (null !== $max_version) {
$criteria->andWhere(Criteria::expr()->lte('version', $max_version));
}
if (null !== $min_version) {
$criteria->andWhere(Criteria::expr()->gte('version', $min_version));
}
if (null !== $user) {
$criteria->andWhere(Criteria::expr()->eq('user', $user));
}
$criteria->orderBy(['version' => Criteria::ASC]);
$eventObjectsResults = $this->em->getRepository($objectClass)->matching($criteria);
return $eventObjectsResults ? $eventObjectsResults->toArray() : [];
}
|
php
|
public function findEventObjects(string $objectClass, string $uuid, int $max_version = null, int $min_version = null, int $user = null): array
{
$criteria = new Criteria();
$criteria->where(Criteria::expr()->eq('uuid', $uuid));
if (null !== $max_version) {
$criteria->andWhere(Criteria::expr()->lte('version', $max_version));
}
if (null !== $min_version) {
$criteria->andWhere(Criteria::expr()->gte('version', $min_version));
}
if (null !== $user) {
$criteria->andWhere(Criteria::expr()->eq('user', $user));
}
$criteria->orderBy(['version' => Criteria::ASC]);
$eventObjectsResults = $this->em->getRepository($objectClass)->matching($criteria);
return $eventObjectsResults ? $eventObjectsResults->toArray() : [];
}
|
[
"public",
"function",
"findEventObjects",
"(",
"string",
"$",
"objectClass",
",",
"string",
"$",
"uuid",
",",
"int",
"$",
"max_version",
"=",
"null",
",",
"int",
"$",
"min_version",
"=",
"null",
",",
"int",
"$",
"user",
"=",
"null",
")",
":",
"array",
"{",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
")",
";",
"$",
"criteria",
"->",
"where",
"(",
"Criteria",
"::",
"expr",
"(",
")",
"->",
"eq",
"(",
"'uuid'",
",",
"$",
"uuid",
")",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"max_version",
")",
"{",
"$",
"criteria",
"->",
"andWhere",
"(",
"Criteria",
"::",
"expr",
"(",
")",
"->",
"lte",
"(",
"'version'",
",",
"$",
"max_version",
")",
")",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"min_version",
")",
"{",
"$",
"criteria",
"->",
"andWhere",
"(",
"Criteria",
"::",
"expr",
"(",
")",
"->",
"gte",
"(",
"'version'",
",",
"$",
"min_version",
")",
")",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"user",
")",
"{",
"$",
"criteria",
"->",
"andWhere",
"(",
"Criteria",
"::",
"expr",
"(",
")",
"->",
"eq",
"(",
"'user'",
",",
"$",
"user",
")",
")",
";",
"}",
"$",
"criteria",
"->",
"orderBy",
"(",
"[",
"'version'",
"=>",
"Criteria",
"::",
"ASC",
"]",
")",
";",
"$",
"eventObjectsResults",
"=",
"$",
"this",
"->",
"em",
"->",
"getRepository",
"(",
"$",
"objectClass",
")",
"->",
"matching",
"(",
"$",
"criteria",
")",
";",
"return",
"$",
"eventObjectsResults",
"?",
"$",
"eventObjectsResults",
"->",
"toArray",
"(",
")",
":",
"[",
"]",
";",
"}"
] |
Returns Event Objects for a given Uuid.
@param string $objectClass
@param string $uuid
@param int|null $max_version
@param int|null $min_version
@param int|null $user
@return array
|
[
"Returns",
"Event",
"Objects",
"for",
"a",
"given",
"Uuid",
"."
] |
d94fdd86855a994c4662e24a6c3c08ef586e64f9
|
https://github.com/RevisionTen/cqrs/blob/d94fdd86855a994c4662e24a6c3c08ef586e64f9/Services/EventStore.php#L125-L148
|
225,512
|
RevisionTen/cqrs
|
Services/EventStore.php
|
EventStore.save
|
public function save(): void
{
try {
$this->em->flush();
} catch (OptimisticLockException $e) {
$this->messageBus->dispatch(new Message(
$e->getMessage(),
$e->getCode(),
null,
null,
$e
));
} catch (UniqueConstraintViolationException $e) {
$this->messageBus->dispatch(new Message(
$e->getMessage(),
$e->getCode(),
null,
null,
$e
));
}
}
|
php
|
public function save(): void
{
try {
$this->em->flush();
} catch (OptimisticLockException $e) {
$this->messageBus->dispatch(new Message(
$e->getMessage(),
$e->getCode(),
null,
null,
$e
));
} catch (UniqueConstraintViolationException $e) {
$this->messageBus->dispatch(new Message(
$e->getMessage(),
$e->getCode(),
null,
null,
$e
));
}
}
|
[
"public",
"function",
"save",
"(",
")",
":",
"void",
"{",
"try",
"{",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"}",
"catch",
"(",
"OptimisticLockException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"messageBus",
"->",
"dispatch",
"(",
"new",
"Message",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"null",
",",
"null",
",",
"$",
"e",
")",
")",
";",
"}",
"catch",
"(",
"UniqueConstraintViolationException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"messageBus",
"->",
"dispatch",
"(",
"new",
"Message",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"null",
",",
"null",
",",
"$",
"e",
")",
")",
";",
"}",
"}"
] |
Saves the events to the Event Store.
|
[
"Saves",
"the",
"events",
"to",
"the",
"Event",
"Store",
"."
] |
d94fdd86855a994c4662e24a6c3c08ef586e64f9
|
https://github.com/RevisionTen/cqrs/blob/d94fdd86855a994c4662e24a6c3c08ef586e64f9/Services/EventStore.php#L217-L238
|
225,513
|
DrNixx/yii2-onix
|
src/collections/TreeNode.php
|
TreeNode.predecessor
|
public function predecessor()
{
if ($this->information & 2) {
$node = $this->left;
while ($node->information & 1) {
$node = $node->right;
}
return $node;
} else {
return $this->left;
}
}
|
php
|
public function predecessor()
{
if ($this->information & 2) {
$node = $this->left;
while ($node->information & 1) {
$node = $node->right;
}
return $node;
} else {
return $this->left;
}
}
|
[
"public",
"function",
"predecessor",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"information",
"&",
"2",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"left",
";",
"while",
"(",
"$",
"node",
"->",
"information",
"&",
"1",
")",
"{",
"$",
"node",
"=",
"$",
"node",
"->",
"right",
";",
"}",
"return",
"$",
"node",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"left",
";",
"}",
"}"
] |
Get the predecessor
@return TreeNode the predecessor node
|
[
"Get",
"the",
"predecessor"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeNode.php#L138-L151
|
225,514
|
DrNixx/yii2-onix
|
src/collections/TreeNode.php
|
TreeNode.successor
|
public function successor()
{
if ($this->information & 1) {
$node = $this->right;
while ($node->information & 2) {
$node = $node->left;
}
return $node;
} else {
return $this->right;
}
}
|
php
|
public function successor()
{
if ($this->information & 1) {
$node = $this->right;
while ($node->information & 2) {
$node = $node->left;
}
return $node;
} else {
return $this->right;
}
}
|
[
"public",
"function",
"successor",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"information",
"&",
"1",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"right",
";",
"while",
"(",
"$",
"node",
"->",
"information",
"&",
"2",
")",
"{",
"$",
"node",
"=",
"$",
"node",
"->",
"left",
";",
"}",
"return",
"$",
"node",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"right",
";",
"}",
"}"
] |
Get the successor
@return TreeNode the successor node
|
[
"Get",
"the",
"successor"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeNode.php#L157-L170
|
225,515
|
DrNixx/yii2-onix
|
src/collections/TreeNode.php
|
TreeNode.find
|
public function find($key, $comparator, $type = 0)
{
$cmp = -1;
$node = $this;
while (true) {
$cmp = $comparator->compare($key, $node->fKey);
if ($cmp < 0 && $node->information & 2) {
$node = $node->left;
} elseif ($cmp > 0 && $node->information & 1) {
$node = $node->right;
} else {
break;
}
}
if ($cmp < 0) {
if ($type < 0) {
return $node->left;
} elseif ($type > 0) {
return $node;
} else {
return null;
}
} elseif ($cmp > 0) {
if ($type < 0) {
return $node;
} elseif ($type > 0) {
return $node->right;
} else {
return null;
}
} else {
if ($type < -1) {
return $node->predecessor;
} elseif ($type > 1) {
return $node->successor;
} else {
return $node;
}
}
}
|
php
|
public function find($key, $comparator, $type = 0)
{
$cmp = -1;
$node = $this;
while (true) {
$cmp = $comparator->compare($key, $node->fKey);
if ($cmp < 0 && $node->information & 2) {
$node = $node->left;
} elseif ($cmp > 0 && $node->information & 1) {
$node = $node->right;
} else {
break;
}
}
if ($cmp < 0) {
if ($type < 0) {
return $node->left;
} elseif ($type > 0) {
return $node;
} else {
return null;
}
} elseif ($cmp > 0) {
if ($type < 0) {
return $node;
} elseif ($type > 0) {
return $node->right;
} else {
return null;
}
} else {
if ($type < -1) {
return $node->predecessor;
} elseif ($type > 1) {
return $node->successor;
} else {
return $node;
}
}
}
|
[
"public",
"function",
"find",
"(",
"$",
"key",
",",
"$",
"comparator",
",",
"$",
"type",
"=",
"0",
")",
"{",
"$",
"cmp",
"=",
"-",
"1",
";",
"$",
"node",
"=",
"$",
"this",
";",
"while",
"(",
"true",
")",
"{",
"$",
"cmp",
"=",
"$",
"comparator",
"->",
"compare",
"(",
"$",
"key",
",",
"$",
"node",
"->",
"fKey",
")",
";",
"if",
"(",
"$",
"cmp",
"<",
"0",
"&&",
"$",
"node",
"->",
"information",
"&",
"2",
")",
"{",
"$",
"node",
"=",
"$",
"node",
"->",
"left",
";",
"}",
"elseif",
"(",
"$",
"cmp",
">",
"0",
"&&",
"$",
"node",
"->",
"information",
"&",
"1",
")",
"{",
"$",
"node",
"=",
"$",
"node",
"->",
"right",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"cmp",
"<",
"0",
")",
"{",
"if",
"(",
"$",
"type",
"<",
"0",
")",
"{",
"return",
"$",
"node",
"->",
"left",
";",
"}",
"elseif",
"(",
"$",
"type",
">",
"0",
")",
"{",
"return",
"$",
"node",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"elseif",
"(",
"$",
"cmp",
">",
"0",
")",
"{",
"if",
"(",
"$",
"type",
"<",
"0",
")",
"{",
"return",
"$",
"node",
";",
"}",
"elseif",
"(",
"$",
"type",
">",
"0",
")",
"{",
"return",
"$",
"node",
"->",
"right",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"type",
"<",
"-",
"1",
")",
"{",
"return",
"$",
"node",
"->",
"predecessor",
";",
"}",
"elseif",
"(",
"$",
"type",
">",
"1",
")",
"{",
"return",
"$",
"node",
"->",
"successor",
";",
"}",
"else",
"{",
"return",
"$",
"node",
";",
"}",
"}",
"}"
] |
Get the node for a key
@param mixed $key The key
@param ComparatorInterface $comparator The comparator function
@param integer $type The operation type
-2 for the greatest key lesser than the given key
-1 for the greatest key lesser than or equal to the given key
0 for the given key
+1 for the lowest key greater than or equal to the given key
+2 for the lowest key greater than the given key
@return TreeNode|null The node or null if not found
|
[
"Get",
"the",
"node",
"for",
"a",
"key"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeNode.php#L204-L244
|
225,516
|
DrNixx/yii2-onix
|
src/collections/TreeNode.php
|
TreeNode.rotateLeft
|
private function rotateLeft()
{
$right = $this->right;
if ($right->information & 2) {
$this->right = $right->left;
$right->left = $this;
} else {
$right->information |= 2;
$this->information &= ~ 1;
}
$this->information -= 4;
if ($right->information >= 4) {
$this->information -= $right->information & ~3;
}
$right->information -= 4;
if ($this->information < 0) {
$right->information += $this->information & ~3;
}
return $right;
}
|
php
|
private function rotateLeft()
{
$right = $this->right;
if ($right->information & 2) {
$this->right = $right->left;
$right->left = $this;
} else {
$right->information |= 2;
$this->information &= ~ 1;
}
$this->information -= 4;
if ($right->information >= 4) {
$this->information -= $right->information & ~3;
}
$right->information -= 4;
if ($this->information < 0) {
$right->information += $this->information & ~3;
}
return $right;
}
|
[
"private",
"function",
"rotateLeft",
"(",
")",
"{",
"$",
"right",
"=",
"$",
"this",
"->",
"right",
";",
"if",
"(",
"$",
"right",
"->",
"information",
"&",
"2",
")",
"{",
"$",
"this",
"->",
"right",
"=",
"$",
"right",
"->",
"left",
";",
"$",
"right",
"->",
"left",
"=",
"$",
"this",
";",
"}",
"else",
"{",
"$",
"right",
"->",
"information",
"|=",
"2",
";",
"$",
"this",
"->",
"information",
"&=",
"~",
"1",
";",
"}",
"$",
"this",
"->",
"information",
"-=",
"4",
";",
"if",
"(",
"$",
"right",
"->",
"information",
">=",
"4",
")",
"{",
"$",
"this",
"->",
"information",
"-=",
"$",
"right",
"->",
"information",
"&",
"~",
"3",
";",
"}",
"$",
"right",
"->",
"information",
"-=",
"4",
";",
"if",
"(",
"$",
"this",
"->",
"information",
"<",
"0",
")",
"{",
"$",
"right",
"->",
"information",
"+=",
"$",
"this",
"->",
"information",
"&",
"~",
"3",
";",
"}",
"return",
"$",
"right",
";",
"}"
] |
Rotate the node to the left
@return TreeNode The rotated node
|
[
"Rotate",
"the",
"node",
"to",
"the",
"left"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeNode.php#L250-L275
|
225,517
|
DrNixx/yii2-onix
|
src/collections/TreeNode.php
|
TreeNode.rotateRight
|
private function rotateRight()
{
$left = $this->left;
if ($left->information & 1) {
$this->left = $left->right;
$left->right = $this;
} else {
$this->information &= ~ 2;
$left->information |= 1;
}
$this->information += 4;
if ($left->information < 0) {
$this->information -= $left->information & ~3;
}
$left->information += 4;
if ($this->information >= 4) {
$left->information += $this->information & ~3;
}
return $left;
}
|
php
|
private function rotateRight()
{
$left = $this->left;
if ($left->information & 1) {
$this->left = $left->right;
$left->right = $this;
} else {
$this->information &= ~ 2;
$left->information |= 1;
}
$this->information += 4;
if ($left->information < 0) {
$this->information -= $left->information & ~3;
}
$left->information += 4;
if ($this->information >= 4) {
$left->information += $this->information & ~3;
}
return $left;
}
|
[
"private",
"function",
"rotateRight",
"(",
")",
"{",
"$",
"left",
"=",
"$",
"this",
"->",
"left",
";",
"if",
"(",
"$",
"left",
"->",
"information",
"&",
"1",
")",
"{",
"$",
"this",
"->",
"left",
"=",
"$",
"left",
"->",
"right",
";",
"$",
"left",
"->",
"right",
"=",
"$",
"this",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"information",
"&=",
"~",
"2",
";",
"$",
"left",
"->",
"information",
"|=",
"1",
";",
"}",
"$",
"this",
"->",
"information",
"+=",
"4",
";",
"if",
"(",
"$",
"left",
"->",
"information",
"<",
"0",
")",
"{",
"$",
"this",
"->",
"information",
"-=",
"$",
"left",
"->",
"information",
"&",
"~",
"3",
";",
"}",
"$",
"left",
"->",
"information",
"+=",
"4",
";",
"if",
"(",
"$",
"this",
"->",
"information",
">=",
"4",
")",
"{",
"$",
"left",
"->",
"information",
"+=",
"$",
"this",
"->",
"information",
"&",
"~",
"3",
";",
"}",
"return",
"$",
"left",
";",
"}"
] |
Rotate the node to the right
@return TreeNode The rotated node
|
[
"Rotate",
"the",
"node",
"to",
"the",
"right"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeNode.php#L282-L307
|
225,518
|
DrNixx/yii2-onix
|
src/collections/TreeNode.php
|
TreeNode.incBalance
|
private function incBalance()
{
$this->information += 4;
if ($this->information >= 8) {
if ($this->right->information < 0) {
$this->right = $this->right->rotateRight();
}
return $this->rotateLeft();
}
return $this;
}
|
php
|
private function incBalance()
{
$this->information += 4;
if ($this->information >= 8) {
if ($this->right->information < 0) {
$this->right = $this->right->rotateRight();
}
return $this->rotateLeft();
}
return $this;
}
|
[
"private",
"function",
"incBalance",
"(",
")",
"{",
"$",
"this",
"->",
"information",
"+=",
"4",
";",
"if",
"(",
"$",
"this",
"->",
"information",
">=",
"8",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"right",
"->",
"information",
"<",
"0",
")",
"{",
"$",
"this",
"->",
"right",
"=",
"$",
"this",
"->",
"right",
"->",
"rotateRight",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"rotateLeft",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Increment the balance of the node
@return TreeNode $this or a rotated version of $this
|
[
"Increment",
"the",
"balance",
"of",
"the",
"node"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeNode.php#L314-L327
|
225,519
|
DrNixx/yii2-onix
|
src/collections/TreeNode.php
|
TreeNode.decBalance
|
private function decBalance()
{
$this->information -= 4;
if ($this->information < - 4) {
if ($this->left->information >= 4) {
$this->left = $this->left->rotateLeft();
}
return $this->rotateRight();
}
return $this;
}
|
php
|
private function decBalance()
{
$this->information -= 4;
if ($this->information < - 4) {
if ($this->left->information >= 4) {
$this->left = $this->left->rotateLeft();
}
return $this->rotateRight();
}
return $this;
}
|
[
"private",
"function",
"decBalance",
"(",
")",
"{",
"$",
"this",
"->",
"information",
"-=",
"4",
";",
"if",
"(",
"$",
"this",
"->",
"information",
"<",
"-",
"4",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"left",
"->",
"information",
">=",
"4",
")",
"{",
"$",
"this",
"->",
"left",
"=",
"$",
"this",
"->",
"left",
"->",
"rotateLeft",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"rotateRight",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Decrement the balance of the node
@return TreeNode $this or a rotated version of $this
|
[
"Decrement",
"the",
"balance",
"of",
"the",
"node"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeNode.php#L334-L347
|
225,520
|
DrNixx/yii2-onix
|
src/collections/TreeNode.php
|
TreeNode.pullUpLeftMost
|
private function pullUpLeftMost()
{
if ($this->information & 2) {
$leftBalance = $this->left->information & ~3;
$this->left = $this->left->pullUpLeftMost();
if (!($this->information & 2) || $leftBalance != 0 && ($this->left->information & ~3) == 0) {
return $this->incBalance();
} else {
return $this;
}
} else {
$this->left->fKey = $this->fKey;
$this->left->value = $this->value;
if ($this->information & 1) {
$this->right->left = $this->left;
return $this->right;
} else {
if ($this->left->right === $this) {
$this->left->information &= ~ 1;
return $this->right;
} else {
$this->right->information &= ~ 2;
return $this->left;
}
}
}
}
|
php
|
private function pullUpLeftMost()
{
if ($this->information & 2) {
$leftBalance = $this->left->information & ~3;
$this->left = $this->left->pullUpLeftMost();
if (!($this->information & 2) || $leftBalance != 0 && ($this->left->information & ~3) == 0) {
return $this->incBalance();
} else {
return $this;
}
} else {
$this->left->fKey = $this->fKey;
$this->left->value = $this->value;
if ($this->information & 1) {
$this->right->left = $this->left;
return $this->right;
} else {
if ($this->left->right === $this) {
$this->left->information &= ~ 1;
return $this->right;
} else {
$this->right->information &= ~ 2;
return $this->left;
}
}
}
}
|
[
"private",
"function",
"pullUpLeftMost",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"information",
"&",
"2",
")",
"{",
"$",
"leftBalance",
"=",
"$",
"this",
"->",
"left",
"->",
"information",
"&",
"~",
"3",
";",
"$",
"this",
"->",
"left",
"=",
"$",
"this",
"->",
"left",
"->",
"pullUpLeftMost",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"information",
"&",
"2",
")",
"||",
"$",
"leftBalance",
"!=",
"0",
"&&",
"(",
"$",
"this",
"->",
"left",
"->",
"information",
"&",
"~",
"3",
")",
"==",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"incBalance",
"(",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"left",
"->",
"fKey",
"=",
"$",
"this",
"->",
"fKey",
";",
"$",
"this",
"->",
"left",
"->",
"value",
"=",
"$",
"this",
"->",
"value",
";",
"if",
"(",
"$",
"this",
"->",
"information",
"&",
"1",
")",
"{",
"$",
"this",
"->",
"right",
"->",
"left",
"=",
"$",
"this",
"->",
"left",
";",
"return",
"$",
"this",
"->",
"right",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"left",
"->",
"right",
"===",
"$",
"this",
")",
"{",
"$",
"this",
"->",
"left",
"->",
"information",
"&=",
"~",
"1",
";",
"return",
"$",
"this",
"->",
"right",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"right",
"->",
"information",
"&=",
"~",
"2",
";",
"return",
"$",
"this",
"->",
"left",
";",
"}",
"}",
"}",
"}"
] |
Pull up the left most node of a node
@return TreeNode The new root
|
[
"Pull",
"up",
"the",
"left",
"most",
"node",
"of",
"a",
"node"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeNode.php#L401-L432
|
225,521
|
DrNixx/yii2-onix
|
src/collections/TreeNode.php
|
TreeNode.remove
|
public function remove($key, $comparator)
{
$cmp = $comparator->compare($key, $this->fKey);
if ($cmp < 0) {
if ($this->information & 2) {
$leftBalance = $this->left->information & ~3;
$this->left = $this->left->remove($key, $comparator);
if (!($this->information & 2) || $leftBalance != 0 && ($this->left->information & ~3) == 0) {
return $this->incBalance();
}
}
} elseif ($cmp > 0) {
if ($this->information & 1) {
$rightBalance = $this->right->information & ~3;
$this->right = $this->right->remove($key, $comparator);
if (!($this->information & 1) || $rightBalance != 0 && ($this->right->information & ~3) == 0) {
return $this->decBalance();
}
}
} else {
if ($this->information & 1) {
$rightBalance = $this->right->information & ~3;
$this->right = $this->right->pullUpLeftMost();
if (!($this->information & 1) || $rightBalance != 0 && ($this->right->information & ~3) == 0) {
return $this->decBalance();
}
} else {
$left = $this->left;
$right = $this->right;
if ($this->information & 2) {
$left->right = $right;
return $left;
} else {
if ($left && $left->right === $this) {
$left->information &= ~ 1;
return $right;
} elseif ($right && $right->left === $this) {
$right->information &= ~ 2;
return $left;
} else {
return null;
}
}
}
}
return $this;
}
|
php
|
public function remove($key, $comparator)
{
$cmp = $comparator->compare($key, $this->fKey);
if ($cmp < 0) {
if ($this->information & 2) {
$leftBalance = $this->left->information & ~3;
$this->left = $this->left->remove($key, $comparator);
if (!($this->information & 2) || $leftBalance != 0 && ($this->left->information & ~3) == 0) {
return $this->incBalance();
}
}
} elseif ($cmp > 0) {
if ($this->information & 1) {
$rightBalance = $this->right->information & ~3;
$this->right = $this->right->remove($key, $comparator);
if (!($this->information & 1) || $rightBalance != 0 && ($this->right->information & ~3) == 0) {
return $this->decBalance();
}
}
} else {
if ($this->information & 1) {
$rightBalance = $this->right->information & ~3;
$this->right = $this->right->pullUpLeftMost();
if (!($this->information & 1) || $rightBalance != 0 && ($this->right->information & ~3) == 0) {
return $this->decBalance();
}
} else {
$left = $this->left;
$right = $this->right;
if ($this->information & 2) {
$left->right = $right;
return $left;
} else {
if ($left && $left->right === $this) {
$left->information &= ~ 1;
return $right;
} elseif ($right && $right->left === $this) {
$right->information &= ~ 2;
return $left;
} else {
return null;
}
}
}
}
return $this;
}
|
[
"public",
"function",
"remove",
"(",
"$",
"key",
",",
"$",
"comparator",
")",
"{",
"$",
"cmp",
"=",
"$",
"comparator",
"->",
"compare",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"fKey",
")",
";",
"if",
"(",
"$",
"cmp",
"<",
"0",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"information",
"&",
"2",
")",
"{",
"$",
"leftBalance",
"=",
"$",
"this",
"->",
"left",
"->",
"information",
"&",
"~",
"3",
";",
"$",
"this",
"->",
"left",
"=",
"$",
"this",
"->",
"left",
"->",
"remove",
"(",
"$",
"key",
",",
"$",
"comparator",
")",
";",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"information",
"&",
"2",
")",
"||",
"$",
"leftBalance",
"!=",
"0",
"&&",
"(",
"$",
"this",
"->",
"left",
"->",
"information",
"&",
"~",
"3",
")",
"==",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"incBalance",
"(",
")",
";",
"}",
"}",
"}",
"elseif",
"(",
"$",
"cmp",
">",
"0",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"information",
"&",
"1",
")",
"{",
"$",
"rightBalance",
"=",
"$",
"this",
"->",
"right",
"->",
"information",
"&",
"~",
"3",
";",
"$",
"this",
"->",
"right",
"=",
"$",
"this",
"->",
"right",
"->",
"remove",
"(",
"$",
"key",
",",
"$",
"comparator",
")",
";",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"information",
"&",
"1",
")",
"||",
"$",
"rightBalance",
"!=",
"0",
"&&",
"(",
"$",
"this",
"->",
"right",
"->",
"information",
"&",
"~",
"3",
")",
"==",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"decBalance",
"(",
")",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"this",
"->",
"information",
"&",
"1",
")",
"{",
"$",
"rightBalance",
"=",
"$",
"this",
"->",
"right",
"->",
"information",
"&",
"~",
"3",
";",
"$",
"this",
"->",
"right",
"=",
"$",
"this",
"->",
"right",
"->",
"pullUpLeftMost",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"information",
"&",
"1",
")",
"||",
"$",
"rightBalance",
"!=",
"0",
"&&",
"(",
"$",
"this",
"->",
"right",
"->",
"information",
"&",
"~",
"3",
")",
"==",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"decBalance",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"left",
"=",
"$",
"this",
"->",
"left",
";",
"$",
"right",
"=",
"$",
"this",
"->",
"right",
";",
"if",
"(",
"$",
"this",
"->",
"information",
"&",
"2",
")",
"{",
"$",
"left",
"->",
"right",
"=",
"$",
"right",
";",
"return",
"$",
"left",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"left",
"&&",
"$",
"left",
"->",
"right",
"===",
"$",
"this",
")",
"{",
"$",
"left",
"->",
"information",
"&=",
"~",
"1",
";",
"return",
"$",
"right",
";",
"}",
"elseif",
"(",
"$",
"right",
"&&",
"$",
"right",
"->",
"left",
"===",
"$",
"this",
")",
"{",
"$",
"right",
"->",
"information",
"&=",
"~",
"2",
";",
"return",
"$",
"left",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Remove a key
@param mixed $key The key
@param ComparatorInterface $comparator The comparator function
@return TreeNode The new root
|
[
"Remove",
"a",
"key"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeNode.php#L442-L497
|
225,522
|
railken/amethyst-data-builder
|
src/Validators/DataBuilderValidator.php
|
DataBuilderValidator.raw
|
public function raw(array $schema, array $data)
{
$errors = new Collection();
if (count($schema) !== 0) {
$validator = IlluminateValidator::make($data, $schema);
foreach ($validator->errors()->getMessages() as $key => $error) {
$errors[] = new Exceptions\DataBuilderInputException($key, $error[0], isset($data[$key]) ? $data[$key] : null);
}
}
return $errors;
}
|
php
|
public function raw(array $schema, array $data)
{
$errors = new Collection();
if (count($schema) !== 0) {
$validator = IlluminateValidator::make($data, $schema);
foreach ($validator->errors()->getMessages() as $key => $error) {
$errors[] = new Exceptions\DataBuilderInputException($key, $error[0], isset($data[$key]) ? $data[$key] : null);
}
}
return $errors;
}
|
[
"public",
"function",
"raw",
"(",
"array",
"$",
"schema",
",",
"array",
"$",
"data",
")",
"{",
"$",
"errors",
"=",
"new",
"Collection",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"schema",
")",
"!==",
"0",
")",
"{",
"$",
"validator",
"=",
"IlluminateValidator",
"::",
"make",
"(",
"$",
"data",
",",
"$",
"schema",
")",
";",
"foreach",
"(",
"$",
"validator",
"->",
"errors",
"(",
")",
"->",
"getMessages",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"error",
")",
"{",
"$",
"errors",
"[",
"]",
"=",
"new",
"Exceptions",
"\\",
"DataBuilderInputException",
"(",
"$",
"key",
",",
"$",
"error",
"[",
"0",
"]",
",",
"isset",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"data",
"[",
"$",
"key",
"]",
":",
"null",
")",
";",
"}",
"}",
"return",
"$",
"errors",
";",
"}"
] |
Validate input submitted.
@param array $schema
@param array $data
@return \Illuminate\Support\Collection
|
[
"Validate",
"input",
"submitted",
"."
] |
55334227b6b7f14cf755b02e7cd36a11db00f454
|
https://github.com/railken/amethyst-data-builder/blob/55334227b6b7f14cf755b02e7cd36a11db00f454/src/Validators/DataBuilderValidator.php#L20-L33
|
225,523
|
php-toolkit/str-utils
|
src/UUID.php
|
UUID.mintName
|
protected static function mintName($ver, $node, $ns): string
{
if (empty($node)) {
throw new \InvalidArgumentException('A name-string is required for Version 3 or 5 UUIDs.');
}
// if the namespace UUID isn't binary, make it so
$ns = static::makeBin($ns, 16);
if (null === $ns) {
throw new \InvalidArgumentException('A binary namespace is required for Version 3 or 5 UUIDs.');
}
$version = $uuid = null;
switch ($ver) {
case static::MD5:
$version = static::VERSION_3;
$uuid = \md5($ns . $node, 1);
break;
case static::SHA1:
$version = static::VERSION_5;
$uuid = \substr(\sha1($ns . $node, 1), 0, 16);
break;
default:
// no default really required here
}
// set variant
$uuid[8] = \chr(\ord($uuid[8]) & static::CLEAR_VAR | static::VAR_RFC);
// set version
$uuid[6] = \chr(\ord($uuid[6]) & static::CLEAR_VER | $version);
return $uuid;
}
|
php
|
protected static function mintName($ver, $node, $ns): string
{
if (empty($node)) {
throw new \InvalidArgumentException('A name-string is required for Version 3 or 5 UUIDs.');
}
// if the namespace UUID isn't binary, make it so
$ns = static::makeBin($ns, 16);
if (null === $ns) {
throw new \InvalidArgumentException('A binary namespace is required for Version 3 or 5 UUIDs.');
}
$version = $uuid = null;
switch ($ver) {
case static::MD5:
$version = static::VERSION_3;
$uuid = \md5($ns . $node, 1);
break;
case static::SHA1:
$version = static::VERSION_5;
$uuid = \substr(\sha1($ns . $node, 1), 0, 16);
break;
default:
// no default really required here
}
// set variant
$uuid[8] = \chr(\ord($uuid[8]) & static::CLEAR_VAR | static::VAR_RFC);
// set version
$uuid[6] = \chr(\ord($uuid[6]) & static::CLEAR_VER | $version);
return $uuid;
}
|
[
"protected",
"static",
"function",
"mintName",
"(",
"$",
"ver",
",",
"$",
"node",
",",
"$",
"ns",
")",
":",
"string",
"{",
"if",
"(",
"empty",
"(",
"$",
"node",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'A name-string is required for Version 3 or 5 UUIDs.'",
")",
";",
"}",
"// if the namespace UUID isn't binary, make it so",
"$",
"ns",
"=",
"static",
"::",
"makeBin",
"(",
"$",
"ns",
",",
"16",
")",
";",
"if",
"(",
"null",
"===",
"$",
"ns",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'A binary namespace is required for Version 3 or 5 UUIDs.'",
")",
";",
"}",
"$",
"version",
"=",
"$",
"uuid",
"=",
"null",
";",
"switch",
"(",
"$",
"ver",
")",
"{",
"case",
"static",
"::",
"MD5",
":",
"$",
"version",
"=",
"static",
"::",
"VERSION_3",
";",
"$",
"uuid",
"=",
"\\",
"md5",
"(",
"$",
"ns",
".",
"$",
"node",
",",
"1",
")",
";",
"break",
";",
"case",
"static",
"::",
"SHA1",
":",
"$",
"version",
"=",
"static",
"::",
"VERSION_5",
";",
"$",
"uuid",
"=",
"\\",
"substr",
"(",
"\\",
"sha1",
"(",
"$",
"ns",
".",
"$",
"node",
",",
"1",
")",
",",
"0",
",",
"16",
")",
";",
"break",
";",
"default",
":",
"// no default really required here",
"}",
"// set variant",
"$",
"uuid",
"[",
"8",
"]",
"=",
"\\",
"chr",
"(",
"\\",
"ord",
"(",
"$",
"uuid",
"[",
"8",
"]",
")",
"&",
"static",
"::",
"CLEAR_VAR",
"|",
"static",
"::",
"VAR_RFC",
")",
";",
"// set version",
"$",
"uuid",
"[",
"6",
"]",
"=",
"\\",
"chr",
"(",
"\\",
"ord",
"(",
"$",
"uuid",
"[",
"6",
"]",
")",
"&",
"static",
"::",
"CLEAR_VER",
"|",
"$",
"version",
")",
";",
"return",
"$",
"uuid",
";",
"}"
] |
Generates a Version 3 or Version 5 UUID.
These are derived from a hash of a name and its namespace, in binary form.
@param int $ver
@param string $node
@param string|null $ns
@return string
@throws \InvalidArgumentException
|
[
"Generates",
"a",
"Version",
"3",
"or",
"Version",
"5",
"UUID",
".",
"These",
"are",
"derived",
"from",
"a",
"hash",
"of",
"a",
"name",
"and",
"its",
"namespace",
"in",
"binary",
"form",
"."
] |
2e0b081c7c86e4fb92d1dca63bd8c0449cb6b278
|
https://github.com/php-toolkit/str-utils/blob/2e0b081c7c86e4fb92d1dca63bd8c0449cb6b278/src/UUID.php#L268-L302
|
225,524
|
php-toolkit/str-utils
|
src/UUID.php
|
UUID.mintRand
|
protected static function mintRand(): string
{
$uuid = static::randomBytes(16);
// set variant
$uuid[8] = \chr(\ord($uuid[8]) & static::CLEAR_VAR | static::VAR_RFC);
// set version
$uuid[6] = \chr(\ord($uuid[6]) & static::CLEAR_VER | static::VERSION_4);
return $uuid;
}
|
php
|
protected static function mintRand(): string
{
$uuid = static::randomBytes(16);
// set variant
$uuid[8] = \chr(\ord($uuid[8]) & static::CLEAR_VAR | static::VAR_RFC);
// set version
$uuid[6] = \chr(\ord($uuid[6]) & static::CLEAR_VER | static::VERSION_4);
return $uuid;
}
|
[
"protected",
"static",
"function",
"mintRand",
"(",
")",
":",
"string",
"{",
"$",
"uuid",
"=",
"static",
"::",
"randomBytes",
"(",
"16",
")",
";",
"// set variant",
"$",
"uuid",
"[",
"8",
"]",
"=",
"\\",
"chr",
"(",
"\\",
"ord",
"(",
"$",
"uuid",
"[",
"8",
"]",
")",
"&",
"static",
"::",
"CLEAR_VAR",
"|",
"static",
"::",
"VAR_RFC",
")",
";",
"// set version",
"$",
"uuid",
"[",
"6",
"]",
"=",
"\\",
"chr",
"(",
"\\",
"ord",
"(",
"$",
"uuid",
"[",
"6",
"]",
")",
"&",
"static",
"::",
"CLEAR_VER",
"|",
"static",
"::",
"VERSION_4",
")",
";",
"return",
"$",
"uuid",
";",
"}"
] |
Generate a Version 4 UUID.
These are derived solely from random numbers.
generate random fields
@return string
@throws \Exception
|
[
"Generate",
"a",
"Version",
"4",
"UUID",
".",
"These",
"are",
"derived",
"solely",
"from",
"random",
"numbers",
".",
"generate",
"random",
"fields"
] |
2e0b081c7c86e4fb92d1dca63bd8c0449cb6b278
|
https://github.com/php-toolkit/str-utils/blob/2e0b081c7c86e4fb92d1dca63bd8c0449cb6b278/src/UUID.php#L312-L321
|
225,525
|
php-toolkit/str-utils
|
src/UUID.php
|
UUID.compare
|
public static function compare(string $a, string $b): string
{
return static::makeBin($a, 16) === static::makeBin($b, 16);
}
|
php
|
public static function compare(string $a, string $b): string
{
return static::makeBin($a, 16) === static::makeBin($b, 16);
}
|
[
"public",
"static",
"function",
"compare",
"(",
"string",
"$",
"a",
",",
"string",
"$",
"b",
")",
":",
"string",
"{",
"return",
"static",
"::",
"makeBin",
"(",
"$",
"a",
",",
"16",
")",
"===",
"static",
"::",
"makeBin",
"(",
"$",
"b",
",",
"16",
")",
";",
"}"
] |
Compares the binary representations of two UUIDs.
The comparison will return true if they are bit-exact,
or if neither is valid.
@param string $a
@param string $b
@return string|string
|
[
"Compares",
"the",
"binary",
"representations",
"of",
"two",
"UUIDs",
".",
"The",
"comparison",
"will",
"return",
"true",
"if",
"they",
"are",
"bit",
"-",
"exact",
"or",
"if",
"neither",
"is",
"valid",
"."
] |
2e0b081c7c86e4fb92d1dca63bd8c0449cb6b278
|
https://github.com/php-toolkit/str-utils/blob/2e0b081c7c86e4fb92d1dca63bd8c0449cb6b278/src/UUID.php#L344-L347
|
225,526
|
php-toolkit/str-utils
|
src/UUID.php
|
UUID.validate
|
public static function validate(string $uuid): bool
{
return (boolean)\preg_match('~' . static::VALID_UUID_REGEX . '~', static::import($uuid)->string);
}
|
php
|
public static function validate(string $uuid): bool
{
return (boolean)\preg_match('~' . static::VALID_UUID_REGEX . '~', static::import($uuid)->string);
}
|
[
"public",
"static",
"function",
"validate",
"(",
"string",
"$",
"uuid",
")",
":",
"bool",
"{",
"return",
"(",
"boolean",
")",
"\\",
"preg_match",
"(",
"'~'",
".",
"static",
"::",
"VALID_UUID_REGEX",
".",
"'~'",
",",
"static",
"::",
"import",
"(",
"$",
"uuid",
")",
"->",
"string",
")",
";",
"}"
] |
Import and validate an UUID
@param Uuid|string $uuid
@return boolean
@throws \InvalidArgumentException
|
[
"Import",
"and",
"validate",
"an",
"UUID"
] |
2e0b081c7c86e4fb92d1dca63bd8c0449cb6b278
|
https://github.com/php-toolkit/str-utils/blob/2e0b081c7c86e4fb92d1dca63bd8c0449cb6b278/src/UUID.php#L356-L359
|
225,527
|
sopinetchat/SopinetChatBundle
|
Listener/WebClientEventListener.php
|
WebClientEventListener.onServerStart
|
public function onServerStart(ServerEvent $event)
{
$event = $event->getEventLoop();
// Cuando el servidor se inicie querrá decir que, previamente, estaba parado, por tanto
// debemos eliminar todos los Clientes Web que tuviésemos almacenados.
// Eliminar Device WebClient
$em = $this->container->get('doctrine.orm.default_entity_manager');
$reDevice = $em->getRepository('SopinetChatBundle:Device');
$devices = $reDevice->findByDeviceType(Device::TYPE_WEB);
/** @var Device $device */
foreach($devices as $device) {
echo "State to 0 in device with SessionID: ".$device->getDeviceId() . PHP_EOL;
$device->setState('0');
$em->flush($device);
$em->flush();
}
echo 'Server was successfully started!'. PHP_EOL;
}
|
php
|
public function onServerStart(ServerEvent $event)
{
$event = $event->getEventLoop();
// Cuando el servidor se inicie querrá decir que, previamente, estaba parado, por tanto
// debemos eliminar todos los Clientes Web que tuviésemos almacenados.
// Eliminar Device WebClient
$em = $this->container->get('doctrine.orm.default_entity_manager');
$reDevice = $em->getRepository('SopinetChatBundle:Device');
$devices = $reDevice->findByDeviceType(Device::TYPE_WEB);
/** @var Device $device */
foreach($devices as $device) {
echo "State to 0 in device with SessionID: ".$device->getDeviceId() . PHP_EOL;
$device->setState('0');
$em->flush($device);
$em->flush();
}
echo 'Server was successfully started!'. PHP_EOL;
}
|
[
"public",
"function",
"onServerStart",
"(",
"ServerEvent",
"$",
"event",
")",
"{",
"$",
"event",
"=",
"$",
"event",
"->",
"getEventLoop",
"(",
")",
";",
"// Cuando el servidor se inicie querrá decir que, previamente, estaba parado, por tanto",
"// debemos eliminar todos los Clientes Web que tuviésemos almacenados.",
"// Eliminar Device WebClient",
"$",
"em",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'doctrine.orm.default_entity_manager'",
")",
";",
"$",
"reDevice",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'SopinetChatBundle:Device'",
")",
";",
"$",
"devices",
"=",
"$",
"reDevice",
"->",
"findByDeviceType",
"(",
"Device",
"::",
"TYPE_WEB",
")",
";",
"/** @var Device $device */",
"foreach",
"(",
"$",
"devices",
"as",
"$",
"device",
")",
"{",
"echo",
"\"State to 0 in device with SessionID: \"",
".",
"$",
"device",
"->",
"getDeviceId",
"(",
")",
".",
"PHP_EOL",
";",
"$",
"device",
"->",
"setState",
"(",
"'0'",
")",
";",
"$",
"em",
"->",
"flush",
"(",
"$",
"device",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"}",
"echo",
"'Server was successfully started!'",
".",
"PHP_EOL",
";",
"}"
] |
Called whenever server start
@param ServentEvent $event
|
[
"Called",
"whenever",
"server",
"start"
] |
92c306963d8e9c74ecaa06422cea65bcf1bb3ba2
|
https://github.com/sopinetchat/SopinetChatBundle/blob/92c306963d8e9c74ecaa06422cea65bcf1bb3ba2/Listener/WebClientEventListener.php#L73-L93
|
225,528
|
cmsgears/module-forms
|
common/models/entities/FormSubmit.php
|
FormSubmit.getFieldsMap
|
public function getFieldsMap() {
$formFields = $this->fields;
$formFieldsMap = array();
foreach ( $formFields as $formField ) {
$formFieldsMap[ $formField->name ] = $formField;
}
return $formFieldsMap;
}
|
php
|
public function getFieldsMap() {
$formFields = $this->fields;
$formFieldsMap = array();
foreach ( $formFields as $formField ) {
$formFieldsMap[ $formField->name ] = $formField;
}
return $formFieldsMap;
}
|
[
"public",
"function",
"getFieldsMap",
"(",
")",
"{",
"$",
"formFields",
"=",
"$",
"this",
"->",
"fields",
";",
"$",
"formFieldsMap",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"formFields",
"as",
"$",
"formField",
")",
"{",
"$",
"formFieldsMap",
"[",
"$",
"formField",
"->",
"name",
"]",
"=",
"$",
"formField",
";",
"}",
"return",
"$",
"formFieldsMap",
";",
"}"
] |
Generate and return the map of form submit fields.
@return array
|
[
"Generate",
"and",
"return",
"the",
"map",
"of",
"form",
"submit",
"fields",
"."
] |
84cbb26e8ecb945410bb2604b84440d5ed841308
|
https://github.com/cmsgears/module-forms/blob/84cbb26e8ecb945410bb2604b84440d5ed841308/common/models/entities/FormSubmit.php#L154-L165
|
225,529
|
Innmind/Filesystem
|
src/Adapter/FilesystemAdapter.php
|
FilesystemAdapter.createFileAt
|
private function createFileAt(string $path, File $file)
{
if ($file instanceof Directory) {
$folder = $path.'/'.(string) $file->name();
if (
$this->files->contains($folder) &&
$this->files->get($folder) === $file
) {
return;
}
$this->filesystem->mkdir($folder);
$file
->modifications()
->foreach(function($event) use ($folder) {
if ($this->handledEvents->contains($event)) {
return;
}
switch (true) {
case $event instanceof FileWasRemoved:
$this
->filesystem
->remove($folder.'/'.$event->file());
break;
case $event instanceof FileWasAdded:
$this->createFileAt($folder, $event->file());
break;
}
$this->handledEvents = $this->handledEvents->add($event);
});
$this->files = $this->files->put($folder, $file);
return;
}
$path .= '/'.(string) $file->name();
if (
$this->files->contains($path) &&
$this->files->get($path) === $file
) {
return;
}
$stream = $file->content();
$stream->rewind();
$handle = fopen($path, 'w');
while (!$stream->end()) {
fwrite($handle, (string) $stream->read(8192));
}
$this->files = $this->files->put($path, $file);
}
|
php
|
private function createFileAt(string $path, File $file)
{
if ($file instanceof Directory) {
$folder = $path.'/'.(string) $file->name();
if (
$this->files->contains($folder) &&
$this->files->get($folder) === $file
) {
return;
}
$this->filesystem->mkdir($folder);
$file
->modifications()
->foreach(function($event) use ($folder) {
if ($this->handledEvents->contains($event)) {
return;
}
switch (true) {
case $event instanceof FileWasRemoved:
$this
->filesystem
->remove($folder.'/'.$event->file());
break;
case $event instanceof FileWasAdded:
$this->createFileAt($folder, $event->file());
break;
}
$this->handledEvents = $this->handledEvents->add($event);
});
$this->files = $this->files->put($folder, $file);
return;
}
$path .= '/'.(string) $file->name();
if (
$this->files->contains($path) &&
$this->files->get($path) === $file
) {
return;
}
$stream = $file->content();
$stream->rewind();
$handle = fopen($path, 'w');
while (!$stream->end()) {
fwrite($handle, (string) $stream->read(8192));
}
$this->files = $this->files->put($path, $file);
}
|
[
"private",
"function",
"createFileAt",
"(",
"string",
"$",
"path",
",",
"File",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"instanceof",
"Directory",
")",
"{",
"$",
"folder",
"=",
"$",
"path",
".",
"'/'",
".",
"(",
"string",
")",
"$",
"file",
"->",
"name",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"contains",
"(",
"$",
"folder",
")",
"&&",
"$",
"this",
"->",
"files",
"->",
"get",
"(",
"$",
"folder",
")",
"===",
"$",
"file",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"filesystem",
"->",
"mkdir",
"(",
"$",
"folder",
")",
";",
"$",
"file",
"->",
"modifications",
"(",
")",
"->",
"foreach",
"(",
"function",
"(",
"$",
"event",
")",
"use",
"(",
"$",
"folder",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"handledEvents",
"->",
"contains",
"(",
"$",
"event",
")",
")",
"{",
"return",
";",
"}",
"switch",
"(",
"true",
")",
"{",
"case",
"$",
"event",
"instanceof",
"FileWasRemoved",
":",
"$",
"this",
"->",
"filesystem",
"->",
"remove",
"(",
"$",
"folder",
".",
"'/'",
".",
"$",
"event",
"->",
"file",
"(",
")",
")",
";",
"break",
";",
"case",
"$",
"event",
"instanceof",
"FileWasAdded",
":",
"$",
"this",
"->",
"createFileAt",
"(",
"$",
"folder",
",",
"$",
"event",
"->",
"file",
"(",
")",
")",
";",
"break",
";",
"}",
"$",
"this",
"->",
"handledEvents",
"=",
"$",
"this",
"->",
"handledEvents",
"->",
"add",
"(",
"$",
"event",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"files",
"=",
"$",
"this",
"->",
"files",
"->",
"put",
"(",
"$",
"folder",
",",
"$",
"file",
")",
";",
"return",
";",
"}",
"$",
"path",
".=",
"'/'",
".",
"(",
"string",
")",
"$",
"file",
"->",
"name",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"contains",
"(",
"$",
"path",
")",
"&&",
"$",
"this",
"->",
"files",
"->",
"get",
"(",
"$",
"path",
")",
"===",
"$",
"file",
")",
"{",
"return",
";",
"}",
"$",
"stream",
"=",
"$",
"file",
"->",
"content",
"(",
")",
";",
"$",
"stream",
"->",
"rewind",
"(",
")",
";",
"$",
"handle",
"=",
"fopen",
"(",
"$",
"path",
",",
"'w'",
")",
";",
"while",
"(",
"!",
"$",
"stream",
"->",
"end",
"(",
")",
")",
"{",
"fwrite",
"(",
"$",
"handle",
",",
"(",
"string",
")",
"$",
"stream",
"->",
"read",
"(",
"8192",
")",
")",
";",
"}",
"$",
"this",
"->",
"files",
"=",
"$",
"this",
"->",
"files",
"->",
"put",
"(",
"$",
"path",
",",
"$",
"file",
")",
";",
"}"
] |
Create the wished file at the given absolute path
@param string $path
@param File $file
@return void
|
[
"Create",
"the",
"wished",
"file",
"at",
"the",
"given",
"absolute",
"path"
] |
21700d8424bc88e99fd5c612c5316613e4c45a3b
|
https://github.com/Innmind/Filesystem/blob/21700d8424bc88e99fd5c612c5316613e4c45a3b/src/Adapter/FilesystemAdapter.php#L122-L178
|
225,530
|
Innmind/Filesystem
|
src/Adapter/FilesystemAdapter.php
|
FilesystemAdapter.open
|
private function open(string $folder, string $file): File
{
$path = $folder.'/'.$file;
if (is_dir($path)) {
$object = new Directory\Directory(
$file,
(function($folder) {
$handle = opendir($folder);
while (($name = readdir($handle)) !== false) {
if (\in_array($name, self::INVALID_FILES, true)) {
continue;
}
yield $this->open($folder, $name);
}
closedir($handle);
})($path)
);
} else {
try {
$mediaType = MediaType::fromString(mime_content_type($path));
} catch (InvalidMediaTypeString $e) {
$mediaType = new NullMediaType;
}
$object = new File\File(
$file,
new LazyStream($path),
$mediaType
);
}
$this->files = $this->files->put($path, $object);
return $object;
}
|
php
|
private function open(string $folder, string $file): File
{
$path = $folder.'/'.$file;
if (is_dir($path)) {
$object = new Directory\Directory(
$file,
(function($folder) {
$handle = opendir($folder);
while (($name = readdir($handle)) !== false) {
if (\in_array($name, self::INVALID_FILES, true)) {
continue;
}
yield $this->open($folder, $name);
}
closedir($handle);
})($path)
);
} else {
try {
$mediaType = MediaType::fromString(mime_content_type($path));
} catch (InvalidMediaTypeString $e) {
$mediaType = new NullMediaType;
}
$object = new File\File(
$file,
new LazyStream($path),
$mediaType
);
}
$this->files = $this->files->put($path, $object);
return $object;
}
|
[
"private",
"function",
"open",
"(",
"string",
"$",
"folder",
",",
"string",
"$",
"file",
")",
":",
"File",
"{",
"$",
"path",
"=",
"$",
"folder",
".",
"'/'",
".",
"$",
"file",
";",
"if",
"(",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"$",
"object",
"=",
"new",
"Directory",
"\\",
"Directory",
"(",
"$",
"file",
",",
"(",
"function",
"(",
"$",
"folder",
")",
"{",
"$",
"handle",
"=",
"opendir",
"(",
"$",
"folder",
")",
";",
"while",
"(",
"(",
"$",
"name",
"=",
"readdir",
"(",
"$",
"handle",
")",
")",
"!==",
"false",
")",
"{",
"if",
"(",
"\\",
"in_array",
"(",
"$",
"name",
",",
"self",
"::",
"INVALID_FILES",
",",
"true",
")",
")",
"{",
"continue",
";",
"}",
"yield",
"$",
"this",
"->",
"open",
"(",
"$",
"folder",
",",
"$",
"name",
")",
";",
"}",
"closedir",
"(",
"$",
"handle",
")",
";",
"}",
")",
"(",
"$",
"path",
")",
")",
";",
"}",
"else",
"{",
"try",
"{",
"$",
"mediaType",
"=",
"MediaType",
"::",
"fromString",
"(",
"mime_content_type",
"(",
"$",
"path",
")",
")",
";",
"}",
"catch",
"(",
"InvalidMediaTypeString",
"$",
"e",
")",
"{",
"$",
"mediaType",
"=",
"new",
"NullMediaType",
";",
"}",
"$",
"object",
"=",
"new",
"File",
"\\",
"File",
"(",
"$",
"file",
",",
"new",
"LazyStream",
"(",
"$",
"path",
")",
",",
"$",
"mediaType",
")",
";",
"}",
"$",
"this",
"->",
"files",
"=",
"$",
"this",
"->",
"files",
"->",
"put",
"(",
"$",
"path",
",",
"$",
"object",
")",
";",
"return",
"$",
"object",
";",
"}"
] |
Open the file in the given folder
@param string $folder
@param string $file
@return File
|
[
"Open",
"the",
"file",
"in",
"the",
"given",
"folder"
] |
21700d8424bc88e99fd5c612c5316613e4c45a3b
|
https://github.com/Innmind/Filesystem/blob/21700d8424bc88e99fd5c612c5316613e4c45a3b/src/Adapter/FilesystemAdapter.php#L188-L226
|
225,531
|
SetBased/php-abc-form-louver
|
src/Control/LouverControl.php
|
LouverControl.getHtml
|
public function getHtml(): string
{
$this->prepareOverviewTable();
if (!empty($this->templateData))
{
$this->setAttrData('slat-name', $this->submitName);
// If required add template row to this louver control. This row will be used by JS for adding dynamically
// additional rows to the louver control.
$this->templateData[$this->templateKey] = 0;
$row = $this->rowFactory->createRow($this, $this->templateData);
$row->addClass('slat_template');
$row->setAttrStyle('visibility: collapse');
$row->prepare($this->submitName);
}
$ret = $this->prefix;
$ret .= Html::generateTag('table', $this->attributes);
// Generate HTML code for the column classes.
$ret .= '<colgroup>';
$ret .= $this->rowFactory->getHtmlColumnGroup();
$ret .= '</colgroup>';
$ret .= Html::generateTag('thead', ['class' => OverviewTable::$class]);
$ret .= $this->getHtmlHeader();
$ret .= '</thead>';
if ($this->footerControl)
{
$ret .= Html::generateTag('tfoot', ['class' => OverviewTable::$class]);
$ret .= '<tr>';
$ret .= Html::generateTag('td', ['colspan' => $this->rowFactory->getNumberOfColumns()]);
$ret .= $this->footerControl->getHtml();
$ret .= '</td>';
$ret .= '<td class="error"></td>';
$ret .= '</tr>';
$ret .= '</tfoot>';
}
$ret .= Html::generateTag('tbody', ['class' => OverviewTable::$class]);
$ret .= $this->getHtmlBody();
$ret .= '</tbody>';
$ret .= '</table>';
$ret .= $this->postfix;
$this->rowFactory->generateResponsiveCss($this->getAttribute('id'));
return $ret;
}
|
php
|
public function getHtml(): string
{
$this->prepareOverviewTable();
if (!empty($this->templateData))
{
$this->setAttrData('slat-name', $this->submitName);
// If required add template row to this louver control. This row will be used by JS for adding dynamically
// additional rows to the louver control.
$this->templateData[$this->templateKey] = 0;
$row = $this->rowFactory->createRow($this, $this->templateData);
$row->addClass('slat_template');
$row->setAttrStyle('visibility: collapse');
$row->prepare($this->submitName);
}
$ret = $this->prefix;
$ret .= Html::generateTag('table', $this->attributes);
// Generate HTML code for the column classes.
$ret .= '<colgroup>';
$ret .= $this->rowFactory->getHtmlColumnGroup();
$ret .= '</colgroup>';
$ret .= Html::generateTag('thead', ['class' => OverviewTable::$class]);
$ret .= $this->getHtmlHeader();
$ret .= '</thead>';
if ($this->footerControl)
{
$ret .= Html::generateTag('tfoot', ['class' => OverviewTable::$class]);
$ret .= '<tr>';
$ret .= Html::generateTag('td', ['colspan' => $this->rowFactory->getNumberOfColumns()]);
$ret .= $this->footerControl->getHtml();
$ret .= '</td>';
$ret .= '<td class="error"></td>';
$ret .= '</tr>';
$ret .= '</tfoot>';
}
$ret .= Html::generateTag('tbody', ['class' => OverviewTable::$class]);
$ret .= $this->getHtmlBody();
$ret .= '</tbody>';
$ret .= '</table>';
$ret .= $this->postfix;
$this->rowFactory->generateResponsiveCss($this->getAttribute('id'));
return $ret;
}
|
[
"public",
"function",
"getHtml",
"(",
")",
":",
"string",
"{",
"$",
"this",
"->",
"prepareOverviewTable",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"templateData",
")",
")",
"{",
"$",
"this",
"->",
"setAttrData",
"(",
"'slat-name'",
",",
"$",
"this",
"->",
"submitName",
")",
";",
"// If required add template row to this louver control. This row will be used by JS for adding dynamically",
"// additional rows to the louver control.",
"$",
"this",
"->",
"templateData",
"[",
"$",
"this",
"->",
"templateKey",
"]",
"=",
"0",
";",
"$",
"row",
"=",
"$",
"this",
"->",
"rowFactory",
"->",
"createRow",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"templateData",
")",
";",
"$",
"row",
"->",
"addClass",
"(",
"'slat_template'",
")",
";",
"$",
"row",
"->",
"setAttrStyle",
"(",
"'visibility: collapse'",
")",
";",
"$",
"row",
"->",
"prepare",
"(",
"$",
"this",
"->",
"submitName",
")",
";",
"}",
"$",
"ret",
"=",
"$",
"this",
"->",
"prefix",
";",
"$",
"ret",
".=",
"Html",
"::",
"generateTag",
"(",
"'table'",
",",
"$",
"this",
"->",
"attributes",
")",
";",
"// Generate HTML code for the column classes.",
"$",
"ret",
".=",
"'<colgroup>'",
";",
"$",
"ret",
".=",
"$",
"this",
"->",
"rowFactory",
"->",
"getHtmlColumnGroup",
"(",
")",
";",
"$",
"ret",
".=",
"'</colgroup>'",
";",
"$",
"ret",
".=",
"Html",
"::",
"generateTag",
"(",
"'thead'",
",",
"[",
"'class'",
"=>",
"OverviewTable",
"::",
"$",
"class",
"]",
")",
";",
"$",
"ret",
".=",
"$",
"this",
"->",
"getHtmlHeader",
"(",
")",
";",
"$",
"ret",
".=",
"'</thead>'",
";",
"if",
"(",
"$",
"this",
"->",
"footerControl",
")",
"{",
"$",
"ret",
".=",
"Html",
"::",
"generateTag",
"(",
"'tfoot'",
",",
"[",
"'class'",
"=>",
"OverviewTable",
"::",
"$",
"class",
"]",
")",
";",
"$",
"ret",
".=",
"'<tr>'",
";",
"$",
"ret",
".=",
"Html",
"::",
"generateTag",
"(",
"'td'",
",",
"[",
"'colspan'",
"=>",
"$",
"this",
"->",
"rowFactory",
"->",
"getNumberOfColumns",
"(",
")",
"]",
")",
";",
"$",
"ret",
".=",
"$",
"this",
"->",
"footerControl",
"->",
"getHtml",
"(",
")",
";",
"$",
"ret",
".=",
"'</td>'",
";",
"$",
"ret",
".=",
"'<td class=\"error\"></td>'",
";",
"$",
"ret",
".=",
"'</tr>'",
";",
"$",
"ret",
".=",
"'</tfoot>'",
";",
"}",
"$",
"ret",
".=",
"Html",
"::",
"generateTag",
"(",
"'tbody'",
",",
"[",
"'class'",
"=>",
"OverviewTable",
"::",
"$",
"class",
"]",
")",
";",
"$",
"ret",
".=",
"$",
"this",
"->",
"getHtmlBody",
"(",
")",
";",
"$",
"ret",
".=",
"'</tbody>'",
";",
"$",
"ret",
".=",
"'</table>'",
";",
"$",
"ret",
".=",
"$",
"this",
"->",
"postfix",
";",
"$",
"this",
"->",
"rowFactory",
"->",
"generateResponsiveCss",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
"'id'",
")",
")",
";",
"return",
"$",
"ret",
";",
"}"
] |
Returns the HTML code of displaying the form controls of this complex form control in a table.
@return string
|
[
"Returns",
"the",
"HTML",
"code",
"of",
"displaying",
"the",
"form",
"controls",
"of",
"this",
"complex",
"form",
"control",
"in",
"a",
"table",
"."
] |
59ff07a59da4ba90ef9665a8893559cd66d37233
|
https://github.com/SetBased/php-abc-form-louver/blob/59ff07a59da4ba90ef9665a8893559cd66d37233/src/Control/LouverControl.php#L67-L120
|
225,532
|
SetBased/php-abc-form-louver
|
src/Control/LouverControl.php
|
LouverControl.setFooterControl
|
public function setFooterControl(Control $control): void
{
$this->footerControl = $control;
$this->addFormControl($control);
}
|
php
|
public function setFooterControl(Control $control): void
{
$this->footerControl = $control;
$this->addFormControl($control);
}
|
[
"public",
"function",
"setFooterControl",
"(",
"Control",
"$",
"control",
")",
":",
"void",
"{",
"$",
"this",
"->",
"footerControl",
"=",
"$",
"control",
";",
"$",
"this",
"->",
"addFormControl",
"(",
"$",
"control",
")",
";",
"}"
] |
Sets the footer form control of this table form control.
@param Control $control
|
[
"Sets",
"the",
"footer",
"form",
"control",
"of",
"this",
"table",
"form",
"control",
"."
] |
59ff07a59da4ba90ef9665a8893559cd66d37233
|
https://github.com/SetBased/php-abc-form-louver/blob/59ff07a59da4ba90ef9665a8893559cd66d37233/src/Control/LouverControl.php#L181-L185
|
225,533
|
SetBased/php-abc-form-louver
|
src/Control/LouverControl.php
|
LouverControl.setTemplate
|
public function setTemplate(array $data, string $key): void
{
$this->templateData = $data;
$this->templateKey = $key;
}
|
php
|
public function setTemplate(array $data, string $key): void
{
$this->templateData = $data;
$this->templateKey = $key;
}
|
[
"public",
"function",
"setTemplate",
"(",
"array",
"$",
"data",
",",
"string",
"$",
"key",
")",
":",
"void",
"{",
"$",
"this",
"->",
"templateData",
"=",
"$",
"data",
";",
"$",
"this",
"->",
"templateKey",
"=",
"$",
"key",
";",
"}"
] |
Sets the template data and key of the key for dynamically adding additional rows to form.
@param array $data The data for initializing template row(s).
@param string $key The key of the key in the template row.
|
[
"Sets",
"the",
"template",
"data",
"and",
"key",
"of",
"the",
"key",
"for",
"dynamically",
"adding",
"additional",
"rows",
"to",
"form",
"."
] |
59ff07a59da4ba90ef9665a8893559cd66d37233
|
https://github.com/SetBased/php-abc-form-louver/blob/59ff07a59da4ba90ef9665a8893559cd66d37233/src/Control/LouverControl.php#L205-L209
|
225,534
|
SetBased/php-abc-form-louver
|
src/Control/LouverControl.php
|
LouverControl.getHtmlBody
|
protected function getHtmlBody(): string
{
$ret = '';
$i = 0;
foreach ($this->controls as $control)
{
if ($control!==$this->footerControl)
{
$control->addClass(OverviewTable::$class);
$control->addClass(($i % 2==0) ? 'even' : 'odd');
$ret .= $control->getHtml();
$i++;
}
}
return $ret;
}
|
php
|
protected function getHtmlBody(): string
{
$ret = '';
$i = 0;
foreach ($this->controls as $control)
{
if ($control!==$this->footerControl)
{
$control->addClass(OverviewTable::$class);
$control->addClass(($i % 2==0) ? 'even' : 'odd');
$ret .= $control->getHtml();
$i++;
}
}
return $ret;
}
|
[
"protected",
"function",
"getHtmlBody",
"(",
")",
":",
"string",
"{",
"$",
"ret",
"=",
"''",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"controls",
"as",
"$",
"control",
")",
"{",
"if",
"(",
"$",
"control",
"!==",
"$",
"this",
"->",
"footerControl",
")",
"{",
"$",
"control",
"->",
"addClass",
"(",
"OverviewTable",
"::",
"$",
"class",
")",
";",
"$",
"control",
"->",
"addClass",
"(",
"(",
"$",
"i",
"%",
"2",
"==",
"0",
")",
"?",
"'even'",
":",
"'odd'",
")",
";",
"$",
"ret",
".=",
"$",
"control",
"->",
"getHtml",
"(",
")",
";",
"$",
"i",
"++",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Returns the inner HTML code of the tbody element of this table form control.
@return string
|
[
"Returns",
"the",
"inner",
"HTML",
"code",
"of",
"the",
"tbody",
"element",
"of",
"this",
"table",
"form",
"control",
"."
] |
59ff07a59da4ba90ef9665a8893559cd66d37233
|
https://github.com/SetBased/php-abc-form-louver/blob/59ff07a59da4ba90ef9665a8893559cd66d37233/src/Control/LouverControl.php#L217-L235
|
225,535
|
SetBased/php-abc-form-louver
|
src/Control/LouverControl.php
|
LouverControl.prepareOverviewTable
|
private function prepareOverviewTable(): void
{
$this->addClass(OverviewTable::$class);
if (OverviewTable::$responsiveMediaQuery!==null && $this->getAttribute('id')===null)
{
$this->setAttrId(Html::getAutoId());
}
}
|
php
|
private function prepareOverviewTable(): void
{
$this->addClass(OverviewTable::$class);
if (OverviewTable::$responsiveMediaQuery!==null && $this->getAttribute('id')===null)
{
$this->setAttrId(Html::getAutoId());
}
}
|
[
"private",
"function",
"prepareOverviewTable",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"addClass",
"(",
"OverviewTable",
"::",
"$",
"class",
")",
";",
"if",
"(",
"OverviewTable",
"::",
"$",
"responsiveMediaQuery",
"!==",
"null",
"&&",
"$",
"this",
"->",
"getAttribute",
"(",
"'id'",
")",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setAttrId",
"(",
"Html",
"::",
"getAutoId",
"(",
")",
")",
";",
"}",
"}"
] |
Prepares the Overview table part for generation HTML code.
|
[
"Prepares",
"the",
"Overview",
"table",
"part",
"for",
"generation",
"HTML",
"code",
"."
] |
59ff07a59da4ba90ef9665a8893559cd66d37233
|
https://github.com/SetBased/php-abc-form-louver/blob/59ff07a59da4ba90ef9665a8893559cd66d37233/src/Control/LouverControl.php#L251-L259
|
225,536
|
Eve-PHP/Framework
|
src/Dispatcher.php
|
Dispatcher.run
|
public function run($queue = 'queue')
{
// notify its up
echo ' * Worker online. waiting for tasks.', "\n";
// define job
$callback = function($message) {
// notify once a task is received
echo " * a task is received", "\n";
// get the data
$data = json_decode($message->body, true);
// get application
$app = ucfirst($data['APPLICATION']);
//remove starting \\ and append the Job holder
$app = substr($app, 1).'\\Job\\';
// extract the job to perform
$task = str_replace(' ', '\\', ucwords(str_replace('-', ' ', $data['TASK'])));
$task = $app.$task;
$attempts = isset($data['RETRY']) ? $data['RETRY'] : 0;
try {
// if there's not a class
if(!class_exists($task)) {
//throw
throw new Exception('task do not exist', 404);
}
//instantiate the job
$job = new $task();
// set data and run the process
$job->setData($data)->run();
// once done, notify again, that it is done
echo " * task is done", "\n";
// set or flag that the worker is free
$message->delivery_info['channel']->basic_ack($message->delivery_info['delivery_tag']);
} catch (Exception $e) {
// once an exception is encountered, notify that task is not done
echo " * task not done", "\n";
echo $e->getMessage()."\n";
if ($attempts && $message->delivery_info['redelivered'] > $attempts) {
echo " * Requeueing ....", "\n";
// set or flag that the task is not done and the worker is free and requeue task
$message->delivery_info['channel']->basic_nack($message->delivery_info['delivery_tag'], false, true);
}
// set or flag that the task is not done and the worker is free
$message->delivery_info['channel']->basic_nack($message->delivery_info['delivery_tag']);
}
};
// worker consuming tasks from queue
$this->channel->basic_qos(null, 1, null);
// now we need to catch the channel exception
// when task does not exists in our queue
try {
// comsume messages on queue
$this->channel->basic_consume($queue, '', false, false, false, false, $callback);
} catch(\PhpAmqpLib\Exception\AMQPProtocolChannelException $e) {
// notify that task does not exists
echo " * Task does not exists, creating task. Please re-run the worker. \n";
// create the init queue
eve()->queue('init', array())->save();
}
while(count($this->channel->callbacks)) {
$this->channel->wait();
}
$this->channel->close();
$this->connection->close();
echo 'Closing Dispatcher'. PHP_EOL;
}
|
php
|
public function run($queue = 'queue')
{
// notify its up
echo ' * Worker online. waiting for tasks.', "\n";
// define job
$callback = function($message) {
// notify once a task is received
echo " * a task is received", "\n";
// get the data
$data = json_decode($message->body, true);
// get application
$app = ucfirst($data['APPLICATION']);
//remove starting \\ and append the Job holder
$app = substr($app, 1).'\\Job\\';
// extract the job to perform
$task = str_replace(' ', '\\', ucwords(str_replace('-', ' ', $data['TASK'])));
$task = $app.$task;
$attempts = isset($data['RETRY']) ? $data['RETRY'] : 0;
try {
// if there's not a class
if(!class_exists($task)) {
//throw
throw new Exception('task do not exist', 404);
}
//instantiate the job
$job = new $task();
// set data and run the process
$job->setData($data)->run();
// once done, notify again, that it is done
echo " * task is done", "\n";
// set or flag that the worker is free
$message->delivery_info['channel']->basic_ack($message->delivery_info['delivery_tag']);
} catch (Exception $e) {
// once an exception is encountered, notify that task is not done
echo " * task not done", "\n";
echo $e->getMessage()."\n";
if ($attempts && $message->delivery_info['redelivered'] > $attempts) {
echo " * Requeueing ....", "\n";
// set or flag that the task is not done and the worker is free and requeue task
$message->delivery_info['channel']->basic_nack($message->delivery_info['delivery_tag'], false, true);
}
// set or flag that the task is not done and the worker is free
$message->delivery_info['channel']->basic_nack($message->delivery_info['delivery_tag']);
}
};
// worker consuming tasks from queue
$this->channel->basic_qos(null, 1, null);
// now we need to catch the channel exception
// when task does not exists in our queue
try {
// comsume messages on queue
$this->channel->basic_consume($queue, '', false, false, false, false, $callback);
} catch(\PhpAmqpLib\Exception\AMQPProtocolChannelException $e) {
// notify that task does not exists
echo " * Task does not exists, creating task. Please re-run the worker. \n";
// create the init queue
eve()->queue('init', array())->save();
}
while(count($this->channel->callbacks)) {
$this->channel->wait();
}
$this->channel->close();
$this->connection->close();
echo 'Closing Dispatcher'. PHP_EOL;
}
|
[
"public",
"function",
"run",
"(",
"$",
"queue",
"=",
"'queue'",
")",
"{",
"// notify its up",
"echo",
"' * Worker online. waiting for tasks.'",
",",
"\"\\n\"",
";",
"// define job",
"$",
"callback",
"=",
"function",
"(",
"$",
"message",
")",
"{",
"// notify once a task is received",
"echo",
"\" * a task is received\"",
",",
"\"\\n\"",
";",
"// get the data",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"message",
"->",
"body",
",",
"true",
")",
";",
"// get application",
"$",
"app",
"=",
"ucfirst",
"(",
"$",
"data",
"[",
"'APPLICATION'",
"]",
")",
";",
"//remove starting \\\\ and append the Job holder",
"$",
"app",
"=",
"substr",
"(",
"$",
"app",
",",
"1",
")",
".",
"'\\\\Job\\\\'",
";",
"// extract the job to perform",
"$",
"task",
"=",
"str_replace",
"(",
"' '",
",",
"'\\\\'",
",",
"ucwords",
"(",
"str_replace",
"(",
"'-'",
",",
"' '",
",",
"$",
"data",
"[",
"'TASK'",
"]",
")",
")",
")",
";",
"$",
"task",
"=",
"$",
"app",
".",
"$",
"task",
";",
"$",
"attempts",
"=",
"isset",
"(",
"$",
"data",
"[",
"'RETRY'",
"]",
")",
"?",
"$",
"data",
"[",
"'RETRY'",
"]",
":",
"0",
";",
"try",
"{",
"// if there's not a class",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"task",
")",
")",
"{",
"//throw",
"throw",
"new",
"Exception",
"(",
"'task do not exist'",
",",
"404",
")",
";",
"}",
"//instantiate the job",
"$",
"job",
"=",
"new",
"$",
"task",
"(",
")",
";",
"// set data and run the process",
"$",
"job",
"->",
"setData",
"(",
"$",
"data",
")",
"->",
"run",
"(",
")",
";",
"// once done, notify again, that it is done",
"echo",
"\" * task is done\"",
",",
"\"\\n\"",
";",
"// set or flag that the worker is free",
"$",
"message",
"->",
"delivery_info",
"[",
"'channel'",
"]",
"->",
"basic_ack",
"(",
"$",
"message",
"->",
"delivery_info",
"[",
"'delivery_tag'",
"]",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"// once an exception is encountered, notify that task is not done",
"echo",
"\" * task not done\"",
",",
"\"\\n\"",
";",
"echo",
"$",
"e",
"->",
"getMessage",
"(",
")",
".",
"\"\\n\"",
";",
"if",
"(",
"$",
"attempts",
"&&",
"$",
"message",
"->",
"delivery_info",
"[",
"'redelivered'",
"]",
">",
"$",
"attempts",
")",
"{",
"echo",
"\" * Requeueing ....\"",
",",
"\"\\n\"",
";",
"// set or flag that the task is not done and the worker is free and requeue task",
"$",
"message",
"->",
"delivery_info",
"[",
"'channel'",
"]",
"->",
"basic_nack",
"(",
"$",
"message",
"->",
"delivery_info",
"[",
"'delivery_tag'",
"]",
",",
"false",
",",
"true",
")",
";",
"}",
"// set or flag that the task is not done and the worker is free",
"$",
"message",
"->",
"delivery_info",
"[",
"'channel'",
"]",
"->",
"basic_nack",
"(",
"$",
"message",
"->",
"delivery_info",
"[",
"'delivery_tag'",
"]",
")",
";",
"}",
"}",
";",
"// worker consuming tasks from queue",
"$",
"this",
"->",
"channel",
"->",
"basic_qos",
"(",
"null",
",",
"1",
",",
"null",
")",
";",
"// now we need to catch the channel exception",
"// when task does not exists in our queue",
"try",
"{",
"// comsume messages on queue",
"$",
"this",
"->",
"channel",
"->",
"basic_consume",
"(",
"$",
"queue",
",",
"''",
",",
"false",
",",
"false",
",",
"false",
",",
"false",
",",
"$",
"callback",
")",
";",
"}",
"catch",
"(",
"\\",
"PhpAmqpLib",
"\\",
"Exception",
"\\",
"AMQPProtocolChannelException",
"$",
"e",
")",
"{",
"// notify that task does not exists",
"echo",
"\" * Task does not exists, creating task. Please re-run the worker. \\n\"",
";",
"// create the init queue",
"eve",
"(",
")",
"->",
"queue",
"(",
"'init'",
",",
"array",
"(",
")",
")",
"->",
"save",
"(",
")",
";",
"}",
"while",
"(",
"count",
"(",
"$",
"this",
"->",
"channel",
"->",
"callbacks",
")",
")",
"{",
"$",
"this",
"->",
"channel",
"->",
"wait",
"(",
")",
";",
"}",
"$",
"this",
"->",
"channel",
"->",
"close",
"(",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"close",
"(",
")",
";",
"echo",
"'Closing Dispatcher'",
".",
"PHP_EOL",
";",
"}"
] |
Run the jobs
@return void
|
[
"Run",
"the",
"jobs"
] |
cd4ca9472c6c46034bde402bf20bf2f86657c608
|
https://github.com/Eve-PHP/Framework/blob/cd4ca9472c6c46034bde402bf20bf2f86657c608/src/Dispatcher.php#L27-L110
|
225,537
|
railken/amethyst-api
|
src/Api/Http/Controllers/RestController.php
|
RestController.getResourceName
|
public function getResourceName()
{
return $this->name !== null ? $this->name : str_replace('_', '-', (new Inflector())->tableize($this->getManager()->getName()));
}
|
php
|
public function getResourceName()
{
return $this->name !== null ? $this->name : str_replace('_', '-', (new Inflector())->tableize($this->getManager()->getName()));
}
|
[
"public",
"function",
"getResourceName",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"name",
"!==",
"null",
"?",
"$",
"this",
"->",
"name",
":",
"str_replace",
"(",
"'_'",
",",
"'-'",
",",
"(",
"new",
"Inflector",
"(",
")",
")",
"->",
"tableize",
"(",
"$",
"this",
"->",
"getManager",
"(",
")",
"->",
"getName",
"(",
")",
")",
")",
";",
"}"
] |
Retrieve resource name.
@return string
|
[
"Retrieve",
"resource",
"name",
"."
] |
00b78540b05dac59e6ef9367f1c37623a5754b89
|
https://github.com/railken/amethyst-api/blob/00b78540b05dac59e6ef9367f1c37623a5754b89/src/Api/Http/Controllers/RestController.php#L50-L53
|
225,538
|
railken/amethyst-api
|
src/Api/Http/Controllers/RestController.php
|
RestController.parseKey
|
public function parseKey($key)
{
$keys = explode('.', $key);
if (count($keys) === 1) {
$keys = [$this->getManager()->getRepository()->newEntity()->getTable(), $keys[0]];
}
return DB::raw('`'.implode('.', array_slice($keys, 0, -1)).'`.'.$keys[count($keys) - 1]);
}
|
php
|
public function parseKey($key)
{
$keys = explode('.', $key);
if (count($keys) === 1) {
$keys = [$this->getManager()->getRepository()->newEntity()->getTable(), $keys[0]];
}
return DB::raw('`'.implode('.', array_slice($keys, 0, -1)).'`.'.$keys[count($keys) - 1]);
}
|
[
"public",
"function",
"parseKey",
"(",
"$",
"key",
")",
"{",
"$",
"keys",
"=",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"if",
"(",
"count",
"(",
"$",
"keys",
")",
"===",
"1",
")",
"{",
"$",
"keys",
"=",
"[",
"$",
"this",
"->",
"getManager",
"(",
")",
"->",
"getRepository",
"(",
")",
"->",
"newEntity",
"(",
")",
"->",
"getTable",
"(",
")",
",",
"$",
"keys",
"[",
"0",
"]",
"]",
";",
"}",
"return",
"DB",
"::",
"raw",
"(",
"'`'",
".",
"implode",
"(",
"'.'",
",",
"array_slice",
"(",
"$",
"keys",
",",
"0",
",",
"-",
"1",
")",
")",
".",
"'`.'",
".",
"$",
"keys",
"[",
"count",
"(",
"$",
"keys",
")",
"-",
"1",
"]",
")",
";",
"}"
] |
Parse the key before using it in the query.
@param string $key
@return string
|
[
"Parse",
"the",
"key",
"before",
"using",
"it",
"in",
"the",
"query",
"."
] |
00b78540b05dac59e6ef9367f1c37623a5754b89
|
https://github.com/railken/amethyst-api/blob/00b78540b05dac59e6ef9367f1c37623a5754b89/src/Api/Http/Controllers/RestController.php#L72-L81
|
225,539
|
railken/amethyst-api
|
src/Api/Http/Controllers/RestController.php
|
RestController.getFractalTransformer
|
public function getFractalTransformer(EntityContract $entity = null, Request $request): TransformerAbstract
{
$classTransformer = $this->transformerClass;
return new $classTransformer($this->getManager(), $request);
}
|
php
|
public function getFractalTransformer(EntityContract $entity = null, Request $request): TransformerAbstract
{
$classTransformer = $this->transformerClass;
return new $classTransformer($this->getManager(), $request);
}
|
[
"public",
"function",
"getFractalTransformer",
"(",
"EntityContract",
"$",
"entity",
"=",
"null",
",",
"Request",
"$",
"request",
")",
":",
"TransformerAbstract",
"{",
"$",
"classTransformer",
"=",
"$",
"this",
"->",
"transformerClass",
";",
"return",
"new",
"$",
"classTransformer",
"(",
"$",
"this",
"->",
"getManager",
"(",
")",
",",
"$",
"request",
")",
";",
"}"
] |
Create a new instance of fractal transformer.
@param \Railken\Lem\Contracts\EntityContract $entity
@param \Illuminate\Http\Request $request
@return TransformerAbstract
|
[
"Create",
"a",
"new",
"instance",
"of",
"fractal",
"transformer",
"."
] |
00b78540b05dac59e6ef9367f1c37623a5754b89
|
https://github.com/railken/amethyst-api/blob/00b78540b05dac59e6ef9367f1c37623a5754b89/src/Api/Http/Controllers/RestController.php#L101-L106
|
225,540
|
railken/amethyst-api
|
src/Api/Http/Controllers/RestController.php
|
RestController.getResourceBaseUrl
|
public function getResourceBaseUrl(Request $request): string
{
return $request->getSchemeAndHttpHost().Config::get('amethyst.api.http.'.explode('.', Route::getCurrentRoute()->getName())[0].'.router.prefix');
}
|
php
|
public function getResourceBaseUrl(Request $request): string
{
return $request->getSchemeAndHttpHost().Config::get('amethyst.api.http.'.explode('.', Route::getCurrentRoute()->getName())[0].'.router.prefix');
}
|
[
"public",
"function",
"getResourceBaseUrl",
"(",
"Request",
"$",
"request",
")",
":",
"string",
"{",
"return",
"$",
"request",
"->",
"getSchemeAndHttpHost",
"(",
")",
".",
"Config",
"::",
"get",
"(",
"'amethyst.api.http.'",
".",
"explode",
"(",
"'.'",
",",
"Route",
"::",
"getCurrentRoute",
"(",
")",
"->",
"getName",
"(",
")",
")",
"[",
"0",
"]",
".",
"'.router.prefix'",
")",
";",
"}"
] |
Retrieve url base.
@param \Illuminate\Http\Request $request
@return string
|
[
"Retrieve",
"url",
"base",
"."
] |
00b78540b05dac59e6ef9367f1c37623a5754b89
|
https://github.com/railken/amethyst-api/blob/00b78540b05dac59e6ef9367f1c37623a5754b89/src/Api/Http/Controllers/RestController.php#L115-L118
|
225,541
|
railken/amethyst-api
|
src/Api/Http/Controllers/RestController.php
|
RestController.getFractalManager
|
public function getFractalManager(Request $request)
{
$manager = new Fractal\Manager();
$manager->setSerializer(new JsonApiSerializer($this->getResourceBaseUrl($request)));
if ($request->input('include') !== null) {
$manager->parseIncludes($request->input('include'));
}
return $manager;
}
|
php
|
public function getFractalManager(Request $request)
{
$manager = new Fractal\Manager();
$manager->setSerializer(new JsonApiSerializer($this->getResourceBaseUrl($request)));
if ($request->input('include') !== null) {
$manager->parseIncludes($request->input('include'));
}
return $manager;
}
|
[
"public",
"function",
"getFractalManager",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"manager",
"=",
"new",
"Fractal",
"\\",
"Manager",
"(",
")",
";",
"$",
"manager",
"->",
"setSerializer",
"(",
"new",
"JsonApiSerializer",
"(",
"$",
"this",
"->",
"getResourceBaseUrl",
"(",
"$",
"request",
")",
")",
")",
";",
"if",
"(",
"$",
"request",
"->",
"input",
"(",
"'include'",
")",
"!==",
"null",
")",
"{",
"$",
"manager",
"->",
"parseIncludes",
"(",
"$",
"request",
"->",
"input",
"(",
"'include'",
")",
")",
";",
"}",
"return",
"$",
"manager",
";",
"}"
] |
Retrieve fractal manager.
@param \Illuminate\Http\Request $request
@return Fractal\Manager;
|
[
"Retrieve",
"fractal",
"manager",
"."
] |
00b78540b05dac59e6ef9367f1c37623a5754b89
|
https://github.com/railken/amethyst-api/blob/00b78540b05dac59e6ef9367f1c37623a5754b89/src/Api/Http/Controllers/RestController.php#L127-L137
|
225,542
|
swayok/peskyorm-laravel
|
src/PeskyORMLaravel/Db/Column/Utils/ImageModificationConfig.php
|
ImageModificationConfig.setVerticalAlign
|
public function setVerticalAlign($verticalAlign) {
if (!in_array($verticalAlign, [static::TOP, static::CENTER, static::BOTTOM], true)) {
throw new \InvalidArgumentException(
'$verticalAlign argument must be one of: ImagesGroupConfig::TOP, ImagesGroupConfig::CENTER, ImagesGroupConfig::BOTTOM'
);
}
$this->verticalAlign = $verticalAlign;
return $this;
}
|
php
|
public function setVerticalAlign($verticalAlign) {
if (!in_array($verticalAlign, [static::TOP, static::CENTER, static::BOTTOM], true)) {
throw new \InvalidArgumentException(
'$verticalAlign argument must be one of: ImagesGroupConfig::TOP, ImagesGroupConfig::CENTER, ImagesGroupConfig::BOTTOM'
);
}
$this->verticalAlign = $verticalAlign;
return $this;
}
|
[
"public",
"function",
"setVerticalAlign",
"(",
"$",
"verticalAlign",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"verticalAlign",
",",
"[",
"static",
"::",
"TOP",
",",
"static",
"::",
"CENTER",
",",
"static",
"::",
"BOTTOM",
"]",
",",
"true",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$verticalAlign argument must be one of: ImagesGroupConfig::TOP, ImagesGroupConfig::CENTER, ImagesGroupConfig::BOTTOM'",
")",
";",
"}",
"$",
"this",
"->",
"verticalAlign",
"=",
"$",
"verticalAlign",
";",
"return",
"$",
"this",
";",
"}"
] |
Set vertical align for images with fit mode CONTAIN and COVER
@param int $verticalAlign
@return $this
@throws \InvalidArgumentException
|
[
"Set",
"vertical",
"align",
"for",
"images",
"with",
"fit",
"mode",
"CONTAIN",
"and",
"COVER"
] |
ae5a285790eade3435f9fcbb6c376b755a5c3956
|
https://github.com/swayok/peskyorm-laravel/blob/ae5a285790eade3435f9fcbb6c376b755a5c3956/src/PeskyORMLaravel/Db/Column/Utils/ImageModificationConfig.php#L177-L185
|
225,543
|
swayok/peskyorm-laravel
|
src/PeskyORMLaravel/Db/Column/Utils/ImageModificationConfig.php
|
ImageModificationConfig.setImageType
|
public function setImageType($mimeType) {
if (!in_array($mimeType, [self::SAME_AS_ORIGINAL, self::GIF, self::PNG, self::JPEG, self::SVG], true)) {
throw new \InvalidArgumentException("\$mimeType '{$mimeType}' is not supported");
}
$this->alterImageType = $mimeType;
return $this;
}
|
php
|
public function setImageType($mimeType) {
if (!in_array($mimeType, [self::SAME_AS_ORIGINAL, self::GIF, self::PNG, self::JPEG, self::SVG], true)) {
throw new \InvalidArgumentException("\$mimeType '{$mimeType}' is not supported");
}
$this->alterImageType = $mimeType;
return $this;
}
|
[
"public",
"function",
"setImageType",
"(",
"$",
"mimeType",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"mimeType",
",",
"[",
"self",
"::",
"SAME_AS_ORIGINAL",
",",
"self",
"::",
"GIF",
",",
"self",
"::",
"PNG",
",",
"self",
"::",
"JPEG",
",",
"self",
"::",
"SVG",
"]",
",",
"true",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"\\$mimeType '{$mimeType}' is not supported\"",
")",
";",
"}",
"$",
"this",
"->",
"alterImageType",
"=",
"$",
"mimeType",
";",
"return",
"$",
"this",
";",
"}"
] |
Change image type
@param $mimeType - ImageModificationConfig::SAME_AS_ORIGINAL, ImageModificationConfig::PNG,
ImageModificationConfig::JPEG, ImageModificationConfig::GIF, ImageModificationConfig::SVG
@return ImageModificationConfig
@throws \InvalidArgumentException
|
[
"Change",
"image",
"type"
] |
ae5a285790eade3435f9fcbb6c376b755a5c3956
|
https://github.com/swayok/peskyorm-laravel/blob/ae5a285790eade3435f9fcbb6c376b755a5c3956/src/PeskyORMLaravel/Db/Column/Utils/ImageModificationConfig.php#L265-L271
|
225,544
|
stubbles/stubbles-input
|
src/main/php/errors/messages/PropertyBasedParamErrorMessages.php
|
PropertyBasedParamErrorMessages.messagesFor
|
public function messagesFor(ParamError $error): array
{
return $error->fillMessages($this->properties()->section($error->id()));
}
|
php
|
public function messagesFor(ParamError $error): array
{
return $error->fillMessages($this->properties()->section($error->id()));
}
|
[
"public",
"function",
"messagesFor",
"(",
"ParamError",
"$",
"error",
")",
":",
"array",
"{",
"return",
"$",
"error",
"->",
"fillMessages",
"(",
"$",
"this",
"->",
"properties",
"(",
")",
"->",
"section",
"(",
"$",
"error",
"->",
"id",
"(",
")",
")",
")",
";",
"}"
] |
creates a list of message for given param error
@param \stubbles\input\errors\ParamError $error
@return \stubbles\input\errors\messages\LocalizedMessage[]
|
[
"creates",
"a",
"list",
"of",
"message",
"for",
"given",
"param",
"error"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/errors/messages/PropertyBasedParamErrorMessages.php#L77-L80
|
225,545
|
stubbles/stubbles-input
|
src/main/php/errors/messages/PropertyBasedParamErrorMessages.php
|
PropertyBasedParamErrorMessages.messageFor
|
public function messageFor(ParamError $error, string $locale = null): LocalizedMessage
{
$usedLocale = $this->selectLocale($error->id(), $locale);
return $error->fillMessage(
$this->properties()->value($error->id(), $usedLocale, ''),
$usedLocale
);
}
|
php
|
public function messageFor(ParamError $error, string $locale = null): LocalizedMessage
{
$usedLocale = $this->selectLocale($error->id(), $locale);
return $error->fillMessage(
$this->properties()->value($error->id(), $usedLocale, ''),
$usedLocale
);
}
|
[
"public",
"function",
"messageFor",
"(",
"ParamError",
"$",
"error",
",",
"string",
"$",
"locale",
"=",
"null",
")",
":",
"LocalizedMessage",
"{",
"$",
"usedLocale",
"=",
"$",
"this",
"->",
"selectLocale",
"(",
"$",
"error",
"->",
"id",
"(",
")",
",",
"$",
"locale",
")",
";",
"return",
"$",
"error",
"->",
"fillMessage",
"(",
"$",
"this",
"->",
"properties",
"(",
")",
"->",
"value",
"(",
"$",
"error",
"->",
"id",
"(",
")",
",",
"$",
"usedLocale",
",",
"''",
")",
",",
"$",
"usedLocale",
")",
";",
"}"
] |
creates message for given param error in given locale
If no locale is given the method falls back to a default locale.
@param \stubbles\input\errors\ParamError $error
@param string $locale
@return \stubbles\input\errors\messages\LocalizedMessage
|
[
"creates",
"message",
"for",
"given",
"param",
"error",
"in",
"given",
"locale"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/errors/messages/PropertyBasedParamErrorMessages.php#L91-L98
|
225,546
|
stubbles/stubbles-input
|
src/main/php/errors/messages/PropertyBasedParamErrorMessages.php
|
PropertyBasedParamErrorMessages.selectLocale
|
private function selectLocale(string $errorId, string $requestedLocale = null): string
{
$properties = $this->properties();
if (null !== $requestedLocale) {
if ($properties->containValue($errorId, $requestedLocale)) {
return $requestedLocale;
}
$baseLocale = substr($requestedLocale, 0, strpos($requestedLocale, '_')) . '_*';
if ($properties->containValue($errorId, $baseLocale)) {
return $baseLocale;
}
}
if ($properties->containValue($errorId, $this->defaultLocale)) {
return $this->defaultLocale;
}
return 'default';
}
|
php
|
private function selectLocale(string $errorId, string $requestedLocale = null): string
{
$properties = $this->properties();
if (null !== $requestedLocale) {
if ($properties->containValue($errorId, $requestedLocale)) {
return $requestedLocale;
}
$baseLocale = substr($requestedLocale, 0, strpos($requestedLocale, '_')) . '_*';
if ($properties->containValue($errorId, $baseLocale)) {
return $baseLocale;
}
}
if ($properties->containValue($errorId, $this->defaultLocale)) {
return $this->defaultLocale;
}
return 'default';
}
|
[
"private",
"function",
"selectLocale",
"(",
"string",
"$",
"errorId",
",",
"string",
"$",
"requestedLocale",
"=",
"null",
")",
":",
"string",
"{",
"$",
"properties",
"=",
"$",
"this",
"->",
"properties",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"requestedLocale",
")",
"{",
"if",
"(",
"$",
"properties",
"->",
"containValue",
"(",
"$",
"errorId",
",",
"$",
"requestedLocale",
")",
")",
"{",
"return",
"$",
"requestedLocale",
";",
"}",
"$",
"baseLocale",
"=",
"substr",
"(",
"$",
"requestedLocale",
",",
"0",
",",
"strpos",
"(",
"$",
"requestedLocale",
",",
"'_'",
")",
")",
".",
"'_*'",
";",
"if",
"(",
"$",
"properties",
"->",
"containValue",
"(",
"$",
"errorId",
",",
"$",
"baseLocale",
")",
")",
"{",
"return",
"$",
"baseLocale",
";",
"}",
"}",
"if",
"(",
"$",
"properties",
"->",
"containValue",
"(",
"$",
"errorId",
",",
"$",
"this",
"->",
"defaultLocale",
")",
")",
"{",
"return",
"$",
"this",
"->",
"defaultLocale",
";",
"}",
"return",
"'default'",
";",
"}"
] |
selects locale based on availability of translations
@param string $errorId
@param string $requestedLocale
@return string
|
[
"selects",
"locale",
"based",
"on",
"availability",
"of",
"translations"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/errors/messages/PropertyBasedParamErrorMessages.php#L107-L126
|
225,547
|
stubbles/stubbles-input
|
src/main/php/errors/messages/PropertyBasedParamErrorMessages.php
|
PropertyBasedParamErrorMessages.properties
|
private function properties(): Properties
{
static $properties = null;
if (null === $properties) {
$properties = new Properties();
foreach ($this->resourceLoader->availableResourceUris('input/error/message.ini') as $resourceUri) {
$properties = $properties->merge(Properties::fromFile($resourceUri));
}
}
return $properties;
}
|
php
|
private function properties(): Properties
{
static $properties = null;
if (null === $properties) {
$properties = new Properties();
foreach ($this->resourceLoader->availableResourceUris('input/error/message.ini') as $resourceUri) {
$properties = $properties->merge(Properties::fromFile($resourceUri));
}
}
return $properties;
}
|
[
"private",
"function",
"properties",
"(",
")",
":",
"Properties",
"{",
"static",
"$",
"properties",
"=",
"null",
";",
"if",
"(",
"null",
"===",
"$",
"properties",
")",
"{",
"$",
"properties",
"=",
"new",
"Properties",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"resourceLoader",
"->",
"availableResourceUris",
"(",
"'input/error/message.ini'",
")",
"as",
"$",
"resourceUri",
")",
"{",
"$",
"properties",
"=",
"$",
"properties",
"->",
"merge",
"(",
"Properties",
"::",
"fromFile",
"(",
"$",
"resourceUri",
")",
")",
";",
"}",
"}",
"return",
"$",
"properties",
";",
"}"
] |
parses properties from property files
@return \stubbles\values\Properties
|
[
"parses",
"properties",
"from",
"property",
"files"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/errors/messages/PropertyBasedParamErrorMessages.php#L133-L144
|
225,548
|
DrNixx/yii2-onix
|
src/http/Curl.php
|
Curl.getHeaders
|
private function getHeaders()
{
$result = [];
foreach ($this->headers as $name => $value) {
$result[] = sprintf("%s: %s", $name, $value);
}
return $result;
}
|
php
|
private function getHeaders()
{
$result = [];
foreach ($this->headers as $name => $value) {
$result[] = sprintf("%s: %s", $name, $value);
}
return $result;
}
|
[
"private",
"function",
"getHeaders",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"sprintf",
"(",
"\"%s: %s\"",
",",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Convert name=>value headers to strings
@return array
|
[
"Convert",
"name",
"=",
">",
"value",
"headers",
"to",
"strings"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/http/Curl.php#L289-L297
|
225,549
|
DrNixx/yii2-onix
|
src/http/Curl.php
|
Curl.unsetOption
|
public function unsetOption($key)
{
//reset a single option if its set already
if (isset($this->options[$key])) {
unset($this->options[$key]);
}
return $this;
}
|
php
|
public function unsetOption($key)
{
//reset a single option if its set already
if (isset($this->options[$key])) {
unset($this->options[$key]);
}
return $this;
}
|
[
"public",
"function",
"unsetOption",
"(",
"$",
"key",
")",
"{",
"//reset a single option if its set already",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"key",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Unset a single curl option
@param string $key
@return $this
|
[
"Unset",
"a",
"single",
"curl",
"option"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/http/Curl.php#L306-L314
|
225,550
|
DrNixx/yii2-onix
|
src/http/Curl.php
|
Curl.reset
|
public function reset()
{
if ($this->curl !== null) {
curl_close($this->curl); //stop curl
}
//reset all options
$this->unsetOptions();
//reset response & status code
$this->curl = null;
$this->response = null;
$this->responseCode = null;
return $this;
}
|
php
|
public function reset()
{
if ($this->curl !== null) {
curl_close($this->curl); //stop curl
}
//reset all options
$this->unsetOptions();
//reset response & status code
$this->curl = null;
$this->response = null;
$this->responseCode = null;
return $this;
}
|
[
"public",
"function",
"reset",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"curl",
"!==",
"null",
")",
"{",
"curl_close",
"(",
"$",
"this",
"->",
"curl",
")",
";",
"//stop curl",
"}",
"//reset all options",
"$",
"this",
"->",
"unsetOptions",
"(",
")",
";",
"//reset response & status code",
"$",
"this",
"->",
"curl",
"=",
"null",
";",
"$",
"this",
"->",
"response",
"=",
"null",
";",
"$",
"this",
"->",
"responseCode",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
] |
Total reset of options, responses, etc.
@return $this
|
[
"Total",
"reset",
"of",
"options",
"responses",
"etc",
"."
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/http/Curl.php#L337-L352
|
225,551
|
DrNixx/yii2-onix
|
src/http/Curl.php
|
Curl.getOption
|
public function getOption($key)
{
//get merged options depends on default and user options
$mergesOptions = $this->getOptions();
//return value or false if key is not set.
return isset($mergesOptions[$key]) ? $mergesOptions[$key] : false;
}
|
php
|
public function getOption($key)
{
//get merged options depends on default and user options
$mergesOptions = $this->getOptions();
//return value or false if key is not set.
return isset($mergesOptions[$key]) ? $mergesOptions[$key] : false;
}
|
[
"public",
"function",
"getOption",
"(",
"$",
"key",
")",
"{",
"//get merged options depends on default and user options",
"$",
"mergesOptions",
"=",
"$",
"this",
"->",
"getOptions",
"(",
")",
";",
"//return value or false if key is not set.",
"return",
"isset",
"(",
"$",
"mergesOptions",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"mergesOptions",
"[",
"$",
"key",
"]",
":",
"false",
";",
"}"
] |
Return a single option
@param string|integer $key
@return mixed|boolean
|
[
"Return",
"a",
"single",
"option"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/http/Curl.php#L361-L368
|
225,552
|
DrNixx/yii2-onix
|
src/http/Curl.php
|
Curl.getOptions
|
public function getOptions()
{
$options = [];
if (sizeof($this->headers) > 0) {
$options = [
CURLOPT_HTTPHEADER => $this->getHeaders()
];
}
return $options + $this->options + $this->getDefaultOptions();
}
|
php
|
public function getOptions()
{
$options = [];
if (sizeof($this->headers) > 0) {
$options = [
CURLOPT_HTTPHEADER => $this->getHeaders()
];
}
return $options + $this->options + $this->getDefaultOptions();
}
|
[
"public",
"function",
"getOptions",
"(",
")",
"{",
"$",
"options",
"=",
"[",
"]",
";",
"if",
"(",
"sizeof",
"(",
"$",
"this",
"->",
"headers",
")",
">",
"0",
")",
"{",
"$",
"options",
"=",
"[",
"CURLOPT_HTTPHEADER",
"=>",
"$",
"this",
"->",
"getHeaders",
"(",
")",
"]",
";",
"}",
"return",
"$",
"options",
"+",
"$",
"this",
"->",
"options",
"+",
"$",
"this",
"->",
"getDefaultOptions",
"(",
")",
";",
"}"
] |
Return merged curl options and keep keys!
@return array
|
[
"Return",
"merged",
"curl",
"options",
"and",
"keep",
"keys!"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/http/Curl.php#L376-L386
|
225,553
|
vperyod/vperyod.auth-handler
|
src/AuthRequestAwareTrait.php
|
AuthRequestAwareTrait.getAuth
|
protected function getAuth(Request $request) : Auth
{
$auth = $request->getAttribute($this->authAttribute);
if (! $auth instanceof Auth) {
throw new \InvalidArgumentException(
'Auth attribute not available in request'
);
}
return $auth;
}
|
php
|
protected function getAuth(Request $request) : Auth
{
$auth = $request->getAttribute($this->authAttribute);
if (! $auth instanceof Auth) {
throw new \InvalidArgumentException(
'Auth attribute not available in request'
);
}
return $auth;
}
|
[
"protected",
"function",
"getAuth",
"(",
"Request",
"$",
"request",
")",
":",
"Auth",
"{",
"$",
"auth",
"=",
"$",
"request",
"->",
"getAttribute",
"(",
"$",
"this",
"->",
"authAttribute",
")",
";",
"if",
"(",
"!",
"$",
"auth",
"instanceof",
"Auth",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Auth attribute not available in request'",
")",
";",
"}",
"return",
"$",
"auth",
";",
"}"
] |
Get auth from request
@param Request $request PSR7 Request
@return Auth
@throws \InvalidArgumentException if auth attribute is not an `Auth`
@access protected
|
[
"Get",
"auth",
"from",
"request"
] |
7b90b4ca1d8a39f8ea159022046fe898eaae3db7
|
https://github.com/vperyod/vperyod.auth-handler/blob/7b90b4ca1d8a39f8ea159022046fe898eaae3db7/src/AuthRequestAwareTrait.php#L74-L83
|
225,554
|
edineibauer/helpers
|
public/src/Helpers/Time.php
|
Time.checkValueTime
|
private function checkValueTime(int $value)
{
if ($value > -1 && $value < 60) {
if (!isset($this->data['h']) && $value < 24) {
return "h";
} elseif (!isset($this->data['i'])) {
return "i";
} else {
return "s";
}
}
return null;
}
|
php
|
private function checkValueTime(int $value)
{
if ($value > -1 && $value < 60) {
if (!isset($this->data['h']) && $value < 24) {
return "h";
} elseif (!isset($this->data['i'])) {
return "i";
} else {
return "s";
}
}
return null;
}
|
[
"private",
"function",
"checkValueTime",
"(",
"int",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
">",
"-",
"1",
"&&",
"$",
"value",
"<",
"60",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'h'",
"]",
")",
"&&",
"$",
"value",
"<",
"24",
")",
"{",
"return",
"\"h\"",
";",
"}",
"elseif",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'i'",
"]",
")",
")",
"{",
"return",
"\"i\"",
";",
"}",
"else",
"{",
"return",
"\"s\"",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Verifica qual tempo utilizar
@param int $value
@return mixed
|
[
"Verifica",
"qual",
"tempo",
"utilizar"
] |
3ed14fec3a8f2f282107f79f6bd1ca11e6882300
|
https://github.com/edineibauer/helpers/blob/3ed14fec3a8f2f282107f79f6bd1ca11e6882300/public/src/Helpers/Time.php#L89-L102
|
225,555
|
edineibauer/helpers
|
public/src/Helpers/Time.php
|
Time.checkNameHour
|
private function checkNameHour(string $time)
{
if (preg_match('/\s*\d{1,2}\s*(h|hour|hora|hs|hr|hrs)\s*/i', $time)) {
$this->setCerteza("h", $time);
}
if (preg_match('/\s*\d{1,2}\s*(m|min|minuto)\s*/i', $time)) {
$this->setCerteza("i", $time);
}
if (preg_match('/\s*\d{1,2}\s*(s|seg|segundo)\s*/i', $time)) {
$this->setCerteza("s", $time);
}
}
|
php
|
private function checkNameHour(string $time)
{
if (preg_match('/\s*\d{1,2}\s*(h|hour|hora|hs|hr|hrs)\s*/i', $time)) {
$this->setCerteza("h", $time);
}
if (preg_match('/\s*\d{1,2}\s*(m|min|minuto)\s*/i', $time)) {
$this->setCerteza("i", $time);
}
if (preg_match('/\s*\d{1,2}\s*(s|seg|segundo)\s*/i', $time)) {
$this->setCerteza("s", $time);
}
}
|
[
"private",
"function",
"checkNameHour",
"(",
"string",
"$",
"time",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/\\s*\\d{1,2}\\s*(h|hour|hora|hs|hr|hrs)\\s*/i'",
",",
"$",
"time",
")",
")",
"{",
"$",
"this",
"->",
"setCerteza",
"(",
"\"h\"",
",",
"$",
"time",
")",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/\\s*\\d{1,2}\\s*(m|min|minuto)\\s*/i'",
",",
"$",
"time",
")",
")",
"{",
"$",
"this",
"->",
"setCerteza",
"(",
"\"i\"",
",",
"$",
"time",
")",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/\\s*\\d{1,2}\\s*(s|seg|segundo)\\s*/i'",
",",
"$",
"time",
")",
")",
"{",
"$",
"this",
"->",
"setCerteza",
"(",
"\"s\"",
",",
"$",
"time",
")",
";",
"}",
"}"
] |
Verifica Se a string encontrada diz respeito a uma hora, minuto ou segundo
@param string $time
|
[
"Verifica",
"Se",
"a",
"string",
"encontrada",
"diz",
"respeito",
"a",
"uma",
"hora",
"minuto",
"ou",
"segundo"
] |
3ed14fec3a8f2f282107f79f6bd1ca11e6882300
|
https://github.com/edineibauer/helpers/blob/3ed14fec3a8f2f282107f79f6bd1ca11e6882300/public/src/Helpers/Time.php#L108-L121
|
225,556
|
SlayerBirden/dataflow
|
src/Pipe/Swap.php
|
Swap.pass
|
public function pass(DataBagInterface $dataBag): DataBagInterface
{
$first = $dataBag[$this->first] ?? null;
$second = $dataBag[$this->second] ?? null;
$dataBag[$this->first] = $second;
$dataBag[$this->second] = $first;
return $dataBag;
}
|
php
|
public function pass(DataBagInterface $dataBag): DataBagInterface
{
$first = $dataBag[$this->first] ?? null;
$second = $dataBag[$this->second] ?? null;
$dataBag[$this->first] = $second;
$dataBag[$this->second] = $first;
return $dataBag;
}
|
[
"public",
"function",
"pass",
"(",
"DataBagInterface",
"$",
"dataBag",
")",
":",
"DataBagInterface",
"{",
"$",
"first",
"=",
"$",
"dataBag",
"[",
"$",
"this",
"->",
"first",
"]",
"??",
"null",
";",
"$",
"second",
"=",
"$",
"dataBag",
"[",
"$",
"this",
"->",
"second",
"]",
"??",
"null",
";",
"$",
"dataBag",
"[",
"$",
"this",
"->",
"first",
"]",
"=",
"$",
"second",
";",
"$",
"dataBag",
"[",
"$",
"this",
"->",
"second",
"]",
"=",
"$",
"first",
";",
"return",
"$",
"dataBag",
";",
"}"
] |
Swap one key with another.
@param DataBagInterface $dataBag
@return DataBagInterface
|
[
"Swap",
"one",
"key",
"with",
"another",
"."
] |
a9cb826b106e882e43523d39fea319adc4893e00
|
https://github.com/SlayerBirden/dataflow/blob/a9cb826b106e882e43523d39fea319adc4893e00/src/Pipe/Swap.php#L39-L47
|
225,557
|
SlayerBirden/dataflow
|
src/Pipe/Filter.php
|
Filter.pass
|
public function pass(DataBagInterface $dataBag): DataBagInterface
{
if (!($this->callback)($dataBag)) {
throw new FlowTerminationException(
sprintf(
'Flow was terminated by Filter (%s) for data %s.',
$this->getIdentifier(),
json_encode($dataBag)
)
);
}
return $dataBag;
}
|
php
|
public function pass(DataBagInterface $dataBag): DataBagInterface
{
if (!($this->callback)($dataBag)) {
throw new FlowTerminationException(
sprintf(
'Flow was terminated by Filter (%s) for data %s.',
$this->getIdentifier(),
json_encode($dataBag)
)
);
}
return $dataBag;
}
|
[
"public",
"function",
"pass",
"(",
"DataBagInterface",
"$",
"dataBag",
")",
":",
"DataBagInterface",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"callback",
")",
"(",
"$",
"dataBag",
")",
")",
"{",
"throw",
"new",
"FlowTerminationException",
"(",
"sprintf",
"(",
"'Flow was terminated by Filter (%s) for data %s.'",
",",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
",",
"json_encode",
"(",
"$",
"dataBag",
")",
")",
")",
";",
"}",
"return",
"$",
"dataBag",
";",
"}"
] |
Filtering handler.
Terminate data flow based on a callback applied to DataBag.
{@inheritdoc}
|
[
"Filtering",
"handler",
".",
"Terminate",
"data",
"flow",
"based",
"on",
"a",
"callback",
"applied",
"to",
"DataBag",
"."
] |
a9cb826b106e882e43523d39fea319adc4893e00
|
https://github.com/SlayerBirden/dataflow/blob/a9cb826b106e882e43523d39fea319adc4893e00/src/Pipe/Filter.php#L35-L48
|
225,558
|
bytic/Common
|
src/Controllers/Traits/CrudModels.php
|
CrudModels.add
|
public function add()
{
$record = $this->addNewModel();
$form = $this->addGetForm($record);
if ($form->execute()) {
$this->addRedirect($record);
}
$this->getView()->set('item', $record);
$this->getView()->set('form', $form);
$this->getView()->set('title', $this->getModelManager()->getLabel('add'));
$this->getView()->Breadcrumbs()
->addItem($this->getModelManager()->getLabel('add'));
$this->getView()->TinyMCE()->setEnabled();
$this->getView()->append('section', '.add');
}
|
php
|
public function add()
{
$record = $this->addNewModel();
$form = $this->addGetForm($record);
if ($form->execute()) {
$this->addRedirect($record);
}
$this->getView()->set('item', $record);
$this->getView()->set('form', $form);
$this->getView()->set('title', $this->getModelManager()->getLabel('add'));
$this->getView()->Breadcrumbs()
->addItem($this->getModelManager()->getLabel('add'));
$this->getView()->TinyMCE()->setEnabled();
$this->getView()->append('section', '.add');
}
|
[
"public",
"function",
"add",
"(",
")",
"{",
"$",
"record",
"=",
"$",
"this",
"->",
"addNewModel",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"addGetForm",
"(",
"$",
"record",
")",
";",
"if",
"(",
"$",
"form",
"->",
"execute",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addRedirect",
"(",
"$",
"record",
")",
";",
"}",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"set",
"(",
"'item'",
",",
"$",
"record",
")",
";",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"set",
"(",
"'form'",
",",
"$",
"form",
")",
";",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"set",
"(",
"'title'",
",",
"$",
"this",
"->",
"getModelManager",
"(",
")",
"->",
"getLabel",
"(",
"'add'",
")",
")",
";",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"Breadcrumbs",
"(",
")",
"->",
"addItem",
"(",
"$",
"this",
"->",
"getModelManager",
"(",
")",
"->",
"getLabel",
"(",
"'add'",
")",
")",
";",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"TinyMCE",
"(",
")",
"->",
"setEnabled",
"(",
")",
";",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"append",
"(",
"'section'",
",",
"'.add'",
")",
";",
"}"
] |
Add item method
@return void
|
[
"Add",
"item",
"method"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Controllers/Traits/CrudModels.php#L79-L97
|
225,559
|
bytic/Common
|
src/Controllers/Traits/CrudModels.php
|
CrudModels.duplicate
|
public function duplicate()
{
$record = $this->initExistingItem();
$record->duplicate();
$url = $this->getAfterUrl(
"after-duplicate",
$this->getModelManager()->getURL()
);
$flashName = $this->getAfterFlashName(
"after-duplicate",
$this->getModelManager()->getController()
);
$this->flashRedirect(
$this->getModelManager()->getMessage('duplicate'),
$url,
'success',
$flashName
);
}
|
php
|
public function duplicate()
{
$record = $this->initExistingItem();
$record->duplicate();
$url = $this->getAfterUrl(
"after-duplicate",
$this->getModelManager()->getURL()
);
$flashName = $this->getAfterFlashName(
"after-duplicate",
$this->getModelManager()->getController()
);
$this->flashRedirect(
$this->getModelManager()->getMessage('duplicate'),
$url,
'success',
$flashName
);
}
|
[
"public",
"function",
"duplicate",
"(",
")",
"{",
"$",
"record",
"=",
"$",
"this",
"->",
"initExistingItem",
"(",
")",
";",
"$",
"record",
"->",
"duplicate",
"(",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"getAfterUrl",
"(",
"\"after-duplicate\"",
",",
"$",
"this",
"->",
"getModelManager",
"(",
")",
"->",
"getURL",
"(",
")",
")",
";",
"$",
"flashName",
"=",
"$",
"this",
"->",
"getAfterFlashName",
"(",
"\"after-duplicate\"",
",",
"$",
"this",
"->",
"getModelManager",
"(",
")",
"->",
"getController",
"(",
")",
")",
";",
"$",
"this",
"->",
"flashRedirect",
"(",
"$",
"this",
"->",
"getModelManager",
"(",
")",
"->",
"getMessage",
"(",
"'duplicate'",
")",
",",
"$",
"url",
",",
"'success'",
",",
"$",
"flashName",
")",
";",
"}"
] |
Duplicate item action
@return void
|
[
"Duplicate",
"item",
"action"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Controllers/Traits/CrudModels.php#L269-L291
|
225,560
|
bytic/Common
|
src/Utility/MM.php
|
MM.getNamespaced
|
protected static function getNamespaced($name)
{
$baseNamespace = app('app')->getRootNamespace() . 'Models\\';
if (strpos($name, '\\') === false) {
$name = $name . '\\' . $name;
}
$class = $baseNamespace . $name;
if (class_exists($class)) {
return self::initClass($class);
}
return false;
}
|
php
|
protected static function getNamespaced($name)
{
$baseNamespace = app('app')->getRootNamespace() . 'Models\\';
if (strpos($name, '\\') === false) {
$name = $name . '\\' . $name;
}
$class = $baseNamespace . $name;
if (class_exists($class)) {
return self::initClass($class);
}
return false;
}
|
[
"protected",
"static",
"function",
"getNamespaced",
"(",
"$",
"name",
")",
"{",
"$",
"baseNamespace",
"=",
"app",
"(",
"'app'",
")",
"->",
"getRootNamespace",
"(",
")",
".",
"'Models\\\\'",
";",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"'\\\\'",
")",
"===",
"false",
")",
"{",
"$",
"name",
"=",
"$",
"name",
".",
"'\\\\'",
".",
"$",
"name",
";",
"}",
"$",
"class",
"=",
"$",
"baseNamespace",
".",
"$",
"name",
";",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"return",
"self",
"::",
"initClass",
"(",
"$",
"class",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Get ModelManager from namespaced class
@param string $name
@return mixed
|
[
"Get",
"ModelManager",
"from",
"namespaced",
"class"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Utility/MM.php#L34-L45
|
225,561
|
cmsgears/plugin-file-manager
|
config/FileProperties.php
|
FileProperties.getImageExtensions
|
public function getImageExtensions( $default = null ) {
$prop = $this->properties[ self::PROP_EXTENSION_IMAGE ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return preg_split( "/,/", $prop );
}
return $default;
}
|
php
|
public function getImageExtensions( $default = null ) {
$prop = $this->properties[ self::PROP_EXTENSION_IMAGE ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return preg_split( "/,/", $prop );
}
return $default;
}
|
[
"public",
"function",
"getImageExtensions",
"(",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"prop",
"=",
"$",
"this",
"->",
"properties",
"[",
"self",
"::",
"PROP_EXTENSION_IMAGE",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"prop",
")",
"&&",
"strlen",
"(",
"$",
"prop",
")",
">",
"0",
")",
"{",
"return",
"preg_split",
"(",
"\"/,/\"",
",",
"$",
"prop",
")",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Returns the extensions allowed for images.
@param type $default
@return string
|
[
"Returns",
"the",
"extensions",
"allowed",
"for",
"images",
"."
] |
aad2a109b4c6126efabcadfb38762cd240a60bc5
|
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/config/FileProperties.php#L109-L119
|
225,562
|
cmsgears/plugin-file-manager
|
config/FileProperties.php
|
FileProperties.getVideoExtensions
|
public function getVideoExtensions( $default = null ) {
$prop = $this->properties[ self::PROP_EXTENSION_VIDEO ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return preg_split( "/,/", $prop );
}
return $default;
}
|
php
|
public function getVideoExtensions( $default = null ) {
$prop = $this->properties[ self::PROP_EXTENSION_VIDEO ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return preg_split( "/,/", $prop );
}
return $default;
}
|
[
"public",
"function",
"getVideoExtensions",
"(",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"prop",
"=",
"$",
"this",
"->",
"properties",
"[",
"self",
"::",
"PROP_EXTENSION_VIDEO",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"prop",
")",
"&&",
"strlen",
"(",
"$",
"prop",
")",
">",
"0",
")",
"{",
"return",
"preg_split",
"(",
"\"/,/\"",
",",
"$",
"prop",
")",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Returns the extensions allowed for videos.
@param type $default
@return string
|
[
"Returns",
"the",
"extensions",
"allowed",
"for",
"videos",
"."
] |
aad2a109b4c6126efabcadfb38762cd240a60bc5
|
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/config/FileProperties.php#L127-L137
|
225,563
|
cmsgears/plugin-file-manager
|
config/FileProperties.php
|
FileProperties.getAudioExtensions
|
public function getAudioExtensions( $default = null ) {
$prop = $this->properties[ self::PROP_EXTENSION_AUDIO ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return preg_split( "/,/", $prop );
}
return $default;
}
|
php
|
public function getAudioExtensions( $default = null ) {
$prop = $this->properties[ self::PROP_EXTENSION_AUDIO ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return preg_split( "/,/", $prop );
}
return $default;
}
|
[
"public",
"function",
"getAudioExtensions",
"(",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"prop",
"=",
"$",
"this",
"->",
"properties",
"[",
"self",
"::",
"PROP_EXTENSION_AUDIO",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"prop",
")",
"&&",
"strlen",
"(",
"$",
"prop",
")",
">",
"0",
")",
"{",
"return",
"preg_split",
"(",
"\"/,/\"",
",",
"$",
"prop",
")",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Returns the extensions allowed for music and audio.
@param type $default
@return string
|
[
"Returns",
"the",
"extensions",
"allowed",
"for",
"music",
"and",
"audio",
"."
] |
aad2a109b4c6126efabcadfb38762cd240a60bc5
|
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/config/FileProperties.php#L145-L155
|
225,564
|
cmsgears/plugin-file-manager
|
config/FileProperties.php
|
FileProperties.getDocumentExtensions
|
public function getDocumentExtensions( $default = null ) {
$prop = $this->properties[ self::PROP_EXTENSION_DOCUMENT ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return preg_split( "/,/", $prop );
}
return $default;
}
|
php
|
public function getDocumentExtensions( $default = null ) {
$prop = $this->properties[ self::PROP_EXTENSION_DOCUMENT ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return preg_split( "/,/", $prop );
}
return $default;
}
|
[
"public",
"function",
"getDocumentExtensions",
"(",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"prop",
"=",
"$",
"this",
"->",
"properties",
"[",
"self",
"::",
"PROP_EXTENSION_DOCUMENT",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"prop",
")",
"&&",
"strlen",
"(",
"$",
"prop",
")",
">",
"0",
")",
"{",
"return",
"preg_split",
"(",
"\"/,/\"",
",",
"$",
"prop",
")",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Returns the extensions allowed for documents.
@param type $default
@return string
|
[
"Returns",
"the",
"extensions",
"allowed",
"for",
"documents",
"."
] |
aad2a109b4c6126efabcadfb38762cd240a60bc5
|
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/config/FileProperties.php#L163-L173
|
225,565
|
cmsgears/plugin-file-manager
|
config/FileProperties.php
|
FileProperties.getCompressedExtensions
|
public function getCompressedExtensions( $default = null ) {
$prop = $this->properties[ self::PROP_EXTENSION_COMPRESSED ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return preg_split( "/,/", $prop );
}
return $default;
}
|
php
|
public function getCompressedExtensions( $default = null ) {
$prop = $this->properties[ self::PROP_EXTENSION_COMPRESSED ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return preg_split( "/,/", $prop );
}
return $default;
}
|
[
"public",
"function",
"getCompressedExtensions",
"(",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"prop",
"=",
"$",
"this",
"->",
"properties",
"[",
"self",
"::",
"PROP_EXTENSION_COMPRESSED",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"prop",
")",
"&&",
"strlen",
"(",
"$",
"prop",
")",
">",
"0",
")",
"{",
"return",
"preg_split",
"(",
"\"/,/\"",
",",
"$",
"prop",
")",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Returns the extensions allowed for compressed documents.
@param type $default
@return string
|
[
"Returns",
"the",
"extensions",
"allowed",
"for",
"compressed",
"documents",
"."
] |
aad2a109b4c6126efabcadfb38762cd240a60bc5
|
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/config/FileProperties.php#L181-L191
|
225,566
|
cmsgears/plugin-file-manager
|
config/FileProperties.php
|
FileProperties.isGenerateName
|
public function isGenerateName( $default = null ) {
$prop = $this->properties[ self::PROP_NAME_GENERATE ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
php
|
public function isGenerateName( $default = null ) {
$prop = $this->properties[ self::PROP_NAME_GENERATE ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
[
"public",
"function",
"isGenerateName",
"(",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"prop",
"=",
"$",
"this",
"->",
"properties",
"[",
"self",
"::",
"PROP_NAME_GENERATE",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"prop",
")",
"&&",
"strlen",
"(",
"$",
"prop",
")",
">",
"0",
")",
"{",
"return",
"$",
"prop",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Check whether name must be auto generated while storing the file. The given file
name will be stored in title.
@param type $default
@return string
|
[
"Check",
"whether",
"name",
"must",
"be",
"auto",
"generated",
"while",
"storing",
"the",
"file",
".",
"The",
"given",
"file",
"name",
"will",
"be",
"stored",
"in",
"title",
"."
] |
aad2a109b4c6126efabcadfb38762cd240a60bc5
|
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/config/FileProperties.php#L200-L210
|
225,567
|
cmsgears/plugin-file-manager
|
config/FileProperties.php
|
FileProperties.isPrettyName
|
public function isPrettyName( $default = null ) {
$prop = $this->properties[ self::PROP_NAME_PRETTY ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
php
|
public function isPrettyName( $default = null ) {
$prop = $this->properties[ self::PROP_NAME_PRETTY ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
[
"public",
"function",
"isPrettyName",
"(",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"prop",
"=",
"$",
"this",
"->",
"properties",
"[",
"self",
"::",
"PROP_NAME_PRETTY",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"prop",
")",
"&&",
"strlen",
"(",
"$",
"prop",
")",
">",
"0",
")",
"{",
"return",
"$",
"prop",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Check whether pretty names must be generated by hyphenating the given file name. The
given file name will be stored in title.
@param type $default
@return string
|
[
"Check",
"whether",
"pretty",
"names",
"must",
"be",
"generated",
"by",
"hyphenating",
"the",
"given",
"file",
"name",
".",
"The",
"given",
"file",
"name",
"will",
"be",
"stored",
"in",
"title",
"."
] |
aad2a109b4c6126efabcadfb38762cd240a60bc5
|
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/config/FileProperties.php#L219-L229
|
225,568
|
cmsgears/plugin-file-manager
|
config/FileProperties.php
|
FileProperties.getMaxSize
|
public function getMaxSize( $default = null ) {
$prop = $this->properties[ self::PROP_MAX_SIZE ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
php
|
public function getMaxSize( $default = null ) {
$prop = $this->properties[ self::PROP_MAX_SIZE ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
[
"public",
"function",
"getMaxSize",
"(",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"prop",
"=",
"$",
"this",
"->",
"properties",
"[",
"self",
"::",
"PROP_MAX_SIZE",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"prop",
")",
"&&",
"strlen",
"(",
"$",
"prop",
")",
">",
"0",
")",
"{",
"return",
"$",
"prop",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Returns the maximum size allowed for file.
@param type $default
@return string
|
[
"Returns",
"the",
"maximum",
"size",
"allowed",
"for",
"file",
"."
] |
aad2a109b4c6126efabcadfb38762cd240a60bc5
|
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/config/FileProperties.php#L237-L247
|
225,569
|
cmsgears/plugin-file-manager
|
config/FileProperties.php
|
FileProperties.getMaxResolution
|
public function getMaxResolution( $default = null ) {
$prop = $this->properties[ self::PROP_MAX_RESOLUTION ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
php
|
public function getMaxResolution( $default = null ) {
$prop = $this->properties[ self::PROP_MAX_RESOLUTION ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
[
"public",
"function",
"getMaxResolution",
"(",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"prop",
"=",
"$",
"this",
"->",
"properties",
"[",
"self",
"::",
"PROP_MAX_RESOLUTION",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"prop",
")",
"&&",
"strlen",
"(",
"$",
"prop",
")",
">",
"0",
")",
"{",
"return",
"$",
"prop",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Returns the maximum resolution allowed for image.
@param type $default
@return string
|
[
"Returns",
"the",
"maximum",
"resolution",
"allowed",
"for",
"image",
"."
] |
aad2a109b4c6126efabcadfb38762cd240a60bc5
|
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/config/FileProperties.php#L255-L265
|
225,570
|
cmsgears/plugin-file-manager
|
config/FileProperties.php
|
FileProperties.isGenerateMedium
|
public function isGenerateMedium( $default = null ) {
$prop = $this->properties[ self::PROP_GENERATE_MEDIUM ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
php
|
public function isGenerateMedium( $default = null ) {
$prop = $this->properties[ self::PROP_GENERATE_MEDIUM ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
[
"public",
"function",
"isGenerateMedium",
"(",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"prop",
"=",
"$",
"this",
"->",
"properties",
"[",
"self",
"::",
"PROP_GENERATE_MEDIUM",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"prop",
")",
"&&",
"strlen",
"(",
"$",
"prop",
")",
">",
"0",
")",
"{",
"return",
"$",
"prop",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Check whether medium image must be generated while storing the image file.
@param type $default
@return string
|
[
"Check",
"whether",
"medium",
"image",
"must",
"be",
"generated",
"while",
"storing",
"the",
"image",
"file",
"."
] |
aad2a109b4c6126efabcadfb38762cd240a60bc5
|
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/config/FileProperties.php#L273-L283
|
225,571
|
cmsgears/plugin-file-manager
|
config/FileProperties.php
|
FileProperties.getMediumWidth
|
public function getMediumWidth( $default = null ) {
$prop = $this->properties[ self::PROP_MEDIUM_WIDTH ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
php
|
public function getMediumWidth( $default = null ) {
$prop = $this->properties[ self::PROP_MEDIUM_WIDTH ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
[
"public",
"function",
"getMediumWidth",
"(",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"prop",
"=",
"$",
"this",
"->",
"properties",
"[",
"self",
"::",
"PROP_MEDIUM_WIDTH",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"prop",
")",
"&&",
"strlen",
"(",
"$",
"prop",
")",
">",
"0",
")",
"{",
"return",
"$",
"prop",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Returns the width of medium image.
@param type $default
@return string
|
[
"Returns",
"the",
"width",
"of",
"medium",
"image",
"."
] |
aad2a109b4c6126efabcadfb38762cd240a60bc5
|
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/config/FileProperties.php#L291-L301
|
225,572
|
cmsgears/plugin-file-manager
|
config/FileProperties.php
|
FileProperties.isGenerateThumb
|
public function isGenerateThumb( $default = null ) {
$prop = $this->properties[ self::PROP_GENERATE_THUMB ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
php
|
public function isGenerateThumb( $default = null ) {
$prop = $this->properties[ self::PROP_GENERATE_THUMB ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
[
"public",
"function",
"isGenerateThumb",
"(",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"prop",
"=",
"$",
"this",
"->",
"properties",
"[",
"self",
"::",
"PROP_GENERATE_THUMB",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"prop",
")",
"&&",
"strlen",
"(",
"$",
"prop",
")",
">",
"0",
")",
"{",
"return",
"$",
"prop",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Check whether thumb image must be generated while storing the image file.
@param type $default
@return string
|
[
"Check",
"whether",
"thumb",
"image",
"must",
"be",
"generated",
"while",
"storing",
"the",
"image",
"file",
"."
] |
aad2a109b4c6126efabcadfb38762cd240a60bc5
|
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/config/FileProperties.php#L327-L337
|
225,573
|
cmsgears/plugin-file-manager
|
config/FileProperties.php
|
FileProperties.getThumbWidth
|
public function getThumbWidth( $default = null ) {
$prop = $this->properties[ self::PROP_THUMB_WIDTH ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
php
|
public function getThumbWidth( $default = null ) {
$prop = $this->properties[ self::PROP_THUMB_WIDTH ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
[
"public",
"function",
"getThumbWidth",
"(",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"prop",
"=",
"$",
"this",
"->",
"properties",
"[",
"self",
"::",
"PROP_THUMB_WIDTH",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"prop",
")",
"&&",
"strlen",
"(",
"$",
"prop",
")",
">",
"0",
")",
"{",
"return",
"$",
"prop",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Returns the width of thumb image.
@param type $default
@return string
|
[
"Returns",
"the",
"width",
"of",
"thumb",
"image",
"."
] |
aad2a109b4c6126efabcadfb38762cd240a60bc5
|
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/config/FileProperties.php#L345-L355
|
225,574
|
cmsgears/plugin-file-manager
|
config/FileProperties.php
|
FileProperties.isUpload
|
public function isUpload( $default = null ) {
$prop = $this->properties[ self::PROP_UPLOAD ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
php
|
public function isUpload( $default = null ) {
$prop = $this->properties[ self::PROP_UPLOAD ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
[
"public",
"function",
"isUpload",
"(",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"prop",
"=",
"$",
"this",
"->",
"properties",
"[",
"self",
"::",
"PROP_UPLOAD",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"prop",
")",
"&&",
"strlen",
"(",
"$",
"prop",
")",
">",
"0",
")",
"{",
"return",
"$",
"prop",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Checks whether file upload is allowed.
@param type $default
@return boolean
|
[
"Checks",
"whether",
"file",
"upload",
"is",
"allowed",
"."
] |
aad2a109b4c6126efabcadfb38762cd240a60bc5
|
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/config/FileProperties.php#L381-L391
|
225,575
|
cmsgears/plugin-file-manager
|
config/FileProperties.php
|
FileProperties.getUploadDir
|
public function getUploadDir( $default = null ) {
$prop = $this->properties[ self::PROP_UPLOAD_DIR ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
php
|
public function getUploadDir( $default = null ) {
$prop = $this->properties[ self::PROP_UPLOAD_DIR ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
[
"public",
"function",
"getUploadDir",
"(",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"prop",
"=",
"$",
"this",
"->",
"properties",
"[",
"self",
"::",
"PROP_UPLOAD_DIR",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"prop",
")",
"&&",
"strlen",
"(",
"$",
"prop",
")",
">",
"0",
")",
"{",
"return",
"$",
"prop",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Returns the uploads directory path to which files will be stored.
@param type $default
@return string
|
[
"Returns",
"the",
"uploads",
"directory",
"path",
"to",
"which",
"files",
"will",
"be",
"stored",
"."
] |
aad2a109b4c6126efabcadfb38762cd240a60bc5
|
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/config/FileProperties.php#L399-L409
|
225,576
|
cmsgears/plugin-file-manager
|
config/FileProperties.php
|
FileProperties.getUploadUrl
|
public function getUploadUrl( $default = null ) {
$prop = $this->properties[ self::PROP_UPLOAD_URL ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
php
|
public function getUploadUrl( $default = null ) {
$prop = $this->properties[ self::PROP_UPLOAD_URL ];
if( isset( $prop ) && strlen( $prop ) > 0 ) {
return $prop;
}
return $default;
}
|
[
"public",
"function",
"getUploadUrl",
"(",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"prop",
"=",
"$",
"this",
"->",
"properties",
"[",
"self",
"::",
"PROP_UPLOAD_URL",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"prop",
")",
"&&",
"strlen",
"(",
"$",
"prop",
")",
">",
"0",
")",
"{",
"return",
"$",
"prop",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Returns the uploads URL path to access file via URL.
@param type $default
@return string
|
[
"Returns",
"the",
"uploads",
"URL",
"path",
"to",
"access",
"file",
"via",
"URL",
"."
] |
aad2a109b4c6126efabcadfb38762cd240a60bc5
|
https://github.com/cmsgears/plugin-file-manager/blob/aad2a109b4c6126efabcadfb38762cd240a60bc5/config/FileProperties.php#L417-L427
|
225,577
|
RevisionTen/cqrs
|
Model/EventQeueObject.php
|
EventQeueObject.getEventStreamObject
|
public function getEventStreamObject(): EventStreamObject
{
$eventStreamObject = new EventStreamObject();
$eventStreamObject->setUuid($this->getUuid());
$eventStreamObject->setCommandUuid($this->getCommandUuid());
$eventStreamObject->setVersion($this->getVersion());
$eventStreamObject->setCreated($this->getCreated());
$eventStreamObject->setEvent($this->getEvent());
$eventStreamObject->setAggregateClass($this->getAggregateClass());
$eventStreamObject->setUser($this->getUser());
$eventStreamObject->setPayload($this->getPayload());
$eventStreamObject->setMessage($this->getMessage());
return $eventStreamObject;
}
|
php
|
public function getEventStreamObject(): EventStreamObject
{
$eventStreamObject = new EventStreamObject();
$eventStreamObject->setUuid($this->getUuid());
$eventStreamObject->setCommandUuid($this->getCommandUuid());
$eventStreamObject->setVersion($this->getVersion());
$eventStreamObject->setCreated($this->getCreated());
$eventStreamObject->setEvent($this->getEvent());
$eventStreamObject->setAggregateClass($this->getAggregateClass());
$eventStreamObject->setUser($this->getUser());
$eventStreamObject->setPayload($this->getPayload());
$eventStreamObject->setMessage($this->getMessage());
return $eventStreamObject;
}
|
[
"public",
"function",
"getEventStreamObject",
"(",
")",
":",
"EventStreamObject",
"{",
"$",
"eventStreamObject",
"=",
"new",
"EventStreamObject",
"(",
")",
";",
"$",
"eventStreamObject",
"->",
"setUuid",
"(",
"$",
"this",
"->",
"getUuid",
"(",
")",
")",
";",
"$",
"eventStreamObject",
"->",
"setCommandUuid",
"(",
"$",
"this",
"->",
"getCommandUuid",
"(",
")",
")",
";",
"$",
"eventStreamObject",
"->",
"setVersion",
"(",
"$",
"this",
"->",
"getVersion",
"(",
")",
")",
";",
"$",
"eventStreamObject",
"->",
"setCreated",
"(",
"$",
"this",
"->",
"getCreated",
"(",
")",
")",
";",
"$",
"eventStreamObject",
"->",
"setEvent",
"(",
"$",
"this",
"->",
"getEvent",
"(",
")",
")",
";",
"$",
"eventStreamObject",
"->",
"setAggregateClass",
"(",
"$",
"this",
"->",
"getAggregateClass",
"(",
")",
")",
";",
"$",
"eventStreamObject",
"->",
"setUser",
"(",
"$",
"this",
"->",
"getUser",
"(",
")",
")",
";",
"$",
"eventStreamObject",
"->",
"setPayload",
"(",
"$",
"this",
"->",
"getPayload",
"(",
")",
")",
";",
"$",
"eventStreamObject",
"->",
"setMessage",
"(",
"$",
"this",
"->",
"getMessage",
"(",
")",
")",
";",
"return",
"$",
"eventStreamObject",
";",
"}"
] |
Transforms the EventQeueObject into an EventStreamObject
and returns it.
@return EventStreamObject
|
[
"Transforms",
"the",
"EventQeueObject",
"into",
"an",
"EventStreamObject",
"and",
"returns",
"it",
"."
] |
d94fdd86855a994c4662e24a6c3c08ef586e64f9
|
https://github.com/RevisionTen/cqrs/blob/d94fdd86855a994c4662e24a6c3c08ef586e64f9/Model/EventQeueObject.php#L110-L124
|
225,578
|
edineibauer/entity
|
public/src/Entity/Meta.php
|
Meta.setDados
|
public function setDados($dados = null, $default)
{
if (!empty($dados)) {
if (!$default)
$default = json_decode(file_get_contents(PATH_HOME . VENDOR . "entity-form/public/entity/input_type.json"), true)['default'];
foreach (array_replace_recursive($default, $dados) as $dado => $value) {
switch ($dado) {
case 'id':
$this->setId($value);
break;
case 'allow':
$this->setAllow($value);
break;
case 'column':
$this->setColumn($value);
break;
case 'default':
$this->setDefault($value);
break;
case 'update':
$this->setUpdate($value);
break;
case 'filter':
$this->setFilter($value);
break;
case 'form':
$this->setForm($value);
break;
case 'datagrid':
$this->setDatagrid($value);
break;
case 'format':
$this->setFormat($value);
break;
case 'key':
$this->setKey($value);
break;
case 'indice':
$this->setIndice($value);
break;
case 'group':
$this->setGroup($value);
break;
case 'nome':
$this->setNome($value);
break;
case 'relation':
$this->setRelation($value);
break;
case 'select':
$this->setSelect($value);
break;
case 'size':
$this->setSize($value);
break;
case 'type':
$this->setType($value);
break;
case 'unique':
$this->setUnique($value);
break;
case 'value':
$this->setValue($value);
break;
}
}
}
}
|
php
|
public function setDados($dados = null, $default)
{
if (!empty($dados)) {
if (!$default)
$default = json_decode(file_get_contents(PATH_HOME . VENDOR . "entity-form/public/entity/input_type.json"), true)['default'];
foreach (array_replace_recursive($default, $dados) as $dado => $value) {
switch ($dado) {
case 'id':
$this->setId($value);
break;
case 'allow':
$this->setAllow($value);
break;
case 'column':
$this->setColumn($value);
break;
case 'default':
$this->setDefault($value);
break;
case 'update':
$this->setUpdate($value);
break;
case 'filter':
$this->setFilter($value);
break;
case 'form':
$this->setForm($value);
break;
case 'datagrid':
$this->setDatagrid($value);
break;
case 'format':
$this->setFormat($value);
break;
case 'key':
$this->setKey($value);
break;
case 'indice':
$this->setIndice($value);
break;
case 'group':
$this->setGroup($value);
break;
case 'nome':
$this->setNome($value);
break;
case 'relation':
$this->setRelation($value);
break;
case 'select':
$this->setSelect($value);
break;
case 'size':
$this->setSize($value);
break;
case 'type':
$this->setType($value);
break;
case 'unique':
$this->setUnique($value);
break;
case 'value':
$this->setValue($value);
break;
}
}
}
}
|
[
"public",
"function",
"setDados",
"(",
"$",
"dados",
"=",
"null",
",",
"$",
"default",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"dados",
")",
")",
"{",
"if",
"(",
"!",
"$",
"default",
")",
"$",
"default",
"=",
"json_decode",
"(",
"file_get_contents",
"(",
"PATH_HOME",
".",
"VENDOR",
".",
"\"entity-form/public/entity/input_type.json\"",
")",
",",
"true",
")",
"[",
"'default'",
"]",
";",
"foreach",
"(",
"array_replace_recursive",
"(",
"$",
"default",
",",
"$",
"dados",
")",
"as",
"$",
"dado",
"=>",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"dado",
")",
"{",
"case",
"'id'",
":",
"$",
"this",
"->",
"setId",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'allow'",
":",
"$",
"this",
"->",
"setAllow",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'column'",
":",
"$",
"this",
"->",
"setColumn",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'default'",
":",
"$",
"this",
"->",
"setDefault",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'update'",
":",
"$",
"this",
"->",
"setUpdate",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'filter'",
":",
"$",
"this",
"->",
"setFilter",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'form'",
":",
"$",
"this",
"->",
"setForm",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'datagrid'",
":",
"$",
"this",
"->",
"setDatagrid",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'format'",
":",
"$",
"this",
"->",
"setFormat",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'key'",
":",
"$",
"this",
"->",
"setKey",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'indice'",
":",
"$",
"this",
"->",
"setIndice",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'group'",
":",
"$",
"this",
"->",
"setGroup",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'nome'",
":",
"$",
"this",
"->",
"setNome",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'relation'",
":",
"$",
"this",
"->",
"setRelation",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'select'",
":",
"$",
"this",
"->",
"setSelect",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'size'",
":",
"$",
"this",
"->",
"setSize",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'type'",
":",
"$",
"this",
"->",
"setType",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'unique'",
":",
"$",
"this",
"->",
"setUnique",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"'value'",
":",
"$",
"this",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] |
Informa dados a esta Meta
@param mixed $dados
@param mixed $default
|
[
"Informa",
"dados",
"a",
"esta",
"Meta"
] |
8437f5531ed9cd5f75c4c69c7db27b31e31e02c2
|
https://github.com/edineibauer/entity/blob/8437f5531ed9cd5f75c4c69c7db27b31e31e02c2/public/src/Entity/Meta.php#L450-L518
|
225,579
|
sopinetchat/SopinetChatBundle
|
Service/InterfaceHelper.php
|
InterfaceHelper.sendMessage
|
public function sendMessage(Request $request) {
/** @var MessageHelper $messageHelper */
$messageHelper = $this->container->get('sopinet_chatbundle_messagehelper');
/** @var ApiHelper $apiHelper */
$apiHelper = $this->container->get('sopinet_apihelperbundle_apihelper');
/** @var Message $messageClassObject */
try {
$messageClassObject = $messageHelper->getMessageClassObject($request->get('type'));
} catch(Exception $e) {
throw new Exception($e->getMessage());
}
$formClassString = $messageClassObject->getMyForm();
$formClassObject = new $formClassString($this->container, $request);
$form = $this->container->get('form.factory')->create($formClassObject, $messageClassObject);
/** @var Form $form */
$form = $apiHelper->handleForm($request, $form);
// TODO: Añadir comprobación en el FORM de que el Usuario pertenece al Chat indicado y de que dispone
// es el dueño del Device que se ha especificado.
if ($form->isValid()) {
$em=$this->container->get('doctrine.orm.default_entity_manager');
$em->persist($messageClassObject);
$em->flush();
// Send Message
$messageHelper->sendMessage($messageClassObject);
return $messageClassObject;
} else {
throw new Exception($form->getErrorsAsString());
}
}
|
php
|
public function sendMessage(Request $request) {
/** @var MessageHelper $messageHelper */
$messageHelper = $this->container->get('sopinet_chatbundle_messagehelper');
/** @var ApiHelper $apiHelper */
$apiHelper = $this->container->get('sopinet_apihelperbundle_apihelper');
/** @var Message $messageClassObject */
try {
$messageClassObject = $messageHelper->getMessageClassObject($request->get('type'));
} catch(Exception $e) {
throw new Exception($e->getMessage());
}
$formClassString = $messageClassObject->getMyForm();
$formClassObject = new $formClassString($this->container, $request);
$form = $this->container->get('form.factory')->create($formClassObject, $messageClassObject);
/** @var Form $form */
$form = $apiHelper->handleForm($request, $form);
// TODO: Añadir comprobación en el FORM de que el Usuario pertenece al Chat indicado y de que dispone
// es el dueño del Device que se ha especificado.
if ($form->isValid()) {
$em=$this->container->get('doctrine.orm.default_entity_manager');
$em->persist($messageClassObject);
$em->flush();
// Send Message
$messageHelper->sendMessage($messageClassObject);
return $messageClassObject;
} else {
throw new Exception($form->getErrorsAsString());
}
}
|
[
"public",
"function",
"sendMessage",
"(",
"Request",
"$",
"request",
")",
"{",
"/** @var MessageHelper $messageHelper */",
"$",
"messageHelper",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'sopinet_chatbundle_messagehelper'",
")",
";",
"/** @var ApiHelper $apiHelper */",
"$",
"apiHelper",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'sopinet_apihelperbundle_apihelper'",
")",
";",
"/** @var Message $messageClassObject */",
"try",
"{",
"$",
"messageClassObject",
"=",
"$",
"messageHelper",
"->",
"getMessageClassObject",
"(",
"$",
"request",
"->",
"get",
"(",
"'type'",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"$",
"formClassString",
"=",
"$",
"messageClassObject",
"->",
"getMyForm",
"(",
")",
";",
"$",
"formClassObject",
"=",
"new",
"$",
"formClassString",
"(",
"$",
"this",
"->",
"container",
",",
"$",
"request",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'form.factory'",
")",
"->",
"create",
"(",
"$",
"formClassObject",
",",
"$",
"messageClassObject",
")",
";",
"/** @var Form $form */",
"$",
"form",
"=",
"$",
"apiHelper",
"->",
"handleForm",
"(",
"$",
"request",
",",
"$",
"form",
")",
";",
"// TODO: Añadir comprobación en el FORM de que el Usuario pertenece al Chat indicado y de que dispone",
"// es el dueño del Device que se ha especificado.",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"'doctrine.orm.default_entity_manager'",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"messageClassObject",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"// Send Message",
"$",
"messageHelper",
"->",
"sendMessage",
"(",
"$",
"messageClassObject",
")",
";",
"return",
"$",
"messageClassObject",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"form",
"->",
"getErrorsAsString",
"(",
")",
")",
";",
"}",
"}"
] |
Manda un mensaje a un Chat
request llevará la información pertinente
text - Texto de mensaje en el chat.
type - Tipo de mensaje.
fromDevice - Device que lo envía.
chat - ID del Chat en el servidor en el que se envía el mensaje,
id - ID del Mensaje,
fromTime - Fecha y hora de envío de mensaje, formato Timestamp
@param Request $request
|
[
"Manda",
"un",
"mensaje",
"a",
"un",
"Chat"
] |
92c306963d8e9c74ecaa06422cea65bcf1bb3ba2
|
https://github.com/sopinetchat/SopinetChatBundle/blob/92c306963d8e9c74ecaa06422cea65bcf1bb3ba2/Service/InterfaceHelper.php#L46-L83
|
225,580
|
Everest/Everest-Filesystem
|
src/classes/Everest/Filesystem/Collection.php
|
Collection.delete
|
public function delete(bool $recursive = true): bool
{
$this->each(function (AbstractObject $item) use ($recursive) {
if ($item->isFolder()) {
$item->delete($recursive);
} else {
$item->delete();
}
});
return true;
}
|
php
|
public function delete(bool $recursive = true): bool
{
$this->each(function (AbstractObject $item) use ($recursive) {
if ($item->isFolder()) {
$item->delete($recursive);
} else {
$item->delete();
}
});
return true;
}
|
[
"public",
"function",
"delete",
"(",
"bool",
"$",
"recursive",
"=",
"true",
")",
":",
"bool",
"{",
"$",
"this",
"->",
"each",
"(",
"function",
"(",
"AbstractObject",
"$",
"item",
")",
"use",
"(",
"$",
"recursive",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"isFolder",
"(",
")",
")",
"{",
"$",
"item",
"->",
"delete",
"(",
"$",
"recursive",
")",
";",
"}",
"else",
"{",
"$",
"item",
"->",
"delete",
"(",
")",
";",
"}",
"}",
")",
";",
"return",
"true",
";",
"}"
] |
Delete all files and folders.
@param bool $recursive Set FALSE to prevent recursive deleting all files and sub folders
@return bool
|
[
"Delete",
"all",
"files",
"and",
"folders",
"."
] |
67782256e4b09adc7f761944b88ea317a194d677
|
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/Collection.php#L30-L41
|
225,581
|
Eve-PHP/Framework
|
src/Cli/Database.php
|
Database.createRelations
|
protected function createRelations()
{
foreach($this->schema['relations'] as $table => $many) {
$this->database->query('DROP TABLE IF EXISTS `'.$this->schema['name'].'_'.$table.'`');
$this->database->query('CREATE TABLE `'.$this->schema['name'].'_'.$table.'` (
`'.$this->schema['name'].'_'.$table.'_'.$this->schema['name'].'` int(10) unsigned NOT NULL,
`'.$this->schema['name'].'_'.$table.'_'.$table.'` int(10) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8');
$this->database->query('ALTER TABLE `'
. $this->schema['name'] . '_' . $table . '`'
. 'ADD PRIMARY KEY (`'
. $this->schema['name'] . '_' . $table . '_' . $this->schema['name'] . '`,`'
. $this->schema['name'] . '_' . $table . '_' . $table . '`), '
. 'ADD KEY `' . $table . '_id_idx` (`'
. $this->schema['name'] . '_' . $table . '_' . $table . '`)');
}
return $this;
}
|
php
|
protected function createRelations()
{
foreach($this->schema['relations'] as $table => $many) {
$this->database->query('DROP TABLE IF EXISTS `'.$this->schema['name'].'_'.$table.'`');
$this->database->query('CREATE TABLE `'.$this->schema['name'].'_'.$table.'` (
`'.$this->schema['name'].'_'.$table.'_'.$this->schema['name'].'` int(10) unsigned NOT NULL,
`'.$this->schema['name'].'_'.$table.'_'.$table.'` int(10) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8');
$this->database->query('ALTER TABLE `'
. $this->schema['name'] . '_' . $table . '`'
. 'ADD PRIMARY KEY (`'
. $this->schema['name'] . '_' . $table . '_' . $this->schema['name'] . '`,`'
. $this->schema['name'] . '_' . $table . '_' . $table . '`), '
. 'ADD KEY `' . $table . '_id_idx` (`'
. $this->schema['name'] . '_' . $table . '_' . $table . '`)');
}
return $this;
}
|
[
"protected",
"function",
"createRelations",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"schema",
"[",
"'relations'",
"]",
"as",
"$",
"table",
"=>",
"$",
"many",
")",
"{",
"$",
"this",
"->",
"database",
"->",
"query",
"(",
"'DROP TABLE IF EXISTS `'",
".",
"$",
"this",
"->",
"schema",
"[",
"'name'",
"]",
".",
"'_'",
".",
"$",
"table",
".",
"'`'",
")",
";",
"$",
"this",
"->",
"database",
"->",
"query",
"(",
"'CREATE TABLE `'",
".",
"$",
"this",
"->",
"schema",
"[",
"'name'",
"]",
".",
"'_'",
".",
"$",
"table",
".",
"'` (\n `'",
".",
"$",
"this",
"->",
"schema",
"[",
"'name'",
"]",
".",
"'_'",
".",
"$",
"table",
".",
"'_'",
".",
"$",
"this",
"->",
"schema",
"[",
"'name'",
"]",
".",
"'` int(10) unsigned NOT NULL,\n `'",
".",
"$",
"this",
"->",
"schema",
"[",
"'name'",
"]",
".",
"'_'",
".",
"$",
"table",
".",
"'_'",
".",
"$",
"table",
".",
"'` int(10) unsigned NOT NULL\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8'",
")",
";",
"$",
"this",
"->",
"database",
"->",
"query",
"(",
"'ALTER TABLE `'",
".",
"$",
"this",
"->",
"schema",
"[",
"'name'",
"]",
".",
"'_'",
".",
"$",
"table",
".",
"'`'",
".",
"'ADD PRIMARY KEY (`'",
".",
"$",
"this",
"->",
"schema",
"[",
"'name'",
"]",
".",
"'_'",
".",
"$",
"table",
".",
"'_'",
".",
"$",
"this",
"->",
"schema",
"[",
"'name'",
"]",
".",
"'`,`'",
".",
"$",
"this",
"->",
"schema",
"[",
"'name'",
"]",
".",
"'_'",
".",
"$",
"table",
".",
"'_'",
".",
"$",
"table",
".",
"'`), '",
".",
"'ADD KEY `'",
".",
"$",
"table",
".",
"'_id_idx` (`'",
".",
"$",
"this",
"->",
"schema",
"[",
"'name'",
"]",
".",
"'_'",
".",
"$",
"table",
".",
"'_'",
".",
"$",
"table",
".",
"'`)'",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Create the relational tables
@return Eve\Framework\Cli\Database
|
[
"Create",
"the",
"relational",
"tables"
] |
cd4ca9472c6c46034bde402bf20bf2f86657c608
|
https://github.com/Eve-PHP/Framework/blob/cd4ca9472c6c46034bde402bf20bf2f86657c608/src/Cli/Database.php#L156-L176
|
225,582
|
Eve-PHP/Framework
|
src/Cli/Database.php
|
Database.insertFixtures
|
protected function insertFixtures()
{
foreach($this->schema['fixture'] as $row) {
$model = $this->database
->model($row)
->save($this->schema['name']);
foreach($this->schema['relations'] as $table => $many) {
if(isset($row[$this->schema['name'].'_'.$table.'_'.$this->schema['name']])
&& isset($row[$this->schema['name'].'_'.$table.'_'.$table])
) {
$model->insert($this->schema['name'].'_'.$table);
}
}
}
return $this;
}
|
php
|
protected function insertFixtures()
{
foreach($this->schema['fixture'] as $row) {
$model = $this->database
->model($row)
->save($this->schema['name']);
foreach($this->schema['relations'] as $table => $many) {
if(isset($row[$this->schema['name'].'_'.$table.'_'.$this->schema['name']])
&& isset($row[$this->schema['name'].'_'.$table.'_'.$table])
) {
$model->insert($this->schema['name'].'_'.$table);
}
}
}
return $this;
}
|
[
"protected",
"function",
"insertFixtures",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"schema",
"[",
"'fixture'",
"]",
"as",
"$",
"row",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"database",
"->",
"model",
"(",
"$",
"row",
")",
"->",
"save",
"(",
"$",
"this",
"->",
"schema",
"[",
"'name'",
"]",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"schema",
"[",
"'relations'",
"]",
"as",
"$",
"table",
"=>",
"$",
"many",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"row",
"[",
"$",
"this",
"->",
"schema",
"[",
"'name'",
"]",
".",
"'_'",
".",
"$",
"table",
".",
"'_'",
".",
"$",
"this",
"->",
"schema",
"[",
"'name'",
"]",
"]",
")",
"&&",
"isset",
"(",
"$",
"row",
"[",
"$",
"this",
"->",
"schema",
"[",
"'name'",
"]",
".",
"'_'",
".",
"$",
"table",
".",
"'_'",
".",
"$",
"table",
"]",
")",
")",
"{",
"$",
"model",
"->",
"insert",
"(",
"$",
"this",
"->",
"schema",
"[",
"'name'",
"]",
".",
"'_'",
".",
"$",
"table",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Insert fixtures while we are at it
@param array $args CLI arguments
@return Eve\Framework\Cli\Database
|
[
"Insert",
"fixtures",
"while",
"we",
"are",
"at",
"it"
] |
cd4ca9472c6c46034bde402bf20bf2f86657c608
|
https://github.com/Eve-PHP/Framework/blob/cd4ca9472c6c46034bde402bf20bf2f86657c608/src/Cli/Database.php#L289-L306
|
225,583
|
yawik/behat
|
src/Select2Context.php
|
Select2Context.fillSearchField
|
private function fillSearchField(DocumentElement $page, $field, $value)
{
$driver = $this->getSession()->getDriver();
if ('Behat\Mink\Driver\Selenium2Driver' === get_class($driver)) {
// Can't use `$this->getSession()->getPage()->find()` because of https://github.com/minkphp/MinkSelenium2Driver/issues/188
$element = $page->find('css','.select2-container--open .select2-search__field');
$xpath = $element->getXpath();
$select2Input = $this->getSession()
->getDriver()
->getWebDriverSession()
->element('xpath',$xpath)
//->element('xpath', "//html/descendant-or-self::*[@class and contains(concat(' ', normalize-space(@class), ' '), ' select2-search__field ')]")
;
if (!$select2Input) {
throw new \Exception(sprintf('No field "%s" found', $field));
}
$select2Input->postValue(['value' => [$value]]);
} else {
$select2Input = $page->find('css', '.select2-search__field');
if (!$select2Input) {
throw new \Exception(sprintf('No input found for "%s"', $field));
}
$select2Input->setValue($value);
}
$this->waitForLoadingResults($this->timeout);
}
|
php
|
private function fillSearchField(DocumentElement $page, $field, $value)
{
$driver = $this->getSession()->getDriver();
if ('Behat\Mink\Driver\Selenium2Driver' === get_class($driver)) {
// Can't use `$this->getSession()->getPage()->find()` because of https://github.com/minkphp/MinkSelenium2Driver/issues/188
$element = $page->find('css','.select2-container--open .select2-search__field');
$xpath = $element->getXpath();
$select2Input = $this->getSession()
->getDriver()
->getWebDriverSession()
->element('xpath',$xpath)
//->element('xpath', "//html/descendant-or-self::*[@class and contains(concat(' ', normalize-space(@class), ' '), ' select2-search__field ')]")
;
if (!$select2Input) {
throw new \Exception(sprintf('No field "%s" found', $field));
}
$select2Input->postValue(['value' => [$value]]);
} else {
$select2Input = $page->find('css', '.select2-search__field');
if (!$select2Input) {
throw new \Exception(sprintf('No input found for "%s"', $field));
}
$select2Input->setValue($value);
}
$this->waitForLoadingResults($this->timeout);
}
|
[
"private",
"function",
"fillSearchField",
"(",
"DocumentElement",
"$",
"page",
",",
"$",
"field",
",",
"$",
"value",
")",
"{",
"$",
"driver",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getDriver",
"(",
")",
";",
"if",
"(",
"'Behat\\Mink\\Driver\\Selenium2Driver'",
"===",
"get_class",
"(",
"$",
"driver",
")",
")",
"{",
"// Can't use `$this->getSession()->getPage()->find()` because of https://github.com/minkphp/MinkSelenium2Driver/issues/188",
"$",
"element",
"=",
"$",
"page",
"->",
"find",
"(",
"'css'",
",",
"'.select2-container--open .select2-search__field'",
")",
";",
"$",
"xpath",
"=",
"$",
"element",
"->",
"getXpath",
"(",
")",
";",
"$",
"select2Input",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getDriver",
"(",
")",
"->",
"getWebDriverSession",
"(",
")",
"->",
"element",
"(",
"'xpath'",
",",
"$",
"xpath",
")",
"//->element('xpath', \"//html/descendant-or-self::*[@class and contains(concat(' ', normalize-space(@class), ' '), ' select2-search__field ')]\")",
";",
"if",
"(",
"!",
"$",
"select2Input",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'No field \"%s\" found'",
",",
"$",
"field",
")",
")",
";",
"}",
"$",
"select2Input",
"->",
"postValue",
"(",
"[",
"'value'",
"=>",
"[",
"$",
"value",
"]",
"]",
")",
";",
"}",
"else",
"{",
"$",
"select2Input",
"=",
"$",
"page",
"->",
"find",
"(",
"'css'",
",",
"'.select2-search__field'",
")",
";",
"if",
"(",
"!",
"$",
"select2Input",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'No input found for \"%s\"'",
",",
"$",
"field",
")",
")",
";",
"}",
"$",
"select2Input",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"waitForLoadingResults",
"(",
"$",
"this",
"->",
"timeout",
")",
";",
"}"
] |
Fill Select2 search field
@param DocumentElement $page
@param string $field
@param string $value
@throws \Exception
|
[
"Fill",
"Select2",
"search",
"field"
] |
9e776b8aa8a069da13e35d717f7bb35c2f96b277
|
https://github.com/yawik/behat/blob/9e776b8aa8a069da13e35d717f7bb35c2f96b277/src/Select2Context.php#L64-L92
|
225,584
|
bytic/Common
|
src/Records/Traits/HasForms/RecordTrait.php
|
RecordTrait.getForm
|
public function getForm($type = null)
{
if (!isset($this->forms[$type])) {
$form = $this->getManager()->newForm($type);
$this->forms[$type] = $this->initForm($form);
}
return $this->forms[$type];
}
|
php
|
public function getForm($type = null)
{
if (!isset($this->forms[$type])) {
$form = $this->getManager()->newForm($type);
$this->forms[$type] = $this->initForm($form);
}
return $this->forms[$type];
}
|
[
"public",
"function",
"getForm",
"(",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"forms",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"getManager",
"(",
")",
"->",
"newForm",
"(",
"$",
"type",
")",
";",
"$",
"this",
"->",
"forms",
"[",
"$",
"type",
"]",
"=",
"$",
"this",
"->",
"initForm",
"(",
"$",
"form",
")",
";",
"}",
"return",
"$",
"this",
"->",
"forms",
"[",
"$",
"type",
"]",
";",
"}"
] |
Get Form object by name
@param string $type Form name
@return Form
|
[
"Get",
"Form",
"object",
"by",
"name"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Records/Traits/HasForms/RecordTrait.php#L28-L37
|
225,585
|
n2n/n2n-log4php
|
src/app/n2n/log4php/logging/LoggingEvent.php
|
LoggingEvent.getLocationInformation
|
public function getLocationInformation() {
if($this->locationInfo === null) {
$locationInfo = array();
$trace = debug_backtrace();
$prevHop = null;
// make a downsearch to identify the caller
$hop = array_pop($trace);
while($hop !== null) {
if(isset($hop['class'])) {
// we are sometimes in functions = no class available: avoid php warning here
$className = strtolower($hop['class']);
if(!empty($className) and ($className == 'logger' or
strtolower(get_parent_class($className)) == 'logger')) {
$locationInfo['line'] = $hop['line'];
$locationInfo['file'] = $hop['file'];
break;
}
}
$prevHop = $hop;
$hop = array_pop($trace);
}
$locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main';
if(isset($prevHop['function']) and
$prevHop['function'] !== 'include' and
$prevHop['function'] !== 'include_once' and
$prevHop['function'] !== 'require' and
$prevHop['function'] !== 'require_once') {
$locationInfo['function'] = $prevHop['function'];
} else {
$locationInfo['function'] = 'main';
}
$this->locationInfo = new \n2n\log4php\location\LocationInfo($locationInfo, $this->fqcn);
}
return $this->locationInfo;
}
|
php
|
public function getLocationInformation() {
if($this->locationInfo === null) {
$locationInfo = array();
$trace = debug_backtrace();
$prevHop = null;
// make a downsearch to identify the caller
$hop = array_pop($trace);
while($hop !== null) {
if(isset($hop['class'])) {
// we are sometimes in functions = no class available: avoid php warning here
$className = strtolower($hop['class']);
if(!empty($className) and ($className == 'logger' or
strtolower(get_parent_class($className)) == 'logger')) {
$locationInfo['line'] = $hop['line'];
$locationInfo['file'] = $hop['file'];
break;
}
}
$prevHop = $hop;
$hop = array_pop($trace);
}
$locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main';
if(isset($prevHop['function']) and
$prevHop['function'] !== 'include' and
$prevHop['function'] !== 'include_once' and
$prevHop['function'] !== 'require' and
$prevHop['function'] !== 'require_once') {
$locationInfo['function'] = $prevHop['function'];
} else {
$locationInfo['function'] = 'main';
}
$this->locationInfo = new \n2n\log4php\location\LocationInfo($locationInfo, $this->fqcn);
}
return $this->locationInfo;
}
|
[
"public",
"function",
"getLocationInformation",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"locationInfo",
"===",
"null",
")",
"{",
"$",
"locationInfo",
"=",
"array",
"(",
")",
";",
"$",
"trace",
"=",
"debug_backtrace",
"(",
")",
";",
"$",
"prevHop",
"=",
"null",
";",
"// make a downsearch to identify the caller\r",
"$",
"hop",
"=",
"array_pop",
"(",
"$",
"trace",
")",
";",
"while",
"(",
"$",
"hop",
"!==",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"hop",
"[",
"'class'",
"]",
")",
")",
"{",
"// we are sometimes in functions = no class available: avoid php warning here\r",
"$",
"className",
"=",
"strtolower",
"(",
"$",
"hop",
"[",
"'class'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"className",
")",
"and",
"(",
"$",
"className",
"==",
"'logger'",
"or",
"strtolower",
"(",
"get_parent_class",
"(",
"$",
"className",
")",
")",
"==",
"'logger'",
")",
")",
"{",
"$",
"locationInfo",
"[",
"'line'",
"]",
"=",
"$",
"hop",
"[",
"'line'",
"]",
";",
"$",
"locationInfo",
"[",
"'file'",
"]",
"=",
"$",
"hop",
"[",
"'file'",
"]",
";",
"break",
";",
"}",
"}",
"$",
"prevHop",
"=",
"$",
"hop",
";",
"$",
"hop",
"=",
"array_pop",
"(",
"$",
"trace",
")",
";",
"}",
"$",
"locationInfo",
"[",
"'class'",
"]",
"=",
"isset",
"(",
"$",
"prevHop",
"[",
"'class'",
"]",
")",
"?",
"$",
"prevHop",
"[",
"'class'",
"]",
":",
"'main'",
";",
"if",
"(",
"isset",
"(",
"$",
"prevHop",
"[",
"'function'",
"]",
")",
"and",
"$",
"prevHop",
"[",
"'function'",
"]",
"!==",
"'include'",
"and",
"$",
"prevHop",
"[",
"'function'",
"]",
"!==",
"'include_once'",
"and",
"$",
"prevHop",
"[",
"'function'",
"]",
"!==",
"'require'",
"and",
"$",
"prevHop",
"[",
"'function'",
"]",
"!==",
"'require_once'",
")",
"{",
"$",
"locationInfo",
"[",
"'function'",
"]",
"=",
"$",
"prevHop",
"[",
"'function'",
"]",
";",
"}",
"else",
"{",
"$",
"locationInfo",
"[",
"'function'",
"]",
"=",
"'main'",
";",
"}",
"$",
"this",
"->",
"locationInfo",
"=",
"new",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"location",
"\\",
"LocationInfo",
"(",
"$",
"locationInfo",
",",
"$",
"this",
"->",
"fqcn",
")",
";",
"}",
"return",
"$",
"this",
"->",
"locationInfo",
";",
"}"
] |
Set the location information for this logging event. The collected
information is cached for future use.
<p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists)
to collect informations about caller.</p>
<p>It only recognize informations generated by {@link \n2n\log4php\Logger} and its subclasses.</p>
@return \n2n\log4php\location\LocationInfo
|
[
"Set",
"the",
"location",
"information",
"for",
"this",
"logging",
"event",
".",
"The",
"collected",
"information",
"is",
"cached",
"for",
"future",
"use",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/logging/LoggingEvent.php#L159-L196
|
225,586
|
n2n/n2n-log4php
|
src/app/n2n/log4php/logging/LoggingEvent.php
|
LoggingEvent.getRenderedMessage
|
public function getRenderedMessage() {
if($this->renderedMessage === null and $this->message !== null) {
if(is_string($this->message)) {
$this->renderedMessage = $this->message;
} else {
$rendererMap = \n2n\log4php\Logger::getHierarchy()->getRendererMap();
$this->renderedMessage= $rendererMap->findAndRender($this->message);
}
}
return $this->renderedMessage;
}
|
php
|
public function getRenderedMessage() {
if($this->renderedMessage === null and $this->message !== null) {
if(is_string($this->message)) {
$this->renderedMessage = $this->message;
} else {
$rendererMap = \n2n\log4php\Logger::getHierarchy()->getRendererMap();
$this->renderedMessage= $rendererMap->findAndRender($this->message);
}
}
return $this->renderedMessage;
}
|
[
"public",
"function",
"getRenderedMessage",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"renderedMessage",
"===",
"null",
"and",
"$",
"this",
"->",
"message",
"!==",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"this",
"->",
"message",
")",
")",
"{",
"$",
"this",
"->",
"renderedMessage",
"=",
"$",
"this",
"->",
"message",
";",
"}",
"else",
"{",
"$",
"rendererMap",
"=",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"Logger",
"::",
"getHierarchy",
"(",
")",
"->",
"getRendererMap",
"(",
")",
";",
"$",
"this",
"->",
"renderedMessage",
"=",
"$",
"rendererMap",
"->",
"findAndRender",
"(",
"$",
"this",
"->",
"message",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"renderedMessage",
";",
"}"
] |
Render message.
@return string
|
[
"Render",
"message",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/logging/LoggingEvent.php#L268-L278
|
225,587
|
n2n/n2n-log4php
|
src/app/n2n/log4php/logging/LoggingEvent.php
|
LoggingEvent.getTime
|
public function getTime() {
$eventTime = $this->getTimeStamp();
$eventStartTime = LoggingEvent::getStartTime();
return number_format(($eventTime - $eventStartTime) * 1000, 0, '', '');
}
|
php
|
public function getTime() {
$eventTime = $this->getTimeStamp();
$eventStartTime = LoggingEvent::getStartTime();
return number_format(($eventTime - $eventStartTime) * 1000, 0, '', '');
}
|
[
"public",
"function",
"getTime",
"(",
")",
"{",
"$",
"eventTime",
"=",
"$",
"this",
"->",
"getTimeStamp",
"(",
")",
";",
"$",
"eventStartTime",
"=",
"LoggingEvent",
"::",
"getStartTime",
"(",
")",
";",
"return",
"number_format",
"(",
"(",
"$",
"eventTime",
"-",
"$",
"eventStartTime",
")",
"*",
"1000",
",",
"0",
",",
"''",
",",
"''",
")",
";",
"}"
] |
Returns the time in milliseconds passed from the beginning of execution
to the time the event was constructed.
@deprecated This method has been replaced by getRelativeTime which
does not perform unneccesary multiplication and formatting.
@return integer
|
[
"Returns",
"the",
"time",
"in",
"milliseconds",
"passed",
"from",
"the",
"beginning",
"of",
"execution",
"to",
"the",
"time",
"the",
"event",
"was",
"constructed",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/logging/LoggingEvent.php#L318-L322
|
225,588
|
975L/PaymentBundle
|
Repository/PaymentRepository.php
|
PaymentRepository.findOneByOrderIdNotFinished
|
public function findOneByOrderIdNotFinished($orderId)
{
$qb = $this->createQueryBuilder('p');
$qb->select('p')
->where('p.orderId = :orderId')
->andWhere('p.finished is NULL')
->setParameter('orderId', strtoupper($orderId))
;
return $qb->getQuery()->getOneOrNullResult();
}
|
php
|
public function findOneByOrderIdNotFinished($orderId)
{
$qb = $this->createQueryBuilder('p');
$qb->select('p')
->where('p.orderId = :orderId')
->andWhere('p.finished is NULL')
->setParameter('orderId', strtoupper($orderId))
;
return $qb->getQuery()->getOneOrNullResult();
}
|
[
"public",
"function",
"findOneByOrderIdNotFinished",
"(",
"$",
"orderId",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'p'",
")",
";",
"$",
"qb",
"->",
"select",
"(",
"'p'",
")",
"->",
"where",
"(",
"'p.orderId = :orderId'",
")",
"->",
"andWhere",
"(",
"'p.finished is NULL'",
")",
"->",
"setParameter",
"(",
"'orderId'",
",",
"strtoupper",
"(",
"$",
"orderId",
")",
")",
";",
"return",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"getOneOrNullResult",
"(",
")",
";",
"}"
] |
Finds Payment not finished with its orderId
@return Payment|null
|
[
"Finds",
"Payment",
"not",
"finished",
"with",
"its",
"orderId"
] |
da3beb13842aea6a3dc278eeb565f519040995b7
|
https://github.com/975L/PaymentBundle/blob/da3beb13842aea6a3dc278eeb565f519040995b7/Repository/PaymentRepository.php#L26-L36
|
225,589
|
UCSLabs/form
|
ArrayFormType.php
|
ArrayFormType.getBuilder
|
public function getBuilder($group, array $options, array $model, $editMode)
{
if (!isset($options['attr'])) {
$options['attr'] = array();
}
$options['attr']['class'] = 'ucs-fieldgroup';
$builder = $this->formFactory->createNamedBuilder($group, 'form', null, $options);
$this->addFromModel($builder, $model, $editMode);
return $builder;
}
|
php
|
public function getBuilder($group, array $options, array $model, $editMode)
{
if (!isset($options['attr'])) {
$options['attr'] = array();
}
$options['attr']['class'] = 'ucs-fieldgroup';
$builder = $this->formFactory->createNamedBuilder($group, 'form', null, $options);
$this->addFromModel($builder, $model, $editMode);
return $builder;
}
|
[
"public",
"function",
"getBuilder",
"(",
"$",
"group",
",",
"array",
"$",
"options",
",",
"array",
"$",
"model",
",",
"$",
"editMode",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'attr'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'attr'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"options",
"[",
"'attr'",
"]",
"[",
"'class'",
"]",
"=",
"'ucs-fieldgroup'",
";",
"$",
"builder",
"=",
"$",
"this",
"->",
"formFactory",
"->",
"createNamedBuilder",
"(",
"$",
"group",
",",
"'form'",
",",
"null",
",",
"$",
"options",
")",
";",
"$",
"this",
"->",
"addFromModel",
"(",
"$",
"builder",
",",
"$",
"model",
",",
"$",
"editMode",
")",
";",
"return",
"$",
"builder",
";",
"}"
] |
Create a form builder for the given group
@param string $group
@param array $options
@param array $model
@return FormBuilderInterface
|
[
"Create",
"a",
"form",
"builder",
"for",
"the",
"given",
"group"
] |
ce2f609c4ee48ab8fbd10924685d2531c18652da
|
https://github.com/UCSLabs/form/blob/ce2f609c4ee48ab8fbd10924685d2531c18652da/ArrayFormType.php#L94-L106
|
225,590
|
UCSLabs/form
|
ArrayFormType.php
|
ArrayFormType.addFromModel
|
public function addFromModel(FormBuilderInterface $builder, array $model, $editMode)
{
foreach( $model as $property => $parameters ) {
if( isset($parameters['type']) && $parameters['type'] == 'group') {
$options = array();
if (isset($parameters['options'])) {
$options = $parameters['options'];
}
$builder->add($this->getBuilder($property, $options, $parameters['fields'], $editMode));
} else {
if (!isset($parameters['widget'])) {
throw new \RuntimeException("You must specify a widget for $property");
}
$widget = $parameters['widget'];
$this->buildField($builder, $property, $widget, $editMode);
}
}
}
|
php
|
public function addFromModel(FormBuilderInterface $builder, array $model, $editMode)
{
foreach( $model as $property => $parameters ) {
if( isset($parameters['type']) && $parameters['type'] == 'group') {
$options = array();
if (isset($parameters['options'])) {
$options = $parameters['options'];
}
$builder->add($this->getBuilder($property, $options, $parameters['fields'], $editMode));
} else {
if (!isset($parameters['widget'])) {
throw new \RuntimeException("You must specify a widget for $property");
}
$widget = $parameters['widget'];
$this->buildField($builder, $property, $widget, $editMode);
}
}
}
|
[
"public",
"function",
"addFromModel",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"model",
",",
"$",
"editMode",
")",
"{",
"foreach",
"(",
"$",
"model",
"as",
"$",
"property",
"=>",
"$",
"parameters",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"parameters",
"[",
"'type'",
"]",
")",
"&&",
"$",
"parameters",
"[",
"'type'",
"]",
"==",
"'group'",
")",
"{",
"$",
"options",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"parameters",
"[",
"'options'",
"]",
")",
")",
"{",
"$",
"options",
"=",
"$",
"parameters",
"[",
"'options'",
"]",
";",
"}",
"$",
"builder",
"->",
"add",
"(",
"$",
"this",
"->",
"getBuilder",
"(",
"$",
"property",
",",
"$",
"options",
",",
"$",
"parameters",
"[",
"'fields'",
"]",
",",
"$",
"editMode",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"parameters",
"[",
"'widget'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"You must specify a widget for $property\"",
")",
";",
"}",
"$",
"widget",
"=",
"$",
"parameters",
"[",
"'widget'",
"]",
";",
"$",
"this",
"->",
"buildField",
"(",
"$",
"builder",
",",
"$",
"property",
",",
"$",
"widget",
",",
"$",
"editMode",
")",
";",
"}",
"}",
"}"
] |
Add fields to the builder from the given model
@param FormBuilderInterface $builder
@param array $model
@throws \RuntimeException if the property widget was not set
|
[
"Add",
"fields",
"to",
"the",
"builder",
"from",
"the",
"given",
"model"
] |
ce2f609c4ee48ab8fbd10924685d2531c18652da
|
https://github.com/UCSLabs/form/blob/ce2f609c4ee48ab8fbd10924685d2531c18652da/ArrayFormType.php#L116-L135
|
225,591
|
UCSLabs/form
|
ArrayFormType.php
|
ArrayFormType.buildField
|
public function buildField(FormBuilderInterface $builder, $property, array $widget, $editMode)
{
if (!isset($widget['options'])) {
$widget['options'] = array();
}
if( !isset($widget['attr']) ) {
$widget['attr'] = array();
}
if (!isset($widget['type'])) {
throw new \RuntimeException("You must specify a type for property $property");
}
$options = $widget['options'];
$options['attr'] = $widget['attr'];
$type = $widget['type'];
if( isset($widget['default']) && !$editMode) {
$options['data'] = $widget['default'];
}
if( !isset($options['attr']) ) {
$options['attr'] = array();
}
$options['attr']['data-property'] = $property;
if( isset($parameters['data']) ) {
$options['attr']['data-default-value'] = $parameters['data'];
}
// Transform validation constraints
if (isset($options['constraints'])) {
$options['constraints'] = $this->buildConstraints($options['constraints']);
}
$builder->add($property, $type, $options);
}
|
php
|
public function buildField(FormBuilderInterface $builder, $property, array $widget, $editMode)
{
if (!isset($widget['options'])) {
$widget['options'] = array();
}
if( !isset($widget['attr']) ) {
$widget['attr'] = array();
}
if (!isset($widget['type'])) {
throw new \RuntimeException("You must specify a type for property $property");
}
$options = $widget['options'];
$options['attr'] = $widget['attr'];
$type = $widget['type'];
if( isset($widget['default']) && !$editMode) {
$options['data'] = $widget['default'];
}
if( !isset($options['attr']) ) {
$options['attr'] = array();
}
$options['attr']['data-property'] = $property;
if( isset($parameters['data']) ) {
$options['attr']['data-default-value'] = $parameters['data'];
}
// Transform validation constraints
if (isset($options['constraints'])) {
$options['constraints'] = $this->buildConstraints($options['constraints']);
}
$builder->add($property, $type, $options);
}
|
[
"public",
"function",
"buildField",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"$",
"property",
",",
"array",
"$",
"widget",
",",
"$",
"editMode",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"widget",
"[",
"'options'",
"]",
")",
")",
"{",
"$",
"widget",
"[",
"'options'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"widget",
"[",
"'attr'",
"]",
")",
")",
"{",
"$",
"widget",
"[",
"'attr'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"widget",
"[",
"'type'",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"You must specify a type for property $property\"",
")",
";",
"}",
"$",
"options",
"=",
"$",
"widget",
"[",
"'options'",
"]",
";",
"$",
"options",
"[",
"'attr'",
"]",
"=",
"$",
"widget",
"[",
"'attr'",
"]",
";",
"$",
"type",
"=",
"$",
"widget",
"[",
"'type'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"widget",
"[",
"'default'",
"]",
")",
"&&",
"!",
"$",
"editMode",
")",
"{",
"$",
"options",
"[",
"'data'",
"]",
"=",
"$",
"widget",
"[",
"'default'",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'attr'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'attr'",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"options",
"[",
"'attr'",
"]",
"[",
"'data-property'",
"]",
"=",
"$",
"property",
";",
"if",
"(",
"isset",
"(",
"$",
"parameters",
"[",
"'data'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'attr'",
"]",
"[",
"'data-default-value'",
"]",
"=",
"$",
"parameters",
"[",
"'data'",
"]",
";",
"}",
"// Transform validation constraints",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'constraints'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'constraints'",
"]",
"=",
"$",
"this",
"->",
"buildConstraints",
"(",
"$",
"options",
"[",
"'constraints'",
"]",
")",
";",
"}",
"$",
"builder",
"->",
"add",
"(",
"$",
"property",
",",
"$",
"type",
",",
"$",
"options",
")",
";",
"}"
] |
Add the field to the given widget
@param FormBuilderInterface $builder
@param string $property
@param array $widget
@throws \RuntimeException if the property widget was not set
|
[
"Add",
"the",
"field",
"to",
"the",
"given",
"widget"
] |
ce2f609c4ee48ab8fbd10924685d2531c18652da
|
https://github.com/UCSLabs/form/blob/ce2f609c4ee48ab8fbd10924685d2531c18652da/ArrayFormType.php#L146-L183
|
225,592
|
UCSLabs/form
|
ArrayFormType.php
|
ArrayFormType.buildConstraints
|
protected function buildConstraints($original)
{
$constraints = array();
foreach ($constraints as $name => $params) {
$constraints[] = $this->constraintFactory->buildConstraint($name, $params);
}
return $constraints;
}
|
php
|
protected function buildConstraints($original)
{
$constraints = array();
foreach ($constraints as $name => $params) {
$constraints[] = $this->constraintFactory->buildConstraint($name, $params);
}
return $constraints;
}
|
[
"protected",
"function",
"buildConstraints",
"(",
"$",
"original",
")",
"{",
"$",
"constraints",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"constraints",
"as",
"$",
"name",
"=>",
"$",
"params",
")",
"{",
"$",
"constraints",
"[",
"]",
"=",
"$",
"this",
"->",
"constraintFactory",
"->",
"buildConstraint",
"(",
"$",
"name",
",",
"$",
"params",
")",
";",
"}",
"return",
"$",
"constraints",
";",
"}"
] |
Build the final constraints array frmp the original one
@param array $original
@return array
|
[
"Build",
"the",
"final",
"constraints",
"array",
"frmp",
"the",
"original",
"one"
] |
ce2f609c4ee48ab8fbd10924685d2531c18652da
|
https://github.com/UCSLabs/form/blob/ce2f609c4ee48ab8fbd10924685d2531c18652da/ArrayFormType.php#L192-L201
|
225,593
|
sopinetchat/SopinetChatBundle
|
Topic/SessionTopic.php
|
SessionTopic.onSubscribe
|
public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
{
//this will broadcast the message to ALL subscribers of this topic.
$topic->broadcast(['msg' => $connection->resourceId . " has joined " . $topic->getId()]);
}
|
php
|
public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request)
{
//this will broadcast the message to ALL subscribers of this topic.
$topic->broadcast(['msg' => $connection->resourceId . " has joined " . $topic->getId()]);
}
|
[
"public",
"function",
"onSubscribe",
"(",
"ConnectionInterface",
"$",
"connection",
",",
"Topic",
"$",
"topic",
",",
"WampRequest",
"$",
"request",
")",
"{",
"//this will broadcast the message to ALL subscribers of this topic.",
"$",
"topic",
"->",
"broadcast",
"(",
"[",
"'msg'",
"=>",
"$",
"connection",
"->",
"resourceId",
".",
"\" has joined \"",
".",
"$",
"topic",
"->",
"getId",
"(",
")",
"]",
")",
";",
"}"
] |
This will receive any Subscription requests for this topic.
@param ConnectionInterface $connection
@param Topic $topic
@param WampRequest $request
@return void
|
[
"This",
"will",
"receive",
"any",
"Subscription",
"requests",
"for",
"this",
"topic",
"."
] |
92c306963d8e9c74ecaa06422cea65bcf1bb3ba2
|
https://github.com/sopinetchat/SopinetChatBundle/blob/92c306963d8e9c74ecaa06422cea65bcf1bb3ba2/Topic/SessionTopic.php#L32-L36
|
225,594
|
sopinetchat/SopinetChatBundle
|
Topic/SessionTopic.php
|
SessionTopic.onPublish
|
public function onPublish(ConnectionInterface $connection, Topic $topic, WampRequest $request, $event, array $exclude, array $eligible)
{
/*
$topic->getId() will contain the FULL requested uri, so you can proceed based on that
if ($topic->getId() == "chat/channel/shout") ????????????????¿¿¿¿¿¿¿¿¿¿¿¿¿¿
//shout something to all subs.
*/
$topic->broadcast([
'msg' => $event
]);
}
|
php
|
public function onPublish(ConnectionInterface $connection, Topic $topic, WampRequest $request, $event, array $exclude, array $eligible)
{
/*
$topic->getId() will contain the FULL requested uri, so you can proceed based on that
if ($topic->getId() == "chat/channel/shout") ????????????????¿¿¿¿¿¿¿¿¿¿¿¿¿¿
//shout something to all subs.
*/
$topic->broadcast([
'msg' => $event
]);
}
|
[
"public",
"function",
"onPublish",
"(",
"ConnectionInterface",
"$",
"connection",
",",
"Topic",
"$",
"topic",
",",
"WampRequest",
"$",
"request",
",",
"$",
"event",
",",
"array",
"$",
"exclude",
",",
"array",
"$",
"eligible",
")",
"{",
"/*\n $topic->getId() will contain the FULL requested uri, so you can proceed based on that\n\n if ($topic->getId() == \"chat/channel/shout\") ????????????????¿¿¿¿¿¿¿¿¿¿¿¿¿¿\n //shout something to all subs.\n */",
"$",
"topic",
"->",
"broadcast",
"(",
"[",
"'msg'",
"=>",
"$",
"event",
"]",
")",
";",
"}"
] |
This will receive any Publish requests for this topic.
@param ConnectionInterface $connection
@param $Topic topic
@param WampRequest $request
@param $event
@param array $exclude
@param array $eligibles
@return mixed|void
|
[
"This",
"will",
"receive",
"any",
"Publish",
"requests",
"for",
"this",
"topic",
"."
] |
92c306963d8e9c74ecaa06422cea65bcf1bb3ba2
|
https://github.com/sopinetchat/SopinetChatBundle/blob/92c306963d8e9c74ecaa06422cea65bcf1bb3ba2/Topic/SessionTopic.php#L63-L75
|
225,595
|
Erebot/API
|
src/Utils.php
|
Utils.humanSize
|
public static function humanSize($size, $max = null, $system = 'si', $retstring = '%01.2f %s')
{
// Pick units
$systems = array();
$systems['si']['suffix'] = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
$systems['si']['size'] = 1000;
$systems['bi']['suffix'] = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB');
$systems['bi']['size'] = 1024;
$sys = isset($systems[$system]) ? $systems[$system] : $systems['si'];
// Max unit to display
$depth = count($sys['suffix']) - 1;
if ($max && false !== $d = array_search($max, $sys['suffix'])) {
$depth = $d;
}
// Loop
$i = 0;
while ($size >= $sys['size'] && $i < $depth) {
$size /= $sys['size'];
$i++;
}
return sprintf($retstring, $size, $sys['suffix'][$i]);
}
|
php
|
public static function humanSize($size, $max = null, $system = 'si', $retstring = '%01.2f %s')
{
// Pick units
$systems = array();
$systems['si']['suffix'] = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
$systems['si']['size'] = 1000;
$systems['bi']['suffix'] = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB');
$systems['bi']['size'] = 1024;
$sys = isset($systems[$system]) ? $systems[$system] : $systems['si'];
// Max unit to display
$depth = count($sys['suffix']) - 1;
if ($max && false !== $d = array_search($max, $sys['suffix'])) {
$depth = $d;
}
// Loop
$i = 0;
while ($size >= $sys['size'] && $i < $depth) {
$size /= $sys['size'];
$i++;
}
return sprintf($retstring, $size, $sys['suffix'][$i]);
}
|
[
"public",
"static",
"function",
"humanSize",
"(",
"$",
"size",
",",
"$",
"max",
"=",
"null",
",",
"$",
"system",
"=",
"'si'",
",",
"$",
"retstring",
"=",
"'%01.2f %s'",
")",
"{",
"// Pick units",
"$",
"systems",
"=",
"array",
"(",
")",
";",
"$",
"systems",
"[",
"'si'",
"]",
"[",
"'suffix'",
"]",
"=",
"array",
"(",
"'B'",
",",
"'KB'",
",",
"'MB'",
",",
"'GB'",
",",
"'TB'",
",",
"'PB'",
")",
";",
"$",
"systems",
"[",
"'si'",
"]",
"[",
"'size'",
"]",
"=",
"1000",
";",
"$",
"systems",
"[",
"'bi'",
"]",
"[",
"'suffix'",
"]",
"=",
"array",
"(",
"'B'",
",",
"'KiB'",
",",
"'MiB'",
",",
"'GiB'",
",",
"'TiB'",
",",
"'PiB'",
")",
";",
"$",
"systems",
"[",
"'bi'",
"]",
"[",
"'size'",
"]",
"=",
"1024",
";",
"$",
"sys",
"=",
"isset",
"(",
"$",
"systems",
"[",
"$",
"system",
"]",
")",
"?",
"$",
"systems",
"[",
"$",
"system",
"]",
":",
"$",
"systems",
"[",
"'si'",
"]",
";",
"// Max unit to display",
"$",
"depth",
"=",
"count",
"(",
"$",
"sys",
"[",
"'suffix'",
"]",
")",
"-",
"1",
";",
"if",
"(",
"$",
"max",
"&&",
"false",
"!==",
"$",
"d",
"=",
"array_search",
"(",
"$",
"max",
",",
"$",
"sys",
"[",
"'suffix'",
"]",
")",
")",
"{",
"$",
"depth",
"=",
"$",
"d",
";",
"}",
"// Loop",
"$",
"i",
"=",
"0",
";",
"while",
"(",
"$",
"size",
">=",
"$",
"sys",
"[",
"'size'",
"]",
"&&",
"$",
"i",
"<",
"$",
"depth",
")",
"{",
"$",
"size",
"/=",
"$",
"sys",
"[",
"'size'",
"]",
";",
"$",
"i",
"++",
";",
"}",
"return",
"sprintf",
"(",
"$",
"retstring",
",",
"$",
"size",
",",
"$",
"sys",
"[",
"'suffix'",
"]",
"[",
"$",
"i",
"]",
")",
";",
"}"
] |
Return human readable sizes.
@author Aidan Lister <aidan@php.net>
@version 1.3.0
@see http://aidanlister.com/2004/04/human-readable-file-sizes/
@param int $size size in bytes
@param string $max maximum unit
@param string $system 'si' for SI, 'bi' for binary suffixes
@param string $retstring return string format
@retval string The given size, in a human readable format.
|
[
"Return",
"human",
"readable",
"sizes",
"."
] |
0bff8d2048ace141aca0a536b931cf9a0186e1e3
|
https://github.com/Erebot/API/blob/0bff8d2048ace141aca0a536b931cf9a0186e1e3/src/Utils.php#L280-L304
|
225,596
|
bytic/Common
|
src/Application/Controllers/Traits/PageControllerTrait.php
|
PageControllerTrait.setMeta
|
protected function setMeta()
{
$this->getView()->Meta()->populateFromConfig(
$this->getConfig()->get('meta')
);
$favicon = new Favicon();
$favicon->setBaseDir(asset('images/favicon'));
$favicon->addAll();
$this->getView()->set('favicon', $favicon);
}
|
php
|
protected function setMeta()
{
$this->getView()->Meta()->populateFromConfig(
$this->getConfig()->get('meta')
);
$favicon = new Favicon();
$favicon->setBaseDir(asset('images/favicon'));
$favicon->addAll();
$this->getView()->set('favicon', $favicon);
}
|
[
"protected",
"function",
"setMeta",
"(",
")",
"{",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"Meta",
"(",
")",
"->",
"populateFromConfig",
"(",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"get",
"(",
"'meta'",
")",
")",
";",
"$",
"favicon",
"=",
"new",
"Favicon",
"(",
")",
";",
"$",
"favicon",
"->",
"setBaseDir",
"(",
"asset",
"(",
"'images/favicon'",
")",
")",
";",
"$",
"favicon",
"->",
"addAll",
"(",
")",
";",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"set",
"(",
"'favicon'",
",",
"$",
"favicon",
")",
";",
"}"
] |
Set meta information
@return void
|
[
"Set",
"meta",
"information"
] |
5d17043e03a2274a758fba1f6dedb7d85195bcfb
|
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Application/Controllers/Traits/PageControllerTrait.php#L58-L68
|
225,597
|
swayok/peskyorm-laravel
|
src/PeskyORMLaravel/Db/Column/Utils/FileUploadingColumnClosures.php
|
FileUploadingColumnClosures.valueDeleteExtender
|
static public function valueDeleteExtender(RecordValue $valueContainer, $deleteFiles) {
if ($deleteFiles) {
/** @var FileColumn $column */
$column = $valueContainer->getColumn();
$fileConfig = $column->getConfiguration();
$pkValue = $valueContainer->getRecord()->getPrimaryKeyValue();
\File::cleanDirectory($fileConfig->getAbsolutePathToFileFolder($valueContainer->getRecord()));
if ($pkValue) {
\File::cleanDirectory($fileConfig->getAbsolutePathToFileFolder($valueContainer->getRecord()));
}
}
}
|
php
|
static public function valueDeleteExtender(RecordValue $valueContainer, $deleteFiles) {
if ($deleteFiles) {
/** @var FileColumn $column */
$column = $valueContainer->getColumn();
$fileConfig = $column->getConfiguration();
$pkValue = $valueContainer->getRecord()->getPrimaryKeyValue();
\File::cleanDirectory($fileConfig->getAbsolutePathToFileFolder($valueContainer->getRecord()));
if ($pkValue) {
\File::cleanDirectory($fileConfig->getAbsolutePathToFileFolder($valueContainer->getRecord()));
}
}
}
|
[
"static",
"public",
"function",
"valueDeleteExtender",
"(",
"RecordValue",
"$",
"valueContainer",
",",
"$",
"deleteFiles",
")",
"{",
"if",
"(",
"$",
"deleteFiles",
")",
"{",
"/** @var FileColumn $column */",
"$",
"column",
"=",
"$",
"valueContainer",
"->",
"getColumn",
"(",
")",
";",
"$",
"fileConfig",
"=",
"$",
"column",
"->",
"getConfiguration",
"(",
")",
";",
"$",
"pkValue",
"=",
"$",
"valueContainer",
"->",
"getRecord",
"(",
")",
"->",
"getPrimaryKeyValue",
"(",
")",
";",
"\\",
"File",
"::",
"cleanDirectory",
"(",
"$",
"fileConfig",
"->",
"getAbsolutePathToFileFolder",
"(",
"$",
"valueContainer",
"->",
"getRecord",
"(",
")",
")",
")",
";",
"if",
"(",
"$",
"pkValue",
")",
"{",
"\\",
"File",
"::",
"cleanDirectory",
"(",
"$",
"fileConfig",
"->",
"getAbsolutePathToFileFolder",
"(",
"$",
"valueContainer",
"->",
"getRecord",
"(",
")",
")",
")",
";",
"}",
"}",
"}"
] |
Additional actions after record deleted from DB
@param RecordValue $valueContainer
@param bool $deleteFiles
@return void
@throws \UnexpectedValueException
@throws \InvalidArgumentException
@throws \BadMethodCallException
|
[
"Additional",
"actions",
"after",
"record",
"deleted",
"from",
"DB"
] |
ae5a285790eade3435f9fcbb6c376b755a5c3956
|
https://github.com/swayok/peskyorm-laravel/blob/ae5a285790eade3435f9fcbb6c376b755a5c3956/src/PeskyORMLaravel/Db/Column/Utils/FileUploadingColumnClosures.php#L426-L437
|
225,598
|
n2n/n2n-log4php
|
src/app/n2n/log4php/appender/mongo/MongoDB.php
|
MongoDB.append
|
public function append(\n2n\log4php\logging\LoggingEvent $event) {
try {
if ($this->collection != null) {
$this->collection->insert($this->format($event));
}
} catch (MongoCursorException $ex) {
$this->warn(sprintf('Error while writing to mongo collection: %s', $ex->getMessage()));
}
}
|
php
|
public function append(\n2n\log4php\logging\LoggingEvent $event) {
try {
if ($this->collection != null) {
$this->collection->insert($this->format($event));
}
} catch (MongoCursorException $ex) {
$this->warn(sprintf('Error while writing to mongo collection: %s', $ex->getMessage()));
}
}
|
[
"public",
"function",
"append",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"logging",
"\\",
"LoggingEvent",
"$",
"event",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"this",
"->",
"collection",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"collection",
"->",
"insert",
"(",
"$",
"this",
"->",
"format",
"(",
"$",
"event",
")",
")",
";",
"}",
"}",
"catch",
"(",
"MongoCursorException",
"$",
"ex",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"sprintf",
"(",
"'Error while writing to mongo collection: %s'",
",",
"$",
"ex",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"}"
] |
Appends a new event to the mongo database.
@param \n2n\log4php\logging\LoggingEvent $event
|
[
"Appends",
"a",
"new",
"event",
"to",
"the",
"mongo",
"database",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/appender/mongo/MongoDB.php#L152-L160
|
225,599
|
n2n/n2n-log4php
|
src/app/n2n/log4php/appender/mongo/MongoDB.php
|
MongoDB.format
|
protected function format(\n2n\log4php\logging\LoggingEvent $event) {
$timestampSec = (int) $event->getTimestamp();
$timestampUsec = (int) (($event->getTimestamp() - $timestampSec) * 1000000);
$document = array(
'timestamp' => new MongoDate($timestampSec, $timestampUsec),
'level' => $event->getLevel()->toString(),
'thread' => (int) $event->getThreadName(),
'message' => $event->getMessage(),
'loggerName' => $event->getLoggerName()
);
$locationInfo = $event->getLocationInformation();
if ($locationInfo != null) {
$document['fileName'] = $locationInfo->getFileName();
$document['method'] = $locationInfo->getMethodName();
$document['lineNumber'] = ($locationInfo->getLineNumber() == 'NA') ? 'NA' : (int) $locationInfo->getLineNumber();
$document['className'] = $locationInfo->getClassName();
}
$throwableInfo = $event->getThrowableInformation();
if ($throwableInfo != null) {
$document['exception'] = $this->formatThrowable($throwableInfo->getThrowable());
}
return $document;
}
|
php
|
protected function format(\n2n\log4php\logging\LoggingEvent $event) {
$timestampSec = (int) $event->getTimestamp();
$timestampUsec = (int) (($event->getTimestamp() - $timestampSec) * 1000000);
$document = array(
'timestamp' => new MongoDate($timestampSec, $timestampUsec),
'level' => $event->getLevel()->toString(),
'thread' => (int) $event->getThreadName(),
'message' => $event->getMessage(),
'loggerName' => $event->getLoggerName()
);
$locationInfo = $event->getLocationInformation();
if ($locationInfo != null) {
$document['fileName'] = $locationInfo->getFileName();
$document['method'] = $locationInfo->getMethodName();
$document['lineNumber'] = ($locationInfo->getLineNumber() == 'NA') ? 'NA' : (int) $locationInfo->getLineNumber();
$document['className'] = $locationInfo->getClassName();
}
$throwableInfo = $event->getThrowableInformation();
if ($throwableInfo != null) {
$document['exception'] = $this->formatThrowable($throwableInfo->getThrowable());
}
return $document;
}
|
[
"protected",
"function",
"format",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"logging",
"\\",
"LoggingEvent",
"$",
"event",
")",
"{",
"$",
"timestampSec",
"=",
"(",
"int",
")",
"$",
"event",
"->",
"getTimestamp",
"(",
")",
";",
"$",
"timestampUsec",
"=",
"(",
"int",
")",
"(",
"(",
"$",
"event",
"->",
"getTimestamp",
"(",
")",
"-",
"$",
"timestampSec",
")",
"*",
"1000000",
")",
";",
"$",
"document",
"=",
"array",
"(",
"'timestamp'",
"=>",
"new",
"MongoDate",
"(",
"$",
"timestampSec",
",",
"$",
"timestampUsec",
")",
",",
"'level'",
"=>",
"$",
"event",
"->",
"getLevel",
"(",
")",
"->",
"toString",
"(",
")",
",",
"'thread'",
"=>",
"(",
"int",
")",
"$",
"event",
"->",
"getThreadName",
"(",
")",
",",
"'message'",
"=>",
"$",
"event",
"->",
"getMessage",
"(",
")",
",",
"'loggerName'",
"=>",
"$",
"event",
"->",
"getLoggerName",
"(",
")",
")",
";",
"$",
"locationInfo",
"=",
"$",
"event",
"->",
"getLocationInformation",
"(",
")",
";",
"if",
"(",
"$",
"locationInfo",
"!=",
"null",
")",
"{",
"$",
"document",
"[",
"'fileName'",
"]",
"=",
"$",
"locationInfo",
"->",
"getFileName",
"(",
")",
";",
"$",
"document",
"[",
"'method'",
"]",
"=",
"$",
"locationInfo",
"->",
"getMethodName",
"(",
")",
";",
"$",
"document",
"[",
"'lineNumber'",
"]",
"=",
"(",
"$",
"locationInfo",
"->",
"getLineNumber",
"(",
")",
"==",
"'NA'",
")",
"?",
"'NA'",
":",
"(",
"int",
")",
"$",
"locationInfo",
"->",
"getLineNumber",
"(",
")",
";",
"$",
"document",
"[",
"'className'",
"]",
"=",
"$",
"locationInfo",
"->",
"getClassName",
"(",
")",
";",
"}",
"$",
"throwableInfo",
"=",
"$",
"event",
"->",
"getThrowableInformation",
"(",
")",
";",
"if",
"(",
"$",
"throwableInfo",
"!=",
"null",
")",
"{",
"$",
"document",
"[",
"'exception'",
"]",
"=",
"$",
"this",
"->",
"formatThrowable",
"(",
"$",
"throwableInfo",
"->",
"getThrowable",
"(",
")",
")",
";",
"}",
"return",
"$",
"document",
";",
"}"
] |
Converts the logging event into an array which can be logged to mongodb.
@param \n2n\log4php\logging\LoggingEvent $event
@return array The array representation of the logging event.
|
[
"Converts",
"the",
"logging",
"event",
"into",
"an",
"array",
"which",
"can",
"be",
"logged",
"to",
"mongodb",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/appender/mongo/MongoDB.php#L168-L194
|
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.