repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.add
public function add( $id, $parentId, $blockType, array $options = [], $siblingId = null, $prepend = null ) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::ADD, __FUNCTION__, [$id, $parentId, $blockType, $options, $siblingId, $prepend] ]; return $this; }
php
public function add( $id, $parentId, $blockType, array $options = [], $siblingId = null, $prepend = null ) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::ADD, __FUNCTION__, [$id, $parentId, $blockType, $options, $siblingId, $prepend] ]; return $this; }
[ "public", "function", "add", "(", "$", "id", ",", "$", "parentId", ",", "$", "blockType", ",", "array", "$", "options", "=", "[", "]", ",", "$", "siblingId", "=", "null", ",", "$", "prepend", "=", "null", ")", "{", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "[", "++", "$", "this", "->", "lastIndex", "]", "=", "[", "self", "::", "ADD", ",", "__FUNCTION__", ",", "[", "$", "id", ",", "$", "parentId", ",", "$", "blockType", ",", "$", "options", ",", "$", "siblingId", ",", "$", "prepend", "]", "]", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L141-L156
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.remove
public function remove($id) { $this->actions[self::GROUP_REMOVE][++$this->lastIndex] = [ self::REMOVE, __FUNCTION__, [$id] ]; $this->links[self::REMOVE][$id][$this->lastIndex] = true; return $this; }
php
public function remove($id) { $this->actions[self::GROUP_REMOVE][++$this->lastIndex] = [ self::REMOVE, __FUNCTION__, [$id] ]; $this->links[self::REMOVE][$id][$this->lastIndex] = true; return $this; }
[ "public", "function", "remove", "(", "$", "id", ")", "{", "$", "this", "->", "actions", "[", "self", "::", "GROUP_REMOVE", "]", "[", "++", "$", "this", "->", "lastIndex", "]", "=", "[", "self", "::", "REMOVE", ",", "__FUNCTION__", ",", "[", "$", "id", "]", "]", ";", "$", "this", "->", "links", "[", "self", "::", "REMOVE", "]", "[", "$", "id", "]", "[", "$", "this", "->", "lastIndex", "]", "=", "true", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L161-L172
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.move
public function move($id, $parentId = null, $siblingId = null, $prepend = null) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::MOVE, __FUNCTION__, [$id, $parentId, $siblingId, $prepend] ]; return $this; }
php
public function move($id, $parentId = null, $siblingId = null, $prepend = null) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::MOVE, __FUNCTION__, [$id, $parentId, $siblingId, $prepend] ]; return $this; }
[ "public", "function", "move", "(", "$", "id", ",", "$", "parentId", "=", "null", ",", "$", "siblingId", "=", "null", ",", "$", "prepend", "=", "null", ")", "{", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "[", "++", "$", "this", "->", "lastIndex", "]", "=", "[", "self", "::", "MOVE", ",", "__FUNCTION__", ",", "[", "$", "id", ",", "$", "parentId", ",", "$", "siblingId", ",", "$", "prepend", "]", "]", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L177-L186
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.addAlias
public function addAlias($alias, $id) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::ADD_ALIAS, __FUNCTION__, [$alias, $id] ]; return $this; }
php
public function addAlias($alias, $id) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::ADD_ALIAS, __FUNCTION__, [$alias, $id] ]; return $this; }
[ "public", "function", "addAlias", "(", "$", "alias", ",", "$", "id", ")", "{", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "[", "++", "$", "this", "->", "lastIndex", "]", "=", "[", "self", "::", "ADD_ALIAS", ",", "__FUNCTION__", ",", "[", "$", "alias", ",", "$", "id", "]", "]", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L191-L200
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.removeAlias
public function removeAlias($alias) { $this->actions[self::GROUP_REMOVE][++$this->lastIndex] = [ self::REMOVE_ALIAS, __FUNCTION__, [$alias] ]; return $this; }
php
public function removeAlias($alias) { $this->actions[self::GROUP_REMOVE][++$this->lastIndex] = [ self::REMOVE_ALIAS, __FUNCTION__, [$alias] ]; return $this; }
[ "public", "function", "removeAlias", "(", "$", "alias", ")", "{", "$", "this", "->", "actions", "[", "self", "::", "GROUP_REMOVE", "]", "[", "++", "$", "this", "->", "lastIndex", "]", "=", "[", "self", "::", "REMOVE_ALIAS", ",", "__FUNCTION__", ",", "[", "$", "alias", "]", "]", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L205-L214
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.setOption
public function setOption($id, $optionName, $optionValue) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::SET_OPTION, __FUNCTION__, [$id, $optionName, $optionValue] ]; return $this; }
php
public function setOption($id, $optionName, $optionValue) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::SET_OPTION, __FUNCTION__, [$id, $optionName, $optionValue] ]; return $this; }
[ "public", "function", "setOption", "(", "$", "id", ",", "$", "optionName", ",", "$", "optionValue", ")", "{", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "[", "++", "$", "this", "->", "lastIndex", "]", "=", "[", "self", "::", "SET_OPTION", ",", "__FUNCTION__", ",", "[", "$", "id", ",", "$", "optionName", ",", "$", "optionValue", "]", "]", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L219-L228
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.appendOption
public function appendOption($id, $optionName, $optionValue) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::APPEND_OPTION, __FUNCTION__, [$id, $optionName, $optionValue] ]; return $this; }
php
public function appendOption($id, $optionName, $optionValue) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::APPEND_OPTION, __FUNCTION__, [$id, $optionName, $optionValue] ]; return $this; }
[ "public", "function", "appendOption", "(", "$", "id", ",", "$", "optionName", ",", "$", "optionValue", ")", "{", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "[", "++", "$", "this", "->", "lastIndex", "]", "=", "[", "self", "::", "APPEND_OPTION", ",", "__FUNCTION__", ",", "[", "$", "id", ",", "$", "optionName", ",", "$", "optionValue", "]", "]", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L233-L242
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.subtractOption
public function subtractOption($id, $optionName, $optionValue) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::SUBTRACT_OPTION, __FUNCTION__, [$id, $optionName, $optionValue] ]; return $this; }
php
public function subtractOption($id, $optionName, $optionValue) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::SUBTRACT_OPTION, __FUNCTION__, [$id, $optionName, $optionValue] ]; return $this; }
[ "public", "function", "subtractOption", "(", "$", "id", ",", "$", "optionName", ",", "$", "optionValue", ")", "{", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "[", "++", "$", "this", "->", "lastIndex", "]", "=", "[", "self", "::", "SUBTRACT_OPTION", ",", "__FUNCTION__", ",", "[", "$", "id", ",", "$", "optionName", ",", "$", "optionValue", "]", "]", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L247-L256
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.replaceOption
public function replaceOption($id, $optionName, $oldOptionValue, $newOptionValue) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::REPLACE_OPTION, __FUNCTION__, [$id, $optionName, $oldOptionValue, $newOptionValue] ]; return $this; }
php
public function replaceOption($id, $optionName, $oldOptionValue, $newOptionValue) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::REPLACE_OPTION, __FUNCTION__, [$id, $optionName, $oldOptionValue, $newOptionValue] ]; return $this; }
[ "public", "function", "replaceOption", "(", "$", "id", ",", "$", "optionName", ",", "$", "oldOptionValue", ",", "$", "newOptionValue", ")", "{", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "[", "++", "$", "this", "->", "lastIndex", "]", "=", "[", "self", "::", "REPLACE_OPTION", ",", "__FUNCTION__", ",", "[", "$", "id", ",", "$", "optionName", ",", "$", "oldOptionValue", ",", "$", "newOptionValue", "]", "]", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L261-L270
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.removeOption
public function removeOption($id, $optionName) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::REMOVE_OPTION, __FUNCTION__, [$id, $optionName] ]; return $this; }
php
public function removeOption($id, $optionName) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::REMOVE_OPTION, __FUNCTION__, [$id, $optionName] ]; return $this; }
[ "public", "function", "removeOption", "(", "$", "id", ",", "$", "optionName", ")", "{", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "[", "++", "$", "this", "->", "lastIndex", "]", "=", "[", "self", "::", "REMOVE_OPTION", ",", "__FUNCTION__", ",", "[", "$", "id", ",", "$", "optionName", "]", "]", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L275-L284
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.changeBlockType
public function changeBlockType($id, $blockType, $optionsCallback = null) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::CHANGE_BLOCK_TYPE, __FUNCTION__, [$id, $blockType, $optionsCallback] ]; return $this; }
php
public function changeBlockType($id, $blockType, $optionsCallback = null) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::CHANGE_BLOCK_TYPE, __FUNCTION__, [$id, $blockType, $optionsCallback] ]; return $this; }
[ "public", "function", "changeBlockType", "(", "$", "id", ",", "$", "blockType", ",", "$", "optionsCallback", "=", "null", ")", "{", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "[", "++", "$", "this", "->", "lastIndex", "]", "=", "[", "self", "::", "CHANGE_BLOCK_TYPE", ",", "__FUNCTION__", ",", "[", "$", "id", ",", "$", "blockType", ",", "$", "optionsCallback", "]", "]", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L289-L298
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.setBlockTheme
public function setBlockTheme($themes, $id = null) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::SET_BLOCK_THEME, __FUNCTION__, [$themes, $id] ]; return $this; }
php
public function setBlockTheme($themes, $id = null) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::SET_BLOCK_THEME, __FUNCTION__, [$themes, $id] ]; return $this; }
[ "public", "function", "setBlockTheme", "(", "$", "themes", ",", "$", "id", "=", "null", ")", "{", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "[", "++", "$", "this", "->", "lastIndex", "]", "=", "[", "self", "::", "SET_BLOCK_THEME", ",", "__FUNCTION__", ",", "[", "$", "themes", ",", "$", "id", "]", "]", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L303-L312
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.setFormTheme
public function setFormTheme($themes) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::SET_FORM_THEME, __FUNCTION__, [$themes] ]; return $this; }
php
public function setFormTheme($themes) { $this->actions[self::GROUP_ADD][++$this->lastIndex] = [ self::SET_FORM_THEME, __FUNCTION__, [$themes] ]; return $this; }
[ "public", "function", "setFormTheme", "(", "$", "themes", ")", "{", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "[", "++", "$", "this", "->", "lastIndex", "]", "=", "[", "self", "::", "SET_FORM_THEME", ",", "__FUNCTION__", ",", "[", "$", "themes", "]", "]", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L317-L326
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.clear
public function clear() { $this->rawLayoutBuilder->clear(); $this->actions = []; $this->lastIndex = 0; $this->addCounter = 0; $this->links = []; return $this; }
php
public function clear() { $this->rawLayoutBuilder->clear(); $this->actions = []; $this->lastIndex = 0; $this->addCounter = 0; $this->links = []; return $this; }
[ "public", "function", "clear", "(", ")", "{", "$", "this", "->", "rawLayoutBuilder", "->", "clear", "(", ")", ";", "$", "this", "->", "actions", "=", "[", "]", ";", "$", "this", "->", "lastIndex", "=", "0", ";", "$", "this", "->", "addCounter", "=", "0", ";", "$", "this", "->", "links", "=", "[", "]", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L331-L340
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.applyChanges
public function applyChanges(ContextInterface $context, $finalize = false) { $this->addCounter = 0; $this->item = new LayoutItem($this->rawLayoutBuilder, $context); try { $total = $this->calculateActionCount(); if ($total !== 0) { $this->executeAllActions($finalize); if ($finalize) { $this->removeNotImportantRemainingActions(); } } $this->item = null; } catch (\Exception $e) { $this->item = null; throw $e; } }
php
public function applyChanges(ContextInterface $context, $finalize = false) { $this->addCounter = 0; $this->item = new LayoutItem($this->rawLayoutBuilder, $context); try { $total = $this->calculateActionCount(); if ($total !== 0) { $this->executeAllActions($finalize); if ($finalize) { $this->removeNotImportantRemainingActions(); } } $this->item = null; } catch (\Exception $e) { $this->item = null; throw $e; } }
[ "public", "function", "applyChanges", "(", "ContextInterface", "$", "context", ",", "$", "finalize", "=", "false", ")", "{", "$", "this", "->", "addCounter", "=", "0", ";", "$", "this", "->", "item", "=", "new", "LayoutItem", "(", "$", "this", "->", "rawLayoutBuilder", ",", "$", "context", ")", ";", "try", "{", "$", "total", "=", "$", "this", "->", "calculateActionCount", "(", ")", ";", "if", "(", "$", "total", "!==", "0", ")", "{", "$", "this", "->", "executeAllActions", "(", "$", "finalize", ")", ";", "if", "(", "$", "finalize", ")", "{", "$", "this", "->", "removeNotImportantRemainingActions", "(", ")", ";", "}", "}", "$", "this", "->", "item", "=", "null", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "item", "=", "null", ";", "throw", "$", "e", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L353-L371
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.calculateActionCount
protected function calculateActionCount() { $counter = 0; foreach ($this->actions as $actions) { $counter += count($actions); } return $counter; }
php
protected function calculateActionCount() { $counter = 0; foreach ($this->actions as $actions) { $counter += count($actions); } return $counter; }
[ "protected", "function", "calculateActionCount", "(", ")", "{", "$", "counter", "=", "0", ";", "foreach", "(", "$", "this", "->", "actions", "as", "$", "actions", ")", "{", "$", "counter", "+=", "count", "(", "$", "actions", ")", ";", "}", "return", "$", "counter", ";", "}" ]
Returns the total number of actions in all groups @return int
[ "Returns", "the", "total", "number", "of", "actions", "in", "all", "groups" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L378-L386
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.removeNotImportantRemainingActions
protected function removeNotImportantRemainingActions() { // remove remaining 'move' actions if (!empty($this->actions[self::GROUP_ADD])) { foreach ($this->actions[self::GROUP_ADD] as $index => $action) { if ($action[0] === self::MOVE) { unset($this->actions[self::GROUP_ADD][$index]); } } } // remove remaining 'remove' actions if there are no any 'add' actions if (!empty($this->actions[self::GROUP_REMOVE]) && empty($this->actions[self::GROUP_ADD])) { unset($this->actions[self::GROUP_REMOVE]); } }
php
protected function removeNotImportantRemainingActions() { // remove remaining 'move' actions if (!empty($this->actions[self::GROUP_ADD])) { foreach ($this->actions[self::GROUP_ADD] as $index => $action) { if ($action[0] === self::MOVE) { unset($this->actions[self::GROUP_ADD][$index]); } } } // remove remaining 'remove' actions if there are no any 'add' actions if (!empty($this->actions[self::GROUP_REMOVE]) && empty($this->actions[self::GROUP_ADD])) { unset($this->actions[self::GROUP_REMOVE]); } }
[ "protected", "function", "removeNotImportantRemainingActions", "(", ")", "{", "// remove remaining 'move' actions", "if", "(", "!", "empty", "(", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "as", "$", "index", "=>", "$", "action", ")", "{", "if", "(", "$", "action", "[", "0", "]", "===", "self", "::", "MOVE", ")", "{", "unset", "(", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "[", "$", "index", "]", ")", ";", "}", "}", "}", "// remove remaining 'remove' actions if there are no any 'add' actions", "if", "(", "!", "empty", "(", "$", "this", "->", "actions", "[", "self", "::", "GROUP_REMOVE", "]", ")", "&&", "empty", "(", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "actions", "[", "self", "::", "GROUP_REMOVE", "]", ")", ";", "}", "}" ]
Checks if there are any not executed actions and remove actions which are not important
[ "Checks", "if", "there", "are", "any", "not", "executed", "actions", "and", "remove", "actions", "which", "are", "not", "important" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L405-L419
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.executeAddActions
protected function executeAddActions() { if (!empty($this->actions[self::GROUP_ADD])) { $this->executeDependedActions(self::GROUP_ADD); } }
php
protected function executeAddActions() { if (!empty($this->actions[self::GROUP_ADD])) { $this->executeDependedActions(self::GROUP_ADD); } }
[ "protected", "function", "executeAddActions", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", ")", ")", "{", "$", "this", "->", "executeDependedActions", "(", "self", "::", "GROUP_ADD", ")", ";", "}", "}" ]
Executes all add new items related actions like * add * move * addAlias * setOption * appendOption * subtractOption * replaceOption * removeOption * changeBlockType
[ "Executes", "all", "add", "new", "items", "related", "actions", "like", "*", "add", "*", "move", "*", "addAlias", "*", "setOption", "*", "appendOption", "*", "subtractOption", "*", "replaceOption", "*", "removeOption", "*", "changeBlockType" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L433-L438
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.executeAdaptiveAddActions
protected function executeAdaptiveAddActions() { // Here are several special rules: // 1) the siblingId argument in the 'add' action is "optional", this means that // if it is not possible to add an item near to the sibling item due to it does not exist // we should try to execute such 'add' action without siblingId argument // 2) the siblingId argument in the 'move' action is "optional", this means that // if it is not possible to locate an item near to the sibling item due to it does not exist // we should try to execute such 'move' action without siblingId argument $continue = true; while ($continue && !empty($this->actions[self::GROUP_ADD])) { $continue = false; foreach ($this->actions[self::GROUP_ADD] as $index => $action) { if (self::ADD === $action[0] && $action[2][4]) { // remember siblingId for the case if the removing of it does not allow to execute the action $siblingId = $this->actions[self::GROUP_ADD][$index][2][4]; // remove siblingId $this->actions[self::GROUP_ADD][$index][2][4] = null; // try to execute the action without siblingId if (0 !== $this->executeDependedActions(self::GROUP_ADD)) { $continue = true; break; } else { // restore siblingId if the action was not executed $this->actions[self::GROUP_ADD][$index][2][4] = $siblingId; } } elseif (self::MOVE === $action[0] && $action[2][2]) { // remember siblingId for the case if the removing of it does not allow to execute the action $siblingId = $this->actions[self::GROUP_ADD][$index][2][2]; // remove siblingId $this->actions[self::GROUP_ADD][$index][2][2] = null; // try to execute the action without siblingId if (0 !== $this->executeDependedActions(self::GROUP_ADD)) { $continue = true; break; } else { // restore siblingId if the action was not executed $this->actions[self::GROUP_ADD][$index][2][2] = $siblingId; } } } } }
php
protected function executeAdaptiveAddActions() { // Here are several special rules: // 1) the siblingId argument in the 'add' action is "optional", this means that // if it is not possible to add an item near to the sibling item due to it does not exist // we should try to execute such 'add' action without siblingId argument // 2) the siblingId argument in the 'move' action is "optional", this means that // if it is not possible to locate an item near to the sibling item due to it does not exist // we should try to execute such 'move' action without siblingId argument $continue = true; while ($continue && !empty($this->actions[self::GROUP_ADD])) { $continue = false; foreach ($this->actions[self::GROUP_ADD] as $index => $action) { if (self::ADD === $action[0] && $action[2][4]) { // remember siblingId for the case if the removing of it does not allow to execute the action $siblingId = $this->actions[self::GROUP_ADD][$index][2][4]; // remove siblingId $this->actions[self::GROUP_ADD][$index][2][4] = null; // try to execute the action without siblingId if (0 !== $this->executeDependedActions(self::GROUP_ADD)) { $continue = true; break; } else { // restore siblingId if the action was not executed $this->actions[self::GROUP_ADD][$index][2][4] = $siblingId; } } elseif (self::MOVE === $action[0] && $action[2][2]) { // remember siblingId for the case if the removing of it does not allow to execute the action $siblingId = $this->actions[self::GROUP_ADD][$index][2][2]; // remove siblingId $this->actions[self::GROUP_ADD][$index][2][2] = null; // try to execute the action without siblingId if (0 !== $this->executeDependedActions(self::GROUP_ADD)) { $continue = true; break; } else { // restore siblingId if the action was not executed $this->actions[self::GROUP_ADD][$index][2][2] = $siblingId; } } } } }
[ "protected", "function", "executeAdaptiveAddActions", "(", ")", "{", "// Here are several special rules:", "// 1) the siblingId argument in the 'add' action is \"optional\", this means that", "// if it is not possible to add an item near to the sibling item due to it does not exist", "// we should try to execute such 'add' action without siblingId argument", "// 2) the siblingId argument in the 'move' action is \"optional\", this means that", "// if it is not possible to locate an item near to the sibling item due to it does not exist", "// we should try to execute such 'move' action without siblingId argument", "$", "continue", "=", "true", ";", "while", "(", "$", "continue", "&&", "!", "empty", "(", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", ")", ")", "{", "$", "continue", "=", "false", ";", "foreach", "(", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "as", "$", "index", "=>", "$", "action", ")", "{", "if", "(", "self", "::", "ADD", "===", "$", "action", "[", "0", "]", "&&", "$", "action", "[", "2", "]", "[", "4", "]", ")", "{", "// remember siblingId for the case if the removing of it does not allow to execute the action", "$", "siblingId", "=", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "[", "$", "index", "]", "[", "2", "]", "[", "4", "]", ";", "// remove siblingId", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "[", "$", "index", "]", "[", "2", "]", "[", "4", "]", "=", "null", ";", "// try to execute the action without siblingId", "if", "(", "0", "!==", "$", "this", "->", "executeDependedActions", "(", "self", "::", "GROUP_ADD", ")", ")", "{", "$", "continue", "=", "true", ";", "break", ";", "}", "else", "{", "// restore siblingId if the action was not executed", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "[", "$", "index", "]", "[", "2", "]", "[", "4", "]", "=", "$", "siblingId", ";", "}", "}", "elseif", "(", "self", "::", "MOVE", "===", "$", "action", "[", "0", "]", "&&", "$", "action", "[", "2", "]", "[", "2", "]", ")", "{", "// remember siblingId for the case if the removing of it does not allow to execute the action", "$", "siblingId", "=", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "[", "$", "index", "]", "[", "2", "]", "[", "2", "]", ";", "// remove siblingId", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "[", "$", "index", "]", "[", "2", "]", "[", "2", "]", "=", "null", ";", "// try to execute the action without siblingId", "if", "(", "0", "!==", "$", "this", "->", "executeDependedActions", "(", "self", "::", "GROUP_ADD", ")", ")", "{", "$", "continue", "=", "true", ";", "break", ";", "}", "else", "{", "// restore siblingId if the action was not executed", "$", "this", "->", "actions", "[", "self", "::", "GROUP_ADD", "]", "[", "$", "index", "]", "[", "2", "]", "[", "2", "]", "=", "$", "siblingId", ";", "}", "}", "}", "}", "}" ]
Executes all add new items related actions which were skipped by {@see executeAddActions} method, but may be executed after removing/modifying some arguments
[ "Executes", "all", "add", "new", "items", "related", "actions", "which", "were", "skipped", "by", "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L444-L486
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.executeRemoveActions
protected function executeRemoveActions() { if (!empty($this->actions[self::GROUP_REMOVE])) { $this->executeActions(self::GROUP_REMOVE); } }
php
protected function executeRemoveActions() { if (!empty($this->actions[self::GROUP_REMOVE])) { $this->executeActions(self::GROUP_REMOVE); } }
[ "protected", "function", "executeRemoveActions", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "actions", "[", "self", "::", "GROUP_REMOVE", "]", ")", ")", "{", "$", "this", "->", "executeActions", "(", "self", "::", "GROUP_REMOVE", ")", ";", "}", "}" ]
Executes all remove items related actions like * remove * removeAlias
[ "Executes", "all", "remove", "items", "related", "actions", "like", "*", "remove", "*", "removeAlias" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L493-L498
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.isActionReadyToExecute
protected function isActionReadyToExecute($key, $args) { switch ($key) { case self::ADD: $parentId = $args[1]; $siblingId = $args[4]; return !$parentId || ( $this->rawLayoutBuilder->has($parentId) && (!$siblingId || $this->rawLayoutBuilder->isParentFor($parentId, $siblingId)) ); case self::MOVE: list($id, $parentId, $siblingId) = $args; return (!$id || $this->rawLayoutBuilder->has($id)) && (!$parentId || $this->rawLayoutBuilder->has($parentId)) && ( !$siblingId || ($parentId && $this->rawLayoutBuilder->isParentFor($parentId, $siblingId)) || (!$parentId && $this->rawLayoutBuilder->has($siblingId)) ); case self::REMOVE: case self::SET_OPTION: case self::APPEND_OPTION: case self::SUBTRACT_OPTION: case self::REPLACE_OPTION: case self::REMOVE_OPTION: case self::CHANGE_BLOCK_TYPE: $id = $args[0]; return !$id || $this->rawLayoutBuilder->has($id); case self::SET_BLOCK_THEME: $id = $args[1]; return (!$id && !$this->rawLayoutBuilder->isEmpty()) || $this->rawLayoutBuilder->has($id); case self::ADD_ALIAS: $id = $args[1]; return !$id || $this->rawLayoutBuilder->has($id); case self::REMOVE_ALIAS: $alias = $args[0]; return !$alias || $this->rawLayoutBuilder->hasAlias($alias); } return true; }
php
protected function isActionReadyToExecute($key, $args) { switch ($key) { case self::ADD: $parentId = $args[1]; $siblingId = $args[4]; return !$parentId || ( $this->rawLayoutBuilder->has($parentId) && (!$siblingId || $this->rawLayoutBuilder->isParentFor($parentId, $siblingId)) ); case self::MOVE: list($id, $parentId, $siblingId) = $args; return (!$id || $this->rawLayoutBuilder->has($id)) && (!$parentId || $this->rawLayoutBuilder->has($parentId)) && ( !$siblingId || ($parentId && $this->rawLayoutBuilder->isParentFor($parentId, $siblingId)) || (!$parentId && $this->rawLayoutBuilder->has($siblingId)) ); case self::REMOVE: case self::SET_OPTION: case self::APPEND_OPTION: case self::SUBTRACT_OPTION: case self::REPLACE_OPTION: case self::REMOVE_OPTION: case self::CHANGE_BLOCK_TYPE: $id = $args[0]; return !$id || $this->rawLayoutBuilder->has($id); case self::SET_BLOCK_THEME: $id = $args[1]; return (!$id && !$this->rawLayoutBuilder->isEmpty()) || $this->rawLayoutBuilder->has($id); case self::ADD_ALIAS: $id = $args[1]; return !$id || $this->rawLayoutBuilder->has($id); case self::REMOVE_ALIAS: $alias = $args[0]; return !$alias || $this->rawLayoutBuilder->hasAlias($alias); } return true; }
[ "protected", "function", "isActionReadyToExecute", "(", "$", "key", ",", "$", "args", ")", "{", "switch", "(", "$", "key", ")", "{", "case", "self", "::", "ADD", ":", "$", "parentId", "=", "$", "args", "[", "1", "]", ";", "$", "siblingId", "=", "$", "args", "[", "4", "]", ";", "return", "!", "$", "parentId", "||", "(", "$", "this", "->", "rawLayoutBuilder", "->", "has", "(", "$", "parentId", ")", "&&", "(", "!", "$", "siblingId", "||", "$", "this", "->", "rawLayoutBuilder", "->", "isParentFor", "(", "$", "parentId", ",", "$", "siblingId", ")", ")", ")", ";", "case", "self", "::", "MOVE", ":", "list", "(", "$", "id", ",", "$", "parentId", ",", "$", "siblingId", ")", "=", "$", "args", ";", "return", "(", "!", "$", "id", "||", "$", "this", "->", "rawLayoutBuilder", "->", "has", "(", "$", "id", ")", ")", "&&", "(", "!", "$", "parentId", "||", "$", "this", "->", "rawLayoutBuilder", "->", "has", "(", "$", "parentId", ")", ")", "&&", "(", "!", "$", "siblingId", "||", "(", "$", "parentId", "&&", "$", "this", "->", "rawLayoutBuilder", "->", "isParentFor", "(", "$", "parentId", ",", "$", "siblingId", ")", ")", "||", "(", "!", "$", "parentId", "&&", "$", "this", "->", "rawLayoutBuilder", "->", "has", "(", "$", "siblingId", ")", ")", ")", ";", "case", "self", "::", "REMOVE", ":", "case", "self", "::", "SET_OPTION", ":", "case", "self", "::", "APPEND_OPTION", ":", "case", "self", "::", "SUBTRACT_OPTION", ":", "case", "self", "::", "REPLACE_OPTION", ":", "case", "self", "::", "REMOVE_OPTION", ":", "case", "self", "::", "CHANGE_BLOCK_TYPE", ":", "$", "id", "=", "$", "args", "[", "0", "]", ";", "return", "!", "$", "id", "||", "$", "this", "->", "rawLayoutBuilder", "->", "has", "(", "$", "id", ")", ";", "case", "self", "::", "SET_BLOCK_THEME", ":", "$", "id", "=", "$", "args", "[", "1", "]", ";", "return", "(", "!", "$", "id", "&&", "!", "$", "this", "->", "rawLayoutBuilder", "->", "isEmpty", "(", ")", ")", "||", "$", "this", "->", "rawLayoutBuilder", "->", "has", "(", "$", "id", ")", ";", "case", "self", "::", "ADD_ALIAS", ":", "$", "id", "=", "$", "args", "[", "1", "]", ";", "return", "!", "$", "id", "||", "$", "this", "->", "rawLayoutBuilder", "->", "has", "(", "$", "id", ")", ";", "case", "self", "::", "REMOVE_ALIAS", ":", "$", "alias", "=", "$", "args", "[", "0", "]", ";", "return", "!", "$", "alias", "||", "$", "this", "->", "rawLayoutBuilder", "->", "hasAlias", "(", "$", "alias", ")", ";", "}", "return", "true", ";", "}" ]
Checks whether an action is ready to execute @param string $key The action key @param array $args The action arguments @return bool @SuppressWarnings(PHPMD.CyclomaticComplexity)
[ "Checks", "whether", "an", "action", "is", "ready", "to", "execute" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L510-L559
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.executeActions
protected function executeActions($group) { $executedCount = 0; reset($this->actions[$group]); while (list($index, $action) = each($this->actions[$group])) { if ($this->isActionReadyToExecute($action[0], $action[2])) { $executedCount += $this->executeAction($index, $action); unset($this->actions[$group][$index]); } } return $executedCount; }
php
protected function executeActions($group) { $executedCount = 0; reset($this->actions[$group]); while (list($index, $action) = each($this->actions[$group])) { if ($this->isActionReadyToExecute($action[0], $action[2])) { $executedCount += $this->executeAction($index, $action); unset($this->actions[$group][$index]); } } return $executedCount; }
[ "protected", "function", "executeActions", "(", "$", "group", ")", "{", "$", "executedCount", "=", "0", ";", "reset", "(", "$", "this", "->", "actions", "[", "$", "group", "]", ")", ";", "while", "(", "list", "(", "$", "index", ",", "$", "action", ")", "=", "each", "(", "$", "this", "->", "actions", "[", "$", "group", "]", ")", ")", "{", "if", "(", "$", "this", "->", "isActionReadyToExecute", "(", "$", "action", "[", "0", "]", ",", "$", "action", "[", "2", "]", ")", ")", "{", "$", "executedCount", "+=", "$", "this", "->", "executeAction", "(", "$", "index", ",", "$", "action", ")", ";", "unset", "(", "$", "this", "->", "actions", "[", "$", "group", "]", "[", "$", "index", "]", ")", ";", "}", "}", "return", "$", "executedCount", ";", "}" ]
Executes actions from the given group Use this method if the group does not contain depended each other actions @param string $group @return int The number of executed actions
[ "Executes", "actions", "from", "the", "given", "group", "Use", "this", "method", "if", "the", "group", "does", "not", "contain", "depended", "each", "other", "actions" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L569-L581
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.executeDependedActions
protected function executeDependedActions($group) { $executedCount = 0; $continue = true; while ($continue) { $continue = false; $hasExecuted = false; $hasSkipped = false; reset($this->actions[$group]); while (list($index, $action) = each($this->actions[$group])) { if ($this->isActionReadyToExecute($action[0], $action[2])) { $executedCount += $this->executeAction($index, $action); unset($this->actions[$group][$index]); $hasExecuted = true; if ($hasSkipped) { // start execution from the begin $continue = true; break; } } else { $hasSkipped = true; if ($hasExecuted) { // start execution from the begin $continue = true; break; } } } } return $executedCount; }
php
protected function executeDependedActions($group) { $executedCount = 0; $continue = true; while ($continue) { $continue = false; $hasExecuted = false; $hasSkipped = false; reset($this->actions[$group]); while (list($index, $action) = each($this->actions[$group])) { if ($this->isActionReadyToExecute($action[0], $action[2])) { $executedCount += $this->executeAction($index, $action); unset($this->actions[$group][$index]); $hasExecuted = true; if ($hasSkipped) { // start execution from the begin $continue = true; break; } } else { $hasSkipped = true; if ($hasExecuted) { // start execution from the begin $continue = true; break; } } } } return $executedCount; }
[ "protected", "function", "executeDependedActions", "(", "$", "group", ")", "{", "$", "executedCount", "=", "0", ";", "$", "continue", "=", "true", ";", "while", "(", "$", "continue", ")", "{", "$", "continue", "=", "false", ";", "$", "hasExecuted", "=", "false", ";", "$", "hasSkipped", "=", "false", ";", "reset", "(", "$", "this", "->", "actions", "[", "$", "group", "]", ")", ";", "while", "(", "list", "(", "$", "index", ",", "$", "action", ")", "=", "each", "(", "$", "this", "->", "actions", "[", "$", "group", "]", ")", ")", "{", "if", "(", "$", "this", "->", "isActionReadyToExecute", "(", "$", "action", "[", "0", "]", ",", "$", "action", "[", "2", "]", ")", ")", "{", "$", "executedCount", "+=", "$", "this", "->", "executeAction", "(", "$", "index", ",", "$", "action", ")", ";", "unset", "(", "$", "this", "->", "actions", "[", "$", "group", "]", "[", "$", "index", "]", ")", ";", "$", "hasExecuted", "=", "true", ";", "if", "(", "$", "hasSkipped", ")", "{", "// start execution from the begin", "$", "continue", "=", "true", ";", "break", ";", "}", "}", "else", "{", "$", "hasSkipped", "=", "true", ";", "if", "(", "$", "hasExecuted", ")", "{", "// start execution from the begin", "$", "continue", "=", "true", ";", "break", ";", "}", "}", "}", "}", "return", "$", "executedCount", ";", "}" ]
Executes depended actions from the given group Use this method if the group can contain depended each other actions This method guarantee that all actions are executed in the order they are registered @param string $group @return int The number of executed actions
[ "Executes", "depended", "actions", "from", "the", "given", "group", "Use", "this", "method", "if", "the", "group", "can", "contain", "depended", "each", "other", "actions", "This", "method", "guarantee", "that", "all", "actions", "are", "executed", "in", "the", "order", "they", "are", "registered" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L592-L623
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.executeAction
protected function executeAction($index, $action) { list($key, $name, $args) = $action; $executedCount = $this->preExecuteAction($key, $index, $args); call_user_func_array([$this->rawLayoutBuilder, $name], $args); $executedCount++; $executedCount += $this->postExecuteAction($key, $index, $args); return $executedCount; }
php
protected function executeAction($index, $action) { list($key, $name, $args) = $action; $executedCount = $this->preExecuteAction($key, $index, $args); call_user_func_array([$this->rawLayoutBuilder, $name], $args); $executedCount++; $executedCount += $this->postExecuteAction($key, $index, $args); return $executedCount; }
[ "protected", "function", "executeAction", "(", "$", "index", ",", "$", "action", ")", "{", "list", "(", "$", "key", ",", "$", "name", ",", "$", "args", ")", "=", "$", "action", ";", "$", "executedCount", "=", "$", "this", "->", "preExecuteAction", "(", "$", "key", ",", "$", "index", ",", "$", "args", ")", ";", "call_user_func_array", "(", "[", "$", "this", "->", "rawLayoutBuilder", ",", "$", "name", "]", ",", "$", "args", ")", ";", "$", "executedCount", "++", ";", "$", "executedCount", "+=", "$", "this", "->", "postExecuteAction", "(", "$", "key", ",", "$", "index", ",", "$", "args", ")", ";", "return", "$", "executedCount", ";", "}" ]
@param int $index The action index @param array $action The action to be executed @return int The number of executed actions including the given action and all related actions
[ "@param", "int", "$index", "The", "action", "index", "@param", "array", "$action", "The", "action", "to", "be", "executed" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L631-L641
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.preExecuteAction
protected function preExecuteAction($key, $index, $args) { $executedCount = 0; switch ($key) { case self::ADD: $id = $args[0]; if ($id && $this->rawLayoutBuilder->has($id)) { $executedCount += $this->executeDependedRemoveAction($index, $id); } break; } return $executedCount; }
php
protected function preExecuteAction($key, $index, $args) { $executedCount = 0; switch ($key) { case self::ADD: $id = $args[0]; if ($id && $this->rawLayoutBuilder->has($id)) { $executedCount += $this->executeDependedRemoveAction($index, $id); } break; } return $executedCount; }
[ "protected", "function", "preExecuteAction", "(", "$", "key", ",", "$", "index", ",", "$", "args", ")", "{", "$", "executedCount", "=", "0", ";", "switch", "(", "$", "key", ")", "{", "case", "self", "::", "ADD", ":", "$", "id", "=", "$", "args", "[", "0", "]", ";", "if", "(", "$", "id", "&&", "$", "this", "->", "rawLayoutBuilder", "->", "has", "(", "$", "id", ")", ")", "{", "$", "executedCount", "+=", "$", "this", "->", "executeDependedRemoveAction", "(", "$", "index", ",", "$", "id", ")", ";", "}", "break", ";", "}", "return", "$", "executedCount", ";", "}" ]
@param int $key The action key @param int $index The action index @param array $args The action arguments @return int The number of executed actions
[ "@param", "int", "$key", "The", "action", "key", "@param", "int", "$index", "The", "action", "index", "@param", "array", "$args", "The", "action", "arguments" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L650-L663
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.postExecuteAction
protected function postExecuteAction($key, $index, $args) { switch ($key) { case self::ADD: $this->addCounter++; $this->item->initialize($args[0]); $this->registry->updateLayout($args[0], $this, $this->item); break; case self::ADD_ALIAS: $this->item->initialize($this->rawLayoutBuilder->resolveId($args[1]), $args[0]); $this->registry->updateLayout($args[0], $this, $this->item); break; case self::MOVE: $this->addCounter++; break; case self::REMOVE: $this->removeLink($key, $index, $args[0]); break; } return 0; }
php
protected function postExecuteAction($key, $index, $args) { switch ($key) { case self::ADD: $this->addCounter++; $this->item->initialize($args[0]); $this->registry->updateLayout($args[0], $this, $this->item); break; case self::ADD_ALIAS: $this->item->initialize($this->rawLayoutBuilder->resolveId($args[1]), $args[0]); $this->registry->updateLayout($args[0], $this, $this->item); break; case self::MOVE: $this->addCounter++; break; case self::REMOVE: $this->removeLink($key, $index, $args[0]); break; } return 0; }
[ "protected", "function", "postExecuteAction", "(", "$", "key", ",", "$", "index", ",", "$", "args", ")", "{", "switch", "(", "$", "key", ")", "{", "case", "self", "::", "ADD", ":", "$", "this", "->", "addCounter", "++", ";", "$", "this", "->", "item", "->", "initialize", "(", "$", "args", "[", "0", "]", ")", ";", "$", "this", "->", "registry", "->", "updateLayout", "(", "$", "args", "[", "0", "]", ",", "$", "this", ",", "$", "this", "->", "item", ")", ";", "break", ";", "case", "self", "::", "ADD_ALIAS", ":", "$", "this", "->", "item", "->", "initialize", "(", "$", "this", "->", "rawLayoutBuilder", "->", "resolveId", "(", "$", "args", "[", "1", "]", ")", ",", "$", "args", "[", "0", "]", ")", ";", "$", "this", "->", "registry", "->", "updateLayout", "(", "$", "args", "[", "0", "]", ",", "$", "this", ",", "$", "this", "->", "item", ")", ";", "break", ";", "case", "self", "::", "MOVE", ":", "$", "this", "->", "addCounter", "++", ";", "break", ";", "case", "self", "::", "REMOVE", ":", "$", "this", "->", "removeLink", "(", "$", "key", ",", "$", "index", ",", "$", "args", "[", "0", "]", ")", ";", "break", ";", "}", "return", "0", ";", "}" ]
@param int $key The action key @param int $index The action index @param array $args The action arguments @return int The number of executed actions
[ "@param", "int", "$key", "The", "action", "key", "@param", "int", "$index", "The", "action", "index", "@param", "array", "$args", "The", "action", "arguments" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L672-L693
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.executeDependedRemoveAction
protected function executeDependedRemoveAction($index, $id) { $executedCount = 0; if (isset($this->links[self::REMOVE][$id])) { $executedCount += $this->executeLinkedAction(self::GROUP_REMOVE, self::REMOVE, $index, $id); } if (0 === $executedCount) { $aliases = $this->rawLayoutBuilder->getAliases($this->rawLayoutBuilder->resolveId($id)); foreach ($aliases as $alias) { $executedCount += $this->executeLinkedAction(self::GROUP_REMOVE, self::REMOVE, $index, $alias); if (0 !== $executedCount) { break; } } } if (0 === $executedCount && $this->rawLayoutBuilder->has($id)) { $parentId = $this->rawLayoutBuilder->getParentId($id); if ($parentId) { $executedCount += $this->executeDependedRemoveAction($index, $parentId); } } return $executedCount; }
php
protected function executeDependedRemoveAction($index, $id) { $executedCount = 0; if (isset($this->links[self::REMOVE][$id])) { $executedCount += $this->executeLinkedAction(self::GROUP_REMOVE, self::REMOVE, $index, $id); } if (0 === $executedCount) { $aliases = $this->rawLayoutBuilder->getAliases($this->rawLayoutBuilder->resolveId($id)); foreach ($aliases as $alias) { $executedCount += $this->executeLinkedAction(self::GROUP_REMOVE, self::REMOVE, $index, $alias); if (0 !== $executedCount) { break; } } } if (0 === $executedCount && $this->rawLayoutBuilder->has($id)) { $parentId = $this->rawLayoutBuilder->getParentId($id); if ($parentId) { $executedCount += $this->executeDependedRemoveAction($index, $parentId); } } return $executedCount; }
[ "protected", "function", "executeDependedRemoveAction", "(", "$", "index", ",", "$", "id", ")", "{", "$", "executedCount", "=", "0", ";", "if", "(", "isset", "(", "$", "this", "->", "links", "[", "self", "::", "REMOVE", "]", "[", "$", "id", "]", ")", ")", "{", "$", "executedCount", "+=", "$", "this", "->", "executeLinkedAction", "(", "self", "::", "GROUP_REMOVE", ",", "self", "::", "REMOVE", ",", "$", "index", ",", "$", "id", ")", ";", "}", "if", "(", "0", "===", "$", "executedCount", ")", "{", "$", "aliases", "=", "$", "this", "->", "rawLayoutBuilder", "->", "getAliases", "(", "$", "this", "->", "rawLayoutBuilder", "->", "resolveId", "(", "$", "id", ")", ")", ";", "foreach", "(", "$", "aliases", "as", "$", "alias", ")", "{", "$", "executedCount", "+=", "$", "this", "->", "executeLinkedAction", "(", "self", "::", "GROUP_REMOVE", ",", "self", "::", "REMOVE", ",", "$", "index", ",", "$", "alias", ")", ";", "if", "(", "0", "!==", "$", "executedCount", ")", "{", "break", ";", "}", "}", "}", "if", "(", "0", "===", "$", "executedCount", "&&", "$", "this", "->", "rawLayoutBuilder", "->", "has", "(", "$", "id", ")", ")", "{", "$", "parentId", "=", "$", "this", "->", "rawLayoutBuilder", "->", "getParentId", "(", "$", "id", ")", ";", "if", "(", "$", "parentId", ")", "{", "$", "executedCount", "+=", "$", "this", "->", "executeDependedRemoveAction", "(", "$", "index", ",", "$", "parentId", ")", ";", "}", "}", "return", "$", "executedCount", ";", "}" ]
@param int $index The action index @param string $id The item id @return int The number of executed actions
[ "@param", "int", "$index", "The", "action", "index", "@param", "string", "$id", "The", "item", "id" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L701-L724
oroinc/OroLayoutComponent
DeferredLayoutManipulator.php
DeferredLayoutManipulator.executeLinkedAction
protected function executeLinkedAction($group, $key, $index, $id) { $executedCount = 0; reset($this->links[$key][$id]); while (isset($this->links[$key][$id]) && list($removeIndex) = each($this->links[$key][$id])) { if ($removeIndex > $index) { break; } $removeAction = $this->actions[$group][$removeIndex]; if ($this->isActionReadyToExecute($removeAction[0], $removeAction[2])) { $executedCount += $this->executeAction($removeIndex, $removeAction); unset($this->actions[$group][$removeIndex]); break; } } return $executedCount; }
php
protected function executeLinkedAction($group, $key, $index, $id) { $executedCount = 0; reset($this->links[$key][$id]); while (isset($this->links[$key][$id]) && list($removeIndex) = each($this->links[$key][$id])) { if ($removeIndex > $index) { break; } $removeAction = $this->actions[$group][$removeIndex]; if ($this->isActionReadyToExecute($removeAction[0], $removeAction[2])) { $executedCount += $this->executeAction($removeIndex, $removeAction); unset($this->actions[$group][$removeIndex]); break; } } return $executedCount; }
[ "protected", "function", "executeLinkedAction", "(", "$", "group", ",", "$", "key", ",", "$", "index", ",", "$", "id", ")", "{", "$", "executedCount", "=", "0", ";", "reset", "(", "$", "this", "->", "links", "[", "$", "key", "]", "[", "$", "id", "]", ")", ";", "while", "(", "isset", "(", "$", "this", "->", "links", "[", "$", "key", "]", "[", "$", "id", "]", ")", "&&", "list", "(", "$", "removeIndex", ")", "=", "each", "(", "$", "this", "->", "links", "[", "$", "key", "]", "[", "$", "id", "]", ")", ")", "{", "if", "(", "$", "removeIndex", ">", "$", "index", ")", "{", "break", ";", "}", "$", "removeAction", "=", "$", "this", "->", "actions", "[", "$", "group", "]", "[", "$", "removeIndex", "]", ";", "if", "(", "$", "this", "->", "isActionReadyToExecute", "(", "$", "removeAction", "[", "0", "]", ",", "$", "removeAction", "[", "2", "]", ")", ")", "{", "$", "executedCount", "+=", "$", "this", "->", "executeAction", "(", "$", "removeIndex", ",", "$", "removeAction", ")", ";", "unset", "(", "$", "this", "->", "actions", "[", "$", "group", "]", "[", "$", "removeIndex", "]", ")", ";", "break", ";", "}", "}", "return", "$", "executedCount", ";", "}" ]
@param string $group The action group @param int $key The action key @param int $index The action index @param string $id The item id @return int The number of executed actions
[ "@param", "string", "$group", "The", "action", "group", "@param", "int", "$key", "The", "action", "key", "@param", "int", "$index", "The", "action", "index", "@param", "string", "$id", "The", "item", "id" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/DeferredLayoutManipulator.php#L734-L751
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/Builder/Reflector/PropertyAssembler.php
PropertyAssembler.create
public function create($data) { $propertyDescriptor = new PropertyDescriptor(); $propertyDescriptor->setFullyQualifiedStructuralElementName($data->getName()); $propertyDescriptor->setName($data->getShortName()); $propertyDescriptor->setVisibility($data->getVisibility() ?: 'public'); $propertyDescriptor->setStatic($data->isStatic()); $propertyDescriptor->setDefault($data->getDefault()); $this->assembleDocBlock($data->getDocBlock(), $propertyDescriptor); $propertyDescriptor->setLine($data->getLinenumber()); return $propertyDescriptor; }
php
public function create($data) { $propertyDescriptor = new PropertyDescriptor(); $propertyDescriptor->setFullyQualifiedStructuralElementName($data->getName()); $propertyDescriptor->setName($data->getShortName()); $propertyDescriptor->setVisibility($data->getVisibility() ?: 'public'); $propertyDescriptor->setStatic($data->isStatic()); $propertyDescriptor->setDefault($data->getDefault()); $this->assembleDocBlock($data->getDocBlock(), $propertyDescriptor); $propertyDescriptor->setLine($data->getLinenumber()); return $propertyDescriptor; }
[ "public", "function", "create", "(", "$", "data", ")", "{", "$", "propertyDescriptor", "=", "new", "PropertyDescriptor", "(", ")", ";", "$", "propertyDescriptor", "->", "setFullyQualifiedStructuralElementName", "(", "$", "data", "->", "getName", "(", ")", ")", ";", "$", "propertyDescriptor", "->", "setName", "(", "$", "data", "->", "getShortName", "(", ")", ")", ";", "$", "propertyDescriptor", "->", "setVisibility", "(", "$", "data", "->", "getVisibility", "(", ")", "?", ":", "'public'", ")", ";", "$", "propertyDescriptor", "->", "setStatic", "(", "$", "data", "->", "isStatic", "(", ")", ")", ";", "$", "propertyDescriptor", "->", "setDefault", "(", "$", "data", "->", "getDefault", "(", ")", ")", ";", "$", "this", "->", "assembleDocBlock", "(", "$", "data", "->", "getDocBlock", "(", ")", ",", "$", "propertyDescriptor", ")", ";", "$", "propertyDescriptor", "->", "setLine", "(", "$", "data", "->", "getLinenumber", "(", ")", ")", ";", "return", "$", "propertyDescriptor", ";", "}" ]
Creates a Descriptor from the provided data. @param PropertyReflector $data @return PropertyDescriptor
[ "Creates", "a", "Descriptor", "from", "the", "provided", "data", "." ]
train
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/PropertyAssembler.php#L29-L42
spiral-modules/listing
source/Listing/Listing.php
Listing.setSelector
public function setSelector(PaginatorAwareInterface $selector) { $this->validateSelector($selector); $this->selector = $selector; return $this; }
php
public function setSelector(PaginatorAwareInterface $selector) { $this->validateSelector($selector); $this->selector = $selector; return $this; }
[ "public", "function", "setSelector", "(", "PaginatorAwareInterface", "$", "selector", ")", "{", "$", "this", "->", "validateSelector", "(", "$", "selector", ")", ";", "$", "this", "->", "selector", "=", "$", "selector", ";", "return", "$", "this", ";", "}" ]
Set active listing selector. @param RecordSelector|DocumentSelector|PaginatorAwareInterface $selector @return $this @throws InvalidSelectorException
[ "Set", "active", "listing", "selector", "." ]
train
https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/Listing.php#L93-L99
spiral-modules/listing
source/Listing/Listing.php
Listing.activeState
public function activeState() { if (!empty($this->state) && $this->state->isActive()) { return $this->getState(); } if (!empty($this->defaultState) && $this->defaultState->isActive()) { //Falling back to default state return $this->getDefaultState(); } if (empty($this->defaultState) && !empty($this->state)) { //No default state, so we have to use state anyway return $this->getState(); } throw new ListingException("Unable to get active state, no active states are set"); }
php
public function activeState() { if (!empty($this->state) && $this->state->isActive()) { return $this->getState(); } if (!empty($this->defaultState) && $this->defaultState->isActive()) { //Falling back to default state return $this->getDefaultState(); } if (empty($this->defaultState) && !empty($this->state)) { //No default state, so we have to use state anyway return $this->getState(); } throw new ListingException("Unable to get active state, no active states are set"); }
[ "public", "function", "activeState", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "state", ")", "&&", "$", "this", "->", "state", "->", "isActive", "(", ")", ")", "{", "return", "$", "this", "->", "getState", "(", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "defaultState", ")", "&&", "$", "this", "->", "defaultState", "->", "isActive", "(", ")", ")", "{", "//Falling back to default state", "return", "$", "this", "->", "getDefaultState", "(", ")", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "defaultState", ")", "&&", "!", "empty", "(", "$", "this", "->", "state", ")", ")", "{", "//No default state, so we have to use state anyway", "return", "$", "this", "->", "getState", "(", ")", ";", "}", "throw", "new", "ListingException", "(", "\"Unable to get active state, no active states are set\"", ")", ";", "}" ]
Active listing state (with fallback to default state) @return StateInterface @throws ListingException
[ "Active", "listing", "state", "(", "with", "fallback", "to", "default", "state", ")" ]
train
https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/Listing.php#L179-L196
spiral-modules/listing
source/Listing/Listing.php
Listing.setLimits
public function setLimits(array $limits = []) { if (empty($limits)) { throw new ListingException("You must provide at least one limit option"); } $this->limits = array_values($limits); return $this; }
php
public function setLimits(array $limits = []) { if (empty($limits)) { throw new ListingException("You must provide at least one limit option"); } $this->limits = array_values($limits); return $this; }
[ "public", "function", "setLimits", "(", "array", "$", "limits", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "limits", ")", ")", "{", "throw", "new", "ListingException", "(", "\"You must provide at least one limit option\"", ")", ";", "}", "$", "this", "->", "limits", "=", "array_values", "(", "$", "limits", ")", ";", "return", "$", "this", ";", "}" ]
Set allowed pagination limits @param array $limits @return $this
[ "Set", "allowed", "pagination", "limits" ]
train
https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/Listing.php#L227-L236
spiral-modules/listing
source/Listing/Listing.php
Listing.configureSelector
public function configureSelector(PaginatorAwareInterface $selector) { if (empty($this->state)) { throw new ListingException("Unable to pagination without state being set"); } $this->validateSelector($selector); foreach ($this->activeFilters() as $filter) { $selector = $filter->apply($selector); } if (!empty($sorter = $this->activeSorter())) { $selector = $sorter->apply($selector); } //Pagination $selector->setPaginator($this->createPaginator()); return $selector; }
php
public function configureSelector(PaginatorAwareInterface $selector) { if (empty($this->state)) { throw new ListingException("Unable to pagination without state being set"); } $this->validateSelector($selector); foreach ($this->activeFilters() as $filter) { $selector = $filter->apply($selector); } if (!empty($sorter = $this->activeSorter())) { $selector = $sorter->apply($selector); } //Pagination $selector->setPaginator($this->createPaginator()); return $selector; }
[ "public", "function", "configureSelector", "(", "PaginatorAwareInterface", "$", "selector", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "state", ")", ")", "{", "throw", "new", "ListingException", "(", "\"Unable to pagination without state being set\"", ")", ";", "}", "$", "this", "->", "validateSelector", "(", "$", "selector", ")", ";", "foreach", "(", "$", "this", "->", "activeFilters", "(", ")", "as", "$", "filter", ")", "{", "$", "selector", "=", "$", "filter", "->", "apply", "(", "$", "selector", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "sorter", "=", "$", "this", "->", "activeSorter", "(", ")", ")", ")", "{", "$", "selector", "=", "$", "sorter", "->", "apply", "(", "$", "selector", ")", ";", "}", "//Pagination", "$", "selector", "->", "setPaginator", "(", "$", "this", "->", "createPaginator", "(", ")", ")", ";", "return", "$", "selector", ";", "}" ]
Modify selector @param PaginatorAwareInterface|RecordSelector|DocumentSelector $selector @return RecordSelector|DocumentSelector Modified selector @throws InvalidSelectorException
[ "Modify", "selector" ]
train
https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/Listing.php#L257-L277
spiral-modules/listing
source/Listing/Listing.php
Listing.activeFilters
public function activeFilters() { $state = $this->activeState(); $result = []; foreach ($state->activeFilters() as $name) { if (!isset($this->filters[$name])) { //No such filter continue; } $filter = $this->filters[$name]; $value = $state->getValue($name); if ($filter->isApplicable($value)) { $result[$name] = $filter->withValue($value); } } return $result; }
php
public function activeFilters() { $state = $this->activeState(); $result = []; foreach ($state->activeFilters() as $name) { if (!isset($this->filters[$name])) { //No such filter continue; } $filter = $this->filters[$name]; $value = $state->getValue($name); if ($filter->isApplicable($value)) { $result[$name] = $filter->withValue($value); } } return $result; }
[ "public", "function", "activeFilters", "(", ")", "{", "$", "state", "=", "$", "this", "->", "activeState", "(", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "state", "->", "activeFilters", "(", ")", "as", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "filters", "[", "$", "name", "]", ")", ")", "{", "//No such filter", "continue", ";", "}", "$", "filter", "=", "$", "this", "->", "filters", "[", "$", "name", "]", ";", "$", "value", "=", "$", "state", "->", "getValue", "(", "$", "name", ")", ";", "if", "(", "$", "filter", "->", "isApplicable", "(", "$", "value", ")", ")", "{", "$", "result", "[", "$", "name", "]", "=", "$", "filter", "->", "withValue", "(", "$", "value", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
List of filters to be applied to current selection (named list) @return FilterInterface[] @throws ListingException
[ "List", "of", "filters", "to", "be", "applied", "to", "current", "selection", "(", "named", "list", ")" ]
train
https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/Listing.php#L336-L356
spiral-modules/listing
source/Listing/Listing.php
Listing.getSorter
public function getSorter() { $state = $this->activeState(); if (!isset($this->sorters[$state->activeSorter()])) { //No such sorter return null; } return $state->activeSorter(); }
php
public function getSorter() { $state = $this->activeState(); if (!isset($this->sorters[$state->activeSorter()])) { //No such sorter return null; } return $state->activeSorter(); }
[ "public", "function", "getSorter", "(", ")", "{", "$", "state", "=", "$", "this", "->", "activeState", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "sorters", "[", "$", "state", "->", "activeSorter", "(", ")", "]", ")", ")", "{", "//No such sorter", "return", "null", ";", "}", "return", "$", "state", "->", "activeSorter", "(", ")", ";", "}" ]
Looking for active sorter name (normalized). @return string|null
[ "Looking", "for", "active", "sorter", "name", "(", "normalized", ")", "." ]
train
https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/Listing.php#L363-L373
spiral-modules/listing
source/Listing/Listing.php
Listing.activeSorter
public function activeSorter() { if (empty($sorter = $this->getSorter())) { return null; } $sorter = $this->sorters[$sorter]; if ($sorter instanceof DirectionalSorterInterface) { return $sorter->withDirection($this->activeState()->sortDirection()); } return clone $sorter; }
php
public function activeSorter() { if (empty($sorter = $this->getSorter())) { return null; } $sorter = $this->sorters[$sorter]; if ($sorter instanceof DirectionalSorterInterface) { return $sorter->withDirection($this->activeState()->sortDirection()); } return clone $sorter; }
[ "public", "function", "activeSorter", "(", ")", "{", "if", "(", "empty", "(", "$", "sorter", "=", "$", "this", "->", "getSorter", "(", ")", ")", ")", "{", "return", "null", ";", "}", "$", "sorter", "=", "$", "this", "->", "sorters", "[", "$", "sorter", "]", ";", "if", "(", "$", "sorter", "instanceof", "DirectionalSorterInterface", ")", "{", "return", "$", "sorter", "->", "withDirection", "(", "$", "this", "->", "activeState", "(", ")", "->", "sortDirection", "(", ")", ")", ";", "}", "return", "clone", "$", "sorter", ";", "}" ]
Active sorter instance (if any) @return SorterInterface|null @throws SorterException
[ "Active", "sorter", "instance", "(", "if", "any", ")" ]
train
https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/Listing.php#L382-L395
spiral-modules/listing
source/Listing/Listing.php
Listing.createPaginator
protected function createPaginator() { $paginator = new Paginator($this->getLimit()); $paginator = $paginator->withPage($this->getPage()); return $paginator; }
php
protected function createPaginator() { $paginator = new Paginator($this->getLimit()); $paginator = $paginator->withPage($this->getPage()); return $paginator; }
[ "protected", "function", "createPaginator", "(", ")", "{", "$", "paginator", "=", "new", "Paginator", "(", "$", "this", "->", "getLimit", "(", ")", ")", ";", "$", "paginator", "=", "$", "paginator", "->", "withPage", "(", "$", "this", "->", "getPage", "(", ")", ")", ";", "return", "$", "paginator", ";", "}" ]
Get paginator associated with current listing @return Paginator
[ "Get", "paginator", "associated", "with", "current", "listing" ]
train
https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/Listing.php#L402-L408
spiral-modules/listing
source/Listing/Listing.php
Listing.getLimit
protected function getLimit() { $limit = $this->activeState()->getLimit(); if (!in_array($limit, $this->limits)) { //We are using lowest limit by default return $this->limits[0]; } return $limit; }
php
protected function getLimit() { $limit = $this->activeState()->getLimit(); if (!in_array($limit, $this->limits)) { //We are using lowest limit by default return $this->limits[0]; } return $limit; }
[ "protected", "function", "getLimit", "(", ")", "{", "$", "limit", "=", "$", "this", "->", "activeState", "(", ")", "->", "getLimit", "(", ")", ";", "if", "(", "!", "in_array", "(", "$", "limit", ",", "$", "this", "->", "limits", ")", ")", "{", "//We are using lowest limit by default", "return", "$", "this", "->", "limits", "[", "0", "]", ";", "}", "return", "$", "limit", ";", "}" ]
Get active pagination limit @return int
[ "Get", "active", "pagination", "limit" ]
train
https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/Listing.php#L415-L424
kouks/laravel-filters
src/Filters/Behavior/Searchable.php
Searchable.search
public function search($pattern = null) { if (! $pattern) { return; } foreach ($this->searchable as $column) { $this->resolveSearch($column, $pattern); } }
php
public function search($pattern = null) { if (! $pattern) { return; } foreach ($this->searchable as $column) { $this->resolveSearch($column, $pattern); } }
[ "public", "function", "search", "(", "$", "pattern", "=", "null", ")", "{", "if", "(", "!", "$", "pattern", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "searchable", "as", "$", "column", ")", "{", "$", "this", "->", "resolveSearch", "(", "$", "column", ",", "$", "pattern", ")", ";", "}", "}" ]
Searches given columns. @param string $pattern @return void
[ "Searches", "given", "columns", "." ]
train
https://github.com/kouks/laravel-filters/blob/c1a594fd40173dcbb454ea7ec59818a919fff6bd/src/Filters/Behavior/Searchable.php#L13-L22
kouks/laravel-filters
src/Filters/Behavior/Searchable.php
Searchable.resolveSearch
protected function resolveSearch($column, $key) { $this->resolve($column, $key, $this->getTableName(), function ($query, $pattern) { $this->builder->orWhere($query, 'LIKE', "%{$pattern}%"); }); }
php
protected function resolveSearch($column, $key) { $this->resolve($column, $key, $this->getTableName(), function ($query, $pattern) { $this->builder->orWhere($query, 'LIKE', "%{$pattern}%"); }); }
[ "protected", "function", "resolveSearch", "(", "$", "column", ",", "$", "key", ")", "{", "$", "this", "->", "resolve", "(", "$", "column", ",", "$", "key", ",", "$", "this", "->", "getTableName", "(", ")", ",", "function", "(", "$", "query", ",", "$", "pattern", ")", "{", "$", "this", "->", "builder", "->", "orWhere", "(", "$", "query", ",", "'LIKE'", ",", "\"%{$pattern}%\"", ")", ";", "}", ")", ";", "}" ]
Recursively build up the search query. @param string $column @param string $key @return void
[ "Recursively", "build", "up", "the", "search", "query", "." ]
train
https://github.com/kouks/laravel-filters/blob/c1a594fd40173dcbb454ea7ec59818a919fff6bd/src/Filters/Behavior/Searchable.php#L31-L36
willhoffmann/domuserp-php
src/Resources/People/Data/PersonData.php
PersonData.address
public function address(array $address) { if (! isset($this->data->addresses)) { $this->data->addresses = []; } return $this->data->addresses[] = (object) $address; }
php
public function address(array $address) { if (! isset($this->data->addresses)) { $this->data->addresses = []; } return $this->data->addresses[] = (object) $address; }
[ "public", "function", "address", "(", "array", "$", "address", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "->", "addresses", ")", ")", "{", "$", "this", "->", "data", "->", "addresses", "=", "[", "]", ";", "}", "return", "$", "this", "->", "data", "->", "addresses", "[", "]", "=", "(", "object", ")", "$", "address", ";", "}" ]
Put a address on person data @param array $address @return object
[ "Put", "a", "address", "on", "person", "data" ]
train
https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/Resources/People/Data/PersonData.php#L15-L22
willhoffmann/domuserp-php
src/Resources/People/Data/PersonData.php
PersonData.contacts
public function contacts(array $contact) { if (! isset($this->data->contacts)) { $this->data->contacts = []; } return $this->data->contacts[] = (object) $contact; }
php
public function contacts(array $contact) { if (! isset($this->data->contacts)) { $this->data->contacts = []; } return $this->data->contacts[] = (object) $contact; }
[ "public", "function", "contacts", "(", "array", "$", "contact", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "->", "contacts", ")", ")", "{", "$", "this", "->", "data", "->", "contacts", "=", "[", "]", ";", "}", "return", "$", "this", "->", "data", "->", "contacts", "[", "]", "=", "(", "object", ")", "$", "contact", ";", "}" ]
Put a contact on person data @param array $contact @return object
[ "Put", "a", "contact", "on", "person", "data" ]
train
https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/Resources/People/Data/PersonData.php#L30-L37
willhoffmann/domuserp-php
src/Resources/People/Data/PersonData.php
PersonData.references
public function references(array $reference = null) { if (! isset($this->data->references)) { $this->data->references = []; } return $this->data->contacts[] = (object) $reference; }
php
public function references(array $reference = null) { if (! isset($this->data->references)) { $this->data->references = []; } return $this->data->contacts[] = (object) $reference; }
[ "public", "function", "references", "(", "array", "$", "reference", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "->", "references", ")", ")", "{", "$", "this", "->", "data", "->", "references", "=", "[", "]", ";", "}", "return", "$", "this", "->", "data", "->", "contacts", "[", "]", "=", "(", "object", ")", "$", "reference", ";", "}" ]
Put a commercial reference on person data @param array $reference @return object
[ "Put", "a", "commercial", "reference", "on", "person", "data" ]
train
https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/Resources/People/Data/PersonData.php#L45-L52
weew/http
src/Weew/Http/CookieParser.php
CookieParser.parse
public function parse($string) { $cookie = $this->createCookie(); $cookie->setSecure(false); $cookie->setHttpOnly(false); $parts = explode(';', $string); foreach ($parts as $part) { $part = trim($part); $this->parseFlags($cookie, $part); $this->parseProperties($cookie, $part); } return $cookie; }
php
public function parse($string) { $cookie = $this->createCookie(); $cookie->setSecure(false); $cookie->setHttpOnly(false); $parts = explode(';', $string); foreach ($parts as $part) { $part = trim($part); $this->parseFlags($cookie, $part); $this->parseProperties($cookie, $part); } return $cookie; }
[ "public", "function", "parse", "(", "$", "string", ")", "{", "$", "cookie", "=", "$", "this", "->", "createCookie", "(", ")", ";", "$", "cookie", "->", "setSecure", "(", "false", ")", ";", "$", "cookie", "->", "setHttpOnly", "(", "false", ")", ";", "$", "parts", "=", "explode", "(", "';'", ",", "$", "string", ")", ";", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "$", "part", "=", "trim", "(", "$", "part", ")", ";", "$", "this", "->", "parseFlags", "(", "$", "cookie", ",", "$", "part", ")", ";", "$", "this", "->", "parseProperties", "(", "$", "cookie", ",", "$", "part", ")", ";", "}", "return", "$", "cookie", ";", "}" ]
@param $string @return Cookie
[ "@param", "$string" ]
train
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/CookieParser.php#L11-L25
weew/http
src/Weew/Http/CookieParser.php
CookieParser.parseKeyValuePair
protected function parseKeyValuePair($string) { list($key, $value) = explode('=', $string); $key = trim($key); $value = trim($value); return [$key, $value]; }
php
protected function parseKeyValuePair($string) { list($key, $value) = explode('=', $string); $key = trim($key); $value = trim($value); return [$key, $value]; }
[ "protected", "function", "parseKeyValuePair", "(", "$", "string", ")", "{", "list", "(", "$", "key", ",", "$", "value", ")", "=", "explode", "(", "'='", ",", "$", "string", ")", ";", "$", "key", "=", "trim", "(", "$", "key", ")", ";", "$", "value", "=", "trim", "(", "$", "value", ")", ";", "return", "[", "$", "key", ",", "$", "value", "]", ";", "}" ]
@param $string @return array
[ "@param", "$string" ]
train
https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/CookieParser.php#L66-L73
mothership-ec/composer
src/Composer/Repository/CompositeRepository.php
CompositeRepository.filterPackages
public function filterPackages($callback, $class = 'Composer\Package\Package') { foreach ($this->repositories as $repository) { if (false === $repository->filterPackages($callback, $class)) { return false; } } return true; }
php
public function filterPackages($callback, $class = 'Composer\Package\Package') { foreach ($this->repositories as $repository) { if (false === $repository->filterPackages($callback, $class)) { return false; } } return true; }
[ "public", "function", "filterPackages", "(", "$", "callback", ",", "$", "class", "=", "'Composer\\Package\\Package'", ")", "{", "foreach", "(", "$", "this", "->", "repositories", "as", "$", "repository", ")", "{", "if", "(", "false", "===", "$", "repository", "->", "filterPackages", "(", "$", "callback", ",", "$", "class", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Repository/CompositeRepository.php#L114-L123
zicht/z
src/Zicht/Tool/Script/Node/Task/SetNode.php
SetNode.compile
public function compile(Buffer $buffer) { $name = explode('.', $this->name); $phpName = Util::toPhp($name); $buffer->write('$z->set(')->raw($phpName)->raw(', '); $buffer->raw('$z->value('); $this->nodes[0]->compile($buffer); $buffer->raw('));')->eol(); }
php
public function compile(Buffer $buffer) { $name = explode('.', $this->name); $phpName = Util::toPhp($name); $buffer->write('$z->set(')->raw($phpName)->raw(', '); $buffer->raw('$z->value('); $this->nodes[0]->compile($buffer); $buffer->raw('));')->eol(); }
[ "public", "function", "compile", "(", "Buffer", "$", "buffer", ")", "{", "$", "name", "=", "explode", "(", "'.'", ",", "$", "this", "->", "name", ")", ";", "$", "phpName", "=", "Util", "::", "toPhp", "(", "$", "name", ")", ";", "$", "buffer", "->", "write", "(", "'$z->set('", ")", "->", "raw", "(", "$", "phpName", ")", "->", "raw", "(", "', '", ")", ";", "$", "buffer", "->", "raw", "(", "'$z->value('", ")", ";", "$", "this", "->", "nodes", "[", "0", "]", "->", "compile", "(", "$", "buffer", ")", ";", "$", "buffer", "->", "raw", "(", "'));'", ")", "->", "eol", "(", ")", ";", "}" ]
Compiles the arg node. @param \Zicht\Tool\Script\Buffer $buffer @return void
[ "Compiles", "the", "arg", "node", "." ]
train
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Script/Node/Task/SetNode.php#L40-L49
dave-redfern/laravel-doctrine-entity-audit
src/Collection/AuditedCollection.php
AuditedCollection.initialize
protected function initialize() { if (!$this->initialized) { $params = []; $sql = 'SELECT MAX(' . $this->configuration->getRevisionFieldName() . ') as rev, '; $sql .= $this->configuration->getRevisionTypeFieldName() . ' AS revtype, '; $sql .= implode(', ', $this->metadata->getIdentifierColumnNames()) . ' '; if (isset($this->associationDefinition['indexBy'])) { $sql .= ', ' . $this->associationDefinition['indexBy'] . ' '; } $sql .= 'FROM ' . $this->configuration->getTableName($this->metadata) . ' t '; $sql .= 'WHERE ' . $this->configuration->getRevisionFieldName() . ' <= ' . $this->revision . ' '; foreach ($this->foreignKeys as $column => $value) { $sql .= 'AND ' . $column . ' = ? '; $params[] = $value; } //we check for revisions greater than current belonging to other entities $sql .= 'AND NOT EXISTS (SELECT * FROM ' . $this->configuration->getTableName($this->metadata) . ' st WHERE'; //ids foreach ($this->metadata->getIdentifierColumnNames() as $name) { $sql .= ' st.' . $name . ' = t.' . $name . ' AND'; } //foreigns $sql .= ' (('; //master entity query, not equals $notEqualParts = $nullParts = []; foreach ($this->foreignKeys as $column => $value) { $notEqualParts[] = $column . ' <> ?'; $nullParts[] = $column . ' IS NULL'; $params[] = $value; } $sql .= implode(' AND ', $notEqualParts) . ') OR (' . implode(' AND ', $nullParts) . '))'; //revision $sql .= ' AND st.' . $this->configuration->getRevisionFieldName() . ' <= ' . $this->revision; $sql .= ' AND st.' . $this->configuration->getRevisionFieldName() . ' > t.' . $this->configuration->getRevisionFieldName(); $sql .= ') '; //end of check for for belonging to other entities //check for deleted revisions older than requested $sql .= 'AND NOT EXISTS (SELECT * FROM ' . $this->configuration->getTableName($this->metadata) . ' sd WHERE'; //ids foreach ($this->metadata->getIdentifierColumnNames() as $name) { $sql .= ' sd.' . $name . ' = t.' . $name . ' AND'; } //revision $sql .= ' sd.' . $this->configuration->getRevisionFieldName() . ' <= ' . $this->revision; $sql .= ' AND sd.' . $this->configuration->getRevisionFieldName() . ' > t.' . $this->configuration->getRevisionFieldName(); $sql .= ' AND sd.' . $this->configuration->getRevisionTypeFieldName() . ' = ?'; $params[] = 'DEL'; $sql .= ') '; //end check for deleted revisions older than requested $sql .= 'GROUP BY ' . implode(', ', $this->metadata->getIdentifierColumnNames()) ./*', '.$this->configuration->getRevisionTypeFieldName().*/ ' '; $sql .= 'HAVING ' . $this->configuration->getRevisionTypeFieldName() . ' <> ?'; //add rev type parameter $params[] = 'DEL'; $rows = $this->auditReader->getConnection()->fetchAll($sql, $params); foreach ($rows as $row) { $entity = [ 'rev' => $row['rev'], 'revtype' => $row['revtype'], ]; unset($row['rev'], $row['revtype']); $entity['keys'] = $row; if (isset($this->associationDefinition['indexBy'])) { $key = $row[$this->associationDefinition['indexBy']]; unset($entity['keys'][$this->associationDefinition['indexBy']]); $this->entities[$key] = $entity; } else { $this->entities[] = $entity; } } $this->initialized = true; } }
php
protected function initialize() { if (!$this->initialized) { $params = []; $sql = 'SELECT MAX(' . $this->configuration->getRevisionFieldName() . ') as rev, '; $sql .= $this->configuration->getRevisionTypeFieldName() . ' AS revtype, '; $sql .= implode(', ', $this->metadata->getIdentifierColumnNames()) . ' '; if (isset($this->associationDefinition['indexBy'])) { $sql .= ', ' . $this->associationDefinition['indexBy'] . ' '; } $sql .= 'FROM ' . $this->configuration->getTableName($this->metadata) . ' t '; $sql .= 'WHERE ' . $this->configuration->getRevisionFieldName() . ' <= ' . $this->revision . ' '; foreach ($this->foreignKeys as $column => $value) { $sql .= 'AND ' . $column . ' = ? '; $params[] = $value; } //we check for revisions greater than current belonging to other entities $sql .= 'AND NOT EXISTS (SELECT * FROM ' . $this->configuration->getTableName($this->metadata) . ' st WHERE'; //ids foreach ($this->metadata->getIdentifierColumnNames() as $name) { $sql .= ' st.' . $name . ' = t.' . $name . ' AND'; } //foreigns $sql .= ' (('; //master entity query, not equals $notEqualParts = $nullParts = []; foreach ($this->foreignKeys as $column => $value) { $notEqualParts[] = $column . ' <> ?'; $nullParts[] = $column . ' IS NULL'; $params[] = $value; } $sql .= implode(' AND ', $notEqualParts) . ') OR (' . implode(' AND ', $nullParts) . '))'; //revision $sql .= ' AND st.' . $this->configuration->getRevisionFieldName() . ' <= ' . $this->revision; $sql .= ' AND st.' . $this->configuration->getRevisionFieldName() . ' > t.' . $this->configuration->getRevisionFieldName(); $sql .= ') '; //end of check for for belonging to other entities //check for deleted revisions older than requested $sql .= 'AND NOT EXISTS (SELECT * FROM ' . $this->configuration->getTableName($this->metadata) . ' sd WHERE'; //ids foreach ($this->metadata->getIdentifierColumnNames() as $name) { $sql .= ' sd.' . $name . ' = t.' . $name . ' AND'; } //revision $sql .= ' sd.' . $this->configuration->getRevisionFieldName() . ' <= ' . $this->revision; $sql .= ' AND sd.' . $this->configuration->getRevisionFieldName() . ' > t.' . $this->configuration->getRevisionFieldName(); $sql .= ' AND sd.' . $this->configuration->getRevisionTypeFieldName() . ' = ?'; $params[] = 'DEL'; $sql .= ') '; //end check for deleted revisions older than requested $sql .= 'GROUP BY ' . implode(', ', $this->metadata->getIdentifierColumnNames()) ./*', '.$this->configuration->getRevisionTypeFieldName().*/ ' '; $sql .= 'HAVING ' . $this->configuration->getRevisionTypeFieldName() . ' <> ?'; //add rev type parameter $params[] = 'DEL'; $rows = $this->auditReader->getConnection()->fetchAll($sql, $params); foreach ($rows as $row) { $entity = [ 'rev' => $row['rev'], 'revtype' => $row['revtype'], ]; unset($row['rev'], $row['revtype']); $entity['keys'] = $row; if (isset($this->associationDefinition['indexBy'])) { $key = $row[$this->associationDefinition['indexBy']]; unset($entity['keys'][$this->associationDefinition['indexBy']]); $this->entities[$key] = $entity; } else { $this->entities[] = $entity; } } $this->initialized = true; } }
[ "protected", "function", "initialize", "(", ")", "{", "if", "(", "!", "$", "this", "->", "initialized", ")", "{", "$", "params", "=", "[", "]", ";", "$", "sql", "=", "'SELECT MAX('", ".", "$", "this", "->", "configuration", "->", "getRevisionFieldName", "(", ")", ".", "') as rev, '", ";", "$", "sql", ".=", "$", "this", "->", "configuration", "->", "getRevisionTypeFieldName", "(", ")", ".", "' AS revtype, '", ";", "$", "sql", ".=", "implode", "(", "', '", ",", "$", "this", "->", "metadata", "->", "getIdentifierColumnNames", "(", ")", ")", ".", "' '", ";", "if", "(", "isset", "(", "$", "this", "->", "associationDefinition", "[", "'indexBy'", "]", ")", ")", "{", "$", "sql", ".=", "', '", ".", "$", "this", "->", "associationDefinition", "[", "'indexBy'", "]", ".", "' '", ";", "}", "$", "sql", ".=", "'FROM '", ".", "$", "this", "->", "configuration", "->", "getTableName", "(", "$", "this", "->", "metadata", ")", ".", "' t '", ";", "$", "sql", ".=", "'WHERE '", ".", "$", "this", "->", "configuration", "->", "getRevisionFieldName", "(", ")", ".", "' <= '", ".", "$", "this", "->", "revision", ".", "' '", ";", "foreach", "(", "$", "this", "->", "foreignKeys", "as", "$", "column", "=>", "$", "value", ")", "{", "$", "sql", ".=", "'AND '", ".", "$", "column", ".", "' = ? '", ";", "$", "params", "[", "]", "=", "$", "value", ";", "}", "//we check for revisions greater than current belonging to other entities", "$", "sql", ".=", "'AND NOT EXISTS (SELECT * FROM '", ".", "$", "this", "->", "configuration", "->", "getTableName", "(", "$", "this", "->", "metadata", ")", ".", "' st WHERE'", ";", "//ids", "foreach", "(", "$", "this", "->", "metadata", "->", "getIdentifierColumnNames", "(", ")", "as", "$", "name", ")", "{", "$", "sql", ".=", "' st.'", ".", "$", "name", ".", "' = t.'", ".", "$", "name", ".", "' AND'", ";", "}", "//foreigns", "$", "sql", ".=", "' (('", ";", "//master entity query, not equals", "$", "notEqualParts", "=", "$", "nullParts", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "foreignKeys", "as", "$", "column", "=>", "$", "value", ")", "{", "$", "notEqualParts", "[", "]", "=", "$", "column", ".", "' <> ?'", ";", "$", "nullParts", "[", "]", "=", "$", "column", ".", "' IS NULL'", ";", "$", "params", "[", "]", "=", "$", "value", ";", "}", "$", "sql", ".=", "implode", "(", "' AND '", ",", "$", "notEqualParts", ")", ".", "') OR ('", ".", "implode", "(", "' AND '", ",", "$", "nullParts", ")", ".", "'))'", ";", "//revision", "$", "sql", ".=", "' AND st.'", ".", "$", "this", "->", "configuration", "->", "getRevisionFieldName", "(", ")", ".", "' <= '", ".", "$", "this", "->", "revision", ";", "$", "sql", ".=", "' AND st.'", ".", "$", "this", "->", "configuration", "->", "getRevisionFieldName", "(", ")", ".", "' > t.'", ".", "$", "this", "->", "configuration", "->", "getRevisionFieldName", "(", ")", ";", "$", "sql", ".=", "') '", ";", "//end of check for for belonging to other entities", "//check for deleted revisions older than requested", "$", "sql", ".=", "'AND NOT EXISTS (SELECT * FROM '", ".", "$", "this", "->", "configuration", "->", "getTableName", "(", "$", "this", "->", "metadata", ")", ".", "' sd WHERE'", ";", "//ids", "foreach", "(", "$", "this", "->", "metadata", "->", "getIdentifierColumnNames", "(", ")", "as", "$", "name", ")", "{", "$", "sql", ".=", "' sd.'", ".", "$", "name", ".", "' = t.'", ".", "$", "name", ".", "' AND'", ";", "}", "//revision", "$", "sql", ".=", "' sd.'", ".", "$", "this", "->", "configuration", "->", "getRevisionFieldName", "(", ")", ".", "' <= '", ".", "$", "this", "->", "revision", ";", "$", "sql", ".=", "' AND sd.'", ".", "$", "this", "->", "configuration", "->", "getRevisionFieldName", "(", ")", ".", "' > t.'", ".", "$", "this", "->", "configuration", "->", "getRevisionFieldName", "(", ")", ";", "$", "sql", ".=", "' AND sd.'", ".", "$", "this", "->", "configuration", "->", "getRevisionTypeFieldName", "(", ")", ".", "' = ?'", ";", "$", "params", "[", "]", "=", "'DEL'", ";", "$", "sql", ".=", "') '", ";", "//end check for deleted revisions older than requested", "$", "sql", ".=", "'GROUP BY '", ".", "implode", "(", "', '", ",", "$", "this", "->", "metadata", "->", "getIdentifierColumnNames", "(", ")", ")", ".", "/*', '.$this->configuration->getRevisionTypeFieldName().*/", "' '", ";", "$", "sql", ".=", "'HAVING '", ".", "$", "this", "->", "configuration", "->", "getRevisionTypeFieldName", "(", ")", ".", "' <> ?'", ";", "//add rev type parameter", "$", "params", "[", "]", "=", "'DEL'", ";", "$", "rows", "=", "$", "this", "->", "auditReader", "->", "getConnection", "(", ")", "->", "fetchAll", "(", "$", "sql", ",", "$", "params", ")", ";", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "$", "entity", "=", "[", "'rev'", "=>", "$", "row", "[", "'rev'", "]", ",", "'revtype'", "=>", "$", "row", "[", "'revtype'", "]", ",", "]", ";", "unset", "(", "$", "row", "[", "'rev'", "]", ",", "$", "row", "[", "'revtype'", "]", ")", ";", "$", "entity", "[", "'keys'", "]", "=", "$", "row", ";", "if", "(", "isset", "(", "$", "this", "->", "associationDefinition", "[", "'indexBy'", "]", ")", ")", "{", "$", "key", "=", "$", "row", "[", "$", "this", "->", "associationDefinition", "[", "'indexBy'", "]", "]", ";", "unset", "(", "$", "entity", "[", "'keys'", "]", "[", "$", "this", "->", "associationDefinition", "[", "'indexBy'", "]", "]", ")", ";", "$", "this", "->", "entities", "[", "$", "key", "]", "=", "$", "entity", ";", "}", "else", "{", "$", "this", "->", "entities", "[", "]", "=", "$", "entity", ";", "}", "}", "$", "this", "->", "initialized", "=", "true", ";", "}", "}" ]
Initialize the collection
[ "Initialize", "the", "collection" ]
train
https://github.com/dave-redfern/laravel-doctrine-entity-audit/blob/ab79e305fe512ceefbc14d585fefe0a40cf911ab/src/Collection/AuditedCollection.php#L467-L561
giftcards/Encryption
Form/DataTransformer/EncryptTransformer.php
EncryptTransformer.reverseTransform
public function reverseTransform($value) { if ($value == '') { return null; } return $this->encryptor->encrypt($value, $this->profile); }
php
public function reverseTransform($value) { if ($value == '') { return null; } return $this->encryptor->encrypt($value, $this->profile); }
[ "public", "function", "reverseTransform", "(", "$", "value", ")", "{", "if", "(", "$", "value", "==", "''", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "encryptor", "->", "encrypt", "(", "$", "value", ",", "$", "this", "->", "profile", ")", ";", "}" ]
Transforms a value from the transformed representation to its original representation. This method is called when {@link Form::submit()} is called to transform the requests tainted data into an acceptable format for your data processing/model layer. This method must be able to deal with empty values. Usually this will be an empty string, but depending on your implementation other empty values are possible as well (such as empty strings). The reasoning behind this is that value transformers must be chainable. If the reverseTransform() method of the first value transformer outputs an empty string, the second value transformer must be able to process that value. By convention, reverseTransform() should return NULL if an empty string is passed. @param mixed $value The value in the transformed representation @return mixed The value in the original representation @throws TransformationFailedException When the transformation fails.
[ "Transforms", "a", "value", "from", "the", "transformed", "representation", "to", "its", "original", "representation", "." ]
train
https://github.com/giftcards/Encryption/blob/a48f92408538e2ffe1c8603f168d57803aad7100/Form/DataTransformer/EncryptTransformer.php#L93-L100
technote-space/wordpress-plugin-base
src/traits/controller/admin.php
Admin.action
public final function action() { if ( $this->is_post() && $this->nonce_check() ) { $this->post_action(); } else { $this->get_action(); } $this->common_action(); $this->do_action( 'controller_action', $this->is_post() ); }
php
public final function action() { if ( $this->is_post() && $this->nonce_check() ) { $this->post_action(); } else { $this->get_action(); } $this->common_action(); $this->do_action( 'controller_action', $this->is_post() ); }
[ "public", "final", "function", "action", "(", ")", "{", "if", "(", "$", "this", "->", "is_post", "(", ")", "&&", "$", "this", "->", "nonce_check", "(", ")", ")", "{", "$", "this", "->", "post_action", "(", ")", ";", "}", "else", "{", "$", "this", "->", "get_action", "(", ")", ";", "}", "$", "this", "->", "common_action", "(", ")", ";", "$", "this", "->", "do_action", "(", "'controller_action'", ",", "$", "this", "->", "is_post", "(", ")", ")", ";", "}" ]
action
[ "action" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/controller/admin.php#L86-L94
technote-space/wordpress-plugin-base
src/traits/controller/admin.php
Admin.get_help_tab_id
private function get_help_tab_id( $index ) { $slug = $this->get_page_slug(); return $this->apply_filters( 'get_help_tab_id', $slug . '_help_' . $index, $slug, $index ); }
php
private function get_help_tab_id( $index ) { $slug = $this->get_page_slug(); return $this->apply_filters( 'get_help_tab_id', $slug . '_help_' . $index, $slug, $index ); }
[ "private", "function", "get_help_tab_id", "(", "$", "index", ")", "{", "$", "slug", "=", "$", "this", "->", "get_page_slug", "(", ")", ";", "return", "$", "this", "->", "apply_filters", "(", "'get_help_tab_id'", ",", "$", "slug", ".", "'_help_'", ".", "$", "index", ",", "$", "slug", ",", "$", "index", ")", ";", "}" ]
@param int $index @return string
[ "@param", "int", "$index" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/controller/admin.php#L134-L138
technote-space/wordpress-plugin-base
src/traits/controller/admin.php
Admin.get_help_content
private function get_help_content( $slug ) { if ( empty( $slug ) ) { return ''; } return $this->get_view( 'admin/help/' . $slug, $this->get_help_content_params(), false, false ); }
php
private function get_help_content( $slug ) { if ( empty( $slug ) ) { return ''; } return $this->get_view( 'admin/help/' . $slug, $this->get_help_content_params(), false, false ); }
[ "private", "function", "get_help_content", "(", "$", "slug", ")", "{", "if", "(", "empty", "(", "$", "slug", ")", ")", "{", "return", "''", ";", "}", "return", "$", "this", "->", "get_view", "(", "'admin/help/'", ".", "$", "slug", ",", "$", "this", "->", "get_help_content_params", "(", ")", ",", "false", ",", "false", ")", ";", "}" ]
@param string $slug @return string
[ "@param", "string", "$slug" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/controller/admin.php#L145-L151
technote-space/wordpress-plugin-base
src/traits/controller/admin.php
Admin.get_sidebar_content
private function get_sidebar_content( $slug ) { if ( empty( $slug ) ) { return ''; } return $this->get_view( 'admin/sidebar/' . $slug, $this->get_sidebar_content_params(), false, false ); }
php
private function get_sidebar_content( $slug ) { if ( empty( $slug ) ) { return ''; } return $this->get_view( 'admin/sidebar/' . $slug, $this->get_sidebar_content_params(), false, false ); }
[ "private", "function", "get_sidebar_content", "(", "$", "slug", ")", "{", "if", "(", "empty", "(", "$", "slug", ")", ")", "{", "return", "''", ";", "}", "return", "$", "this", "->", "get_view", "(", "'admin/sidebar/'", ".", "$", "slug", ",", "$", "this", "->", "get_sidebar_content_params", "(", ")", ",", "false", ",", "false", ")", ";", "}" ]
@param string $slug @return string
[ "@param", "string", "$slug" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/controller/admin.php#L165-L171
technote-space/wordpress-plugin-base
src/traits/controller/admin.php
Admin.setup_help
public function setup_help() { $slug = $this->get_page_slug(); $contents = $this->apply_filters( 'get_help_contents', $this->get_help_contents(), $slug ); if ( ! empty( $contents ) && is_array( $contents ) ) { /** @var \WP_Screen|null $current_screen */ $current_screen = get_current_screen(); if ( isset( $current_screen ) ) { $index = 0; if ( isset( $contents['content'] ) || isset( $contents['view'] ) ) { $contents = [ $contents ]; } foreach ( $contents as $content ) { if ( ! is_array( $content ) ) { continue; } $id = $this->apply_filters( 'help_tag_id', $this->app->utility->array_get( $content, 'id', $this->get_help_tab_id( $index ) ), $content, $slug, $index ); $title = $this->apply_filters( 'help_tag_title', $this->app->utility->array_get( $content, 'title', 'Help Tab' ), $content, $slug, $index ); $content = $this->apply_filters( 'help_tag_content', $this->app->utility->array_get( $content, 'content', $this->get_help_content( $this->app->utility->array_get( $content, 'view' ) ) ), $content, $slug, $index ); if ( ! empty( $content ) ) { $current_screen->add_help_tab( [ 'id' => $id, 'title' => $this->app->translate( $title ), 'content' => $content, ] ); } $index ++; } $sidebar = $this->apply_filters( 'get_help_sidebar', $this->get_help_sidebar(), $slug ); if ( is_string( $sidebar ) && ! empty( $sidebar ) ) { $content = $this->get_sidebar_content( $sidebar ); if ( ! empty( $content ) ) { $current_screen->set_help_sidebar( $content ); } } } } }
php
public function setup_help() { $slug = $this->get_page_slug(); $contents = $this->apply_filters( 'get_help_contents', $this->get_help_contents(), $slug ); if ( ! empty( $contents ) && is_array( $contents ) ) { /** @var \WP_Screen|null $current_screen */ $current_screen = get_current_screen(); if ( isset( $current_screen ) ) { $index = 0; if ( isset( $contents['content'] ) || isset( $contents['view'] ) ) { $contents = [ $contents ]; } foreach ( $contents as $content ) { if ( ! is_array( $content ) ) { continue; } $id = $this->apply_filters( 'help_tag_id', $this->app->utility->array_get( $content, 'id', $this->get_help_tab_id( $index ) ), $content, $slug, $index ); $title = $this->apply_filters( 'help_tag_title', $this->app->utility->array_get( $content, 'title', 'Help Tab' ), $content, $slug, $index ); $content = $this->apply_filters( 'help_tag_content', $this->app->utility->array_get( $content, 'content', $this->get_help_content( $this->app->utility->array_get( $content, 'view' ) ) ), $content, $slug, $index ); if ( ! empty( $content ) ) { $current_screen->add_help_tab( [ 'id' => $id, 'title' => $this->app->translate( $title ), 'content' => $content, ] ); } $index ++; } $sidebar = $this->apply_filters( 'get_help_sidebar', $this->get_help_sidebar(), $slug ); if ( is_string( $sidebar ) && ! empty( $sidebar ) ) { $content = $this->get_sidebar_content( $sidebar ); if ( ! empty( $content ) ) { $current_screen->set_help_sidebar( $content ); } } } } }
[ "public", "function", "setup_help", "(", ")", "{", "$", "slug", "=", "$", "this", "->", "get_page_slug", "(", ")", ";", "$", "contents", "=", "$", "this", "->", "apply_filters", "(", "'get_help_contents'", ",", "$", "this", "->", "get_help_contents", "(", ")", ",", "$", "slug", ")", ";", "if", "(", "!", "empty", "(", "$", "contents", ")", "&&", "is_array", "(", "$", "contents", ")", ")", "{", "/** @var \\WP_Screen|null $current_screen */", "$", "current_screen", "=", "get_current_screen", "(", ")", ";", "if", "(", "isset", "(", "$", "current_screen", ")", ")", "{", "$", "index", "=", "0", ";", "if", "(", "isset", "(", "$", "contents", "[", "'content'", "]", ")", "||", "isset", "(", "$", "contents", "[", "'view'", "]", ")", ")", "{", "$", "contents", "=", "[", "$", "contents", "]", ";", "}", "foreach", "(", "$", "contents", "as", "$", "content", ")", "{", "if", "(", "!", "is_array", "(", "$", "content", ")", ")", "{", "continue", ";", "}", "$", "id", "=", "$", "this", "->", "apply_filters", "(", "'help_tag_id'", ",", "$", "this", "->", "app", "->", "utility", "->", "array_get", "(", "$", "content", ",", "'id'", ",", "$", "this", "->", "get_help_tab_id", "(", "$", "index", ")", ")", ",", "$", "content", ",", "$", "slug", ",", "$", "index", ")", ";", "$", "title", "=", "$", "this", "->", "apply_filters", "(", "'help_tag_title'", ",", "$", "this", "->", "app", "->", "utility", "->", "array_get", "(", "$", "content", ",", "'title'", ",", "'Help Tab'", ")", ",", "$", "content", ",", "$", "slug", ",", "$", "index", ")", ";", "$", "content", "=", "$", "this", "->", "apply_filters", "(", "'help_tag_content'", ",", "$", "this", "->", "app", "->", "utility", "->", "array_get", "(", "$", "content", ",", "'content'", ",", "$", "this", "->", "get_help_content", "(", "$", "this", "->", "app", "->", "utility", "->", "array_get", "(", "$", "content", ",", "'view'", ")", ")", ")", ",", "$", "content", ",", "$", "slug", ",", "$", "index", ")", ";", "if", "(", "!", "empty", "(", "$", "content", ")", ")", "{", "$", "current_screen", "->", "add_help_tab", "(", "[", "'id'", "=>", "$", "id", ",", "'title'", "=>", "$", "this", "->", "app", "->", "translate", "(", "$", "title", ")", ",", "'content'", "=>", "$", "content", ",", "]", ")", ";", "}", "$", "index", "++", ";", "}", "$", "sidebar", "=", "$", "this", "->", "apply_filters", "(", "'get_help_sidebar'", ",", "$", "this", "->", "get_help_sidebar", "(", ")", ",", "$", "slug", ")", ";", "if", "(", "is_string", "(", "$", "sidebar", ")", "&&", "!", "empty", "(", "$", "sidebar", ")", ")", "{", "$", "content", "=", "$", "this", "->", "get_sidebar_content", "(", "$", "sidebar", ")", ";", "if", "(", "!", "empty", "(", "$", "content", ")", ")", "{", "$", "current_screen", "->", "set_help_sidebar", "(", "$", "content", ")", ";", "}", "}", "}", "}", "}" ]
setup help
[ "setup", "help" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/traits/controller/admin.php#L183-L222
gedex/php-janrain-api
lib/Janrain/Api/Capture/Access.php
Access.getAuthorizationCode
public function getAuthorizationCode(array $params) { if (isset($params['transaction_state'])) { $params['transaction_state'] = json_encode($params['transaction_state']); } return $this->post('access/getAuthorizationCode', $params); }
php
public function getAuthorizationCode(array $params) { if (isset($params['transaction_state'])) { $params['transaction_state'] = json_encode($params['transaction_state']); } return $this->post('access/getAuthorizationCode', $params); }
[ "public", "function", "getAuthorizationCode", "(", "array", "$", "params", ")", "{", "if", "(", "isset", "(", "$", "params", "[", "'transaction_state'", "]", ")", ")", "{", "$", "params", "[", "'transaction_state'", "]", "=", "json_encode", "(", "$", "params", "[", "'transaction_state'", "]", ")", ";", "}", "return", "$", "this", "->", "post", "(", "'access/getAuthorizationCode'", ",", "$", "params", ")", ";", "}" ]
Get an authorization code that can be exchanged for an `access_token` and a `refresh_token`. @param array $params @link http://developers.janrain.com/documentation/api-methods/capture/access-codes-and-tokens/getauthorizationcode/
[ "Get", "an", "authorization", "code", "that", "can", "be", "exchanged", "for", "an", "access_token", "and", "a", "refresh_token", "." ]
train
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Capture/Access.php#L29-L36
zicht/z
src/Zicht/Tool/Command/TaskCommand.php
TaskCommand.setApplication
public function setApplication(Application $application = null) { parent::setApplication($application); if (!is_null($application)) { try { foreach($this->getContainer()->plugins as $plugin) { if ($plugin instanceof PluginTaskListenerInterface) { $name = implode('.', array_slice($this->getTaskReference(), 1)); $listeners = $plugin->getTaskListeners(); if (in_array($name, array_keys($listeners))) { call_user_func_array(array($plugin, $listeners[$name]), array($this)); } } } } catch (\UnexpectedValueException $e) {} } }
php
public function setApplication(Application $application = null) { parent::setApplication($application); if (!is_null($application)) { try { foreach($this->getContainer()->plugins as $plugin) { if ($plugin instanceof PluginTaskListenerInterface) { $name = implode('.', array_slice($this->getTaskReference(), 1)); $listeners = $plugin->getTaskListeners(); if (in_array($name, array_keys($listeners))) { call_user_func_array(array($plugin, $listeners[$name]), array($this)); } } } } catch (\UnexpectedValueException $e) {} } }
[ "public", "function", "setApplication", "(", "Application", "$", "application", "=", "null", ")", "{", "parent", "::", "setApplication", "(", "$", "application", ")", ";", "if", "(", "!", "is_null", "(", "$", "application", ")", ")", "{", "try", "{", "foreach", "(", "$", "this", "->", "getContainer", "(", ")", "->", "plugins", "as", "$", "plugin", ")", "{", "if", "(", "$", "plugin", "instanceof", "PluginTaskListenerInterface", ")", "{", "$", "name", "=", "implode", "(", "'.'", ",", "array_slice", "(", "$", "this", "->", "getTaskReference", "(", ")", ",", "1", ")", ")", ";", "$", "listeners", "=", "$", "plugin", "->", "getTaskListeners", "(", ")", ";", "if", "(", "in_array", "(", "$", "name", ",", "array_keys", "(", "$", "listeners", ")", ")", ")", "{", "call_user_func_array", "(", "array", "(", "$", "plugin", ",", "$", "listeners", "[", "$", "name", "]", ")", ",", "array", "(", "$", "this", ")", ")", ";", "}", "}", "}", "}", "catch", "(", "\\", "UnexpectedValueException", "$", "e", ")", "{", "}", "}", "}" ]
Sets the application instance for this command. @param Application $application An Application instance
[ "Sets", "the", "application", "instance", "for", "this", "command", "." ]
train
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Command/TaskCommand.php#L79-L97
zicht/z
src/Zicht/Tool/Command/TaskCommand.php
TaskCommand.addResolvableOption
public function addResolvableOption($name, $shortcut = null, $mode = null, $help = null, $default = null) { $this->opts[] = $name; return parent::addOption($name, $shortcut, $mode, $help, $default); }
php
public function addResolvableOption($name, $shortcut = null, $mode = null, $help = null, $default = null) { $this->opts[] = $name; return parent::addOption($name, $shortcut, $mode, $help, $default); }
[ "public", "function", "addResolvableOption", "(", "$", "name", ",", "$", "shortcut", "=", "null", ",", "$", "mode", "=", "null", ",", "$", "help", "=", "null", ",", "$", "default", "=", "null", ")", "{", "$", "this", "->", "opts", "[", "]", "=", "$", "name", ";", "return", "parent", "::", "addOption", "(", "$", "name", ",", "$", "shortcut", ",", "$", "mode", ",", "$", "help", ",", "$", "default", ")", ";", "}" ]
will add the given option the opt stack so it will resolved for the z plugin. @param string $name @param null $shortcut @param null $mode @param null $help @param null $default @return $this
[ "will", "add", "the", "given", "option", "the", "opt", "stack", "so", "it", "will", "resolved", "for", "the", "z", "plugin", "." ]
train
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Command/TaskCommand.php#L126-L130
zicht/z
src/Zicht/Tool/Command/TaskCommand.php
TaskCommand.configure
protected function configure() { $this ->addOption('explain', '', InputOption::VALUE_NONE, 'Explains the commands that would be executed.') ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force execution of otherwise skipped tasks.') ->addOption('plugin', '', InputOption::VALUE_REQUIRED, 'Load additional plugins on-the-fly') ->addOption('debug', '', InputOption::VALUE_NONE, "Set the debug flag") ; }
php
protected function configure() { $this ->addOption('explain', '', InputOption::VALUE_NONE, 'Explains the commands that would be executed.') ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force execution of otherwise skipped tasks.') ->addOption('plugin', '', InputOption::VALUE_REQUIRED, 'Load additional plugins on-the-fly') ->addOption('debug', '', InputOption::VALUE_NONE, "Set the debug flag") ; }
[ "protected", "function", "configure", "(", ")", "{", "$", "this", "->", "addOption", "(", "'explain'", ",", "''", ",", "InputOption", "::", "VALUE_NONE", ",", "'Explains the commands that would be executed.'", ")", "->", "addOption", "(", "'force'", ",", "'f'", ",", "InputOption", "::", "VALUE_NONE", ",", "'Force execution of otherwise skipped tasks.'", ")", "->", "addOption", "(", "'plugin'", ",", "''", ",", "InputOption", "::", "VALUE_REQUIRED", ",", "'Load additional plugins on-the-fly'", ")", "->", "addOption", "(", "'debug'", ",", "''", ",", "InputOption", "::", "VALUE_NONE", ",", "\"Set the debug flag\"", ")", ";", "}" ]
Adds the default '--explain', '--force', '--plugin' and '--debug' options @return void
[ "Adds", "the", "default", "--", "explain", "--", "force", "--", "plugin", "and", "--", "debug", "options" ]
train
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Command/TaskCommand.php#L196-L204
zicht/z
src/Zicht/Tool/Command/TaskCommand.php
TaskCommand.execute
protected function execute(InputInterface $input, Output\OutputInterface $output) { foreach ($this->getDefinition()->getArguments() as $arg) { if ($arg->getName() === 'command') { continue; } if ($input->getArgument($arg->getName())) { $this->getContainer()->set(explode('.', $this->nameToVar($arg->getName())), $input->getArgument($arg->getName())); } } foreach ($this->opts as $opt) { if ($value = $input->getOption($this->varToName($opt))) { $this->getContainer()->set(explode('.', $opt), $value); } } foreach ($this->flags as $name => $value) { $varName = explode('.', $name); $optName = $this->varToName($name); $this->getContainer()->set($varName, $value); if ($input->getOption('no-' . $optName) && $input->getOption($optName)) { throw new \InvalidArgumentException("Conflicting options --no-{$optName} and --{$optName} supplied. That confuses me."); } if ($input->getOption('no-' . $optName)) { $this->getContainer()->set($varName, false); } elseif ($input->getOption($optName)) { $this->getContainer()->set($varName, true); } } $callable = $this->getContainer()->get($this->getTaskReference()); call_user_func($callable, $this->getContainer()); }
php
protected function execute(InputInterface $input, Output\OutputInterface $output) { foreach ($this->getDefinition()->getArguments() as $arg) { if ($arg->getName() === 'command') { continue; } if ($input->getArgument($arg->getName())) { $this->getContainer()->set(explode('.', $this->nameToVar($arg->getName())), $input->getArgument($arg->getName())); } } foreach ($this->opts as $opt) { if ($value = $input->getOption($this->varToName($opt))) { $this->getContainer()->set(explode('.', $opt), $value); } } foreach ($this->flags as $name => $value) { $varName = explode('.', $name); $optName = $this->varToName($name); $this->getContainer()->set($varName, $value); if ($input->getOption('no-' . $optName) && $input->getOption($optName)) { throw new \InvalidArgumentException("Conflicting options --no-{$optName} and --{$optName} supplied. That confuses me."); } if ($input->getOption('no-' . $optName)) { $this->getContainer()->set($varName, false); } elseif ($input->getOption($optName)) { $this->getContainer()->set($varName, true); } } $callable = $this->getContainer()->get($this->getTaskReference()); call_user_func($callable, $this->getContainer()); }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "Output", "\\", "OutputInterface", "$", "output", ")", "{", "foreach", "(", "$", "this", "->", "getDefinition", "(", ")", "->", "getArguments", "(", ")", "as", "$", "arg", ")", "{", "if", "(", "$", "arg", "->", "getName", "(", ")", "===", "'command'", ")", "{", "continue", ";", "}", "if", "(", "$", "input", "->", "getArgument", "(", "$", "arg", "->", "getName", "(", ")", ")", ")", "{", "$", "this", "->", "getContainer", "(", ")", "->", "set", "(", "explode", "(", "'.'", ",", "$", "this", "->", "nameToVar", "(", "$", "arg", "->", "getName", "(", ")", ")", ")", ",", "$", "input", "->", "getArgument", "(", "$", "arg", "->", "getName", "(", ")", ")", ")", ";", "}", "}", "foreach", "(", "$", "this", "->", "opts", "as", "$", "opt", ")", "{", "if", "(", "$", "value", "=", "$", "input", "->", "getOption", "(", "$", "this", "->", "varToName", "(", "$", "opt", ")", ")", ")", "{", "$", "this", "->", "getContainer", "(", ")", "->", "set", "(", "explode", "(", "'.'", ",", "$", "opt", ")", ",", "$", "value", ")", ";", "}", "}", "foreach", "(", "$", "this", "->", "flags", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "varName", "=", "explode", "(", "'.'", ",", "$", "name", ")", ";", "$", "optName", "=", "$", "this", "->", "varToName", "(", "$", "name", ")", ";", "$", "this", "->", "getContainer", "(", ")", "->", "set", "(", "$", "varName", ",", "$", "value", ")", ";", "if", "(", "$", "input", "->", "getOption", "(", "'no-'", ".", "$", "optName", ")", "&&", "$", "input", "->", "getOption", "(", "$", "optName", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Conflicting options --no-{$optName} and --{$optName} supplied. That confuses me.\"", ")", ";", "}", "if", "(", "$", "input", "->", "getOption", "(", "'no-'", ".", "$", "optName", ")", ")", "{", "$", "this", "->", "getContainer", "(", ")", "->", "set", "(", "$", "varName", ",", "false", ")", ";", "}", "elseif", "(", "$", "input", "->", "getOption", "(", "$", "optName", ")", ")", "{", "$", "this", "->", "getContainer", "(", ")", "->", "set", "(", "$", "varName", ",", "true", ")", ";", "}", "}", "$", "callable", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "$", "this", "->", "getTaskReference", "(", ")", ")", ";", "call_user_func", "(", "$", "callable", ",", "$", "this", "->", "getContainer", "(", ")", ")", ";", "}" ]
Executes the specified task @param \Symfony\Component\Console\Input\InputInterface $input @param \Symfony\Component\Console\Output\OutputInterface $output @return mixed
[ "Executes", "the", "specified", "task" ]
train
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Command/TaskCommand.php#L214-L248
raideer/twitch-api
src/Resources/Chat.php
Chat.getEmoticonImages
public function getEmoticonImages($params = []) { $defaults = [ 'emotesets' => null, ]; return $this->wrapper->request('GET', 'chat/emoticon_images', ['query' => $this->resolveOptions($params, $defaults)]); }
php
public function getEmoticonImages($params = []) { $defaults = [ 'emotesets' => null, ]; return $this->wrapper->request('GET', 'chat/emoticon_images', ['query' => $this->resolveOptions($params, $defaults)]); }
[ "public", "function", "getEmoticonImages", "(", "$", "params", "=", "[", "]", ")", "{", "$", "defaults", "=", "[", "'emotesets'", "=>", "null", ",", "]", ";", "return", "$", "this", "->", "wrapper", "->", "request", "(", "'GET'", ",", "'chat/emoticon_images'", ",", "[", "'query'", "=>", "$", "this", "->", "resolveOptions", "(", "$", "params", ",", "$", "defaults", ")", "]", ")", ";", "}" ]
Returns a list of emoticons. Learn more: https://github.com/justintv/Twitch-API/blob/master/v3_resources/chat.md#get-chatemoticon_images @param array $params Optional parameters @return array
[ "Returns", "a", "list", "of", "emoticons", "." ]
train
https://github.com/raideer/twitch-api/blob/27ebf1dcb0315206300d507600b6a82ebe33d57e/src/Resources/Chat.php#L58-L65
Erdiko/core
src/datasource/File.php
File.createDir
private function createDir($path) { if (!is_dir($path)) { $success = mkdir($path, 0775, true); if (!$success) { throw new \Exception("Cannot create folder {$path}. Check file system permissions."); } } }
php
private function createDir($path) { if (!is_dir($path)) { $success = mkdir($path, 0775, true); if (!$success) { throw new \Exception("Cannot create folder {$path}. Check file system permissions."); } } }
[ "private", "function", "createDir", "(", "$", "path", ")", "{", "if", "(", "!", "is_dir", "(", "$", "path", ")", ")", "{", "$", "success", "=", "mkdir", "(", "$", "path", ",", "0775", ",", "true", ")", ";", "if", "(", "!", "$", "success", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Cannot create folder {$path}. Check file system permissions.\"", ")", ";", "}", "}", "}" ]
Create Directory If path doesn't exist, create it
[ "Create", "Directory", "If", "path", "doesn", "t", "exist", "create", "it" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/datasource/File.php#L43-L51
Erdiko/core
src/datasource/File.php
File.write
public function write($content, $filename, $pathToFile = null, $mode = "w") { if ($pathToFile == null) { $pathToFile = $this->_filePath; } $this->createDir($pathToFile); $fileHandle = fopen($pathToFile."/".$filename, $mode); $success = fwrite($fileHandle, $content); fclose($fileHandle); return $success; }
php
public function write($content, $filename, $pathToFile = null, $mode = "w") { if ($pathToFile == null) { $pathToFile = $this->_filePath; } $this->createDir($pathToFile); $fileHandle = fopen($pathToFile."/".$filename, $mode); $success = fwrite($fileHandle, $content); fclose($fileHandle); return $success; }
[ "public", "function", "write", "(", "$", "content", ",", "$", "filename", ",", "$", "pathToFile", "=", "null", ",", "$", "mode", "=", "\"w\"", ")", "{", "if", "(", "$", "pathToFile", "==", "null", ")", "{", "$", "pathToFile", "=", "$", "this", "->", "_filePath", ";", "}", "$", "this", "->", "createDir", "(", "$", "pathToFile", ")", ";", "$", "fileHandle", "=", "fopen", "(", "$", "pathToFile", ".", "\"/\"", ".", "$", "filename", ",", "$", "mode", ")", ";", "$", "success", "=", "fwrite", "(", "$", "fileHandle", ",", "$", "content", ")", ";", "fclose", "(", "$", "fileHandle", ")", ";", "return", "$", "success", ";", "}" ]
Write string to file @param string $content @param string $filename @param string $pathToFile @param string $mode - Default mode: w @return int - bytes written to file
[ "Write", "string", "to", "file" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/datasource/File.php#L62-L75
Erdiko/core
src/datasource/File.php
File.read
public function read($filename, $pathToFile = null) { if(!$this->fileExists($filename, $pathToFile)) throw new \Exception("File, '{$filename}', does not exist."); if ($pathToFile==null) { return file_get_contents($this->_filePath."/".$filename); } else { return file_get_contents($pathToFile."/".$filename); } }
php
public function read($filename, $pathToFile = null) { if(!$this->fileExists($filename, $pathToFile)) throw new \Exception("File, '{$filename}', does not exist."); if ($pathToFile==null) { return file_get_contents($this->_filePath."/".$filename); } else { return file_get_contents($pathToFile."/".$filename); } }
[ "public", "function", "read", "(", "$", "filename", ",", "$", "pathToFile", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "fileExists", "(", "$", "filename", ",", "$", "pathToFile", ")", ")", "throw", "new", "\\", "Exception", "(", "\"File, '{$filename}', does not exist.\"", ")", ";", "if", "(", "$", "pathToFile", "==", "null", ")", "{", "return", "file_get_contents", "(", "$", "this", "->", "_filePath", ".", "\"/\"", ".", "$", "filename", ")", ";", "}", "else", "{", "return", "file_get_contents", "(", "$", "pathToFile", ".", "\"/\"", ".", "$", "filename", ")", ";", "}", "}" ]
Read string to file @param string $filename @param string $pathToFile @return string
[ "Read", "string", "to", "file" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/datasource/File.php#L84-L94
Erdiko/core
src/datasource/File.php
File.delete
public function delete($filename, $pathToFile = null) { if ($pathToFile==null) { $pathToFile=$this->_filePath; } if (file_exists($pathToFile."/".$filename)) { return unlink($pathToFile."/".$filename); } else { return false; } }
php
public function delete($filename, $pathToFile = null) { if ($pathToFile==null) { $pathToFile=$this->_filePath; } if (file_exists($pathToFile."/".$filename)) { return unlink($pathToFile."/".$filename); } else { return false; } }
[ "public", "function", "delete", "(", "$", "filename", ",", "$", "pathToFile", "=", "null", ")", "{", "if", "(", "$", "pathToFile", "==", "null", ")", "{", "$", "pathToFile", "=", "$", "this", "->", "_filePath", ";", "}", "if", "(", "file_exists", "(", "$", "pathToFile", ".", "\"/\"", ".", "$", "filename", ")", ")", "{", "return", "unlink", "(", "$", "pathToFile", ".", "\"/\"", ".", "$", "filename", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Delete a file @param string $filename @param string $pathToFile @return bool
[ "Delete", "a", "file" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/datasource/File.php#L103-L113
Erdiko/core
src/datasource/File.php
File.move
public function move($filename, $pathTo, $pathFrom = null) { if ($pathFrom==null) { $pathFrom=$this->_filePath; } if (file_exists($pathFrom."/".$filename)) { $this->createDir($pathTo); return rename($pathFrom."/".$filename, $pathTo."/".$filename); } else { return null; } }
php
public function move($filename, $pathTo, $pathFrom = null) { if ($pathFrom==null) { $pathFrom=$this->_filePath; } if (file_exists($pathFrom."/".$filename)) { $this->createDir($pathTo); return rename($pathFrom."/".$filename, $pathTo."/".$filename); } else { return null; } }
[ "public", "function", "move", "(", "$", "filename", ",", "$", "pathTo", ",", "$", "pathFrom", "=", "null", ")", "{", "if", "(", "$", "pathFrom", "==", "null", ")", "{", "$", "pathFrom", "=", "$", "this", "->", "_filePath", ";", "}", "if", "(", "file_exists", "(", "$", "pathFrom", ".", "\"/\"", ".", "$", "filename", ")", ")", "{", "$", "this", "->", "createDir", "(", "$", "pathTo", ")", ";", "return", "rename", "(", "$", "pathFrom", ".", "\"/\"", ".", "$", "filename", ",", "$", "pathTo", ".", "\"/\"", ".", "$", "filename", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Move a file @param string $filename @param string $pathTo @param string $pathToFrom @return bool
[ "Move", "a", "file" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/datasource/File.php#L123-L134
Erdiko/core
src/datasource/File.php
File.rename
public function rename($oldName, $newName, $pathToFile = null) { if ($pathToFile==null) { $pathToFile=$this->_filePath; } if (file_exists($pathToFile."/".$oldName)) { $this->createDir($pathToFile); return rename($pathToFile."/".$oldName, $pathToFile."/".$newName); } else { return false; } }
php
public function rename($oldName, $newName, $pathToFile = null) { if ($pathToFile==null) { $pathToFile=$this->_filePath; } if (file_exists($pathToFile."/".$oldName)) { $this->createDir($pathToFile); return rename($pathToFile."/".$oldName, $pathToFile."/".$newName); } else { return false; } }
[ "public", "function", "rename", "(", "$", "oldName", ",", "$", "newName", ",", "$", "pathToFile", "=", "null", ")", "{", "if", "(", "$", "pathToFile", "==", "null", ")", "{", "$", "pathToFile", "=", "$", "this", "->", "_filePath", ";", "}", "if", "(", "file_exists", "(", "$", "pathToFile", ".", "\"/\"", ".", "$", "oldName", ")", ")", "{", "$", "this", "->", "createDir", "(", "$", "pathToFile", ")", ";", "return", "rename", "(", "$", "pathToFile", ".", "\"/\"", ".", "$", "oldName", ",", "$", "pathToFile", ".", "\"/\"", ".", "$", "newName", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Rename a file @param string $oldName @param string $pathTo @param string $pathToFrom @return bool @todo consider merging rename() and move() into one method
[ "Rename", "a", "file" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/datasource/File.php#L145-L156
Erdiko/core
src/datasource/File.php
File.copy
public function copy($filename, $newFilePath, $newFileName = null, $pathToFile = null) { if ($pathToFile==null) { $pathToFile=$this->_filePath; } if ($newFileName==null) { $newFileName=$filename; } if (file_exists($pathToFile."/".$filename)) { return copy($pathToFile."/".$filename, $newFilePath."/".$newFileName); } else { return false; } }
php
public function copy($filename, $newFilePath, $newFileName = null, $pathToFile = null) { if ($pathToFile==null) { $pathToFile=$this->_filePath; } if ($newFileName==null) { $newFileName=$filename; } if (file_exists($pathToFile."/".$filename)) { return copy($pathToFile."/".$filename, $newFilePath."/".$newFileName); } else { return false; } }
[ "public", "function", "copy", "(", "$", "filename", ",", "$", "newFilePath", ",", "$", "newFileName", "=", "null", ",", "$", "pathToFile", "=", "null", ")", "{", "if", "(", "$", "pathToFile", "==", "null", ")", "{", "$", "pathToFile", "=", "$", "this", "->", "_filePath", ";", "}", "if", "(", "$", "newFileName", "==", "null", ")", "{", "$", "newFileName", "=", "$", "filename", ";", "}", "if", "(", "file_exists", "(", "$", "pathToFile", ".", "\"/\"", ".", "$", "filename", ")", ")", "{", "return", "copy", "(", "$", "pathToFile", ".", "\"/\"", ".", "$", "filename", ",", "$", "newFilePath", ".", "\"/\"", ".", "$", "newFileName", ")", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Copy a file @param string $filename @param string $newFilePath @param string $newFileName @param string $pathToFile @return bool
[ "Copy", "a", "file" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/datasource/File.php#L167-L180
Erdiko/core
src/datasource/File.php
File.fileExists
public function fileExists($filename, $pathToFile = null) { if ($pathToFile==null) { $pathToFile=$this->_filePath; } return file_exists($pathToFile."/".$filename); }
php
public function fileExists($filename, $pathToFile = null) { if ($pathToFile==null) { $pathToFile=$this->_filePath; } return file_exists($pathToFile."/".$filename); }
[ "public", "function", "fileExists", "(", "$", "filename", ",", "$", "pathToFile", "=", "null", ")", "{", "if", "(", "$", "pathToFile", "==", "null", ")", "{", "$", "pathToFile", "=", "$", "this", "->", "_filePath", ";", "}", "return", "file_exists", "(", "$", "pathToFile", ".", "\"/\"", ".", "$", "filename", ")", ";", "}" ]
Check if a file exists @param string $filename @param string $pathToFile @return bool
[ "Check", "if", "a", "file", "exists" ]
train
https://github.com/Erdiko/core/blob/c7947ee973b0ad2fd05a6d1d8ce45696618c8fa6/src/datasource/File.php#L189-L195
php-lug/lug
src/Component/Translation/Repository/Doctrine/MongoDB/TranslatableRepository.php
TranslatableRepository.getProperty
public function getProperty($property, $root = null) { if ($this->cache === null) { $translationMetadata = $this ->getDocumentManager() ->getClassMetadata($this->getClassMetadata()->getAssociationTargetClass($this->getTranslationAlias())); $this->cache = array_diff( $this->getProperties($translationMetadata), $this->getProperties($this->getClassMetadata()) ); } if (in_array($this->getRootProperty($property), $this->cache, true)) { $root = $this->getTranslationAlias(); } return parent::getProperty($property, $root); }
php
public function getProperty($property, $root = null) { if ($this->cache === null) { $translationMetadata = $this ->getDocumentManager() ->getClassMetadata($this->getClassMetadata()->getAssociationTargetClass($this->getTranslationAlias())); $this->cache = array_diff( $this->getProperties($translationMetadata), $this->getProperties($this->getClassMetadata()) ); } if (in_array($this->getRootProperty($property), $this->cache, true)) { $root = $this->getTranslationAlias(); } return parent::getProperty($property, $root); }
[ "public", "function", "getProperty", "(", "$", "property", ",", "$", "root", "=", "null", ")", "{", "if", "(", "$", "this", "->", "cache", "===", "null", ")", "{", "$", "translationMetadata", "=", "$", "this", "->", "getDocumentManager", "(", ")", "->", "getClassMetadata", "(", "$", "this", "->", "getClassMetadata", "(", ")", "->", "getAssociationTargetClass", "(", "$", "this", "->", "getTranslationAlias", "(", ")", ")", ")", ";", "$", "this", "->", "cache", "=", "array_diff", "(", "$", "this", "->", "getProperties", "(", "$", "translationMetadata", ")", ",", "$", "this", "->", "getProperties", "(", "$", "this", "->", "getClassMetadata", "(", ")", ")", ")", ";", "}", "if", "(", "in_array", "(", "$", "this", "->", "getRootProperty", "(", "$", "property", ")", ",", "$", "this", "->", "cache", ",", "true", ")", ")", "{", "$", "root", "=", "$", "this", "->", "getTranslationAlias", "(", ")", ";", "}", "return", "parent", "::", "getProperty", "(", "$", "property", ",", "$", "root", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Translation/Repository/Doctrine/MongoDB/TranslatableRepository.php#L66-L84
php-lug/lug
src/Component/Translation/Repository/Doctrine/MongoDB/TranslatableRepository.php
TranslatableRepository.getProperties
private function getProperties(ClassMetadata $metadata) { return array_merge( $metadata->getFieldNames(), array_map(function (array $mapping) { return $mapping['fieldName']; }, $metadata->getEmbeddedFieldsMappings()) ); }
php
private function getProperties(ClassMetadata $metadata) { return array_merge( $metadata->getFieldNames(), array_map(function (array $mapping) { return $mapping['fieldName']; }, $metadata->getEmbeddedFieldsMappings()) ); }
[ "private", "function", "getProperties", "(", "ClassMetadata", "$", "metadata", ")", "{", "return", "array_merge", "(", "$", "metadata", "->", "getFieldNames", "(", ")", ",", "array_map", "(", "function", "(", "array", "$", "mapping", ")", "{", "return", "$", "mapping", "[", "'fieldName'", "]", ";", "}", ",", "$", "metadata", "->", "getEmbeddedFieldsMappings", "(", ")", ")", ")", ";", "}" ]
@param ClassMetadata $metadata @return string[]
[ "@param", "ClassMetadata", "$metadata" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Translation/Repository/Doctrine/MongoDB/TranslatableRepository.php#L99-L107
zicht/z
src/Zicht/Tool/Script/Buffer.php
Buffer.indent
public function indent($increment = null) { if (null !== $increment) { $this->indent += $increment; if ($this->indent < 0) { throw new \InvalidArgumentException("Indent can not reach below zero!"); } } else { $this->raw(str_repeat(' ', $this->indent)); } return $this; }
php
public function indent($increment = null) { if (null !== $increment) { $this->indent += $increment; if ($this->indent < 0) { throw new \InvalidArgumentException("Indent can not reach below zero!"); } } else { $this->raw(str_repeat(' ', $this->indent)); } return $this; }
[ "public", "function", "indent", "(", "$", "increment", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "increment", ")", "{", "$", "this", "->", "indent", "+=", "$", "increment", ";", "if", "(", "$", "this", "->", "indent", "<", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Indent can not reach below zero!\"", ")", ";", "}", "}", "else", "{", "$", "this", "->", "raw", "(", "str_repeat", "(", "' '", ",", "$", "this", "->", "indent", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds indentation to the buffer if $increment is not specified. Otherwise increment the current indentation $increment steps. You should pass a negative number to outdent. @param int $increment @return Buffer
[ "Adds", "indentation", "to", "the", "buffer", "if", "$increment", "is", "not", "specified", ".", "Otherwise", "increment", "the", "current", "indentation", "$increment", "steps", ".", "You", "should", "pass", "a", "negative", "number", "to", "outdent", "." ]
train
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Script/Buffer.php#L89-L100
Eresus/EresusCMS
src/core/Template.php
Eresus_Template.loadFromFile
public static function loadFromFile($filename) { $path = $filename; /* Если это относительный путь, добавляем папку шаблонов */ if (!preg_match('#^(/|\w{1,10}://|[A-Z]:\\\)#', $filename)) { $templateDir = Eresus_Kernel::app()->getFsRoot(); $path = $templateDir . '/' . $path; } $template = new self(); $template->template = new TemplateFile($path, null, $filename, $filename); return $template; }
php
public static function loadFromFile($filename) { $path = $filename; /* Если это относительный путь, добавляем папку шаблонов */ if (!preg_match('#^(/|\w{1,10}://|[A-Z]:\\\)#', $filename)) { $templateDir = Eresus_Kernel::app()->getFsRoot(); $path = $templateDir . '/' . $path; } $template = new self(); $template->template = new TemplateFile($path, null, $filename, $filename); return $template; }
[ "public", "static", "function", "loadFromFile", "(", "$", "filename", ")", "{", "$", "path", "=", "$", "filename", ";", "/* Если это относительный путь, добавляем папку шаблонов */", "if", "(", "!", "preg_match", "(", "'#^(/|\\w{1,10}://|[A-Z]:\\\\\\)#'", ",", "$", "filename", ")", ")", "{", "$", "templateDir", "=", "Eresus_Kernel", "::", "app", "(", ")", "->", "getFsRoot", "(", ")", ";", "$", "path", "=", "$", "templateDir", ".", "'/'", ".", "$", "path", ";", "}", "$", "template", "=", "new", "self", "(", ")", ";", "$", "template", "->", "template", "=", "new", "TemplateFile", "(", "$", "path", ",", "null", ",", "$", "filename", ",", "$", "filename", ")", ";", "return", "$", "template", ";", "}" ]
Загружает шаблон из файла Если $filename — относительный путь, то он будет расценен как путь относительно корня сайта. @param string $filename имя файла шаблона @return Eresus_Template @since 3.01
[ "Загружает", "шаблон", "из", "файла" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Template.php#L62-L74
Eresus/EresusCMS
src/core/Template.php
Eresus_Template.loadFile
public function loadFile($filename) { $templateDir = Eresus_Kernel::app()->getFsRoot(); $template = $templateDir . '/' . $filename; $this->template = new TemplateFile($template, null, $filename, $filename); }
php
public function loadFile($filename) { $templateDir = Eresus_Kernel::app()->getFsRoot(); $template = $templateDir . '/' . $filename; $this->template = new TemplateFile($template, null, $filename, $filename); }
[ "public", "function", "loadFile", "(", "$", "filename", ")", "{", "$", "templateDir", "=", "Eresus_Kernel", "::", "app", "(", ")", "->", "getFsRoot", "(", ")", ";", "$", "template", "=", "$", "templateDir", ".", "'/'", ".", "$", "filename", ";", "$", "this", "->", "template", "=", "new", "TemplateFile", "(", "$", "template", ",", "null", ",", "$", "filename", ",", "$", "filename", ")", ";", "}" ]
Загружает шаблон из файла @param string $filename имя файла шаблона
[ "Загружает", "шаблон", "из", "файла" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Template.php#L130-L135
Eresus/EresusCMS
src/core/Template.php
Eresus_Template.compile
public function compile($data = null) { if ($data) { $data = array_merge($data, TemplateSettings::getGlobalValues()); } else { $data = TemplateSettings::getGlobalValues(); } return self::$dwoo->get($this->template, $data); }
php
public function compile($data = null) { if ($data) { $data = array_merge($data, TemplateSettings::getGlobalValues()); } else { $data = TemplateSettings::getGlobalValues(); } return self::$dwoo->get($this->template, $data); }
[ "public", "function", "compile", "(", "$", "data", "=", "null", ")", "{", "if", "(", "$", "data", ")", "{", "$", "data", "=", "array_merge", "(", "$", "data", ",", "TemplateSettings", "::", "getGlobalValues", "(", ")", ")", ";", "}", "else", "{", "$", "data", "=", "TemplateSettings", "::", "getGlobalValues", "(", ")", ";", "}", "return", "self", "::", "$", "dwoo", "->", "get", "(", "$", "this", "->", "template", ",", "$", "data", ")", ";", "}" ]
Компилирует шаблон @param array $data данные для подстановки в шаблон @return string
[ "Компилирует", "шаблон" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Template.php#L144-L156
caffeinated/beverage
src/Traits/MultiSingleton.php
MultiSingleton.getInstance
public static function getInstance($name = 'default') { if (isset(static::$instances[$name])) { return static::$instances[$name]; } $instance = new static(); static::$instances[$name] = $instance; return $instance; }
php
public static function getInstance($name = 'default') { if (isset(static::$instances[$name])) { return static::$instances[$name]; } $instance = new static(); static::$instances[$name] = $instance; return $instance; }
[ "public", "static", "function", "getInstance", "(", "$", "name", "=", "'default'", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "instances", "[", "$", "name", "]", ")", ")", "{", "return", "static", "::", "$", "instances", "[", "$", "name", "]", ";", "}", "$", "instance", "=", "new", "static", "(", ")", ";", "static", "::", "$", "instances", "[", "$", "name", "]", "=", "$", "instance", ";", "return", "$", "instance", ";", "}" ]
Get the current instance. @param string $name @return static
[ "Get", "the", "current", "instance", "." ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Traits/MultiSingleton.php#L49-L60
PeeHaa/AsyncTwitter
src/Api/Request/Search/Search.php
Search.geocode
public function geocode(string $latitude, string $longitude, string $radius): Search { $this->parameters['geocode'] = sprintf('%s %s %s', $latitude, $longitude, $radius); return $this; }
php
public function geocode(string $latitude, string $longitude, string $radius): Search { $this->parameters['geocode'] = sprintf('%s %s %s', $latitude, $longitude, $radius); return $this; }
[ "public", "function", "geocode", "(", "string", "$", "latitude", ",", "string", "$", "longitude", ",", "string", "$", "radius", ")", ":", "Search", "{", "$", "this", "->", "parameters", "[", "'geocode'", "]", "=", "sprintf", "(", "'%s %s %s'", ",", "$", "latitude", ",", "$", "longitude", ",", "$", "radius", ")", ";", "return", "$", "this", ";", "}" ]
use string instead of float
[ "use", "string", "instead", "of", "float" ]
train
https://github.com/PeeHaa/AsyncTwitter/blob/a968909e7ed470bd87a0f25ef0c494338273c29c/src/Api/Request/Search/Search.php#L25-L30
inhere/php-librarys
src/Helpers/DataHelper.php
DataHelper.toArray
public static function toArray($data, $recursive = false) { // Ensure the input data is an array. if (\is_object($data)) { if ($data instanceof \Traversable) { $data = iterator_to_array($data); } elseif (method_exists($data, 'toArray')) { $data = $data->toArray(); } } else { $data = (array)$data; } if ($recursive) { foreach ($data as &$value) { if (\is_array($value) || \is_object($value)) { $value = static::toArray($value, $recursive); } } } return $data; }
php
public static function toArray($data, $recursive = false) { // Ensure the input data is an array. if (\is_object($data)) { if ($data instanceof \Traversable) { $data = iterator_to_array($data); } elseif (method_exists($data, 'toArray')) { $data = $data->toArray(); } } else { $data = (array)$data; } if ($recursive) { foreach ($data as &$value) { if (\is_array($value) || \is_object($value)) { $value = static::toArray($value, $recursive); } } } return $data; }
[ "public", "static", "function", "toArray", "(", "$", "data", ",", "$", "recursive", "=", "false", ")", "{", "// Ensure the input data is an array.", "if", "(", "\\", "is_object", "(", "$", "data", ")", ")", "{", "if", "(", "$", "data", "instanceof", "\\", "Traversable", ")", "{", "$", "data", "=", "iterator_to_array", "(", "$", "data", ")", ";", "}", "elseif", "(", "method_exists", "(", "$", "data", ",", "'toArray'", ")", ")", "{", "$", "data", "=", "$", "data", "->", "toArray", "(", ")", ";", "}", "}", "else", "{", "$", "data", "=", "(", "array", ")", "$", "data", ";", "}", "if", "(", "$", "recursive", ")", "{", "foreach", "(", "$", "data", "as", "&", "$", "value", ")", "{", "if", "(", "\\", "is_array", "(", "$", "value", ")", "||", "\\", "is_object", "(", "$", "value", ")", ")", "{", "$", "value", "=", "static", "::", "toArray", "(", "$", "value", ",", "$", "recursive", ")", ";", "}", "}", "}", "return", "$", "data", ";", "}" ]
php对象转换成为数组 @param iterable|array|\Traversable $data @param bool $recursive @return array|bool
[ "php对象转换成为数组" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/DataHelper.php#L45-L67
inhere/php-librarys
src/Helpers/DataHelper.php
DataHelper.toObject
public static function toObject($array, $class = \stdClass::class) { $object = new $class; foreach ($array as $name => $value) { $name = trim($name); if (!$name || is_numeric($name)) { continue; } $object->$name = \is_array($value) ? self::toObject($value) : $value; } return $object; }
php
public static function toObject($array, $class = \stdClass::class) { $object = new $class; foreach ($array as $name => $value) { $name = trim($name); if (!$name || is_numeric($name)) { continue; } $object->$name = \is_array($value) ? self::toObject($value) : $value; } return $object; }
[ "public", "static", "function", "toObject", "(", "$", "array", ",", "$", "class", "=", "\\", "stdClass", "::", "class", ")", "{", "$", "object", "=", "new", "$", "class", ";", "foreach", "(", "$", "array", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "name", "=", "trim", "(", "$", "name", ")", ";", "if", "(", "!", "$", "name", "||", "is_numeric", "(", "$", "name", ")", ")", "{", "continue", ";", "}", "$", "object", "->", "$", "name", "=", "\\", "is_array", "(", "$", "value", ")", "?", "self", "::", "toObject", "(", "$", "value", ")", ":", "$", "value", ";", "}", "return", "$", "object", ";", "}" ]
data to array @param array|\Traversable $array @param string $class @return mixed
[ "data", "to", "array" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/DataHelper.php#L75-L90
inhere/php-librarys
src/Helpers/DataHelper.php
DataHelper.safeOutput
public static function safeOutput($string, $clearTag = false) { if (!$clearTag) { $string = strip_tags($string); } return @self::htmlentitiesUTF8($string); }
php
public static function safeOutput($string, $clearTag = false) { if (!$clearTag) { $string = strip_tags($string); } return @self::htmlentitiesUTF8($string); }
[ "public", "static", "function", "safeOutput", "(", "$", "string", ",", "$", "clearTag", "=", "false", ")", "{", "if", "(", "!", "$", "clearTag", ")", "{", "$", "string", "=", "strip_tags", "(", "$", "string", ")", ";", "}", "return", "@", "self", "::", "htmlentitiesUTF8", "(", "$", "string", ")", ";", "}" ]
Sanitize a string @param string $string String to sanitize @param bool $clearTag clear html tag @return string Sanitized string
[ "Sanitize", "a", "string" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/DataHelper.php#L98-L105
inhere/php-librarys
src/Helpers/DataHelper.php
DataHelper.stripTags
public static function stripTags($data, $allow_tags = null) { if (\is_array($data)) { foreach ($data as $k => $v) { $data[$k] = self::stripTags($v, $allow_tags); } return $data; } if (\is_string($data) || is_numeric($data)) { return strip_tags($data, $allow_tags); } return false; }
php
public static function stripTags($data, $allow_tags = null) { if (\is_array($data)) { foreach ($data as $k => $v) { $data[$k] = self::stripTags($v, $allow_tags); } return $data; } if (\is_string($data) || is_numeric($data)) { return strip_tags($data, $allow_tags); } return false; }
[ "public", "static", "function", "stripTags", "(", "$", "data", ",", "$", "allow_tags", "=", "null", ")", "{", "if", "(", "\\", "is_array", "(", "$", "data", ")", ")", "{", "foreach", "(", "$", "data", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "data", "[", "$", "k", "]", "=", "self", "::", "stripTags", "(", "$", "v", ",", "$", "allow_tags", ")", ";", "}", "return", "$", "data", ";", "}", "if", "(", "\\", "is_string", "(", "$", "data", ")", "||", "is_numeric", "(", "$", "data", ")", ")", "{", "return", "strip_tags", "(", "$", "data", ",", "$", "allow_tags", ")", ";", "}", "return", "false", ";", "}" ]
/* strip_tags — 从字符串中去除 HTML 和 PHP 标记 由于 strip_tags() 无法实际验证 HTML,不完整或者破损标签将导致更多的数据被删除。 $allow_tags 允许的标记,多个以空格隔开
[ "/", "*", "strip_tags", "—", "从字符串中去除", "HTML", "和", "PHP", "标记", "由于", "strip_tags", "()", "无法实际验证", "HTML,不完整或者破损标签将导致更多的数据被删除。", "$allow_tags", "允许的标记", "多个以空格隔开" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/DataHelper.php#L182-L197
inhere/php-librarys
src/Helpers/DataHelper.php
DataHelper.slashes
public static function slashes($data, $escape = 1, $level = 0) { if (\is_array($data)) { foreach ((array)$data as $key => $value) { $data[$key] = self::slashes($value, $escape, $level); } return $data; } $data = trim($data); if (!$escape) { return stripslashes($data); } $data = addslashes($data); if ($level) { // 两个str_replace替换转义目的是防止黑客转换SQL编码进行攻击。 $data = str_replace(['_', '%'], ["\_", "\%"], $data); // 转义掉_ % } return $data; }
php
public static function slashes($data, $escape = 1, $level = 0) { if (\is_array($data)) { foreach ((array)$data as $key => $value) { $data[$key] = self::slashes($value, $escape, $level); } return $data; } $data = trim($data); if (!$escape) { return stripslashes($data); } $data = addslashes($data); if ($level) { // 两个str_replace替换转义目的是防止黑客转换SQL编码进行攻击。 $data = str_replace(['_', '%'], ["\_", "\%"], $data); // 转义掉_ % } return $data; }
[ "public", "static", "function", "slashes", "(", "$", "data", ",", "$", "escape", "=", "1", ",", "$", "level", "=", "0", ")", "{", "if", "(", "\\", "is_array", "(", "$", "data", ")", ")", "{", "foreach", "(", "(", "array", ")", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "data", "[", "$", "key", "]", "=", "self", "::", "slashes", "(", "$", "value", ",", "$", "escape", ",", "$", "level", ")", ";", "}", "return", "$", "data", ";", "}", "$", "data", "=", "trim", "(", "$", "data", ")", ";", "if", "(", "!", "$", "escape", ")", "{", "return", "stripslashes", "(", "$", "data", ")", ";", "}", "$", "data", "=", "addslashes", "(", "$", "data", ")", ";", "if", "(", "$", "level", ")", "{", "// 两个str_replace替换转义目的是防止黑客转换SQL编码进行攻击。", "$", "data", "=", "str_replace", "(", "[", "'_'", ",", "'%'", "]", ",", "[", "\"\\_\"", ",", "\"\\%\"", "]", ",", "$", "data", ")", ";", "// 转义掉_ %", "}", "return", "$", "data", ";", "}" ]
对数组或字符串进行加斜杠\转义处理 去除转义 去除转义返回一个去除反斜线后的字符串(\' 转换为 ' 等等)。双反斜线(\\)被转换为单个反斜线(\)。 @param array|string $data 数据可以是字符串或数组 @param int $escape 进行转义 true 转义处理 false 去除转义 @param int $level 增强 @return array|string
[ "对数组或字符串进行加斜杠", "\\", "转义处理", "去除转义", "去除转义返回一个去除反斜线后的字符串(", "\\", "转换为", "等等)。双反斜线(", "\\\\", ")被转换为单个反斜线(", "\\", ")。" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/DataHelper.php#L207-L231
inhere/php-librarys
src/Helpers/DataHelper.php
DataHelper.changeEncode
public static function changeEncode($data, $in_charset = 'GBK', $out_charset = 'UTF-8') { if (\is_array($data)) { foreach ($data as $key => $value) { $data[$key] = self::changeEncode($value, $in_charset, $out_charset); } return $data; } if (\function_exists('mb_convert_encoding')) { return mb_convert_encoding($data, $out_charset, $in_charset); } return iconv($in_charset, $out_charset . '/' . '/IGNORE', $data); }
php
public static function changeEncode($data, $in_charset = 'GBK', $out_charset = 'UTF-8') { if (\is_array($data)) { foreach ($data as $key => $value) { $data[$key] = self::changeEncode($value, $in_charset, $out_charset); } return $data; } if (\function_exists('mb_convert_encoding')) { return mb_convert_encoding($data, $out_charset, $in_charset); } return iconv($in_charset, $out_charset . '/' . '/IGNORE', $data); }
[ "public", "static", "function", "changeEncode", "(", "$", "data", ",", "$", "in_charset", "=", "'GBK'", ",", "$", "out_charset", "=", "'UTF-8'", ")", "{", "if", "(", "\\", "is_array", "(", "$", "data", ")", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "data", "[", "$", "key", "]", "=", "self", "::", "changeEncode", "(", "$", "value", ",", "$", "in_charset", ",", "$", "out_charset", ")", ";", "}", "return", "$", "data", ";", "}", "if", "(", "\\", "function_exists", "(", "'mb_convert_encoding'", ")", ")", "{", "return", "mb_convert_encoding", "(", "$", "data", ",", "$", "out_charset", ",", "$", "in_charset", ")", ";", "}", "return", "iconv", "(", "$", "in_charset", ",", "$", "out_charset", ".", "'/'", ".", "'/IGNORE'", ",", "$", "data", ")", ";", "}" ]
对数据进行字符集转换处理,数据可以是字符串或数组及对象 @param array|string $data @param $in_charset @param $out_charset @return array|string
[ "对数据进行字符集转换处理,数据可以是字符串或数组及对象" ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/DataHelper.php#L253-L269
technote-space/wordpress-plugin-base
src/classes/models/lib/log.php
Log.shutdown
private function shutdown() { $error = error_get_last(); if ( $error === null ) { return; } if ( $error['type'] & $this->app->get_config( 'config', 'target_shutdown_error' ) ) { $suppress = $this->app->get_config( 'config', 'suppress_log_messages' ); $message = str_replace( [ "\r\n", "\r", "\n" ], "\n", $error['message'] ); $messages = explode( "\n", $message ); $message = reset( $messages ); if ( empty( $suppress ) || ( is_array( $suppress ) && ! in_array( $message, $suppress ) ) ) { $this->app->log( $message, $error, 'error' ); } } }
php
private function shutdown() { $error = error_get_last(); if ( $error === null ) { return; } if ( $error['type'] & $this->app->get_config( 'config', 'target_shutdown_error' ) ) { $suppress = $this->app->get_config( 'config', 'suppress_log_messages' ); $message = str_replace( [ "\r\n", "\r", "\n" ], "\n", $error['message'] ); $messages = explode( "\n", $message ); $message = reset( $messages ); if ( empty( $suppress ) || ( is_array( $suppress ) && ! in_array( $message, $suppress ) ) ) { $this->app->log( $message, $error, 'error' ); } } }
[ "private", "function", "shutdown", "(", ")", "{", "$", "error", "=", "error_get_last", "(", ")", ";", "if", "(", "$", "error", "===", "null", ")", "{", "return", ";", "}", "if", "(", "$", "error", "[", "'type'", "]", "&", "$", "this", "->", "app", "->", "get_config", "(", "'config'", ",", "'target_shutdown_error'", ")", ")", "{", "$", "suppress", "=", "$", "this", "->", "app", "->", "get_config", "(", "'config'", ",", "'suppress_log_messages'", ")", ";", "$", "message", "=", "str_replace", "(", "[", "\"\\r\\n\"", ",", "\"\\r\"", ",", "\"\\n\"", "]", ",", "\"\\n\"", ",", "$", "error", "[", "'message'", "]", ")", ";", "$", "messages", "=", "explode", "(", "\"\\n\"", ",", "$", "message", ")", ";", "$", "message", "=", "reset", "(", "$", "messages", ")", ";", "if", "(", "empty", "(", "$", "suppress", ")", "||", "(", "is_array", "(", "$", "suppress", ")", "&&", "!", "in_array", "(", "$", "message", ",", "$", "suppress", ")", ")", ")", "{", "$", "this", "->", "app", "->", "log", "(", "$", "message", ",", "$", "error", ",", "'error'", ")", ";", "}", "}", "}" ]
shutdown @since 2.8.5 @since 2.9.0 Changed: capture error target @since 2.9.13 Changed: moved function
[ "shutdown" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/log.php#L53-L68
technote-space/wordpress-plugin-base
src/classes/models/lib/log.php
Log.log
public function log( $message, $context = null, $level = '' ) { if ( ! $this->is_valid() ) { return false; } $log_level = $this->app->get_config( 'config', 'log_level' ); $level = $this->get_log_level( $level, $log_level ); if ( empty( $log_level[ $level ] ) ) { return false; } global $wp_version; $data = $this->get_called_info(); $data['message'] = is_string( $message ) ? $this->app->translate( $message ) : json_encode( $message ); $data['lib_version'] = $this->app->get_library_version(); $data['plugin_version'] = $this->app->get_plugin_version(); $data['php_version'] = phpversion(); $data['wordpress_version'] = $wp_version; $data['level'] = $level; if ( isset( $context ) ) { $data['context'] = json_encode( $context ); } $this->send_mail( $level, $log_level, $message, $data ); $this->insert_log( $level, $log_level, $data ); return true; }
php
public function log( $message, $context = null, $level = '' ) { if ( ! $this->is_valid() ) { return false; } $log_level = $this->app->get_config( 'config', 'log_level' ); $level = $this->get_log_level( $level, $log_level ); if ( empty( $log_level[ $level ] ) ) { return false; } global $wp_version; $data = $this->get_called_info(); $data['message'] = is_string( $message ) ? $this->app->translate( $message ) : json_encode( $message ); $data['lib_version'] = $this->app->get_library_version(); $data['plugin_version'] = $this->app->get_plugin_version(); $data['php_version'] = phpversion(); $data['wordpress_version'] = $wp_version; $data['level'] = $level; if ( isset( $context ) ) { $data['context'] = json_encode( $context ); } $this->send_mail( $level, $log_level, $message, $data ); $this->insert_log( $level, $log_level, $data ); return true; }
[ "public", "function", "log", "(", "$", "message", ",", "$", "context", "=", "null", ",", "$", "level", "=", "''", ")", "{", "if", "(", "!", "$", "this", "->", "is_valid", "(", ")", ")", "{", "return", "false", ";", "}", "$", "log_level", "=", "$", "this", "->", "app", "->", "get_config", "(", "'config'", ",", "'log_level'", ")", ";", "$", "level", "=", "$", "this", "->", "get_log_level", "(", "$", "level", ",", "$", "log_level", ")", ";", "if", "(", "empty", "(", "$", "log_level", "[", "$", "level", "]", ")", ")", "{", "return", "false", ";", "}", "global", "$", "wp_version", ";", "$", "data", "=", "$", "this", "->", "get_called_info", "(", ")", ";", "$", "data", "[", "'message'", "]", "=", "is_string", "(", "$", "message", ")", "?", "$", "this", "->", "app", "->", "translate", "(", "$", "message", ")", ":", "json_encode", "(", "$", "message", ")", ";", "$", "data", "[", "'lib_version'", "]", "=", "$", "this", "->", "app", "->", "get_library_version", "(", ")", ";", "$", "data", "[", "'plugin_version'", "]", "=", "$", "this", "->", "app", "->", "get_plugin_version", "(", ")", ";", "$", "data", "[", "'php_version'", "]", "=", "phpversion", "(", ")", ";", "$", "data", "[", "'wordpress_version'", "]", "=", "$", "wp_version", ";", "$", "data", "[", "'level'", "]", "=", "$", "level", ";", "if", "(", "isset", "(", "$", "context", ")", ")", "{", "$", "data", "[", "'context'", "]", "=", "json_encode", "(", "$", "context", ")", ";", "}", "$", "this", "->", "send_mail", "(", "$", "level", ",", "$", "log_level", ",", "$", "message", ",", "$", "data", ")", ";", "$", "this", "->", "insert_log", "(", "$", "level", ",", "$", "log_level", ",", "$", "data", ")", ";", "return", "true", ";", "}" ]
@since 2.7.0 Added: $context @since 2.9.0 Added: log level arg @since 2.9.0 Added: send mail feature @param string $message @param mixed $context @param string $level @return bool
[ "@since", "2", ".", "7", ".", "0", "Added", ":", "$context", "@since", "2", ".", "9", ".", "0", "Added", ":", "log", "level", "arg", "@since", "2", ".", "9", ".", "0", "Added", ":", "send", "mail", "feature" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/log.php#L93-L120
technote-space/wordpress-plugin-base
src/classes/models/lib/log.php
Log.get_log_level
private function get_log_level( $level, $log_level ) { if ( ! isset( $log_level[ $level ] ) && ! isset( $log_level[''] ) ) { return 'info'; } '' === $level || ! isset( $log_level[ $level ] ) and $level = $log_level['']; if ( empty( $log_level[ $level ] ) ) { return 'info'; } return $level; }
php
private function get_log_level( $level, $log_level ) { if ( ! isset( $log_level[ $level ] ) && ! isset( $log_level[''] ) ) { return 'info'; } '' === $level || ! isset( $log_level[ $level ] ) and $level = $log_level['']; if ( empty( $log_level[ $level ] ) ) { return 'info'; } return $level; }
[ "private", "function", "get_log_level", "(", "$", "level", ",", "$", "log_level", ")", "{", "if", "(", "!", "isset", "(", "$", "log_level", "[", "$", "level", "]", ")", "&&", "!", "isset", "(", "$", "log_level", "[", "''", "]", ")", ")", "{", "return", "'info'", ";", "}", "''", "===", "$", "level", "||", "!", "isset", "(", "$", "log_level", "[", "$", "level", "]", ")", "and", "$", "level", "=", "$", "log_level", "[", "''", "]", ";", "if", "(", "empty", "(", "$", "log_level", "[", "$", "level", "]", ")", ")", "{", "return", "'info'", ";", "}", "return", "$", "level", ";", "}" ]
@since 2.9.0 @param string $level @param array $log_level @return string
[ "@since", "2", ".", "9", ".", "0" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/log.php#L130-L140
technote-space/wordpress-plugin-base
src/classes/models/lib/log.php
Log.insert_log
private function insert_log( $level, $log_level, $data ) { if ( empty( $log_level[ $level ]['is_valid_log'] ) ) { return; } if ( $this->apply_filters( 'save___log_term' ) <= 0 ) { return; } $this->app->db->insert( '__log', $data ); }
php
private function insert_log( $level, $log_level, $data ) { if ( empty( $log_level[ $level ]['is_valid_log'] ) ) { return; } if ( $this->apply_filters( 'save___log_term' ) <= 0 ) { return; } $this->app->db->insert( '__log', $data ); }
[ "private", "function", "insert_log", "(", "$", "level", ",", "$", "log_level", ",", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "log_level", "[", "$", "level", "]", "[", "'is_valid_log'", "]", ")", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "apply_filters", "(", "'save___log_term'", ")", "<=", "0", ")", "{", "return", ";", "}", "$", "this", "->", "app", "->", "db", "->", "insert", "(", "'__log'", ",", "$", "data", ")", ";", "}" ]
@since 2.9.0 @param string $level @param array $log_level @param array $data
[ "@since", "2", ".", "9", ".", "0" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/log.php#L149-L157
technote-space/wordpress-plugin-base
src/classes/models/lib/log.php
Log.send_mail
private function send_mail( $level, $log_level, $message, $data ) { if ( empty( $log_level[ $level ]['is_valid_mail'] ) ) { return; } $level = $log_level[ $level ]; $roles = $this->app->utility->array_get( $level, 'roles' ); $emails = $this->app->utility->array_get( $level, 'emails' ); if ( empty( $roles ) && empty( $emails ) ) { return; } $emails = array_unique( $emails ); $emails = array_combine( $emails, $emails ); foreach ( $roles as $role ) { foreach ( get_users( [ 'role' => $role ] ) as $user ) { /** @var \WP_User $user */ ! empty( $user->user_email ) and $emails[ $user->user_email ] = $user->user_email; } } foreach ( $emails as $email ) { $this->app->mail->send( $email, $message, $this->dump( $data, false ) ); } }
php
private function send_mail( $level, $log_level, $message, $data ) { if ( empty( $log_level[ $level ]['is_valid_mail'] ) ) { return; } $level = $log_level[ $level ]; $roles = $this->app->utility->array_get( $level, 'roles' ); $emails = $this->app->utility->array_get( $level, 'emails' ); if ( empty( $roles ) && empty( $emails ) ) { return; } $emails = array_unique( $emails ); $emails = array_combine( $emails, $emails ); foreach ( $roles as $role ) { foreach ( get_users( [ 'role' => $role ] ) as $user ) { /** @var \WP_User $user */ ! empty( $user->user_email ) and $emails[ $user->user_email ] = $user->user_email; } } foreach ( $emails as $email ) { $this->app->mail->send( $email, $message, $this->dump( $data, false ) ); } }
[ "private", "function", "send_mail", "(", "$", "level", ",", "$", "log_level", ",", "$", "message", ",", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "log_level", "[", "$", "level", "]", "[", "'is_valid_mail'", "]", ")", ")", "{", "return", ";", "}", "$", "level", "=", "$", "log_level", "[", "$", "level", "]", ";", "$", "roles", "=", "$", "this", "->", "app", "->", "utility", "->", "array_get", "(", "$", "level", ",", "'roles'", ")", ";", "$", "emails", "=", "$", "this", "->", "app", "->", "utility", "->", "array_get", "(", "$", "level", ",", "'emails'", ")", ";", "if", "(", "empty", "(", "$", "roles", ")", "&&", "empty", "(", "$", "emails", ")", ")", "{", "return", ";", "}", "$", "emails", "=", "array_unique", "(", "$", "emails", ")", ";", "$", "emails", "=", "array_combine", "(", "$", "emails", ",", "$", "emails", ")", ";", "foreach", "(", "$", "roles", "as", "$", "role", ")", "{", "foreach", "(", "get_users", "(", "[", "'role'", "=>", "$", "role", "]", ")", "as", "$", "user", ")", "{", "/** @var \\WP_User $user */", "!", "empty", "(", "$", "user", "->", "user_email", ")", "and", "$", "emails", "[", "$", "user", "->", "user_email", "]", "=", "$", "user", "->", "user_email", ";", "}", "}", "foreach", "(", "$", "emails", "as", "$", "email", ")", "{", "$", "this", "->", "app", "->", "mail", "->", "send", "(", "$", "email", ",", "$", "message", ",", "$", "this", "->", "dump", "(", "$", "data", ",", "false", ")", ")", ";", "}", "}" ]
@since 2.9.0 @param string $level @param array $log_level @param string $message @param array $data
[ "@since", "2", ".", "9", ".", "0" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/log.php#L167-L192
Eresus/EresusCMS
src/core/files.php
TFiles.renderControls
private function renderControls() { $maxFileSize = floor(Eresus_PHP::getMaxUploadSize() / 1024 / 1024) . ' Mb'; $result = "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n". "<tr><td align=\"center\">Загрузить файл</td><td><form name=\"upload\" action=\"". Eresus_CMS::getLegacyKernel()->request['url']."\" method=\"post\" " . "enctype=\"multipart/form-data\"><div id=\"fm_upload\"><input type=\"file\" " . "name=\"upload\" size=\"50\"><input type=\"submit\" value=\"Загрузить\"> " . "Максимальный размер файла: " . $maxFileSize . "</div></form></td></tr>". "<tr><td align=\"center\"><a href=\"javascript:Copy('SelFileName');\">Скопировать имя</a>" . "</td><td style=\"width: 100%;\"><input type=\"text\" id=\"SelFileName\" value=\"" . "Нет выбранных объектов\" style=\"width: 100%;\"></td></tr>". "</table>"; return $result; }
php
private function renderControls() { $maxFileSize = floor(Eresus_PHP::getMaxUploadSize() / 1024 / 1024) . ' Mb'; $result = "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n". "<tr><td align=\"center\">Загрузить файл</td><td><form name=\"upload\" action=\"". Eresus_CMS::getLegacyKernel()->request['url']."\" method=\"post\" " . "enctype=\"multipart/form-data\"><div id=\"fm_upload\"><input type=\"file\" " . "name=\"upload\" size=\"50\"><input type=\"submit\" value=\"Загрузить\"> " . "Максимальный размер файла: " . $maxFileSize . "</div></form></td></tr>". "<tr><td align=\"center\"><a href=\"javascript:Copy('SelFileName');\">Скопировать имя</a>" . "</td><td style=\"width: 100%;\"><input type=\"text\" id=\"SelFileName\" value=\"" . "Нет выбранных объектов\" style=\"width: 100%;\"></td></tr>". "</table>"; return $result; }
[ "private", "function", "renderControls", "(", ")", "{", "$", "maxFileSize", "=", "floor", "(", "Eresus_PHP", "::", "getMaxUploadSize", "(", ")", "/", "1024", "/", "1024", ")", ".", "' Mb'", ";", "$", "result", "=", "\"<table width=\\\"100%\\\" cellpadding=\\\"0\\\" cellspacing=\\\"0\\\" border=\\\"0\\\">\\n\"", ".", "\"<tr><td align=\\\"center\\\">Загрузить файл</td><td><form name=\\\"upload\\\" action=\\\"\".", "", "Eresus_CMS", "::", "getLegacyKernel", "(", ")", "->", "request", "[", "'url'", "]", ".", "\"\\\" method=\\\"post\\\" \"", ".", "\"enctype=\\\"multipart/form-data\\\"><div id=\\\"fm_upload\\\"><input type=\\\"file\\\" \"", ".", "\"name=\\\"upload\\\" size=\\\"50\\\"><input type=\\\"submit\\\" value=\\\"Загрузить\\\"> \" .", "", "\"Максимальный размер файла: \" . $maxFileSize . \"</di", ">", "/", "form></td><", "t", ">\".", "", "\"<tr><td align=\\\"center\\\"><a href=\\\"javascript:Copy('SelFileName');\\\">Скопировать имя</a>\" .", "", "\"</td><td style=\\\"width: 100%;\\\"><input type=\\\"text\\\" id=\\\"SelFileName\\\" value=\\\"\"", ".", "\"Нет выбранных объектов\\\" style=\\\"width: 100%;\\\"></td></tr>\".", "", "\"</table>\"", ";", "return", "$", "result", ";", "}" ]
Возвращает разметку элементов управления @return string
[ "Возвращает", "разметку", "элементов", "управления" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/files.php#L320-L335
Eresus/EresusCMS
src/core/files.php
TFiles.mkDir
function mkDir() { $pathname = Eresus_CMS::getLegacyKernel()->froot . $this->root . $this->panels[$this->sp] . arg('mkdir', FILES_FILTER); mkdir($pathname, 0777, true); HTTP::redirect(str_replace('&amp;', '&', $this->url())); }
php
function mkDir() { $pathname = Eresus_CMS::getLegacyKernel()->froot . $this->root . $this->panels[$this->sp] . arg('mkdir', FILES_FILTER); mkdir($pathname, 0777, true); HTTP::redirect(str_replace('&amp;', '&', $this->url())); }
[ "function", "mkDir", "(", ")", "{", "$", "pathname", "=", "Eresus_CMS", "::", "getLegacyKernel", "(", ")", "->", "froot", ".", "$", "this", "->", "root", ".", "$", "this", "->", "panels", "[", "$", "this", "->", "sp", "]", ".", "arg", "(", "'mkdir'", ",", "FILES_FILTER", ")", ";", "mkdir", "(", "$", "pathname", ",", "0777", ",", "true", ")", ";", "HTTP", "::", "redirect", "(", "str_replace", "(", "'&amp;'", ",", "'&'", ",", "$", "this", "->", "url", "(", ")", ")", ")", ";", "}" ]
Создаёт директорию @return void @uses FS::mkDir() @uses HTTP::redirect()
[ "Создаёт", "директорию" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/files.php#L364-L370
Eresus/EresusCMS
src/core/files.php
TFiles.adminRender
public function adminRender() { $this->root = 'data/'; $this->panels['l'] = (arg('lf')?preg_replace('!^/|/$!','',arg('lf')).'/':''); $this->panels['l'] = preg_replace('~(/\.\.|^\.\./)~', '', $this->panels['l']); $this->panels['l'] = preg_replace('!^/!', '', $this->panels['l']); while (!empty($this->panels['l']) && !is_dir(Eresus_CMS::getLegacyKernel()->froot.$this->root.$this->panels['l'])) { $this->panels['l'] = preg_replace('![^/]+/$!', '', $this->panels['l']); } $this->panels['r'] = (arg('rf')?preg_replace('!^/|/$!','',arg('rf')).'/':''); $this->panels['r'] = preg_replace('~(/\.\.|^\.\./)~', '', $this->panels['r']); $this->panels['r'] = preg_replace('!^/!', '', $this->panels['r']); while (!empty($this->panels['r']) && !is_dir(Eresus_CMS::getLegacyKernel()->froot.$this->root.$this->panels['r'])) { $this->panels['r'] = preg_replace('![^/]+/$!', '', $this->panels['r']); } $this->sp = substr(arg('sp', '/[^lr]/'), 0, 1); if (!$this->sp) { $this->sp = 'l'; } if (count($_FILES)) { $this->upload(); } elseif (arg('mkdir')) { $this->mkDir(); } elseif (arg('rename')) { $this->renameEntry(); } elseif (arg('chmod')) { $this->chmodEntry(); } elseif (arg('copyfile')) { $this->copyFile(); } elseif (arg('movefile')) { $this->moveFile(); } elseif (arg('delete')) { $this->deleteFile(); } else { $root = Eresus_CMS::getLegacyKernel()->root; Eresus_Kernel::app()->getPage()-> linkScripts($root . 'core/files.js'); $result = "<table id=\"fileManager\">\n" . '<tr><td colspan="2" class="filesMenu">' . $this->renderMenu() . "</td></tr>\n" . '<tr><td colspan="2" class="filesControls">' . $this->renderControls() . "</td></tr>" . '<tr>' . '<td valign="top" class="filesPanel">' . $this->renderFileList('l') . "</td>\n" . '<td valign="top" class="filesPanel">' . $this->renderFileList('r') . "</td>\n" . "</tr>\n" . '<tr><td colspan="2" class="filesControls">' . $this->renderStatus() . "</td></tr>" . "</table>" . "<script type=\"text/javascript\"><!--\n" . " filesInit('" . $root . $this->root . "', '" . $this->sp . "');\n" . "--></script>\n"; return $result; } return ''; }
php
public function adminRender() { $this->root = 'data/'; $this->panels['l'] = (arg('lf')?preg_replace('!^/|/$!','',arg('lf')).'/':''); $this->panels['l'] = preg_replace('~(/\.\.|^\.\./)~', '', $this->panels['l']); $this->panels['l'] = preg_replace('!^/!', '', $this->panels['l']); while (!empty($this->panels['l']) && !is_dir(Eresus_CMS::getLegacyKernel()->froot.$this->root.$this->panels['l'])) { $this->panels['l'] = preg_replace('![^/]+/$!', '', $this->panels['l']); } $this->panels['r'] = (arg('rf')?preg_replace('!^/|/$!','',arg('rf')).'/':''); $this->panels['r'] = preg_replace('~(/\.\.|^\.\./)~', '', $this->panels['r']); $this->panels['r'] = preg_replace('!^/!', '', $this->panels['r']); while (!empty($this->panels['r']) && !is_dir(Eresus_CMS::getLegacyKernel()->froot.$this->root.$this->panels['r'])) { $this->panels['r'] = preg_replace('![^/]+/$!', '', $this->panels['r']); } $this->sp = substr(arg('sp', '/[^lr]/'), 0, 1); if (!$this->sp) { $this->sp = 'l'; } if (count($_FILES)) { $this->upload(); } elseif (arg('mkdir')) { $this->mkDir(); } elseif (arg('rename')) { $this->renameEntry(); } elseif (arg('chmod')) { $this->chmodEntry(); } elseif (arg('copyfile')) { $this->copyFile(); } elseif (arg('movefile')) { $this->moveFile(); } elseif (arg('delete')) { $this->deleteFile(); } else { $root = Eresus_CMS::getLegacyKernel()->root; Eresus_Kernel::app()->getPage()-> linkScripts($root . 'core/files.js'); $result = "<table id=\"fileManager\">\n" . '<tr><td colspan="2" class="filesMenu">' . $this->renderMenu() . "</td></tr>\n" . '<tr><td colspan="2" class="filesControls">' . $this->renderControls() . "</td></tr>" . '<tr>' . '<td valign="top" class="filesPanel">' . $this->renderFileList('l') . "</td>\n" . '<td valign="top" class="filesPanel">' . $this->renderFileList('r') . "</td>\n" . "</tr>\n" . '<tr><td colspan="2" class="filesControls">' . $this->renderStatus() . "</td></tr>" . "</table>" . "<script type=\"text/javascript\"><!--\n" . " filesInit('" . $root . $this->root . "', '" . $this->sp . "');\n" . "--></script>\n"; return $result; } return ''; }
[ "public", "function", "adminRender", "(", ")", "{", "$", "this", "->", "root", "=", "'data/'", ";", "$", "this", "->", "panels", "[", "'l'", "]", "=", "(", "arg", "(", "'lf'", ")", "?", "preg_replace", "(", "'!^/|/$!'", ",", "''", ",", "arg", "(", "'lf'", ")", ")", ".", "'/'", ":", "''", ")", ";", "$", "this", "->", "panels", "[", "'l'", "]", "=", "preg_replace", "(", "'~(/\\.\\.|^\\.\\./)~'", ",", "''", ",", "$", "this", "->", "panels", "[", "'l'", "]", ")", ";", "$", "this", "->", "panels", "[", "'l'", "]", "=", "preg_replace", "(", "'!^/!'", ",", "''", ",", "$", "this", "->", "panels", "[", "'l'", "]", ")", ";", "while", "(", "!", "empty", "(", "$", "this", "->", "panels", "[", "'l'", "]", ")", "&&", "!", "is_dir", "(", "Eresus_CMS", "::", "getLegacyKernel", "(", ")", "->", "froot", ".", "$", "this", "->", "root", ".", "$", "this", "->", "panels", "[", "'l'", "]", ")", ")", "{", "$", "this", "->", "panels", "[", "'l'", "]", "=", "preg_replace", "(", "'![^/]+/$!'", ",", "''", ",", "$", "this", "->", "panels", "[", "'l'", "]", ")", ";", "}", "$", "this", "->", "panels", "[", "'r'", "]", "=", "(", "arg", "(", "'rf'", ")", "?", "preg_replace", "(", "'!^/|/$!'", ",", "''", ",", "arg", "(", "'rf'", ")", ")", ".", "'/'", ":", "''", ")", ";", "$", "this", "->", "panels", "[", "'r'", "]", "=", "preg_replace", "(", "'~(/\\.\\.|^\\.\\./)~'", ",", "''", ",", "$", "this", "->", "panels", "[", "'r'", "]", ")", ";", "$", "this", "->", "panels", "[", "'r'", "]", "=", "preg_replace", "(", "'!^/!'", ",", "''", ",", "$", "this", "->", "panels", "[", "'r'", "]", ")", ";", "while", "(", "!", "empty", "(", "$", "this", "->", "panels", "[", "'r'", "]", ")", "&&", "!", "is_dir", "(", "Eresus_CMS", "::", "getLegacyKernel", "(", ")", "->", "froot", ".", "$", "this", "->", "root", ".", "$", "this", "->", "panels", "[", "'r'", "]", ")", ")", "{", "$", "this", "->", "panels", "[", "'r'", "]", "=", "preg_replace", "(", "'![^/]+/$!'", ",", "''", ",", "$", "this", "->", "panels", "[", "'r'", "]", ")", ";", "}", "$", "this", "->", "sp", "=", "substr", "(", "arg", "(", "'sp'", ",", "'/[^lr]/'", ")", ",", "0", ",", "1", ")", ";", "if", "(", "!", "$", "this", "->", "sp", ")", "{", "$", "this", "->", "sp", "=", "'l'", ";", "}", "if", "(", "count", "(", "$", "_FILES", ")", ")", "{", "$", "this", "->", "upload", "(", ")", ";", "}", "elseif", "(", "arg", "(", "'mkdir'", ")", ")", "{", "$", "this", "->", "mkDir", "(", ")", ";", "}", "elseif", "(", "arg", "(", "'rename'", ")", ")", "{", "$", "this", "->", "renameEntry", "(", ")", ";", "}", "elseif", "(", "arg", "(", "'chmod'", ")", ")", "{", "$", "this", "->", "chmodEntry", "(", ")", ";", "}", "elseif", "(", "arg", "(", "'copyfile'", ")", ")", "{", "$", "this", "->", "copyFile", "(", ")", ";", "}", "elseif", "(", "arg", "(", "'movefile'", ")", ")", "{", "$", "this", "->", "moveFile", "(", ")", ";", "}", "elseif", "(", "arg", "(", "'delete'", ")", ")", "{", "$", "this", "->", "deleteFile", "(", ")", ";", "}", "else", "{", "$", "root", "=", "Eresus_CMS", "::", "getLegacyKernel", "(", ")", "->", "root", ";", "Eresus_Kernel", "::", "app", "(", ")", "->", "getPage", "(", ")", "->", "linkScripts", "(", "$", "root", ".", "'core/files.js'", ")", ";", "$", "result", "=", "\"<table id=\\\"fileManager\\\">\\n\"", ".", "'<tr><td colspan=\"2\" class=\"filesMenu\">'", ".", "$", "this", "->", "renderMenu", "(", ")", ".", "\"</td></tr>\\n\"", ".", "'<tr><td colspan=\"2\" class=\"filesControls\">'", ".", "$", "this", "->", "renderControls", "(", ")", ".", "\"</td></tr>\"", ".", "'<tr>'", ".", "'<td valign=\"top\" class=\"filesPanel\">'", ".", "$", "this", "->", "renderFileList", "(", "'l'", ")", ".", "\"</td>\\n\"", ".", "'<td valign=\"top\" class=\"filesPanel\">'", ".", "$", "this", "->", "renderFileList", "(", "'r'", ")", ".", "\"</td>\\n\"", ".", "\"</tr>\\n\"", ".", "'<tr><td colspan=\"2\" class=\"filesControls\">'", ".", "$", "this", "->", "renderStatus", "(", ")", ".", "\"</td></tr>\"", ".", "\"</table>\"", ".", "\"<script type=\\\"text/javascript\\\"><!--\\n\"", ".", "\" filesInit('\"", ".", "$", "root", ".", "$", "this", "->", "root", ".", "\"', '\"", ".", "$", "this", "->", "sp", ".", "\"');\\n\"", ".", "\"--></script>\\n\"", ";", "return", "$", "result", ";", "}", "return", "''", ";", "}" ]
Возвращает разметку интерфейса @return string
[ "Возвращает", "разметку", "интерфейса" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/files.php#L479-L553
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/interfaces/base_meta_data.php
ezcCacheStackBaseMetaData.addItem
public function addItem( $storageId, $itemId ) { $this->storageData[$storageId][$itemId] = true; // Abstract call $this->addItemToReplacementData( $itemId ); }
php
public function addItem( $storageId, $itemId ) { $this->storageData[$storageId][$itemId] = true; // Abstract call $this->addItemToReplacementData( $itemId ); }
[ "public", "function", "addItem", "(", "$", "storageId", ",", "$", "itemId", ")", "{", "$", "this", "->", "storageData", "[", "$", "storageId", "]", "[", "$", "itemId", "]", "=", "true", ";", "// Abstract call", "$", "this", "->", "addItemToReplacementData", "(", "$", "itemId", ")", ";", "}" ]
Adds the given $itemId to the storage identified by $storageId. This method adds the given $itemId to the storage identified by $storageId. It must also add the $itemId to the replacement data or update its status there, if the item is already in there. The method calls the abstract {@link self::addItemToReplacementData()} method to make the item be reflected in the replacement data. @param string $storageId @param string $itemId
[ "Adds", "the", "given", "$itemId", "to", "the", "storage", "identified", "by", "$storageId", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/interfaces/base_meta_data.php#L93-L98
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/interfaces/base_meta_data.php
ezcCacheStackBaseMetaData.removeItem
public function removeItem( $storageId, $itemId ) { // Remove from storage if ( isset( $this->storageData[$storageId] ) ) { // No error if not set unset( $this->storageData[$storageId][$itemId] ); // Remove empty storage if ( count( $this->storageData[$storageId] ) === 0 ) { unset( $this->storageData[$storageId] ); } } // Check for complete removal foreach ( $this->storageData as $storage => $items ) { if ( isset( $items[$itemId] ) ) { // Item is available in other storage return; } } // No storage has the item, savely unset it unset( $this->replacementData[$itemId] ); }
php
public function removeItem( $storageId, $itemId ) { // Remove from storage if ( isset( $this->storageData[$storageId] ) ) { // No error if not set unset( $this->storageData[$storageId][$itemId] ); // Remove empty storage if ( count( $this->storageData[$storageId] ) === 0 ) { unset( $this->storageData[$storageId] ); } } // Check for complete removal foreach ( $this->storageData as $storage => $items ) { if ( isset( $items[$itemId] ) ) { // Item is available in other storage return; } } // No storage has the item, savely unset it unset( $this->replacementData[$itemId] ); }
[ "public", "function", "removeItem", "(", "$", "storageId", ",", "$", "itemId", ")", "{", "// Remove from storage", "if", "(", "isset", "(", "$", "this", "->", "storageData", "[", "$", "storageId", "]", ")", ")", "{", "// No error if not set", "unset", "(", "$", "this", "->", "storageData", "[", "$", "storageId", "]", "[", "$", "itemId", "]", ")", ";", "// Remove empty storage", "if", "(", "count", "(", "$", "this", "->", "storageData", "[", "$", "storageId", "]", ")", "===", "0", ")", "{", "unset", "(", "$", "this", "->", "storageData", "[", "$", "storageId", "]", ")", ";", "}", "}", "// Check for complete removal", "foreach", "(", "$", "this", "->", "storageData", "as", "$", "storage", "=>", "$", "items", ")", "{", "if", "(", "isset", "(", "$", "items", "[", "$", "itemId", "]", ")", ")", "{", "// Item is available in other storage", "return", ";", "}", "}", "// No storage has the item, savely unset it", "unset", "(", "$", "this", "->", "replacementData", "[", "$", "itemId", "]", ")", ";", "}" ]
Removes the given $itemId from the storage identified by $storageId. Removes the given $itemId from the storage identified by $storageId in {@link self::$storageData} and also removes the key from {@link self::$metaData}. @param string $storageId @param string $itemId
[ "Removes", "the", "given", "$itemId", "from", "the", "storage", "identified", "by", "$storageId", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/interfaces/base_meta_data.php#L127-L152
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/interfaces/base_meta_data.php
ezcCacheStackBaseMetaData.reachedItemLimit
public function reachedItemLimit( $storageId, $limit ) { return ( isset( $this->storageData[$storageId] ) && count( $this->storageData[$storageId] ) >= $limit ); }
php
public function reachedItemLimit( $storageId, $limit ) { return ( isset( $this->storageData[$storageId] ) && count( $this->storageData[$storageId] ) >= $limit ); }
[ "public", "function", "reachedItemLimit", "(", "$", "storageId", ",", "$", "limit", ")", "{", "return", "(", "isset", "(", "$", "this", "->", "storageData", "[", "$", "storageId", "]", ")", "&&", "count", "(", "$", "this", "->", "storageData", "[", "$", "storageId", "]", ")", ">=", "$", "limit", ")", ";", "}" ]
Returns if the given $storageId has reached the given $limit of items. Returns if the storage identified by $storageId has $limit or more items stored. @param string $storageId @param int $limit @return bool
[ "Returns", "if", "the", "given", "$storageId", "has", "reached", "the", "given", "$limit", "of", "items", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/interfaces/base_meta_data.php#L179-L185
gregorybesson/PlaygroundCms
src/Entity/Block.php
Block.populate
public function populate($data = array()) { $this->title = (isset($data['title'])) ? $data['title'] : null; if (isset($data['is_active']) && $data['is_active'] != null) { $this->is_active = $data['is_active']; } if (isset($data['content']) && $data['content'] != null) { $this->content = $data['content']; } $this->identifier = (isset($data['identifier'])) ? $data['identifier'] : null; }
php
public function populate($data = array()) { $this->title = (isset($data['title'])) ? $data['title'] : null; if (isset($data['is_active']) && $data['is_active'] != null) { $this->is_active = $data['is_active']; } if (isset($data['content']) && $data['content'] != null) { $this->content = $data['content']; } $this->identifier = (isset($data['identifier'])) ? $data['identifier'] : null; }
[ "public", "function", "populate", "(", "$", "data", "=", "array", "(", ")", ")", "{", "$", "this", "->", "title", "=", "(", "isset", "(", "$", "data", "[", "'title'", "]", ")", ")", "?", "$", "data", "[", "'title'", "]", ":", "null", ";", "if", "(", "isset", "(", "$", "data", "[", "'is_active'", "]", ")", "&&", "$", "data", "[", "'is_active'", "]", "!=", "null", ")", "{", "$", "this", "->", "is_active", "=", "$", "data", "[", "'is_active'", "]", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'content'", "]", ")", "&&", "$", "data", "[", "'content'", "]", "!=", "null", ")", "{", "$", "this", "->", "content", "=", "$", "data", "[", "'content'", "]", ";", "}", "$", "this", "->", "identifier", "=", "(", "isset", "(", "$", "data", "[", "'identifier'", "]", ")", ")", "?", "$", "data", "[", "'identifier'", "]", ":", "null", ";", "}" ]
Populate from an array. @param array $data
[ "Populate", "from", "an", "array", "." ]
train
https://github.com/gregorybesson/PlaygroundCms/blob/e929a283f2a6e82d4f248c930f7aa454ce20cbc3/src/Entity/Block.php#L253-L263
gyselroth/micro-container
src/Config.php
Config.get
public function get(string $name): array { if (isset($this->compiled[$name])) { $config = $this->compiled[$name]; } else { $this->compiled[$name] = $this->createServiceConfig($name); $config = $this->compiled[$name]; } if (!isset($config['use'])) { $config['use'] = $name; } return $config; }
php
public function get(string $name): array { if (isset($this->compiled[$name])) { $config = $this->compiled[$name]; } else { $this->compiled[$name] = $this->createServiceConfig($name); $config = $this->compiled[$name]; } if (!isset($config['use'])) { $config['use'] = $name; } return $config; }
[ "public", "function", "get", "(", "string", "$", "name", ")", ":", "array", "{", "if", "(", "isset", "(", "$", "this", "->", "compiled", "[", "$", "name", "]", ")", ")", "{", "$", "config", "=", "$", "this", "->", "compiled", "[", "$", "name", "]", ";", "}", "else", "{", "$", "this", "->", "compiled", "[", "$", "name", "]", "=", "$", "this", "->", "createServiceConfig", "(", "$", "name", ")", ";", "$", "config", "=", "$", "this", "->", "compiled", "[", "$", "name", "]", ";", "}", "if", "(", "!", "isset", "(", "$", "config", "[", "'use'", "]", ")", ")", "{", "$", "config", "[", "'use'", "]", "=", "$", "name", ";", "}", "return", "$", "config", ";", "}" ]
Get service configuration.
[ "Get", "service", "configuration", "." ]
train
https://github.com/gyselroth/micro-container/blob/728cf35af9645648392c50752b4b555d491bac4e/src/Config.php#L65-L79
gyselroth/micro-container
src/Config.php
Config.getEnv
public function getEnv(string $param): string { if (preg_match_all('#\{ENV\(([A-Za-z0-9_]+)(?:(,?)([^}]*))\)\}#', $param, $matches)) { if (4 !== count($matches)) { return $param; } for ($i = 0; $i < count($matches[0]); ++$i) { $param = $this->parseEnv($param, $matches, $i); } return $param; } return $param; }
php
public function getEnv(string $param): string { if (preg_match_all('#\{ENV\(([A-Za-z0-9_]+)(?:(,?)([^}]*))\)\}#', $param, $matches)) { if (4 !== count($matches)) { return $param; } for ($i = 0; $i < count($matches[0]); ++$i) { $param = $this->parseEnv($param, $matches, $i); } return $param; } return $param; }
[ "public", "function", "getEnv", "(", "string", "$", "param", ")", ":", "string", "{", "if", "(", "preg_match_all", "(", "'#\\{ENV\\(([A-Za-z0-9_]+)(?:(,?)([^}]*))\\)\\}#'", ",", "$", "param", ",", "$", "matches", ")", ")", "{", "if", "(", "4", "!==", "count", "(", "$", "matches", ")", ")", "{", "return", "$", "param", ";", "}", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "matches", "[", "0", "]", ")", ";", "++", "$", "i", ")", "{", "$", "param", "=", "$", "this", "->", "parseEnv", "(", "$", "param", ",", "$", "matches", ",", "$", "i", ")", ";", "}", "return", "$", "param", ";", "}", "return", "$", "param", ";", "}" ]
Parse env param.
[ "Parse", "env", "param", "." ]
train
https://github.com/gyselroth/micro-container/blob/728cf35af9645648392c50752b4b555d491bac4e/src/Config.php#L84-L99
gyselroth/micro-container
src/Config.php
Config.parseEnv
protected function parseEnv(string $param, array $variables, int $key): string { $env = getenv($variables[1][$key]); if (false === $env && !empty($variables[3][$key])) { return str_replace($variables[0][$key], $variables[3][$key], $param); } if (false === $env) { throw new Exception\EnvVariableNotFound('env variable '.$variables[1][$key].' required but it is neither set not a default value exists'); } return str_replace($variables[0][$key], $env, $param); }
php
protected function parseEnv(string $param, array $variables, int $key): string { $env = getenv($variables[1][$key]); if (false === $env && !empty($variables[3][$key])) { return str_replace($variables[0][$key], $variables[3][$key], $param); } if (false === $env) { throw new Exception\EnvVariableNotFound('env variable '.$variables[1][$key].' required but it is neither set not a default value exists'); } return str_replace($variables[0][$key], $env, $param); }
[ "protected", "function", "parseEnv", "(", "string", "$", "param", ",", "array", "$", "variables", ",", "int", "$", "key", ")", ":", "string", "{", "$", "env", "=", "getenv", "(", "$", "variables", "[", "1", "]", "[", "$", "key", "]", ")", ";", "if", "(", "false", "===", "$", "env", "&&", "!", "empty", "(", "$", "variables", "[", "3", "]", "[", "$", "key", "]", ")", ")", "{", "return", "str_replace", "(", "$", "variables", "[", "0", "]", "[", "$", "key", "]", ",", "$", "variables", "[", "3", "]", "[", "$", "key", "]", ",", "$", "param", ")", ";", "}", "if", "(", "false", "===", "$", "env", ")", "{", "throw", "new", "Exception", "\\", "EnvVariableNotFound", "(", "'env variable '", ".", "$", "variables", "[", "1", "]", "[", "$", "key", "]", ".", "' required but it is neither set not a default value exists'", ")", ";", "}", "return", "str_replace", "(", "$", "variables", "[", "0", "]", "[", "$", "key", "]", ",", "$", "env", ",", "$", "param", ")", ";", "}" ]
Parse env.
[ "Parse", "env", "." ]
train
https://github.com/gyselroth/micro-container/blob/728cf35af9645648392c50752b4b555d491bac4e/src/Config.php#L104-L115
gyselroth/micro-container
src/Config.php
Config.createServiceConfig
protected function createServiceConfig(string $name): array { $config = []; if ($this->has($name)) { $config = $this->config[$name]; } $class = $name; if (isset($config['use'])) { if (!is_string($config['use'])) { throw new Exception\InvalidConfiguration('use must be a string for service '.$name); } $class = $config['use'] = $this->getEnv($config['use']); } if (preg_match('#^\{([^{}]+)\}$#', $class)) { $config = array_merge($this->getServiceDefaults(), $config); return $config; } $config = $this->mergeServiceConfig($name, $class, $config); if (isset($config['use'])) { $class = $config['use'] = $this->getEnv($config['use']); } if (!class_exists($class)) { throw new Exception\InvalidConfiguration('class '.$class.' is either not a class or can not be found'); } return $config; }
php
protected function createServiceConfig(string $name): array { $config = []; if ($this->has($name)) { $config = $this->config[$name]; } $class = $name; if (isset($config['use'])) { if (!is_string($config['use'])) { throw new Exception\InvalidConfiguration('use must be a string for service '.$name); } $class = $config['use'] = $this->getEnv($config['use']); } if (preg_match('#^\{([^{}]+)\}$#', $class)) { $config = array_merge($this->getServiceDefaults(), $config); return $config; } $config = $this->mergeServiceConfig($name, $class, $config); if (isset($config['use'])) { $class = $config['use'] = $this->getEnv($config['use']); } if (!class_exists($class)) { throw new Exception\InvalidConfiguration('class '.$class.' is either not a class or can not be found'); } return $config; }
[ "protected", "function", "createServiceConfig", "(", "string", "$", "name", ")", ":", "array", "{", "$", "config", "=", "[", "]", ";", "if", "(", "$", "this", "->", "has", "(", "$", "name", ")", ")", "{", "$", "config", "=", "$", "this", "->", "config", "[", "$", "name", "]", ";", "}", "$", "class", "=", "$", "name", ";", "if", "(", "isset", "(", "$", "config", "[", "'use'", "]", ")", ")", "{", "if", "(", "!", "is_string", "(", "$", "config", "[", "'use'", "]", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidConfiguration", "(", "'use must be a string for service '", ".", "$", "name", ")", ";", "}", "$", "class", "=", "$", "config", "[", "'use'", "]", "=", "$", "this", "->", "getEnv", "(", "$", "config", "[", "'use'", "]", ")", ";", "}", "if", "(", "preg_match", "(", "'#^\\{([^{}]+)\\}$#'", ",", "$", "class", ")", ")", "{", "$", "config", "=", "array_merge", "(", "$", "this", "->", "getServiceDefaults", "(", ")", ",", "$", "config", ")", ";", "return", "$", "config", ";", "}", "$", "config", "=", "$", "this", "->", "mergeServiceConfig", "(", "$", "name", ",", "$", "class", ",", "$", "config", ")", ";", "if", "(", "isset", "(", "$", "config", "[", "'use'", "]", ")", ")", "{", "$", "class", "=", "$", "config", "[", "'use'", "]", "=", "$", "this", "->", "getEnv", "(", "$", "config", "[", "'use'", "]", ")", ";", "}", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidConfiguration", "(", "'class '", ".", "$", "class", ".", "' is either not a class or can not be found'", ")", ";", "}", "return", "$", "config", ";", "}" ]
Create service config.
[ "Create", "service", "config", "." ]
train
https://github.com/gyselroth/micro-container/blob/728cf35af9645648392c50752b4b555d491bac4e/src/Config.php#L120-L154
gyselroth/micro-container
src/Config.php
Config.mergeServiceConfig
protected function mergeServiceConfig(string $name, string $class, array $config): array { $config = array_merge($this->getServiceDefaults(), $config); if (!class_exists($class) && !interface_exists($class)) { return $config; } if (false === $config['merge']) { return $config; } $tree = $this->getConfigTree(); $parents = array_merge(class_implements($class), class_parents($class)); foreach ($tree as $parent_config) { foreach ($parents as $parent) { if (isset($parent_config[$parent])) { $config = array_replace_recursive($config, $parent_config[$parent]); } } if (isset($parent_config[$name])) { $config = array_replace_recursive($config, $parent_config[$name]); } } return $config; }
php
protected function mergeServiceConfig(string $name, string $class, array $config): array { $config = array_merge($this->getServiceDefaults(), $config); if (!class_exists($class) && !interface_exists($class)) { return $config; } if (false === $config['merge']) { return $config; } $tree = $this->getConfigTree(); $parents = array_merge(class_implements($class), class_parents($class)); foreach ($tree as $parent_config) { foreach ($parents as $parent) { if (isset($parent_config[$parent])) { $config = array_replace_recursive($config, $parent_config[$parent]); } } if (isset($parent_config[$name])) { $config = array_replace_recursive($config, $parent_config[$name]); } } return $config; }
[ "protected", "function", "mergeServiceConfig", "(", "string", "$", "name", ",", "string", "$", "class", ",", "array", "$", "config", ")", ":", "array", "{", "$", "config", "=", "array_merge", "(", "$", "this", "->", "getServiceDefaults", "(", ")", ",", "$", "config", ")", ";", "if", "(", "!", "class_exists", "(", "$", "class", ")", "&&", "!", "interface_exists", "(", "$", "class", ")", ")", "{", "return", "$", "config", ";", "}", "if", "(", "false", "===", "$", "config", "[", "'merge'", "]", ")", "{", "return", "$", "config", ";", "}", "$", "tree", "=", "$", "this", "->", "getConfigTree", "(", ")", ";", "$", "parents", "=", "array_merge", "(", "class_implements", "(", "$", "class", ")", ",", "class_parents", "(", "$", "class", ")", ")", ";", "foreach", "(", "$", "tree", "as", "$", "parent_config", ")", "{", "foreach", "(", "$", "parents", "as", "$", "parent", ")", "{", "if", "(", "isset", "(", "$", "parent_config", "[", "$", "parent", "]", ")", ")", "{", "$", "config", "=", "array_replace_recursive", "(", "$", "config", ",", "$", "parent_config", "[", "$", "parent", "]", ")", ";", "}", "}", "if", "(", "isset", "(", "$", "parent_config", "[", "$", "name", "]", ")", ")", "{", "$", "config", "=", "array_replace_recursive", "(", "$", "config", ",", "$", "parent_config", "[", "$", "name", "]", ")", ";", "}", "}", "return", "$", "config", ";", "}" ]
Find parent classes or interfaces and merge service configurations.
[ "Find", "parent", "classes", "or", "interfaces", "and", "merge", "service", "configurations", "." ]
train
https://github.com/gyselroth/micro-container/blob/728cf35af9645648392c50752b4b555d491bac4e/src/Config.php#L174-L201
gyselroth/micro-container
src/Config.php
Config.getConfigTree
protected function getConfigTree(): array { $tree = [$this->getConfig()]; $parent = $this->container; while ($parent = $parent->getParent()) { $tree[] = $parent->getConfig()->getConfig(); } return $tree; }
php
protected function getConfigTree(): array { $tree = [$this->getConfig()]; $parent = $this->container; while ($parent = $parent->getParent()) { $tree[] = $parent->getConfig()->getConfig(); } return $tree; }
[ "protected", "function", "getConfigTree", "(", ")", ":", "array", "{", "$", "tree", "=", "[", "$", "this", "->", "getConfig", "(", ")", "]", ";", "$", "parent", "=", "$", "this", "->", "container", ";", "while", "(", "$", "parent", "=", "$", "parent", "->", "getParent", "(", ")", ")", "{", "$", "tree", "[", "]", "=", "$", "parent", "->", "getConfig", "(", ")", "->", "getConfig", "(", ")", ";", "}", "return", "$", "tree", ";", "}" ]
Get config tree.
[ "Get", "config", "tree", "." ]
train
https://github.com/gyselroth/micro-container/blob/728cf35af9645648392c50752b4b555d491bac4e/src/Config.php#L206-L215