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
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
oroinc/OroLayoutComponent
BlockFactory.php
BlockFactory.createBlockView
public function createBlockView(RawLayout $rawLayout, ContextInterface $context) { $this->initializeState($rawLayout, $context); try { $rootId = $this->rawLayout->getRootId(); $this->buildBlocks($rootId); $this->layoutManipulator->applyChanges($this->context, true); $rootView = $this->buildBlockViews($rootId); $this->clearState(); return $rootView; } catch (\Exception $e) { $this->clearState(); throw $e; } }
php
public function createBlockView(RawLayout $rawLayout, ContextInterface $context) { $this->initializeState($rawLayout, $context); try { $rootId = $this->rawLayout->getRootId(); $this->buildBlocks($rootId); $this->layoutManipulator->applyChanges($this->context, true); $rootView = $this->buildBlockViews($rootId); $this->clearState(); return $rootView; } catch (\Exception $e) { $this->clearState(); throw $e; } }
[ "public", "function", "createBlockView", "(", "RawLayout", "$", "rawLayout", ",", "ContextInterface", "$", "context", ")", "{", "$", "this", "->", "initializeState", "(", "$", "rawLayout", ",", "$", "context", ")", ";", "try", "{", "$", "rootId", "=", "$", "this", "->", "rawLayout", "->", "getRootId", "(", ")", ";", "$", "this", "->", "buildBlocks", "(", "$", "rootId", ")", ";", "$", "this", "->", "layoutManipulator", "->", "applyChanges", "(", "$", "this", "->", "context", ",", "true", ")", ";", "$", "rootView", "=", "$", "this", "->", "buildBlockViews", "(", "$", "rootId", ")", ";", "$", "this", "->", "clearState", "(", ")", ";", "return", "$", "rootView", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "clearState", "(", ")", ";", "throw", "$", "e", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/BlockFactory.php#L60-L77
oroinc/OroLayoutComponent
BlockFactory.php
BlockFactory.initializeState
protected function initializeState(RawLayout $rawLayout, ContextInterface $context) { $this->rawLayout = $rawLayout; $this->context = $context; $this->dataAccessor = new DataAccessor($this->registry, $this->context); $this->optionsResolver = new BlockOptionsResolver($this->registry); $this->typeHelper = new BlockTypeHelper($this->registry); $this->blockBuilder = new BlockBuilder( $this->layoutManipulator, $this->rawLayout, $this->typeHelper, $this->context ); $this->block = new Block( $this->rawLayout, $this->typeHelper, $this->context, $this->dataAccessor ); }
php
protected function initializeState(RawLayout $rawLayout, ContextInterface $context) { $this->rawLayout = $rawLayout; $this->context = $context; $this->dataAccessor = new DataAccessor($this->registry, $this->context); $this->optionsResolver = new BlockOptionsResolver($this->registry); $this->typeHelper = new BlockTypeHelper($this->registry); $this->blockBuilder = new BlockBuilder( $this->layoutManipulator, $this->rawLayout, $this->typeHelper, $this->context ); $this->block = new Block( $this->rawLayout, $this->typeHelper, $this->context, $this->dataAccessor ); }
[ "protected", "function", "initializeState", "(", "RawLayout", "$", "rawLayout", ",", "ContextInterface", "$", "context", ")", "{", "$", "this", "->", "rawLayout", "=", "$", "rawLayout", ";", "$", "this", "->", "context", "=", "$", "context", ";", "$", "this", "->", "dataAccessor", "=", "new", "DataAccessor", "(", "$", "this", "->", "registry", ",", "$", "this", "->", "context", ")", ";", "$", "this", "->", "optionsResolver", "=", "new", "BlockOptionsResolver", "(", "$", "this", "->", "registry", ")", ";", "$", "this", "->", "typeHelper", "=", "new", "BlockTypeHelper", "(", "$", "this", "->", "registry", ")", ";", "$", "this", "->", "blockBuilder", "=", "new", "BlockBuilder", "(", "$", "this", "->", "layoutManipulator", ",", "$", "this", "->", "rawLayout", ",", "$", "this", "->", "typeHelper", ",", "$", "this", "->", "context", ")", ";", "$", "this", "->", "block", "=", "new", "Block", "(", "$", "this", "->", "rawLayout", ",", "$", "this", "->", "typeHelper", ",", "$", "this", "->", "context", ",", "$", "this", "->", "dataAccessor", ")", ";", "}" ]
Initializes the state of this factory @param RawLayout $rawLayout @param ContextInterface $context
[ "Initializes", "the", "state", "of", "this", "factory" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/BlockFactory.php#L85-L105
oroinc/OroLayoutComponent
BlockFactory.php
BlockFactory.clearState
protected function clearState() { $this->rawLayout = null; $this->context = null; $this->dataAccessor = null; $this->optionsResolver = null; $this->typeHelper = null; $this->blockBuilder = null; $this->block = null; }
php
protected function clearState() { $this->rawLayout = null; $this->context = null; $this->dataAccessor = null; $this->optionsResolver = null; $this->typeHelper = null; $this->blockBuilder = null; $this->block = null; }
[ "protected", "function", "clearState", "(", ")", "{", "$", "this", "->", "rawLayout", "=", "null", ";", "$", "this", "->", "context", "=", "null", ";", "$", "this", "->", "dataAccessor", "=", "null", ";", "$", "this", "->", "optionsResolver", "=", "null", ";", "$", "this", "->", "typeHelper", "=", "null", ";", "$", "this", "->", "blockBuilder", "=", "null", ";", "$", "this", "->", "block", "=", "null", ";", "}" ]
Clears the state of this factory
[ "Clears", "the", "state", "of", "this", "factory" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/BlockFactory.php#L110-L119
oroinc/OroLayoutComponent
BlockFactory.php
BlockFactory.buildBlocks
protected function buildBlocks($rootId) { // build the root block if (!$this->rawLayout->hasProperty($rootId, RawLayout::RESOLVED_OPTIONS, true)) { $this->buildBlock($rootId); } // build child blocks $iterator = $this->rawLayout->getHierarchyIterator($rootId); foreach ($iterator as $id) { if (!$this->rawLayout->has($id) || $this->rawLayout->hasProperty($id, RawLayout::RESOLVED_OPTIONS, true)) { // the block is already built continue; } if (!$this->isContainerBlock($iterator->getParent())) { $blockType = $this->rawLayout->getProperty($iterator->getParent(), RawLayout::BLOCK_TYPE, true); throw new Exception\LogicException( sprintf( 'The "%s" item cannot be added as a child to "%s" item (block type: %s) ' . 'because only container blocks can have children.', $id, $iterator->getParent(), $blockType instanceof BlockTypeInterface ? $blockType->getName() : $blockType ) ); } $this->buildBlock($id); } // apply layout changes were made by built blocks and build newly added blocks $this->layoutManipulator->applyChanges($this->context); if ($this->layoutManipulator->getNumberOfAddedItems() !== 0) { $this->buildBlocks($rootId); } }
php
protected function buildBlocks($rootId) { // build the root block if (!$this->rawLayout->hasProperty($rootId, RawLayout::RESOLVED_OPTIONS, true)) { $this->buildBlock($rootId); } // build child blocks $iterator = $this->rawLayout->getHierarchyIterator($rootId); foreach ($iterator as $id) { if (!$this->rawLayout->has($id) || $this->rawLayout->hasProperty($id, RawLayout::RESOLVED_OPTIONS, true)) { // the block is already built continue; } if (!$this->isContainerBlock($iterator->getParent())) { $blockType = $this->rawLayout->getProperty($iterator->getParent(), RawLayout::BLOCK_TYPE, true); throw new Exception\LogicException( sprintf( 'The "%s" item cannot be added as a child to "%s" item (block type: %s) ' . 'because only container blocks can have children.', $id, $iterator->getParent(), $blockType instanceof BlockTypeInterface ? $blockType->getName() : $blockType ) ); } $this->buildBlock($id); } // apply layout changes were made by built blocks and build newly added blocks $this->layoutManipulator->applyChanges($this->context); if ($this->layoutManipulator->getNumberOfAddedItems() !== 0) { $this->buildBlocks($rootId); } }
[ "protected", "function", "buildBlocks", "(", "$", "rootId", ")", "{", "// build the root block", "if", "(", "!", "$", "this", "->", "rawLayout", "->", "hasProperty", "(", "$", "rootId", ",", "RawLayout", "::", "RESOLVED_OPTIONS", ",", "true", ")", ")", "{", "$", "this", "->", "buildBlock", "(", "$", "rootId", ")", ";", "}", "// build child blocks", "$", "iterator", "=", "$", "this", "->", "rawLayout", "->", "getHierarchyIterator", "(", "$", "rootId", ")", ";", "foreach", "(", "$", "iterator", "as", "$", "id", ")", "{", "if", "(", "!", "$", "this", "->", "rawLayout", "->", "has", "(", "$", "id", ")", "||", "$", "this", "->", "rawLayout", "->", "hasProperty", "(", "$", "id", ",", "RawLayout", "::", "RESOLVED_OPTIONS", ",", "true", ")", ")", "{", "// the block is already built", "continue", ";", "}", "if", "(", "!", "$", "this", "->", "isContainerBlock", "(", "$", "iterator", "->", "getParent", "(", ")", ")", ")", "{", "$", "blockType", "=", "$", "this", "->", "rawLayout", "->", "getProperty", "(", "$", "iterator", "->", "getParent", "(", ")", ",", "RawLayout", "::", "BLOCK_TYPE", ",", "true", ")", ";", "throw", "new", "Exception", "\\", "LogicException", "(", "sprintf", "(", "'The \"%s\" item cannot be added as a child to \"%s\" item (block type: %s) '", ".", "'because only container blocks can have children.'", ",", "$", "id", ",", "$", "iterator", "->", "getParent", "(", ")", ",", "$", "blockType", "instanceof", "BlockTypeInterface", "?", "$", "blockType", "->", "getName", "(", ")", ":", "$", "blockType", ")", ")", ";", "}", "$", "this", "->", "buildBlock", "(", "$", "id", ")", ";", "}", "// apply layout changes were made by built blocks and build newly added blocks", "$", "this", "->", "layoutManipulator", "->", "applyChanges", "(", "$", "this", "->", "context", ")", ";", "if", "(", "$", "this", "->", "layoutManipulator", "->", "getNumberOfAddedItems", "(", ")", "!==", "0", ")", "{", "$", "this", "->", "buildBlocks", "(", "$", "rootId", ")", ";", "}", "}" ]
Builds all blocks starting with and including the given root block @param string $rootId @throws Exception\LogicException if a child block is added to not container
[ "Builds", "all", "blocks", "starting", "with", "and", "including", "the", "given", "root", "block" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/BlockFactory.php#L128-L163
oroinc/OroLayoutComponent
BlockFactory.php
BlockFactory.buildBlockViews
protected function buildBlockViews($rootId) { /** @var BlockView[] $views */ $views = []; // build the root view $rootView = $this->buildBlockView($rootId); $views[$rootId] = $rootView; // build child views $iterator = $this->rawLayout->getHierarchyIterator($rootId); foreach ($iterator as $id) { $parentView = $views[$iterator->getParent()]; // build child view $view = $this->buildBlockView($id, $parentView); $parentView->children[$id] = $view; $views[$id] = $view; } $viewsCollection = new BlockViewCollection($views); foreach ($views as $view) { $view->blocks = $viewsCollection; } // finish the root view $this->finishBlockView($rootView, $rootId); // finish child views foreach ($iterator as $id) { $this->finishBlockView($views[$id], $id); } return $rootView; }
php
protected function buildBlockViews($rootId) { /** @var BlockView[] $views */ $views = []; // build the root view $rootView = $this->buildBlockView($rootId); $views[$rootId] = $rootView; // build child views $iterator = $this->rawLayout->getHierarchyIterator($rootId); foreach ($iterator as $id) { $parentView = $views[$iterator->getParent()]; // build child view $view = $this->buildBlockView($id, $parentView); $parentView->children[$id] = $view; $views[$id] = $view; } $viewsCollection = new BlockViewCollection($views); foreach ($views as $view) { $view->blocks = $viewsCollection; } // finish the root view $this->finishBlockView($rootView, $rootId); // finish child views foreach ($iterator as $id) { $this->finishBlockView($views[$id], $id); } return $rootView; }
[ "protected", "function", "buildBlockViews", "(", "$", "rootId", ")", "{", "/** @var BlockView[] $views */", "$", "views", "=", "[", "]", ";", "// build the root view", "$", "rootView", "=", "$", "this", "->", "buildBlockView", "(", "$", "rootId", ")", ";", "$", "views", "[", "$", "rootId", "]", "=", "$", "rootView", ";", "// build child views", "$", "iterator", "=", "$", "this", "->", "rawLayout", "->", "getHierarchyIterator", "(", "$", "rootId", ")", ";", "foreach", "(", "$", "iterator", "as", "$", "id", ")", "{", "$", "parentView", "=", "$", "views", "[", "$", "iterator", "->", "getParent", "(", ")", "]", ";", "// build child view", "$", "view", "=", "$", "this", "->", "buildBlockView", "(", "$", "id", ",", "$", "parentView", ")", ";", "$", "parentView", "->", "children", "[", "$", "id", "]", "=", "$", "view", ";", "$", "views", "[", "$", "id", "]", "=", "$", "view", ";", "}", "$", "viewsCollection", "=", "new", "BlockViewCollection", "(", "$", "views", ")", ";", "foreach", "(", "$", "views", "as", "$", "view", ")", "{", "$", "view", "->", "blocks", "=", "$", "viewsCollection", ";", "}", "// finish the root view", "$", "this", "->", "finishBlockView", "(", "$", "rootView", ",", "$", "rootId", ")", ";", "// finish child views", "foreach", "(", "$", "iterator", "as", "$", "id", ")", "{", "$", "this", "->", "finishBlockView", "(", "$", "views", "[", "$", "id", "]", ",", "$", "id", ")", ";", "}", "return", "$", "rootView", ";", "}" ]
Builds views for all blocks starting with and including the given root block @param string $rootId @return BlockView The root block view
[ "Builds", "views", "for", "all", "blocks", "starting", "with", "and", "including", "the", "given", "root", "block" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/BlockFactory.php#L172-L204
oroinc/OroLayoutComponent
BlockFactory.php
BlockFactory.buildBlock
protected function buildBlock($id) { $blockType = $this->rawLayout->getProperty($id, RawLayout::BLOCK_TYPE, true); $options = $this->rawLayout->getProperty($id, RawLayout::OPTIONS, true); $types = $this->typeHelper->getTypes($blockType); $this->setBlockResolvedOptions($id, $blockType, $options, $types); }
php
protected function buildBlock($id) { $blockType = $this->rawLayout->getProperty($id, RawLayout::BLOCK_TYPE, true); $options = $this->rawLayout->getProperty($id, RawLayout::OPTIONS, true); $types = $this->typeHelper->getTypes($blockType); $this->setBlockResolvedOptions($id, $blockType, $options, $types); }
[ "protected", "function", "buildBlock", "(", "$", "id", ")", "{", "$", "blockType", "=", "$", "this", "->", "rawLayout", "->", "getProperty", "(", "$", "id", ",", "RawLayout", "::", "BLOCK_TYPE", ",", "true", ")", ";", "$", "options", "=", "$", "this", "->", "rawLayout", "->", "getProperty", "(", "$", "id", ",", "RawLayout", "::", "OPTIONS", ",", "true", ")", ";", "$", "types", "=", "$", "this", "->", "typeHelper", "->", "getTypes", "(", "$", "blockType", ")", ";", "$", "this", "->", "setBlockResolvedOptions", "(", "$", "id", ",", "$", "blockType", ",", "$", "options", ",", "$", "types", ")", ";", "}" ]
Builds the block @param string $id
[ "Builds", "the", "block" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/BlockFactory.php#L211-L218
oroinc/OroLayoutComponent
BlockFactory.php
BlockFactory.buildBlockView
protected function buildBlockView($id, BlockView $parentView = null) { $blockType = $this->rawLayout->getProperty($id, RawLayout::BLOCK_TYPE, true); $resolvedOptions = $this->rawLayout->getProperty($id, RawLayout::RESOLVED_OPTIONS, true); $types = $this->typeHelper->getTypes($blockType); $view = new BlockView($parentView); if (is_null($resolvedOptions)) { // Try to resolve options again to render block $options = $this->rawLayout->getProperty($id, RawLayout::OPTIONS, true); $resolvedOptions = $this->setBlockResolvedOptions($id, $blockType, $options, $types); } // point the block view state to the current block $this->block->initialize($id); // build the view foreach ($types as $type) { $type->buildView($view, $this->block, $resolvedOptions); $this->registry->buildView($type->getName(), $view, $this->block, $resolvedOptions); } array_walk_recursive( $view->vars, function (&$var) { if ($var instanceof Options) { $var = $var->toArray(); } } ); return $view; }
php
protected function buildBlockView($id, BlockView $parentView = null) { $blockType = $this->rawLayout->getProperty($id, RawLayout::BLOCK_TYPE, true); $resolvedOptions = $this->rawLayout->getProperty($id, RawLayout::RESOLVED_OPTIONS, true); $types = $this->typeHelper->getTypes($blockType); $view = new BlockView($parentView); if (is_null($resolvedOptions)) { // Try to resolve options again to render block $options = $this->rawLayout->getProperty($id, RawLayout::OPTIONS, true); $resolvedOptions = $this->setBlockResolvedOptions($id, $blockType, $options, $types); } // point the block view state to the current block $this->block->initialize($id); // build the view foreach ($types as $type) { $type->buildView($view, $this->block, $resolvedOptions); $this->registry->buildView($type->getName(), $view, $this->block, $resolvedOptions); } array_walk_recursive( $view->vars, function (&$var) { if ($var instanceof Options) { $var = $var->toArray(); } } ); return $view; }
[ "protected", "function", "buildBlockView", "(", "$", "id", ",", "BlockView", "$", "parentView", "=", "null", ")", "{", "$", "blockType", "=", "$", "this", "->", "rawLayout", "->", "getProperty", "(", "$", "id", ",", "RawLayout", "::", "BLOCK_TYPE", ",", "true", ")", ";", "$", "resolvedOptions", "=", "$", "this", "->", "rawLayout", "->", "getProperty", "(", "$", "id", ",", "RawLayout", "::", "RESOLVED_OPTIONS", ",", "true", ")", ";", "$", "types", "=", "$", "this", "->", "typeHelper", "->", "getTypes", "(", "$", "blockType", ")", ";", "$", "view", "=", "new", "BlockView", "(", "$", "parentView", ")", ";", "if", "(", "is_null", "(", "$", "resolvedOptions", ")", ")", "{", "// Try to resolve options again to render block", "$", "options", "=", "$", "this", "->", "rawLayout", "->", "getProperty", "(", "$", "id", ",", "RawLayout", "::", "OPTIONS", ",", "true", ")", ";", "$", "resolvedOptions", "=", "$", "this", "->", "setBlockResolvedOptions", "(", "$", "id", ",", "$", "blockType", ",", "$", "options", ",", "$", "types", ")", ";", "}", "// point the block view state to the current block", "$", "this", "->", "block", "->", "initialize", "(", "$", "id", ")", ";", "// build the view", "foreach", "(", "$", "types", "as", "$", "type", ")", "{", "$", "type", "->", "buildView", "(", "$", "view", ",", "$", "this", "->", "block", ",", "$", "resolvedOptions", ")", ";", "$", "this", "->", "registry", "->", "buildView", "(", "$", "type", "->", "getName", "(", ")", ",", "$", "view", ",", "$", "this", "->", "block", ",", "$", "resolvedOptions", ")", ";", "}", "array_walk_recursive", "(", "$", "view", "->", "vars", ",", "function", "(", "&", "$", "var", ")", "{", "if", "(", "$", "var", "instanceof", "Options", ")", "{", "$", "var", "=", "$", "var", "->", "toArray", "(", ")", ";", "}", "}", ")", ";", "return", "$", "view", ";", "}" ]
Created and builds the block view @param string $id @param BlockView|null $parentView @return BlockView
[ "Created", "and", "builds", "the", "block", "view" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/BlockFactory.php#L228-L258
oroinc/OroLayoutComponent
BlockFactory.php
BlockFactory.finishBlockView
protected function finishBlockView(BlockView $view, $id) { $blockType = $this->rawLayout->getProperty($id, RawLayout::BLOCK_TYPE, true); $types = $this->typeHelper->getTypes($blockType); // point the block view state to the current block $this->block->initialize($id); // finish the view foreach ($types as $type) { $type->finishView($view, $this->block); $this->registry->finishView($type->getName(), $view, $this->block); } }
php
protected function finishBlockView(BlockView $view, $id) { $blockType = $this->rawLayout->getProperty($id, RawLayout::BLOCK_TYPE, true); $types = $this->typeHelper->getTypes($blockType); // point the block view state to the current block $this->block->initialize($id); // finish the view foreach ($types as $type) { $type->finishView($view, $this->block); $this->registry->finishView($type->getName(), $view, $this->block); } }
[ "protected", "function", "finishBlockView", "(", "BlockView", "$", "view", ",", "$", "id", ")", "{", "$", "blockType", "=", "$", "this", "->", "rawLayout", "->", "getProperty", "(", "$", "id", ",", "RawLayout", "::", "BLOCK_TYPE", ",", "true", ")", ";", "$", "types", "=", "$", "this", "->", "typeHelper", "->", "getTypes", "(", "$", "blockType", ")", ";", "// point the block view state to the current block", "$", "this", "->", "block", "->", "initialize", "(", "$", "id", ")", ";", "// finish the view", "foreach", "(", "$", "types", "as", "$", "type", ")", "{", "$", "type", "->", "finishView", "(", "$", "view", ",", "$", "this", "->", "block", ")", ";", "$", "this", "->", "registry", "->", "finishView", "(", "$", "type", "->", "getName", "(", ")", ",", "$", "view", ",", "$", "this", "->", "block", ")", ";", "}", "}" ]
Finishes the building of the block view @param BlockView $view @param string $id
[ "Finishes", "the", "building", "of", "the", "block", "view" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/BlockFactory.php#L266-L278
oroinc/OroLayoutComponent
BlockFactory.php
BlockFactory.isContainerBlock
protected function isContainerBlock($id) { return $this->typeHelper->isInstanceOf( $this->rawLayout->getProperty($id, RawLayout::BLOCK_TYPE, true), ContainerType::NAME ); }
php
protected function isContainerBlock($id) { return $this->typeHelper->isInstanceOf( $this->rawLayout->getProperty($id, RawLayout::BLOCK_TYPE, true), ContainerType::NAME ); }
[ "protected", "function", "isContainerBlock", "(", "$", "id", ")", "{", "return", "$", "this", "->", "typeHelper", "->", "isInstanceOf", "(", "$", "this", "->", "rawLayout", "->", "getProperty", "(", "$", "id", ",", "RawLayout", "::", "BLOCK_TYPE", ",", "true", ")", ",", "ContainerType", "::", "NAME", ")", ";", "}" ]
Checks whether the given block is a container for other blocks @param string $id @return bool
[ "Checks", "whether", "the", "given", "block", "is", "a", "container", "for", "other", "blocks" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/BlockFactory.php#L287-L293
oroinc/OroLayoutComponent
BlockFactory.php
BlockFactory.processExpressions
protected function processExpressions(Options $options) { if (!$this->context->getOr('expressions_evaluate')) { return; } $values = $options->toArray(); if ($this->context->getOr('expressions_evaluate_deferred')) { $this->expressionProcessor->processExpressions($values, $this->context, null, true, null); } else { $this->expressionProcessor->processExpressions( $values, $this->context, $this->dataAccessor, true, $this->context->getOr('expressions_encoding') ); } $options->setMultiple($values); }
php
protected function processExpressions(Options $options) { if (!$this->context->getOr('expressions_evaluate')) { return; } $values = $options->toArray(); if ($this->context->getOr('expressions_evaluate_deferred')) { $this->expressionProcessor->processExpressions($values, $this->context, null, true, null); } else { $this->expressionProcessor->processExpressions( $values, $this->context, $this->dataAccessor, true, $this->context->getOr('expressions_encoding') ); } $options->setMultiple($values); }
[ "protected", "function", "processExpressions", "(", "Options", "$", "options", ")", "{", "if", "(", "!", "$", "this", "->", "context", "->", "getOr", "(", "'expressions_evaluate'", ")", ")", "{", "return", ";", "}", "$", "values", "=", "$", "options", "->", "toArray", "(", ")", ";", "if", "(", "$", "this", "->", "context", "->", "getOr", "(", "'expressions_evaluate_deferred'", ")", ")", "{", "$", "this", "->", "expressionProcessor", "->", "processExpressions", "(", "$", "values", ",", "$", "this", "->", "context", ",", "null", ",", "true", ",", "null", ")", ";", "}", "else", "{", "$", "this", "->", "expressionProcessor", "->", "processExpressions", "(", "$", "values", ",", "$", "this", "->", "context", ",", "$", "this", "->", "dataAccessor", ",", "true", ",", "$", "this", "->", "context", "->", "getOr", "(", "'expressions_encoding'", ")", ")", ";", "}", "$", "options", "->", "setMultiple", "(", "$", "values", ")", ";", "}" ]
Processes expressions that don't work with data @param Options $options
[ "Processes", "expressions", "that", "don", "t", "work", "with", "data" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/BlockFactory.php#L300-L321
oroinc/OroLayoutComponent
BlockFactory.php
BlockFactory.setBlockResolvedOptions
protected function setBlockResolvedOptions($id, $blockType, $options, $types) { // resolve options $resolvedOptions = new Options($this->optionsResolver->resolveOptions($blockType, $options)); $this->processExpressions($resolvedOptions); $resolvedOptions = $this->resolveValueBags($resolvedOptions); if ($resolvedOptions->get('visible', false) !== false) { // point the block builder state to the current block $this->blockBuilder->initialize($id); // iterate from parent to current foreach ($types as $type) { $type->buildBlock($this->blockBuilder, $resolvedOptions); $this->registry->buildBlock($type->getName(), $this->blockBuilder, $resolvedOptions); } $this->rawLayout->setProperty($id, RawLayout::RESOLVED_OPTIONS, $resolvedOptions); } else { $this->rawLayout->remove($id); } return $resolvedOptions; }
php
protected function setBlockResolvedOptions($id, $blockType, $options, $types) { // resolve options $resolvedOptions = new Options($this->optionsResolver->resolveOptions($blockType, $options)); $this->processExpressions($resolvedOptions); $resolvedOptions = $this->resolveValueBags($resolvedOptions); if ($resolvedOptions->get('visible', false) !== false) { // point the block builder state to the current block $this->blockBuilder->initialize($id); // iterate from parent to current foreach ($types as $type) { $type->buildBlock($this->blockBuilder, $resolvedOptions); $this->registry->buildBlock($type->getName(), $this->blockBuilder, $resolvedOptions); } $this->rawLayout->setProperty($id, RawLayout::RESOLVED_OPTIONS, $resolvedOptions); } else { $this->rawLayout->remove($id); } return $resolvedOptions; }
[ "protected", "function", "setBlockResolvedOptions", "(", "$", "id", ",", "$", "blockType", ",", "$", "options", ",", "$", "types", ")", "{", "// resolve options", "$", "resolvedOptions", "=", "new", "Options", "(", "$", "this", "->", "optionsResolver", "->", "resolveOptions", "(", "$", "blockType", ",", "$", "options", ")", ")", ";", "$", "this", "->", "processExpressions", "(", "$", "resolvedOptions", ")", ";", "$", "resolvedOptions", "=", "$", "this", "->", "resolveValueBags", "(", "$", "resolvedOptions", ")", ";", "if", "(", "$", "resolvedOptions", "->", "get", "(", "'visible'", ",", "false", ")", "!==", "false", ")", "{", "// point the block builder state to the current block", "$", "this", "->", "blockBuilder", "->", "initialize", "(", "$", "id", ")", ";", "// iterate from parent to current", "foreach", "(", "$", "types", "as", "$", "type", ")", "{", "$", "type", "->", "buildBlock", "(", "$", "this", "->", "blockBuilder", ",", "$", "resolvedOptions", ")", ";", "$", "this", "->", "registry", "->", "buildBlock", "(", "$", "type", "->", "getName", "(", ")", ",", "$", "this", "->", "blockBuilder", ",", "$", "resolvedOptions", ")", ";", "}", "$", "this", "->", "rawLayout", "->", "setProperty", "(", "$", "id", ",", "RawLayout", "::", "RESOLVED_OPTIONS", ",", "$", "resolvedOptions", ")", ";", "}", "else", "{", "$", "this", "->", "rawLayout", "->", "remove", "(", "$", "id", ")", ";", "}", "return", "$", "resolvedOptions", ";", "}" ]
Setting resolved options for block @param string $id @param string $blockType @param array $options @param array $types @return Options
[ "Setting", "resolved", "options", "for", "block" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/BlockFactory.php#L354-L376
flipboxfactory/craft-psr3
src/Logger.php
Logger.log
public function log($level, $message, array $context = []) { // Resolve category from 'context' $category = ArrayHelper::remove($context, 'category', $this->category); // Resolve level $level = ArrayHelper::getValue($this->map, $level, $this->level); $this->logger->log( $this->interpolate($message, $context), $level, $category ); }
php
public function log($level, $message, array $context = []) { // Resolve category from 'context' $category = ArrayHelper::remove($context, 'category', $this->category); // Resolve level $level = ArrayHelper::getValue($this->map, $level, $this->level); $this->logger->log( $this->interpolate($message, $context), $level, $category ); }
[ "public", "function", "log", "(", "$", "level", ",", "$", "message", ",", "array", "$", "context", "=", "[", "]", ")", "{", "// Resolve category from 'context'", "$", "category", "=", "ArrayHelper", "::", "remove", "(", "$", "context", ",", "'category'", ",", "$", "this", "->", "category", ")", ";", "// Resolve level", "$", "level", "=", "ArrayHelper", "::", "getValue", "(", "$", "this", "->", "map", ",", "$", "level", ",", "$", "this", "->", "level", ")", ";", "$", "this", "->", "logger", "->", "log", "(", "$", "this", "->", "interpolate", "(", "$", "message", ",", "$", "context", ")", ",", "$", "level", ",", "$", "category", ")", ";", "}" ]
Log a message, transforming from PSR3 to the closest Yii2. @inheritdoc
[ "Log", "a", "message", "transforming", "from", "PSR3", "to", "the", "closest", "Yii2", "." ]
train
https://github.com/flipboxfactory/craft-psr3/blob/cac258edc823fddd42f18904a94d603d51d80177/src/Logger.php#L76-L89
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/common_sql_writer.php
ezcDbSchemaCommonSqlWriter.saveToDb
public function saveToDb( ezcDbHandler $db, ezcDbSchema $dbSchema ) { $db->beginTransaction(); foreach ( $this->convertToDDL( $dbSchema ) as $query ) { if ( $this->isQueryAllowed( $db, $query ) ) { $db->exec( $query ); } } $db->commit(); }
php
public function saveToDb( ezcDbHandler $db, ezcDbSchema $dbSchema ) { $db->beginTransaction(); foreach ( $this->convertToDDL( $dbSchema ) as $query ) { if ( $this->isQueryAllowed( $db, $query ) ) { $db->exec( $query ); } } $db->commit(); }
[ "public", "function", "saveToDb", "(", "ezcDbHandler", "$", "db", ",", "ezcDbSchema", "$", "dbSchema", ")", "{", "$", "db", "->", "beginTransaction", "(", ")", ";", "foreach", "(", "$", "this", "->", "convertToDDL", "(", "$", "dbSchema", ")", "as", "$", "query", ")", "{", "if", "(", "$", "this", "->", "isQueryAllowed", "(", "$", "db", ",", "$", "query", ")", ")", "{", "$", "db", "->", "exec", "(", "$", "query", ")", ";", "}", "}", "$", "db", "->", "commit", "(", ")", ";", "}" ]
Creates the tables contained in $schema in the database that is related to $db This method takes the table definitions from $schema and will create the tables according to this definition in the database that is references by the $db handler. If tables with the same name as contained in the definitions already exist they will be removed and recreated with the new definition. @param ezcDbHandler $db @param ezcDbSchema $dbSchema
[ "Creates", "the", "tables", "contained", "in", "$schema", "in", "the", "database", "that", "is", "related", "to", "$db" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/common_sql_writer.php#L58-L69
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/common_sql_writer.php
ezcDbSchemaCommonSqlWriter.convertToDDL
public function convertToDDL( ezcDbSchema $dbSchema ) { $this->schema = $dbSchema->getSchema(); // reset queries $this->queries = array(); $this->context = array(); $this->generateSchemaAsSql(); return $this->queries; }
php
public function convertToDDL( ezcDbSchema $dbSchema ) { $this->schema = $dbSchema->getSchema(); // reset queries $this->queries = array(); $this->context = array(); $this->generateSchemaAsSql(); return $this->queries; }
[ "public", "function", "convertToDDL", "(", "ezcDbSchema", "$", "dbSchema", ")", "{", "$", "this", "->", "schema", "=", "$", "dbSchema", "->", "getSchema", "(", ")", ";", "// reset queries", "$", "this", "->", "queries", "=", "array", "(", ")", ";", "$", "this", "->", "context", "=", "array", "(", ")", ";", "$", "this", "->", "generateSchemaAsSql", "(", ")", ";", "return", "$", "this", "->", "queries", ";", "}" ]
Returns an array with SQL DDL statements that creates the database definition in $dbSchema Converts the schema definition contained in $dbSchema to DDL SQL. This SQL can be used to create tables in an existing database according to the definition. The SQL queries are returned as an array. @param ezcDbSchema $dbSchema @return array(string)
[ "Returns", "an", "array", "with", "SQL", "DDL", "statements", "that", "creates", "the", "database", "definition", "in", "$dbSchema" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/common_sql_writer.php#L81-L91
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/common_sql_writer.php
ezcDbSchemaCommonSqlWriter.generateSchemaAsSql
protected function generateSchemaAsSql() { $prefix = ezcDbSchema::$options->tableNamePrefix; foreach ( $this->schema as $tableName => $tableDefinition ) { $this->generateDropTableSql( $prefix . $tableName ); $this->generateCreateTableSql( $prefix . $tableName, $tableDefinition ); } }
php
protected function generateSchemaAsSql() { $prefix = ezcDbSchema::$options->tableNamePrefix; foreach ( $this->schema as $tableName => $tableDefinition ) { $this->generateDropTableSql( $prefix . $tableName ); $this->generateCreateTableSql( $prefix . $tableName, $tableDefinition ); } }
[ "protected", "function", "generateSchemaAsSql", "(", ")", "{", "$", "prefix", "=", "ezcDbSchema", "::", "$", "options", "->", "tableNamePrefix", ";", "foreach", "(", "$", "this", "->", "schema", "as", "$", "tableName", "=>", "$", "tableDefinition", ")", "{", "$", "this", "->", "generateDropTableSql", "(", "$", "prefix", ".", "$", "tableName", ")", ";", "$", "this", "->", "generateCreateTableSql", "(", "$", "prefix", ".", "$", "tableName", ",", "$", "tableDefinition", ")", ";", "}", "}" ]
Creates SQL DDL statements from a schema definitin. Loops over the tables in the schema definition in $this->schema and creates SQL SSL statements for this which it stores internally into the $this->queries array.
[ "Creates", "SQL", "DDL", "statements", "from", "a", "schema", "definitin", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/common_sql_writer.php#L116-L124
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/common_sql_writer.php
ezcDbSchemaCommonSqlWriter.generateCreateTableSql
protected function generateCreateTableSql( $tableName, ezcDbSchemaTable $tableDefinition ) { $sql = $this->generateCreateTableSqlStatement( $tableName ); $sql .= " (\n"; // dump fields $fieldsSQL = array(); foreach ( $tableDefinition->fields as $fieldName => $fieldDefinition ) { $fieldsSQL[] = "\t" . $this->generateFieldSql( $fieldName, $fieldDefinition ); } $sql .= join( ",\n", $fieldsSQL ); $sql .= "\n)"; $this->queries[] = $sql; // dump indexes foreach ( $tableDefinition->indexes as $indexName => $indexDefinition) { $fieldsSQL[] = $this->generateAddIndexSql( $tableName, $indexName, $indexDefinition ); } }
php
protected function generateCreateTableSql( $tableName, ezcDbSchemaTable $tableDefinition ) { $sql = $this->generateCreateTableSqlStatement( $tableName ); $sql .= " (\n"; // dump fields $fieldsSQL = array(); foreach ( $tableDefinition->fields as $fieldName => $fieldDefinition ) { $fieldsSQL[] = "\t" . $this->generateFieldSql( $fieldName, $fieldDefinition ); } $sql .= join( ",\n", $fieldsSQL ); $sql .= "\n)"; $this->queries[] = $sql; // dump indexes foreach ( $tableDefinition->indexes as $indexName => $indexDefinition) { $fieldsSQL[] = $this->generateAddIndexSql( $tableName, $indexName, $indexDefinition ); } }
[ "protected", "function", "generateCreateTableSql", "(", "$", "tableName", ",", "ezcDbSchemaTable", "$", "tableDefinition", ")", "{", "$", "sql", "=", "$", "this", "->", "generateCreateTableSqlStatement", "(", "$", "tableName", ")", ";", "$", "sql", ".=", "\" (\\n\"", ";", "// dump fields", "$", "fieldsSQL", "=", "array", "(", ")", ";", "foreach", "(", "$", "tableDefinition", "->", "fields", "as", "$", "fieldName", "=>", "$", "fieldDefinition", ")", "{", "$", "fieldsSQL", "[", "]", "=", "\"\\t\"", ".", "$", "this", "->", "generateFieldSql", "(", "$", "fieldName", ",", "$", "fieldDefinition", ")", ";", "}", "$", "sql", ".=", "join", "(", "\",\\n\"", ",", "$", "fieldsSQL", ")", ";", "$", "sql", ".=", "\"\\n)\"", ";", "$", "this", "->", "queries", "[", "]", "=", "$", "sql", ";", "// dump indexes", "foreach", "(", "$", "tableDefinition", "->", "indexes", "as", "$", "indexName", "=>", "$", "indexDefinition", ")", "{", "$", "fieldsSQL", "[", "]", "=", "$", "this", "->", "generateAddIndexSql", "(", "$", "tableName", ",", "$", "indexName", ",", "$", "indexDefinition", ")", ";", "}", "}" ]
Adds a "create table" query for the table $tableName with definition $tableDefinition to the internal list of queries. @param string $tableName @param ezcDbSchemaTable $tableDefinition
[ "Adds", "a", "create", "table", "query", "for", "the", "table", "$tableName", "with", "definition", "$tableDefinition", "to", "the", "internal", "list", "of", "queries", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/common_sql_writer.php#L143-L168
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/common_sql_writer.php
ezcDbSchemaCommonSqlWriter.generateDefault
protected function generateDefault( $type, $value ) { switch ( $type ) { case 'boolean': return ( $value && $value != 'false' ) ? 'true' : 'false'; case 'integer': return (int) $value; case 'float': case 'decimal': return (float) $value; case 'timestamp': return (int) $value; default: return "'$value'"; } }
php
protected function generateDefault( $type, $value ) { switch ( $type ) { case 'boolean': return ( $value && $value != 'false' ) ? 'true' : 'false'; case 'integer': return (int) $value; case 'float': case 'decimal': return (float) $value; case 'timestamp': return (int) $value; default: return "'$value'"; } }
[ "protected", "function", "generateDefault", "(", "$", "type", ",", "$", "value", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'boolean'", ":", "return", "(", "$", "value", "&&", "$", "value", "!=", "'false'", ")", "?", "'true'", ":", "'false'", ";", "case", "'integer'", ":", "return", "(", "int", ")", "$", "value", ";", "case", "'float'", ":", "case", "'decimal'", ":", "return", "(", "float", ")", "$", "value", ";", "case", "'timestamp'", ":", "return", "(", "int", ")", "$", "value", ";", "default", ":", "return", "\"'$value'\"", ";", "}", "}" ]
Returns an appropriate default value for $type with $value. @param string $type @param mixed $value @return string
[ "Returns", "an", "appropriate", "default", "value", "for", "$type", "with", "$value", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/common_sql_writer.php#L177-L197
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/common_sql_writer.php
ezcDbSchemaCommonSqlWriter.generateDiffSchemaAsSql
protected function generateDiffSchemaAsSql() { foreach ( $this->diffSchema->changedTables as $tableName => $tableDiff ) { $this->generateDiffSchemaTableAsSql( $tableName, $tableDiff ); } foreach ( $this->diffSchema->newTables as $tableName => $tableDef ) { $this->generateCreateTableSql( $tableName, $tableDef ); } foreach ( $this->diffSchema->removedTables as $tableName => $dummy ) { $this->generateDropTableSql( $tableName ); } }
php
protected function generateDiffSchemaAsSql() { foreach ( $this->diffSchema->changedTables as $tableName => $tableDiff ) { $this->generateDiffSchemaTableAsSql( $tableName, $tableDiff ); } foreach ( $this->diffSchema->newTables as $tableName => $tableDef ) { $this->generateCreateTableSql( $tableName, $tableDef ); } foreach ( $this->diffSchema->removedTables as $tableName => $dummy ) { $this->generateDropTableSql( $tableName ); } }
[ "protected", "function", "generateDiffSchemaAsSql", "(", ")", "{", "foreach", "(", "$", "this", "->", "diffSchema", "->", "changedTables", "as", "$", "tableName", "=>", "$", "tableDiff", ")", "{", "$", "this", "->", "generateDiffSchemaTableAsSql", "(", "$", "tableName", ",", "$", "tableDiff", ")", ";", "}", "foreach", "(", "$", "this", "->", "diffSchema", "->", "newTables", "as", "$", "tableName", "=>", "$", "tableDef", ")", "{", "$", "this", "->", "generateCreateTableSql", "(", "$", "tableName", ",", "$", "tableDef", ")", ";", "}", "foreach", "(", "$", "this", "->", "diffSchema", "->", "removedTables", "as", "$", "tableName", "=>", "$", "dummy", ")", "{", "$", "this", "->", "generateDropTableSql", "(", "$", "tableName", ")", ";", "}", "}" ]
Generates queries to upgrade an existing database with the changes stored in $this->diffSchema. This method generates queries to migrate a database to a new version with the changes that are stored in the $this->diffSchema property. It will call different subfunctions for the different types of changes, and those functions will add queries to the internal list of queries that is stored in $this->queries.
[ "Generates", "queries", "to", "upgrade", "an", "existing", "database", "with", "the", "changes", "stored", "in", "$this", "-", ">", "diffSchema", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/common_sql_writer.php#L208-L224
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/common_sql_writer.php
ezcDbSchemaCommonSqlWriter.generateDiffSchemaTableAsSql
protected function generateDiffSchemaTableAsSql( $tableName, ezcDbSchemaTableDiff $tableDiff ) { foreach ( $tableDiff->removedIndexes as $indexName => $isRemoved ) { if ( $isRemoved ) { $this->generateDropIndexSql( $tableName, $indexName ); } } foreach ( $tableDiff->changedIndexes as $indexName => $indexDefinition ) { $this->generateDropIndexSql( $tableName, $indexName ); } foreach ( $tableDiff->removedFields as $fieldName => $isRemoved ) { if ( $isRemoved ) { $this->generateDropFieldSql( $tableName, $fieldName ); } } foreach ( $tableDiff->changedFields as $fieldName => $fieldDefinition ) { $this->generateChangeFieldSql( $tableName, $fieldName, $fieldDefinition ); } foreach ( $tableDiff->addedFields as $fieldName => $fieldDefinition ) { $this->generateAddFieldSql( $tableName, $fieldName, $fieldDefinition ); } foreach ( $tableDiff->changedIndexes as $indexName => $indexDefinition ) { $this->generateAddIndexSql( $tableName, $indexName, $indexDefinition ); } foreach ( $tableDiff->addedIndexes as $indexName => $indexDefinition ) { $this->generateAddIndexSql( $tableName, $indexName, $indexDefinition ); } }
php
protected function generateDiffSchemaTableAsSql( $tableName, ezcDbSchemaTableDiff $tableDiff ) { foreach ( $tableDiff->removedIndexes as $indexName => $isRemoved ) { if ( $isRemoved ) { $this->generateDropIndexSql( $tableName, $indexName ); } } foreach ( $tableDiff->changedIndexes as $indexName => $indexDefinition ) { $this->generateDropIndexSql( $tableName, $indexName ); } foreach ( $tableDiff->removedFields as $fieldName => $isRemoved ) { if ( $isRemoved ) { $this->generateDropFieldSql( $tableName, $fieldName ); } } foreach ( $tableDiff->changedFields as $fieldName => $fieldDefinition ) { $this->generateChangeFieldSql( $tableName, $fieldName, $fieldDefinition ); } foreach ( $tableDiff->addedFields as $fieldName => $fieldDefinition ) { $this->generateAddFieldSql( $tableName, $fieldName, $fieldDefinition ); } foreach ( $tableDiff->changedIndexes as $indexName => $indexDefinition ) { $this->generateAddIndexSql( $tableName, $indexName, $indexDefinition ); } foreach ( $tableDiff->addedIndexes as $indexName => $indexDefinition ) { $this->generateAddIndexSql( $tableName, $indexName, $indexDefinition ); } }
[ "protected", "function", "generateDiffSchemaTableAsSql", "(", "$", "tableName", ",", "ezcDbSchemaTableDiff", "$", "tableDiff", ")", "{", "foreach", "(", "$", "tableDiff", "->", "removedIndexes", "as", "$", "indexName", "=>", "$", "isRemoved", ")", "{", "if", "(", "$", "isRemoved", ")", "{", "$", "this", "->", "generateDropIndexSql", "(", "$", "tableName", ",", "$", "indexName", ")", ";", "}", "}", "foreach", "(", "$", "tableDiff", "->", "changedIndexes", "as", "$", "indexName", "=>", "$", "indexDefinition", ")", "{", "$", "this", "->", "generateDropIndexSql", "(", "$", "tableName", ",", "$", "indexName", ")", ";", "}", "foreach", "(", "$", "tableDiff", "->", "removedFields", "as", "$", "fieldName", "=>", "$", "isRemoved", ")", "{", "if", "(", "$", "isRemoved", ")", "{", "$", "this", "->", "generateDropFieldSql", "(", "$", "tableName", ",", "$", "fieldName", ")", ";", "}", "}", "foreach", "(", "$", "tableDiff", "->", "changedFields", "as", "$", "fieldName", "=>", "$", "fieldDefinition", ")", "{", "$", "this", "->", "generateChangeFieldSql", "(", "$", "tableName", ",", "$", "fieldName", ",", "$", "fieldDefinition", ")", ";", "}", "foreach", "(", "$", "tableDiff", "->", "addedFields", "as", "$", "fieldName", "=>", "$", "fieldDefinition", ")", "{", "$", "this", "->", "generateAddFieldSql", "(", "$", "tableName", ",", "$", "fieldName", ",", "$", "fieldDefinition", ")", ";", "}", "foreach", "(", "$", "tableDiff", "->", "changedIndexes", "as", "$", "indexName", "=>", "$", "indexDefinition", ")", "{", "$", "this", "->", "generateAddIndexSql", "(", "$", "tableName", ",", "$", "indexName", ",", "$", "indexDefinition", ")", ";", "}", "foreach", "(", "$", "tableDiff", "->", "addedIndexes", "as", "$", "indexName", "=>", "$", "indexDefinition", ")", "{", "$", "this", "->", "generateAddIndexSql", "(", "$", "tableName", ",", "$", "indexName", ",", "$", "indexDefinition", ")", ";", "}", "}" ]
Generates queries to upgrade a the table $tableName with the differences in $tableDiff. This method generates queries to migrate a table to a new version with the changes that are stored in the $tableDiff property. It will call different subfunctions for the different types of changes, and those functions will add queries to the internal list of queries that is stored in $this->queries. @param string $tableName @param ezcDbSchemaTableDiff $tableDiff
[ "Generates", "queries", "to", "upgrade", "a", "the", "table", "$tableName", "with", "the", "differences", "in", "$tableDiff", "." ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/handlers/common_sql_writer.php#L238-L280
jim-moser/zf2-validators-empty-or
src/OrChain.php
OrChain.attachByName
public function attachByName($name, $options = array(), $showMessages = true, $priority = self::DEFAULT_PRIORITY) { $validator = $this->plugin($name, $options); if (isset($options['show_messages'])) { $showMessages = (bool) $options['show_messages']; } if (isset($options['priority'])) { $priority = (int) $options['priority']; } $this->attach($validator, $showMessages, $priority); return $this; }
php
public function attachByName($name, $options = array(), $showMessages = true, $priority = self::DEFAULT_PRIORITY) { $validator = $this->plugin($name, $options); if (isset($options['show_messages'])) { $showMessages = (bool) $options['show_messages']; } if (isset($options['priority'])) { $priority = (int) $options['priority']; } $this->attach($validator, $showMessages, $priority); return $this; }
[ "public", "function", "attachByName", "(", "$", "name", ",", "$", "options", "=", "array", "(", ")", ",", "$", "showMessages", "=", "true", ",", "$", "priority", "=", "self", "::", "DEFAULT_PRIORITY", ")", "{", "$", "validator", "=", "$", "this", "->", "plugin", "(", "$", "name", ",", "$", "options", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'show_messages'", "]", ")", ")", "{", "$", "showMessages", "=", "(", "bool", ")", "$", "options", "[", "'show_messages'", "]", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'priority'", "]", ")", ")", "{", "$", "priority", "=", "(", "int", ")", "$", "options", "[", "'priority'", "]", ";", "}", "$", "this", "->", "attach", "(", "$", "validator", ",", "$", "showMessages", ",", "$", "priority", ")", ";", "return", "$", "this", ";", "}" ]
Uses plugin manager to add validator by name. @param string $name @param array $options @param boolean $showMessages Show messages for this validator on failure. @param int $priority Validator's priority. @return self
[ "Uses", "plugin", "manager", "to", "add", "validator", "by", "name", "." ]
train
https://github.com/jim-moser/zf2-validators-empty-or/blob/12f799e18ff59986c23ff3f934702834046438f2/src/OrChain.php#L222-L236
jim-moser/zf2-validators-empty-or
src/OrChain.php
OrChain.prependByName
public function prependByName($name, $options = array(), $showMessages = true) { $validator = $this->plugin($name, $options); //To do. Investigate why Zend\Validator\ValidatorChain does not check //for $options['break_on_failure'] in this method. if (isset($options['show_messages'])) { $showMessages = (bool) $options['show_messages']; } $this->prependValidator($validator, $showMessages); return $this; }
php
public function prependByName($name, $options = array(), $showMessages = true) { $validator = $this->plugin($name, $options); //To do. Investigate why Zend\Validator\ValidatorChain does not check //for $options['break_on_failure'] in this method. if (isset($options['show_messages'])) { $showMessages = (bool) $options['show_messages']; } $this->prependValidator($validator, $showMessages); return $this; }
[ "public", "function", "prependByName", "(", "$", "name", ",", "$", "options", "=", "array", "(", ")", ",", "$", "showMessages", "=", "true", ")", "{", "$", "validator", "=", "$", "this", "->", "plugin", "(", "$", "name", ",", "$", "options", ")", ";", "//To do. Investigate why Zend\\Validator\\ValidatorChain does not check ", "//for $options['break_on_failure'] in this method.", "if", "(", "isset", "(", "$", "options", "[", "'show_messages'", "]", ")", ")", "{", "$", "showMessages", "=", "(", "bool", ")", "$", "options", "[", "'show_messages'", "]", ";", "}", "$", "this", "->", "prependValidator", "(", "$", "validator", ",", "$", "showMessages", ")", ";", "return", "$", "this", ";", "}" ]
Uses plugin manager to prepend validator by name. @param string $name @param array $options @param boolean $showMessages Show messages for this validator on failure. @return self
[ "Uses", "plugin", "manager", "to", "prepend", "validator", "by", "name", "." ]
train
https://github.com/jim-moser/zf2-validators-empty-or/blob/12f799e18ff59986c23ff3f934702834046438f2/src/OrChain.php#L247-L260
jim-moser/zf2-validators-empty-or
src/OrChain.php
OrChain.isValid
public function isValid($value, $context = null) { $allMessageData = array(); $this->setValue($value); foreach ($this->validators as $element) { $validator = $element['instance']; // Chain is valid if any single validator in chain is valid. if ($validator->isValid($value, $context)) { $this->abstractOptions['messages'] = array(); return true; } if ($element['show_messages']) { $messages = $validator->getMessages(); if (!empty($messages)) { $allMessageData[] = array( 'messages' => $messages, ); } } } $this->abstractOptions['messages'] = $this-> aggregateMessages($allMessageData); return false; }
php
public function isValid($value, $context = null) { $allMessageData = array(); $this->setValue($value); foreach ($this->validators as $element) { $validator = $element['instance']; // Chain is valid if any single validator in chain is valid. if ($validator->isValid($value, $context)) { $this->abstractOptions['messages'] = array(); return true; } if ($element['show_messages']) { $messages = $validator->getMessages(); if (!empty($messages)) { $allMessageData[] = array( 'messages' => $messages, ); } } } $this->abstractOptions['messages'] = $this-> aggregateMessages($allMessageData); return false; }
[ "public", "function", "isValid", "(", "$", "value", ",", "$", "context", "=", "null", ")", "{", "$", "allMessageData", "=", "array", "(", ")", ";", "$", "this", "->", "setValue", "(", "$", "value", ")", ";", "foreach", "(", "$", "this", "->", "validators", "as", "$", "element", ")", "{", "$", "validator", "=", "$", "element", "[", "'instance'", "]", ";", "// Chain is valid if any single validator in chain is valid.", "if", "(", "$", "validator", "->", "isValid", "(", "$", "value", ",", "$", "context", ")", ")", "{", "$", "this", "->", "abstractOptions", "[", "'messages'", "]", "=", "array", "(", ")", ";", "return", "true", ";", "}", "if", "(", "$", "element", "[", "'show_messages'", "]", ")", "{", "$", "messages", "=", "$", "validator", "->", "getMessages", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "messages", ")", ")", "{", "$", "allMessageData", "[", "]", "=", "array", "(", "'messages'", "=>", "$", "messages", ",", ")", ";", "}", "}", "}", "$", "this", "->", "abstractOptions", "[", "'messages'", "]", "=", "$", "this", "->", "aggregateMessages", "(", "$", "allMessageData", ")", ";", "return", "false", ";", "}" ]
Returns true if $value is valid for any validator in chain. The validators are run in the order in which they appear in the priority queue. If any validator in the chain validates then the chain is considered valid and validation is not performed on any trailing validators. @param mixed $value @param mixed $context Extra "context" to provide validator. @return bool
[ "Returns", "true", "if", "$value", "is", "valid", "for", "any", "validator", "in", "chain", "." ]
train
https://github.com/jim-moser/zf2-validators-empty-or/blob/12f799e18ff59986c23ff3f934702834046438f2/src/OrChain.php#L274-L302
jim-moser/zf2-validators-empty-or
src/OrChain.php
OrChain.getValidators
public function getValidators() { $allValidatorData = $this->validators-> toArray(PriorityQueue::EXTR_DATA); foreach ($allValidatorData as $key => $validatorData) { $allValidatorData[$key] = $validatorData['instance']; } return $allValidatorData; }
php
public function getValidators() { $allValidatorData = $this->validators-> toArray(PriorityQueue::EXTR_DATA); foreach ($allValidatorData as $key => $validatorData) { $allValidatorData[$key] = $validatorData['instance']; } return $allValidatorData; }
[ "public", "function", "getValidators", "(", ")", "{", "$", "allValidatorData", "=", "$", "this", "->", "validators", "->", "toArray", "(", "PriorityQueue", "::", "EXTR_DATA", ")", ";", "foreach", "(", "$", "allValidatorData", "as", "$", "key", "=>", "$", "validatorData", ")", "{", "$", "allValidatorData", "[", "$", "key", "]", "=", "$", "validatorData", "[", "'instance'", "]", ";", "}", "return", "$", "allValidatorData", ";", "}" ]
Returns array of all validators. @return PriorityQueue
[ "Returns", "array", "of", "all", "validators", "." ]
train
https://github.com/jim-moser/zf2-validators-empty-or/blob/12f799e18ff59986c23ff3f934702834046438f2/src/OrChain.php#L376-L384
activecollab/controller
src/ResultEncoder/ResultEncoder.php
ResultEncoder.encode
public function encode($action_result, ServerRequestInterface $request, ResponseInterface $response) { if ($action_result instanceof ResponseInterface) { return $action_result; } if ($action_result instanceof FileDownloadResponse) { return $action_result->createPsrResponse(); } if ($action_result instanceof ViewResponseInterface) { return $action_result->render($response); } $response = $response->withHeader('Content-Type', 'application/json;charset=UTF-8'); if ($action_result === null) { return $response; } elseif ($action_result instanceof StatusResponseInterface) { return $this->encodeStatus($action_result, $response); } elseif (is_array($action_result)) { if (isset($action_result['status']) && isset($action_result['body'])) { return $this->encodeArray($action_result['body'], $response, $action_result['status']); } return $this->encodeArray($action_result, $response); } elseif (is_scalar($action_result)) { return $this->encodeScalar($action_result, $response); } elseif ($action_result instanceof Throwable || $action_result instanceof Exception) { return $this->encodeException($action_result, $response); } else { return $this->onNoEncoderApplied($action_result, $request, $response); } }
php
public function encode($action_result, ServerRequestInterface $request, ResponseInterface $response) { if ($action_result instanceof ResponseInterface) { return $action_result; } if ($action_result instanceof FileDownloadResponse) { return $action_result->createPsrResponse(); } if ($action_result instanceof ViewResponseInterface) { return $action_result->render($response); } $response = $response->withHeader('Content-Type', 'application/json;charset=UTF-8'); if ($action_result === null) { return $response; } elseif ($action_result instanceof StatusResponseInterface) { return $this->encodeStatus($action_result, $response); } elseif (is_array($action_result)) { if (isset($action_result['status']) && isset($action_result['body'])) { return $this->encodeArray($action_result['body'], $response, $action_result['status']); } return $this->encodeArray($action_result, $response); } elseif (is_scalar($action_result)) { return $this->encodeScalar($action_result, $response); } elseif ($action_result instanceof Throwable || $action_result instanceof Exception) { return $this->encodeException($action_result, $response); } else { return $this->onNoEncoderApplied($action_result, $request, $response); } }
[ "public", "function", "encode", "(", "$", "action_result", ",", "ServerRequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ")", "{", "if", "(", "$", "action_result", "instanceof", "ResponseInterface", ")", "{", "return", "$", "action_result", ";", "}", "if", "(", "$", "action_result", "instanceof", "FileDownloadResponse", ")", "{", "return", "$", "action_result", "->", "createPsrResponse", "(", ")", ";", "}", "if", "(", "$", "action_result", "instanceof", "ViewResponseInterface", ")", "{", "return", "$", "action_result", "->", "render", "(", "$", "response", ")", ";", "}", "$", "response", "=", "$", "response", "->", "withHeader", "(", "'Content-Type'", ",", "'application/json;charset=UTF-8'", ")", ";", "if", "(", "$", "action_result", "===", "null", ")", "{", "return", "$", "response", ";", "}", "elseif", "(", "$", "action_result", "instanceof", "StatusResponseInterface", ")", "{", "return", "$", "this", "->", "encodeStatus", "(", "$", "action_result", ",", "$", "response", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "action_result", ")", ")", "{", "if", "(", "isset", "(", "$", "action_result", "[", "'status'", "]", ")", "&&", "isset", "(", "$", "action_result", "[", "'body'", "]", ")", ")", "{", "return", "$", "this", "->", "encodeArray", "(", "$", "action_result", "[", "'body'", "]", ",", "$", "response", ",", "$", "action_result", "[", "'status'", "]", ")", ";", "}", "return", "$", "this", "->", "encodeArray", "(", "$", "action_result", ",", "$", "response", ")", ";", "}", "elseif", "(", "is_scalar", "(", "$", "action_result", ")", ")", "{", "return", "$", "this", "->", "encodeScalar", "(", "$", "action_result", ",", "$", "response", ")", ";", "}", "elseif", "(", "$", "action_result", "instanceof", "Throwable", "||", "$", "action_result", "instanceof", "Exception", ")", "{", "return", "$", "this", "->", "encodeException", "(", "$", "action_result", ",", "$", "response", ")", ";", "}", "else", "{", "return", "$", "this", "->", "onNoEncoderApplied", "(", "$", "action_result", ",", "$", "request", ",", "$", "response", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/activecollab/controller/blob/51d24f3f203f7f5ae56edde2e35b5ef2d9293caa/src/ResultEncoder/ResultEncoder.php#L51-L84
activecollab/controller
src/ResultEncoder/ResultEncoder.php
ResultEncoder.encodeArray
protected function encodeArray(array $action_result, ResponseInterface $response, $status = 200) { return $response->write(json_encode($action_result))->withStatus($status); }
php
protected function encodeArray(array $action_result, ResponseInterface $response, $status = 200) { return $response->write(json_encode($action_result))->withStatus($status); }
[ "protected", "function", "encodeArray", "(", "array", "$", "action_result", ",", "ResponseInterface", "$", "response", ",", "$", "status", "=", "200", ")", "{", "return", "$", "response", "->", "write", "(", "json_encode", "(", "$", "action_result", ")", ")", "->", "withStatus", "(", "$", "status", ")", ";", "}" ]
Encode regular array response, with status 200. @param array $action_result @param ResponseInterface $response @param int $status @return ResponseInterface
[ "Encode", "regular", "array", "response", "with", "status", "200", "." ]
train
https://github.com/activecollab/controller/blob/51d24f3f203f7f5ae56edde2e35b5ef2d9293caa/src/ResultEncoder/ResultEncoder.php#L107-L110
activecollab/controller
src/ResultEncoder/ResultEncoder.php
ResultEncoder.encodeScalar
protected function encodeScalar($action_result, ResponseInterface $response, $status = 200) { return $response->write(json_encode($action_result))->withStatus($status); }
php
protected function encodeScalar($action_result, ResponseInterface $response, $status = 200) { return $response->write(json_encode($action_result))->withStatus($status); }
[ "protected", "function", "encodeScalar", "(", "$", "action_result", ",", "ResponseInterface", "$", "response", ",", "$", "status", "=", "200", ")", "{", "return", "$", "response", "->", "write", "(", "json_encode", "(", "$", "action_result", ")", ")", "->", "withStatus", "(", "$", "status", ")", ";", "}" ]
Encode scalar value, with status 200. @param mixed $action_result @param ResponseInterface $response @param int $status @return ResponseInterface
[ "Encode", "scalar", "value", "with", "status", "200", "." ]
train
https://github.com/activecollab/controller/blob/51d24f3f203f7f5ae56edde2e35b5ef2d9293caa/src/ResultEncoder/ResultEncoder.php#L120-L123
activecollab/controller
src/ResultEncoder/ResultEncoder.php
ResultEncoder.encodeStatus
protected function encodeStatus(StatusResponse $action_result, ResponseInterface $response) { $response = $response->withStatus($action_result->getHttpCode(), $action_result->getMessage()); if ($action_result->getHttpCode() >= 400) { $response = $response->write(json_encode(['message' => $action_result->getMessage()])); } return $response; }
php
protected function encodeStatus(StatusResponse $action_result, ResponseInterface $response) { $response = $response->withStatus($action_result->getHttpCode(), $action_result->getMessage()); if ($action_result->getHttpCode() >= 400) { $response = $response->write(json_encode(['message' => $action_result->getMessage()])); } return $response; }
[ "protected", "function", "encodeStatus", "(", "StatusResponse", "$", "action_result", ",", "ResponseInterface", "$", "response", ")", "{", "$", "response", "=", "$", "response", "->", "withStatus", "(", "$", "action_result", "->", "getHttpCode", "(", ")", ",", "$", "action_result", "->", "getMessage", "(", ")", ")", ";", "if", "(", "$", "action_result", "->", "getHttpCode", "(", ")", ">=", "400", ")", "{", "$", "response", "=", "$", "response", "->", "write", "(", "json_encode", "(", "[", "'message'", "=>", "$", "action_result", "->", "getMessage", "(", ")", "]", ")", ")", ";", "}", "return", "$", "response", ";", "}" ]
Encode and return status response. @param StatusResponse $action_result @param ResponseInterface $response @return ResponseInterface
[ "Encode", "and", "return", "status", "response", "." ]
train
https://github.com/activecollab/controller/blob/51d24f3f203f7f5ae56edde2e35b5ef2d9293caa/src/ResultEncoder/ResultEncoder.php#L132-L141
activecollab/controller
src/ResultEncoder/ResultEncoder.php
ResultEncoder.encodeException
protected function encodeException($exception, ResponseInterface $response, $status = 500) { $error = ['message' => $exception->getMessage(), 'type' => get_class($exception)]; if ($this->getDisplayErrorDetails()) { $error['exception'] = []; do { $error['exception'][] = [ 'type' => get_class($exception), 'code' => $exception->getCode(), 'message' => $exception->getMessage(), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'trace' => explode("\n", $exception->getTraceAsString()), ]; } while ($exception = $exception->getPrevious()); } return $response->write(json_encode($error))->withStatus($status); }
php
protected function encodeException($exception, ResponseInterface $response, $status = 500) { $error = ['message' => $exception->getMessage(), 'type' => get_class($exception)]; if ($this->getDisplayErrorDetails()) { $error['exception'] = []; do { $error['exception'][] = [ 'type' => get_class($exception), 'code' => $exception->getCode(), 'message' => $exception->getMessage(), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'trace' => explode("\n", $exception->getTraceAsString()), ]; } while ($exception = $exception->getPrevious()); } return $response->write(json_encode($error))->withStatus($status); }
[ "protected", "function", "encodeException", "(", "$", "exception", ",", "ResponseInterface", "$", "response", ",", "$", "status", "=", "500", ")", "{", "$", "error", "=", "[", "'message'", "=>", "$", "exception", "->", "getMessage", "(", ")", ",", "'type'", "=>", "get_class", "(", "$", "exception", ")", "]", ";", "if", "(", "$", "this", "->", "getDisplayErrorDetails", "(", ")", ")", "{", "$", "error", "[", "'exception'", "]", "=", "[", "]", ";", "do", "{", "$", "error", "[", "'exception'", "]", "[", "]", "=", "[", "'type'", "=>", "get_class", "(", "$", "exception", ")", ",", "'code'", "=>", "$", "exception", "->", "getCode", "(", ")", ",", "'message'", "=>", "$", "exception", "->", "getMessage", "(", ")", ",", "'file'", "=>", "$", "exception", "->", "getFile", "(", ")", ",", "'line'", "=>", "$", "exception", "->", "getLine", "(", ")", ",", "'trace'", "=>", "explode", "(", "\"\\n\"", ",", "$", "exception", "->", "getTraceAsString", "(", ")", ")", ",", "]", ";", "}", "while", "(", "$", "exception", "=", "$", "exception", "->", "getPrevious", "(", ")", ")", ";", "}", "return", "$", "response", "->", "write", "(", "json_encode", "(", "$", "error", ")", ")", "->", "withStatus", "(", "$", "status", ")", ";", "}" ]
Encode and return exception. @param Throwable|Exception $exception @param ResponseInterface $response @param int $status @return ResponseInterface
[ "Encode", "and", "return", "exception", "." ]
train
https://github.com/activecollab/controller/blob/51d24f3f203f7f5ae56edde2e35b5ef2d9293caa/src/ResultEncoder/ResultEncoder.php#L151-L171
zicht/z
src/Zicht/Tool/Application.php
Application.renderException
public function renderException($e, $output) { if ($output->getVerbosity() > OutputInterface::VERBOSITY_VERBOSE) { parent::renderException($e, $output); } else { /** @var $ancestry \Exception[] */ $ancestry = array(); $maxLength = 0; do { $ancestry[] = $e; $maxLength = max($maxLength, strlen(get_class($e))); $last = $e; } while ($e = $e->getPrevious()); if ($last instanceof VerboseException) { $last->output($output); } else { $depth = 0; foreach ($ancestry as $e) { $output->writeln( sprintf( '%s%-40s %s', ($depth > 0 ? str_repeat(' ', $depth - 1) . '-> ' : ''), '<fg=red;options=bold>' . $e->getMessage() . '</fg=red;options=bold>', $depth == count($ancestry) - 1 ? str_pad('[' . get_class($e) . ']', $maxLength + 15, ' ') : '' ) ); $depth++; } } } $output->writeln('[' . join('::', Debug::$scope) . ']'); }
php
public function renderException($e, $output) { if ($output->getVerbosity() > OutputInterface::VERBOSITY_VERBOSE) { parent::renderException($e, $output); } else { /** @var $ancestry \Exception[] */ $ancestry = array(); $maxLength = 0; do { $ancestry[] = $e; $maxLength = max($maxLength, strlen(get_class($e))); $last = $e; } while ($e = $e->getPrevious()); if ($last instanceof VerboseException) { $last->output($output); } else { $depth = 0; foreach ($ancestry as $e) { $output->writeln( sprintf( '%s%-40s %s', ($depth > 0 ? str_repeat(' ', $depth - 1) . '-> ' : ''), '<fg=red;options=bold>' . $e->getMessage() . '</fg=red;options=bold>', $depth == count($ancestry) - 1 ? str_pad('[' . get_class($e) . ']', $maxLength + 15, ' ') : '' ) ); $depth++; } } } $output->writeln('[' . join('::', Debug::$scope) . ']'); }
[ "public", "function", "renderException", "(", "$", "e", ",", "$", "output", ")", "{", "if", "(", "$", "output", "->", "getVerbosity", "(", ")", ">", "OutputInterface", "::", "VERBOSITY_VERBOSE", ")", "{", "parent", "::", "renderException", "(", "$", "e", ",", "$", "output", ")", ";", "}", "else", "{", "/** @var $ancestry \\Exception[] */", "$", "ancestry", "=", "array", "(", ")", ";", "$", "maxLength", "=", "0", ";", "do", "{", "$", "ancestry", "[", "]", "=", "$", "e", ";", "$", "maxLength", "=", "max", "(", "$", "maxLength", ",", "strlen", "(", "get_class", "(", "$", "e", ")", ")", ")", ";", "$", "last", "=", "$", "e", ";", "}", "while", "(", "$", "e", "=", "$", "e", "->", "getPrevious", "(", ")", ")", ";", "if", "(", "$", "last", "instanceof", "VerboseException", ")", "{", "$", "last", "->", "output", "(", "$", "output", ")", ";", "}", "else", "{", "$", "depth", "=", "0", ";", "foreach", "(", "$", "ancestry", "as", "$", "e", ")", "{", "$", "output", "->", "writeln", "(", "sprintf", "(", "'%s%-40s %s'", ",", "(", "$", "depth", ">", "0", "?", "str_repeat", "(", "' '", ",", "$", "depth", "-", "1", ")", ".", "'-> '", ":", "''", ")", ",", "'<fg=red;options=bold>'", ".", "$", "e", "->", "getMessage", "(", ")", ".", "'</fg=red;options=bold>'", ",", "$", "depth", "==", "count", "(", "$", "ancestry", ")", "-", "1", "?", "str_pad", "(", "'['", ".", "get_class", "(", "$", "e", ")", ".", "']'", ",", "$", "maxLength", "+", "15", ",", "' '", ")", ":", "''", ")", ")", ";", "$", "depth", "++", ";", "}", "}", "}", "$", "output", "->", "writeln", "(", "'['", ".", "join", "(", "'::'", ",", "Debug", "::", "$", "scope", ")", ".", "']'", ")", ";", "}" ]
Custom exception rendering, renders only the exception types and messages, hierarchically, but with regular formatting if verbosity is higher. @param \Exception $e @param \Symfony\Component\Console\Output\OutputInterface $output @return void
[ "Custom", "exception", "rendering", "renders", "only", "the", "exception", "types", "and", "messages", "hierarchically", "but", "with", "regular", "formatting", "if", "verbosity", "is", "higher", "." ]
train
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Application.php#L66-L98
zicht/z
src/Zicht/Tool/Application.php
Application.getContainer
public function getContainer($forceRecompile = false) { if (null === $this->container) { $config = $this->loader->processConfiguration(); $config['z']['sources'] = $this->loader->getSourceFiles(); $config['z']['cache_file'] = sys_get_temp_dir() . '/z_' . $this->getCacheKey($config) . '.php'; if ($forceRecompile && is_file($config['z']['cache_file'])) { unlink($config['z']['cache_file']); clearstatcache(); } $compiler = new ContainerCompiler( $config, $this->loader->getPlugins(), $config['z']['cache_file'] ); $this->container = $compiler->getContainer(); } return $this->container; }
php
public function getContainer($forceRecompile = false) { if (null === $this->container) { $config = $this->loader->processConfiguration(); $config['z']['sources'] = $this->loader->getSourceFiles(); $config['z']['cache_file'] = sys_get_temp_dir() . '/z_' . $this->getCacheKey($config) . '.php'; if ($forceRecompile && is_file($config['z']['cache_file'])) { unlink($config['z']['cache_file']); clearstatcache(); } $compiler = new ContainerCompiler( $config, $this->loader->getPlugins(), $config['z']['cache_file'] ); $this->container = $compiler->getContainer(); } return $this->container; }
[ "public", "function", "getContainer", "(", "$", "forceRecompile", "=", "false", ")", "{", "if", "(", "null", "===", "$", "this", "->", "container", ")", "{", "$", "config", "=", "$", "this", "->", "loader", "->", "processConfiguration", "(", ")", ";", "$", "config", "[", "'z'", "]", "[", "'sources'", "]", "=", "$", "this", "->", "loader", "->", "getSourceFiles", "(", ")", ";", "$", "config", "[", "'z'", "]", "[", "'cache_file'", "]", "=", "sys_get_temp_dir", "(", ")", ".", "'/z_'", ".", "$", "this", "->", "getCacheKey", "(", "$", "config", ")", ".", "'.php'", ";", "if", "(", "$", "forceRecompile", "&&", "is_file", "(", "$", "config", "[", "'z'", "]", "[", "'cache_file'", "]", ")", ")", "{", "unlink", "(", "$", "config", "[", "'z'", "]", "[", "'cache_file'", "]", ")", ";", "clearstatcache", "(", ")", ";", "}", "$", "compiler", "=", "new", "ContainerCompiler", "(", "$", "config", ",", "$", "this", "->", "loader", "->", "getPlugins", "(", ")", ",", "$", "config", "[", "'z'", "]", "[", "'cache_file'", "]", ")", ";", "$", "this", "->", "container", "=", "$", "compiler", "->", "getContainer", "(", ")", ";", "}", "return", "$", "this", "->", "container", ";", "}" ]
Returns the container instance, and initializes it if not yet available. @param bool $forceRecompile @return Container
[ "Returns", "the", "container", "instance", "and", "initializes", "it", "if", "not", "yet", "available", "." ]
train
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Application.php#L134-L152
OKTOTV/OktolabMediaBundle
Controller/SeriesController.php
SeriesController.newAction
public function newAction(Request $request) { $series = $this->get('oktolab_media')->createSeries(); $form = $this->createForm(SeriesType::class, $series); $form->add('submit', SubmitType::class, ['label' => 'oktolab_media.new_series_button', 'attr' => ['class' => 'btn btn-primary']]); if ($request->getMethod() == "POST") { //sends form $form->handleRequest($request); $em = $this->getDoctrine()->getManager(); if ($form->isValid()) { //form is valid, save or preview if ($form->get('submit')->isClicked()) { //save me $em->persist($series); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'oktolab_media.success_create_series'); return $this->redirect($this->generateUrl('oktolab_series_show', ['series' => $series->getUniqId()])); } else { //??? $this->get('session')->getFlashBag()->add('success', 'oktolab_media.unknown_action_series'); return $this->redirect($this->generateUrl('oktolab_series')); } } $this->get('session')->getFlashBag()->add('error', 'oktolab_media.error_create_series'); } return ['form' => $form->createView()]; }
php
public function newAction(Request $request) { $series = $this->get('oktolab_media')->createSeries(); $form = $this->createForm(SeriesType::class, $series); $form->add('submit', SubmitType::class, ['label' => 'oktolab_media.new_series_button', 'attr' => ['class' => 'btn btn-primary']]); if ($request->getMethod() == "POST") { //sends form $form->handleRequest($request); $em = $this->getDoctrine()->getManager(); if ($form->isValid()) { //form is valid, save or preview if ($form->get('submit')->isClicked()) { //save me $em->persist($series); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'oktolab_media.success_create_series'); return $this->redirect($this->generateUrl('oktolab_series_show', ['series' => $series->getUniqId()])); } else { //??? $this->get('session')->getFlashBag()->add('success', 'oktolab_media.unknown_action_series'); return $this->redirect($this->generateUrl('oktolab_series')); } } $this->get('session')->getFlashBag()->add('error', 'oktolab_media.error_create_series'); } return ['form' => $form->createView()]; }
[ "public", "function", "newAction", "(", "Request", "$", "request", ")", "{", "$", "series", "=", "$", "this", "->", "get", "(", "'oktolab_media'", ")", "->", "createSeries", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "SeriesType", "::", "class", ",", "$", "series", ")", ";", "$", "form", "->", "add", "(", "'submit'", ",", "SubmitType", "::", "class", ",", "[", "'label'", "=>", "'oktolab_media.new_series_button'", ",", "'attr'", "=>", "[", "'class'", "=>", "'btn btn-primary'", "]", "]", ")", ";", "if", "(", "$", "request", "->", "getMethod", "(", ")", "==", "\"POST\"", ")", "{", "//sends form", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "//form is valid, save or preview", "if", "(", "$", "form", "->", "get", "(", "'submit'", ")", "->", "isClicked", "(", ")", ")", "{", "//save me", "$", "em", "->", "persist", "(", "$", "series", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'oktolab_media.success_create_series'", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'oktolab_series_show'", ",", "[", "'series'", "=>", "$", "series", "->", "getUniqId", "(", ")", "]", ")", ")", ";", "}", "else", "{", "//???", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'oktolab_media.unknown_action_series'", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'oktolab_series'", ")", ")", ";", "}", "}", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'error'", ",", "'oktolab_media.error_create_series'", ")", ";", "}", "return", "[", "'form'", "=>", "$", "form", "->", "createView", "(", ")", "]", ";", "}" ]
Displays a form to create a new Series entity. @Route("/new", name="oktolab_series_new") @Method({"GET", "POST"}) @Template()
[ "Displays", "a", "form", "to", "create", "a", "new", "Series", "entity", "." ]
train
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Controller/SeriesController.php#L60-L84
OKTOTV/OktolabMediaBundle
Controller/SeriesController.php
SeriesController.showAction
public function showAction($series) { $series = $this->get('oktolab_media')->getSeries($series); if ($series) { return ['series' => $series]; } $this->get('session')->getFlashBag()->add( 'info', 'oktolab_media.series_not_found' ); return $this->redirect($this->generateUrl('oktolab_series')); }
php
public function showAction($series) { $series = $this->get('oktolab_media')->getSeries($series); if ($series) { return ['series' => $series]; } $this->get('session')->getFlashBag()->add( 'info', 'oktolab_media.series_not_found' ); return $this->redirect($this->generateUrl('oktolab_series')); }
[ "public", "function", "showAction", "(", "$", "series", ")", "{", "$", "series", "=", "$", "this", "->", "get", "(", "'oktolab_media'", ")", "->", "getSeries", "(", "$", "series", ")", ";", "if", "(", "$", "series", ")", "{", "return", "[", "'series'", "=>", "$", "series", "]", ";", "}", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'info'", ",", "'oktolab_media.series_not_found'", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'oktolab_series'", ")", ")", ";", "}" ]
Finds and displays a Series entity. @ParamConverter("series", class="OktolabMediaBundle:Series") @Method("GET") @Template()
[ "Finds", "and", "displays", "a", "Series", "entity", "." ]
train
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Controller/SeriesController.php#L93-L105
OKTOTV/OktolabMediaBundle
Controller/SeriesController.php
SeriesController.editAction
public function editAction(Request $request, $series) { $series = $this->get('oktolab_media')->getSeries($series); $form = $this->createForm(SeriesType::class, $series); $form->add('submit', SubmitType::class, ['label' => 'oktolab_media.edit_series_button', 'attr' => ['class' => 'btn btn-primary']]); $form->add('delete', SubmitType::class, ['label' => 'oktolab_media.delete_series_button', 'attr' => ['class' => 'btn btn-danger']]); if ($request->getMethod() == "POST") { //sends form $form->handleRequest($request); $em = $this->getDoctrine()->getManager(); if ($form->isValid() || $form->get('delete')->isClicked()) { //form is valid, save or preview if ($form->get('submit')->isClicked()) { //save me $em->persist($series); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'oktolab_media.success_edit_series'); return $this->redirect($this->generateUrl('oktolab_series_show', ['series' => $series->getUniqID()])); } elseif ($form->get('delete')->isClicked()) { $this->get('oktolab_media_helper')->deleteSeries($series); $this->get('session')->getFlashBag()->add('success', 'oktolab_media.success_delete_series'); return $this->redirect($this->generateUrl('oktolab_series')); } else { //??? $this->get('session')->getFlashBag()->add('success', 'oktolab_media.unknown_action_series'); return $this->redirect($this->generateUrl('oktolab_series_show', ['series' => $series->getUniqID()])); } } $this->get('session')->getFlashBag()->add('error', 'oktolab_media.error_edit_series'); } return ['form' => $form->createView()]; }
php
public function editAction(Request $request, $series) { $series = $this->get('oktolab_media')->getSeries($series); $form = $this->createForm(SeriesType::class, $series); $form->add('submit', SubmitType::class, ['label' => 'oktolab_media.edit_series_button', 'attr' => ['class' => 'btn btn-primary']]); $form->add('delete', SubmitType::class, ['label' => 'oktolab_media.delete_series_button', 'attr' => ['class' => 'btn btn-danger']]); if ($request->getMethod() == "POST") { //sends form $form->handleRequest($request); $em = $this->getDoctrine()->getManager(); if ($form->isValid() || $form->get('delete')->isClicked()) { //form is valid, save or preview if ($form->get('submit')->isClicked()) { //save me $em->persist($series); $em->flush(); $this->get('session')->getFlashBag()->add('success', 'oktolab_media.success_edit_series'); return $this->redirect($this->generateUrl('oktolab_series_show', ['series' => $series->getUniqID()])); } elseif ($form->get('delete')->isClicked()) { $this->get('oktolab_media_helper')->deleteSeries($series); $this->get('session')->getFlashBag()->add('success', 'oktolab_media.success_delete_series'); return $this->redirect($this->generateUrl('oktolab_series')); } else { //??? $this->get('session')->getFlashBag()->add('success', 'oktolab_media.unknown_action_series'); return $this->redirect($this->generateUrl('oktolab_series_show', ['series' => $series->getUniqID()])); } } $this->get('session')->getFlashBag()->add('error', 'oktolab_media.error_edit_series'); } return ['form' => $form->createView()]; }
[ "public", "function", "editAction", "(", "Request", "$", "request", ",", "$", "series", ")", "{", "$", "series", "=", "$", "this", "->", "get", "(", "'oktolab_media'", ")", "->", "getSeries", "(", "$", "series", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "SeriesType", "::", "class", ",", "$", "series", ")", ";", "$", "form", "->", "add", "(", "'submit'", ",", "SubmitType", "::", "class", ",", "[", "'label'", "=>", "'oktolab_media.edit_series_button'", ",", "'attr'", "=>", "[", "'class'", "=>", "'btn btn-primary'", "]", "]", ")", ";", "$", "form", "->", "add", "(", "'delete'", ",", "SubmitType", "::", "class", ",", "[", "'label'", "=>", "'oktolab_media.delete_series_button'", ",", "'attr'", "=>", "[", "'class'", "=>", "'btn btn-danger'", "]", "]", ")", ";", "if", "(", "$", "request", "->", "getMethod", "(", ")", "==", "\"POST\"", ")", "{", "//sends form", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", "||", "$", "form", "->", "get", "(", "'delete'", ")", "->", "isClicked", "(", ")", ")", "{", "//form is valid, save or preview", "if", "(", "$", "form", "->", "get", "(", "'submit'", ")", "->", "isClicked", "(", ")", ")", "{", "//save me", "$", "em", "->", "persist", "(", "$", "series", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'oktolab_media.success_edit_series'", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'oktolab_series_show'", ",", "[", "'series'", "=>", "$", "series", "->", "getUniqID", "(", ")", "]", ")", ")", ";", "}", "elseif", "(", "$", "form", "->", "get", "(", "'delete'", ")", "->", "isClicked", "(", ")", ")", "{", "$", "this", "->", "get", "(", "'oktolab_media_helper'", ")", "->", "deleteSeries", "(", "$", "series", ")", ";", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'oktolab_media.success_delete_series'", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'oktolab_series'", ")", ")", ";", "}", "else", "{", "//???", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'success'", ",", "'oktolab_media.unknown_action_series'", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'oktolab_series_show'", ",", "[", "'series'", "=>", "$", "series", "->", "getUniqID", "(", ")", "]", ")", ")", ";", "}", "}", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'error'", ",", "'oktolab_media.error_edit_series'", ")", ";", "}", "return", "[", "'form'", "=>", "$", "form", "->", "createView", "(", ")", "]", ";", "}" ]
Displays a form to edit an existing Series entity. @ ParamConverter("series", class="OktolabMediaBundle:Series") @Method({"GET", "POST"}) @Template()
[ "Displays", "a", "form", "to", "edit", "an", "existing", "Series", "entity", "." ]
train
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Controller/SeriesController.php#L114-L143
thupan/framework
src/Generator/Generator.php
Generator.setHeader
private function setHeader() { $campos = $_REQUEST['campos']; if ($campos) { foreach ($campos as $index => $key) { $key2 = explode(':', $key)[1]; $label = explode('_', $key2); $label = (strtolower($label[0]) == 'id') ? '#' : $label[1]; $key = str_replace(':', '.', $key); $html[] = "\t'$label:$key:ANY'"; } return implode(",\n", $html); } return false; }
php
private function setHeader() { $campos = $_REQUEST['campos']; if ($campos) { foreach ($campos as $index => $key) { $key2 = explode(':', $key)[1]; $label = explode('_', $key2); $label = (strtolower($label[0]) == 'id') ? '#' : $label[1]; $key = str_replace(':', '.', $key); $html[] = "\t'$label:$key:ANY'"; } return implode(",\n", $html); } return false; }
[ "private", "function", "setHeader", "(", ")", "{", "$", "campos", "=", "$", "_REQUEST", "[", "'campos'", "]", ";", "if", "(", "$", "campos", ")", "{", "foreach", "(", "$", "campos", "as", "$", "index", "=>", "$", "key", ")", "{", "$", "key2", "=", "explode", "(", "':'", ",", "$", "key", ")", "[", "1", "]", ";", "$", "label", "=", "explode", "(", "'_'", ",", "$", "key2", ")", ";", "$", "label", "=", "(", "strtolower", "(", "$", "label", "[", "0", "]", ")", "==", "'id'", ")", "?", "'#'", ":", "$", "label", "[", "1", "]", ";", "$", "key", "=", "str_replace", "(", "':'", ",", "'.'", ",", "$", "key", ")", ";", "$", "html", "[", "]", "=", "\"\\t'$label:$key:ANY'\"", ";", "}", "return", "implode", "(", "\",\\n\"", ",", "$", "html", ")", ";", "}", "return", "false", ";", "}" ]
/* <tr> <th>#</th> <th>LOGIN</th> <th>FUNCIONÁRIO</th> <th>UNIDADE GESTORA</th> <th>MOTIVO</th> <th>AÇÕES</th> </tr> <tr class="search-fields"> <form class="form-fields"> <td><input name="USUARIO.ID_USUARIO" class="form-control" type='text'/></td> <td><input name="USUARIO.TX_LOGIN" class="form-control" type='text'/></td> <td><input name="PESSOA.TX_NOME:ANY" class="form-control" type='text'/></td> <td><input name="UNID_GESTORA_PESSOA.TX_UNIDADE_GESTORA:ANY" class="form-control" type='text'/></td> <td><input name="USUARIO.TX_MOTIVO_SITUACAO:ANY" class="form-control" type='text'/></td> <td style='width:130px !important;'> <button type="button" class="btn btn-primary search"> <span class="glyphicon glyphicon-search" aria-hidden="true"></span> </button> <button type="button" class="btn btn-default search-refresh"> <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> </button> </td> </form> </tr>
[ "/", "*" ]
train
https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Generator/Generator.php#L243-L258
thupan/framework
src/Generator/Generator.php
Generator.getFieldType
private function getFieldType($type = false, $label = false) { if (!$type) { return false; } $html = "\n<div class='col-md-12'>\n"; switch ($type) { case 1: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <input class='form-control' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> "; break; case 2: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <textarea class='form-control' id='{$label}' name='{$label}' required>{{{$label}}}</textarea> </div> "; break; case 3: $html .= " <div class='form-group'> <input type='hidden' name='{$label}' id='{$label}' value='{{{$label}}}' /> </div> "; break; case 4: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <input class='form-control' type='password' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> "; break; case 5: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <select class='form-control form-control-select2' name='{$label}' id='{$label}' required> </select> </div> "; break; case 6: $html .= " <div class='form-group'> <input type='file' name='{$label}' id='{$label}' value='{{{$label}}}' /> </div> "; break; case 7: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <input class='form-control cpf' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> "; break; case 8: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <input class='form-control cnpj' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> "; break; case 9: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <input class='form-control data' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> "; break; case 10: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <div class='input-group'> <div class='input-group-addon'>R$</div> <input class='form-control moeda' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> </div> "; break; case 11: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <input class='form-control telefone' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> "; break; case 12: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <input class='form-control celular' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> "; break; case 13: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <div class='input-group'> <div class='input-group-addon'>@</div> <input class='form-control email' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> </div> "; break; case 14: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <div class='input-group'> <div class='input-group-addon'>@</div> <input class='form-control email-gov' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> </div> "; break; case 15: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <input class='form-control cep' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> "; break; } $html .= "\n</div>\n"; return $html; }
php
private function getFieldType($type = false, $label = false) { if (!$type) { return false; } $html = "\n<div class='col-md-12'>\n"; switch ($type) { case 1: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <input class='form-control' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> "; break; case 2: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <textarea class='form-control' id='{$label}' name='{$label}' required>{{{$label}}}</textarea> </div> "; break; case 3: $html .= " <div class='form-group'> <input type='hidden' name='{$label}' id='{$label}' value='{{{$label}}}' /> </div> "; break; case 4: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <input class='form-control' type='password' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> "; break; case 5: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <select class='form-control form-control-select2' name='{$label}' id='{$label}' required> </select> </div> "; break; case 6: $html .= " <div class='form-group'> <input type='file' name='{$label}' id='{$label}' value='{{{$label}}}' /> </div> "; break; case 7: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <input class='form-control cpf' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> "; break; case 8: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <input class='form-control cnpj' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> "; break; case 9: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <input class='form-control data' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> "; break; case 10: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <div class='input-group'> <div class='input-group-addon'>R$</div> <input class='form-control moeda' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> </div> "; break; case 11: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <input class='form-control telefone' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> "; break; case 12: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <input class='form-control celular' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> "; break; case 13: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <div class='input-group'> <div class='input-group-addon'>@</div> <input class='form-control email' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> </div> "; break; case 14: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <div class='input-group'> <div class='input-group-addon'>@</div> <input class='form-control email-gov' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> </div> "; break; case 15: $html .= " <div class='form-group'> <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label> <input class='form-control cep' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required /> </div> "; break; } $html .= "\n</div>\n"; return $html; }
[ "private", "function", "getFieldType", "(", "$", "type", "=", "false", ",", "$", "label", "=", "false", ")", "{", "if", "(", "!", "$", "type", ")", "{", "return", "false", ";", "}", "$", "html", "=", "\"\\n<div class='col-md-12'>\\n\"", ";", "switch", "(", "$", "type", ")", "{", "case", "1", ":", "$", "html", ".=", "\"\n\n <div class='form-group'>\n <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label>\n <input class='form-control' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required />\n </div>\n\n \"", ";", "break", ";", "case", "2", ":", "$", "html", ".=", "\"\n\n <div class='form-group'>\n <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label>\n <textarea class='form-control' id='{$label}' name='{$label}' required>{{{$label}}}</textarea>\n </div>\n\n \"", ";", "break", ";", "case", "3", ":", "$", "html", ".=", "\"\n\n <div class='form-group'>\n <input type='hidden' name='{$label}' id='{$label}' value='{{{$label}}}' />\n </div>\n\n \"", ";", "break", ";", "case", "4", ":", "$", "html", ".=", "\"\n\n <div class='form-group'>\n <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label>\n <input class='form-control' type='password' name='{$label}' id='{$label}' value='{{{$label}}}' required />\n </div>\n\n \"", ";", "break", ";", "case", "5", ":", "$", "html", ".=", "\"\n\n <div class='form-group'>\n <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label>\n <select class='form-control form-control-select2' name='{$label}' id='{$label}' required>\n\n </select>\n </div>\n\n \"", ";", "break", ";", "case", "6", ":", "$", "html", ".=", "\"\n\n <div class='form-group'>\n <input type='file' name='{$label}' id='{$label}' value='{{{$label}}}' />\n </div>\n\n \"", ";", "break", ";", "case", "7", ":", "$", "html", ".=", "\"\n\n <div class='form-group'>\n <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label>\n <input class='form-control cpf' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required />\n </div>\n\n \"", ";", "break", ";", "case", "8", ":", "$", "html", ".=", "\"\n\n <div class='form-group'>\n <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label>\n <input class='form-control cnpj' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required />\n </div>\n\n \"", ";", "break", ";", "case", "9", ":", "$", "html", ".=", "\"\n\n <div class='form-group'>\n <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label>\n <input class='form-control data' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required />\n </div>\n\n \"", ";", "break", ";", "case", "10", ":", "$", "html", ".=", "\"\n\n <div class='form-group'>\n <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label>\n <div class='input-group'>\n <div class='input-group-addon'>R$</div>\n <input class='form-control moeda' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required />\n </div>\n </div>\n\n \"", ";", "break", ";", "case", "11", ":", "$", "html", ".=", "\"\n\n <div class='form-group'>\n <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label>\n <input class='form-control telefone' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required />\n </div>\n\n \"", ";", "break", ";", "case", "12", ":", "$", "html", ".=", "\"\n\n <div class='form-group'>\n <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label>\n <input class='form-control celular' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required />\n </div>\n\n \"", ";", "break", ";", "case", "13", ":", "$", "html", ".=", "\"\n\n <div class='form-group'>\n <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label>\n <div class='input-group'>\n <div class='input-group-addon'>@</div>\n <input class='form-control email' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required />\n </div>\n </div>\n\n \"", ";", "break", ";", "case", "14", ":", "$", "html", ".=", "\"\n\n <div class='form-group'>\n <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label>\n <div class='input-group'>\n <div class='input-group-addon'>@</div>\n <input class='form-control email-gov' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required />\n </div>\n </div>\n\n \"", ";", "break", ";", "case", "15", ":", "$", "html", ".=", "\"\n\n <div class='form-group'>\n <label class='form-control-label obrigatorio' for='{$label}'>{$label}</label>\n <input class='form-control cep' type='text' name='{$label}' id='{$label}' value='{{{$label}}}' required />\n </div>\n\n \"", ";", "break", ";", "}", "$", "html", ".=", "\"\\n</div>\\n\"", ";", "return", "$", "html", ";", "}" ]
}
[ "}" ]
train
https://github.com/thupan/framework/blob/43193c67e87942930fb0cbc53aa069b60b27e749/src/Generator/Generator.php#L317-L503
richardhj/contao-widget-upload-preview
src/FormUploadPreview.php
FormUploadPreview.validate
public function validate() { // Delete the file when requested if (true === $this->enableReset && $this->getPost($this->strName.'_reset')) { if (null !== ($fileModel = FilesModel::findByPk($this->varValue))) { $file = new File($fileModel->path); $file->delete(); } unset($_FILES[$this->strName]); return; } // Handle file upload parent::validate(); // Set the image as varValue $file = $_SESSION['FILES'][$this->strName]; if (true === $file['uploaded']) { $this->varValue = StringUtil::uuidToBin($file['uuid']); } else { $this->blnSubmitInput = false; } }
php
public function validate() { // Delete the file when requested if (true === $this->enableReset && $this->getPost($this->strName.'_reset')) { if (null !== ($fileModel = FilesModel::findByPk($this->varValue))) { $file = new File($fileModel->path); $file->delete(); } unset($_FILES[$this->strName]); return; } // Handle file upload parent::validate(); // Set the image as varValue $file = $_SESSION['FILES'][$this->strName]; if (true === $file['uploaded']) { $this->varValue = StringUtil::uuidToBin($file['uuid']); } else { $this->blnSubmitInput = false; } }
[ "public", "function", "validate", "(", ")", "{", "// Delete the file when requested", "if", "(", "true", "===", "$", "this", "->", "enableReset", "&&", "$", "this", "->", "getPost", "(", "$", "this", "->", "strName", ".", "'_reset'", ")", ")", "{", "if", "(", "null", "!==", "(", "$", "fileModel", "=", "FilesModel", "::", "findByPk", "(", "$", "this", "->", "varValue", ")", ")", ")", "{", "$", "file", "=", "new", "File", "(", "$", "fileModel", "->", "path", ")", ";", "$", "file", "->", "delete", "(", ")", ";", "}", "unset", "(", "$", "_FILES", "[", "$", "this", "->", "strName", "]", ")", ";", "return", ";", "}", "// Handle file upload", "parent", "::", "validate", "(", ")", ";", "// Set the image as varValue", "$", "file", "=", "$", "_SESSION", "[", "'FILES'", "]", "[", "$", "this", "->", "strName", "]", ";", "if", "(", "true", "===", "$", "file", "[", "'uploaded'", "]", ")", "{", "$", "this", "->", "varValue", "=", "StringUtil", "::", "uuidToBin", "(", "$", "file", "[", "'uuid'", "]", ")", ";", "}", "else", "{", "$", "this", "->", "blnSubmitInput", "=", "false", ";", "}", "}" ]
Validate the user input and set the value. @throws \Exception
[ "Validate", "the", "user", "input", "and", "set", "the", "value", "." ]
train
https://github.com/richardhj/contao-widget-upload-preview/blob/5de3488ad55c69cd311ff26e749a74097b7a9db1/src/FormUploadPreview.php#L133-L157
richardhj/contao-widget-upload-preview
src/FormUploadPreview.php
FormUploadPreview.generate
public function generate() { $return = ''; if (empty($this->thumbnailSize)) { $this->thumbnailSize = [ Config::get('imageWidth'), Config::get('imageHeight'), 'box', ]; } $file = FilesModel::findByPk($this->varValue); if (null === $file && null !== $this->fallbackImage) { $file = FilesModel::findByPk($this->fallbackImage); } if (null !== $file) { $altTag = $file->name; $size = deserialize($this->thumbnailSize); $image = Image::create($file->path, $size)->executeResize(); $return .= sprintf( '<img src="%s" width="%s" height="%s" alt="%s" class="uploaded-image">', $image->getResizedPath(), $image->getTargetWidth(), $image->getTargetHeight(), $altTag ); } if ($this->addMetaWizard) { //@todo add meta wizard here } $return .= parent::generate(); if ($this->enableReset) { $return .= sprintf( '<input type="checkbox" name="%s" class="checkbox" value=""><label>%s</label> ', $this->strName.'_reset', 'Reset' ); } return $return; }
php
public function generate() { $return = ''; if (empty($this->thumbnailSize)) { $this->thumbnailSize = [ Config::get('imageWidth'), Config::get('imageHeight'), 'box', ]; } $file = FilesModel::findByPk($this->varValue); if (null === $file && null !== $this->fallbackImage) { $file = FilesModel::findByPk($this->fallbackImage); } if (null !== $file) { $altTag = $file->name; $size = deserialize($this->thumbnailSize); $image = Image::create($file->path, $size)->executeResize(); $return .= sprintf( '<img src="%s" width="%s" height="%s" alt="%s" class="uploaded-image">', $image->getResizedPath(), $image->getTargetWidth(), $image->getTargetHeight(), $altTag ); } if ($this->addMetaWizard) { //@todo add meta wizard here } $return .= parent::generate(); if ($this->enableReset) { $return .= sprintf( '<input type="checkbox" name="%s" class="checkbox" value=""><label>%s</label> ', $this->strName.'_reset', 'Reset' ); } return $return; }
[ "public", "function", "generate", "(", ")", "{", "$", "return", "=", "''", ";", "if", "(", "empty", "(", "$", "this", "->", "thumbnailSize", ")", ")", "{", "$", "this", "->", "thumbnailSize", "=", "[", "Config", "::", "get", "(", "'imageWidth'", ")", ",", "Config", "::", "get", "(", "'imageHeight'", ")", ",", "'box'", ",", "]", ";", "}", "$", "file", "=", "FilesModel", "::", "findByPk", "(", "$", "this", "->", "varValue", ")", ";", "if", "(", "null", "===", "$", "file", "&&", "null", "!==", "$", "this", "->", "fallbackImage", ")", "{", "$", "file", "=", "FilesModel", "::", "findByPk", "(", "$", "this", "->", "fallbackImage", ")", ";", "}", "if", "(", "null", "!==", "$", "file", ")", "{", "$", "altTag", "=", "$", "file", "->", "name", ";", "$", "size", "=", "deserialize", "(", "$", "this", "->", "thumbnailSize", ")", ";", "$", "image", "=", "Image", "::", "create", "(", "$", "file", "->", "path", ",", "$", "size", ")", "->", "executeResize", "(", ")", ";", "$", "return", ".=", "sprintf", "(", "'<img src=\"%s\" width=\"%s\" height=\"%s\" alt=\"%s\" class=\"uploaded-image\">'", ",", "$", "image", "->", "getResizedPath", "(", ")", ",", "$", "image", "->", "getTargetWidth", "(", ")", ",", "$", "image", "->", "getTargetHeight", "(", ")", ",", "$", "altTag", ")", ";", "}", "if", "(", "$", "this", "->", "addMetaWizard", ")", "{", "//@todo add meta wizard here", "}", "$", "return", ".=", "parent", "::", "generate", "(", ")", ";", "if", "(", "$", "this", "->", "enableReset", ")", "{", "$", "return", ".=", "sprintf", "(", "'<input type=\"checkbox\" name=\"%s\" class=\"checkbox\" value=\"\"><label>%s</label> '", ",", "$", "this", "->", "strName", ".", "'_reset'", ",", "'Reset'", ")", ";", "}", "return", "$", "return", ";", "}" ]
Generate the widget and return it as string @return string
[ "Generate", "the", "widget", "and", "return", "it", "as", "string" ]
train
https://github.com/richardhj/contao-widget-upload-preview/blob/5de3488ad55c69cd311ff26e749a74097b7a9db1/src/FormUploadPreview.php#L164-L209
david-mk/mail-map
src/MailMap/MailFactory.php
MailFactory.create
public function create($uid, $stream) { return new $this->mailClass( $uid, $stream, $this->parseMailHeader($stream, $uid), $this->parseHeaders($stream, $uid), $this->parseBody($stream, $uid) ); }
php
public function create($uid, $stream) { return new $this->mailClass( $uid, $stream, $this->parseMailHeader($stream, $uid), $this->parseHeaders($stream, $uid), $this->parseBody($stream, $uid) ); }
[ "public", "function", "create", "(", "$", "uid", ",", "$", "stream", ")", "{", "return", "new", "$", "this", "->", "mailClass", "(", "$", "uid", ",", "$", "stream", ",", "$", "this", "->", "parseMailHeader", "(", "$", "stream", ",", "$", "uid", ")", ",", "$", "this", "->", "parseHeaders", "(", "$", "stream", ",", "$", "uid", ")", ",", "$", "this", "->", "parseBody", "(", "$", "stream", ",", "$", "uid", ")", ")", ";", "}" ]
Create new mail from uid @param int $uid @param resource $stream @return \MailMap\Contracts\Mail
[ "Create", "new", "mail", "from", "uid" ]
train
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/MailFactory.php#L65-L74
david-mk/mail-map
src/MailMap/MailFactory.php
MailFactory.parseMailHeader
protected function parseMailHeader($stream, $uid) { $header = imap_headerinfo($stream, imap_msgno($stream, $uid)); return [ 'msgNo' => (int) $header->Msgno, 'subject' => $this->parseSubject($header->subject), 'date' => $header->udate, 'to' => isset($header->to) ? $this->parseAddress($header->to) : null, 'cc' => isset($header->cc) ? $this->parseAddress($header->cc) : null, 'bcc' => isset($header->bcc) ? $this->parseAddress($header->bcc) : null, 'sender' => isset($header->sender) ? $this->parseAddress($header->sender) : null, 'from' => isset($header->from) ? $this->parseAddress($header->from) : null, 'replyTo' => isset($header->reply_to) ? $this->parseAddress($header->reply_to) : null, 'recent' => $this->parseFlag('R', $header->Recent), 'unseen' => $this->parseFlag('U', $header->Unseen), 'flagged' => $this->parseFlag('F', $header->Flagged), 'answered' => $this->parseFlag('A', $header->Answered), 'deleted' => $this->parseFlag('D', $header->Deleted), 'draft' => $this->parseFlag('X', $header->Draft) ]; }
php
protected function parseMailHeader($stream, $uid) { $header = imap_headerinfo($stream, imap_msgno($stream, $uid)); return [ 'msgNo' => (int) $header->Msgno, 'subject' => $this->parseSubject($header->subject), 'date' => $header->udate, 'to' => isset($header->to) ? $this->parseAddress($header->to) : null, 'cc' => isset($header->cc) ? $this->parseAddress($header->cc) : null, 'bcc' => isset($header->bcc) ? $this->parseAddress($header->bcc) : null, 'sender' => isset($header->sender) ? $this->parseAddress($header->sender) : null, 'from' => isset($header->from) ? $this->parseAddress($header->from) : null, 'replyTo' => isset($header->reply_to) ? $this->parseAddress($header->reply_to) : null, 'recent' => $this->parseFlag('R', $header->Recent), 'unseen' => $this->parseFlag('U', $header->Unseen), 'flagged' => $this->parseFlag('F', $header->Flagged), 'answered' => $this->parseFlag('A', $header->Answered), 'deleted' => $this->parseFlag('D', $header->Deleted), 'draft' => $this->parseFlag('X', $header->Draft) ]; }
[ "protected", "function", "parseMailHeader", "(", "$", "stream", ",", "$", "uid", ")", "{", "$", "header", "=", "imap_headerinfo", "(", "$", "stream", ",", "imap_msgno", "(", "$", "stream", ",", "$", "uid", ")", ")", ";", "return", "[", "'msgNo'", "=>", "(", "int", ")", "$", "header", "->", "Msgno", ",", "'subject'", "=>", "$", "this", "->", "parseSubject", "(", "$", "header", "->", "subject", ")", ",", "'date'", "=>", "$", "header", "->", "udate", ",", "'to'", "=>", "isset", "(", "$", "header", "->", "to", ")", "?", "$", "this", "->", "parseAddress", "(", "$", "header", "->", "to", ")", ":", "null", ",", "'cc'", "=>", "isset", "(", "$", "header", "->", "cc", ")", "?", "$", "this", "->", "parseAddress", "(", "$", "header", "->", "cc", ")", ":", "null", ",", "'bcc'", "=>", "isset", "(", "$", "header", "->", "bcc", ")", "?", "$", "this", "->", "parseAddress", "(", "$", "header", "->", "bcc", ")", ":", "null", ",", "'sender'", "=>", "isset", "(", "$", "header", "->", "sender", ")", "?", "$", "this", "->", "parseAddress", "(", "$", "header", "->", "sender", ")", ":", "null", ",", "'from'", "=>", "isset", "(", "$", "header", "->", "from", ")", "?", "$", "this", "->", "parseAddress", "(", "$", "header", "->", "from", ")", ":", "null", ",", "'replyTo'", "=>", "isset", "(", "$", "header", "->", "reply_to", ")", "?", "$", "this", "->", "parseAddress", "(", "$", "header", "->", "reply_to", ")", ":", "null", ",", "'recent'", "=>", "$", "this", "->", "parseFlag", "(", "'R'", ",", "$", "header", "->", "Recent", ")", ",", "'unseen'", "=>", "$", "this", "->", "parseFlag", "(", "'U'", ",", "$", "header", "->", "Unseen", ")", ",", "'flagged'", "=>", "$", "this", "->", "parseFlag", "(", "'F'", ",", "$", "header", "->", "Flagged", ")", ",", "'answered'", "=>", "$", "this", "->", "parseFlag", "(", "'A'", ",", "$", "header", "->", "Answered", ")", ",", "'deleted'", "=>", "$", "this", "->", "parseFlag", "(", "'D'", ",", "$", "header", "->", "Deleted", ")", ",", "'draft'", "=>", "$", "this", "->", "parseFlag", "(", "'X'", ",", "$", "header", "->", "Draft", ")", "]", ";", "}" ]
Parse the mail header @param resource $stream @param int $uid @return array
[ "Parse", "the", "mail", "header" ]
train
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/MailFactory.php#L83-L110
david-mk/mail-map
src/MailMap/MailFactory.php
MailFactory.parseAddress
protected function parseAddress(array $addresses) { return array_map(function ($address) { return (object) [ 'address' => $address->mailbox.'@'.$address->host, 'domain' => $address->host, 'name' => isset($address->personal) ? static::convertBodyEncoding($address->personal) : null ]; }, array_filter($addresses, function ($address) { return property_exists($address, 'mailbox') && strtolower($address->mailbox) !== 'undisclosed-recipients'; })); }
php
protected function parseAddress(array $addresses) { return array_map(function ($address) { return (object) [ 'address' => $address->mailbox.'@'.$address->host, 'domain' => $address->host, 'name' => isset($address->personal) ? static::convertBodyEncoding($address->personal) : null ]; }, array_filter($addresses, function ($address) { return property_exists($address, 'mailbox') && strtolower($address->mailbox) !== 'undisclosed-recipients'; })); }
[ "protected", "function", "parseAddress", "(", "array", "$", "addresses", ")", "{", "return", "array_map", "(", "function", "(", "$", "address", ")", "{", "return", "(", "object", ")", "[", "'address'", "=>", "$", "address", "->", "mailbox", ".", "'@'", ".", "$", "address", "->", "host", ",", "'domain'", "=>", "$", "address", "->", "host", ",", "'name'", "=>", "isset", "(", "$", "address", "->", "personal", ")", "?", "static", "::", "convertBodyEncoding", "(", "$", "address", "->", "personal", ")", ":", "null", "]", ";", "}", ",", "array_filter", "(", "$", "addresses", ",", "function", "(", "$", "address", ")", "{", "return", "property_exists", "(", "$", "address", ",", "'mailbox'", ")", "&&", "strtolower", "(", "$", "address", "->", "mailbox", ")", "!==", "'undisclosed-recipients'", ";", "}", ")", ")", ";", "}" ]
Parse email addresses from header @param array $addresses @return array
[ "Parse", "email", "addresses", "from", "header" ]
train
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/MailFactory.php#L118-L131
david-mk/mail-map
src/MailMap/MailFactory.php
MailFactory.parseSubject
protected function parseSubject($subject) { $subject = imap_mime_header_decode($subject); $subjectParts = array_map(function ($subj) { if (strtolower($subj->charset) === 'default') { return $subj->text; } return iconv($subj->charset, static::$charset, $subj->text); }, $subject); return implode('', $subjectParts); }
php
protected function parseSubject($subject) { $subject = imap_mime_header_decode($subject); $subjectParts = array_map(function ($subj) { if (strtolower($subj->charset) === 'default') { return $subj->text; } return iconv($subj->charset, static::$charset, $subj->text); }, $subject); return implode('', $subjectParts); }
[ "protected", "function", "parseSubject", "(", "$", "subject", ")", "{", "$", "subject", "=", "imap_mime_header_decode", "(", "$", "subject", ")", ";", "$", "subjectParts", "=", "array_map", "(", "function", "(", "$", "subj", ")", "{", "if", "(", "strtolower", "(", "$", "subj", "->", "charset", ")", "===", "'default'", ")", "{", "return", "$", "subj", "->", "text", ";", "}", "return", "iconv", "(", "$", "subj", "->", "charset", ",", "static", "::", "$", "charset", ",", "$", "subj", "->", "text", ")", ";", "}", ",", "$", "subject", ")", ";", "return", "implode", "(", "''", ",", "$", "subjectParts", ")", ";", "}" ]
Parse the subject of the email @param string $subject @return string
[ "Parse", "the", "subject", "of", "the", "email" ]
train
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/MailFactory.php#L151-L163
david-mk/mail-map
src/MailMap/MailFactory.php
MailFactory.parseHeaders
protected function parseHeaders($stream, $uid) { $rawHeaders = imap_fetchheader($stream, $uid, static::$fetchFlags); $headers = []; $key = null; foreach (explode("\n", $rawHeaders) as $line) { // Test if continutation if ($line !== '' && !preg_match('/^\s/', $line)) { list($key, $val) = explode(':', $line, 2); $headers[$key] = trim($val); } elseif (!is_null($key) && ($trimmed = trim($line)) !== '') { $headers[$key] = $headers[$key].$trimmed; } } foreach($headers as $headerKey => $headerValue) { if (preg_match('/(\w+)=(\S+);(?:\s|$)/', $headerValue)) { $headers[$headerKey] = $this->parseNestedKeyPairHeader($headerValue); } } return $headers; }
php
protected function parseHeaders($stream, $uid) { $rawHeaders = imap_fetchheader($stream, $uid, static::$fetchFlags); $headers = []; $key = null; foreach (explode("\n", $rawHeaders) as $line) { // Test if continutation if ($line !== '' && !preg_match('/^\s/', $line)) { list($key, $val) = explode(':', $line, 2); $headers[$key] = trim($val); } elseif (!is_null($key) && ($trimmed = trim($line)) !== '') { $headers[$key] = $headers[$key].$trimmed; } } foreach($headers as $headerKey => $headerValue) { if (preg_match('/(\w+)=(\S+);(?:\s|$)/', $headerValue)) { $headers[$headerKey] = $this->parseNestedKeyPairHeader($headerValue); } } return $headers; }
[ "protected", "function", "parseHeaders", "(", "$", "stream", ",", "$", "uid", ")", "{", "$", "rawHeaders", "=", "imap_fetchheader", "(", "$", "stream", ",", "$", "uid", ",", "static", "::", "$", "fetchFlags", ")", ";", "$", "headers", "=", "[", "]", ";", "$", "key", "=", "null", ";", "foreach", "(", "explode", "(", "\"\\n\"", ",", "$", "rawHeaders", ")", "as", "$", "line", ")", "{", "// Test if continutation", "if", "(", "$", "line", "!==", "''", "&&", "!", "preg_match", "(", "'/^\\s/'", ",", "$", "line", ")", ")", "{", "list", "(", "$", "key", ",", "$", "val", ")", "=", "explode", "(", "':'", ",", "$", "line", ",", "2", ")", ";", "$", "headers", "[", "$", "key", "]", "=", "trim", "(", "$", "val", ")", ";", "}", "elseif", "(", "!", "is_null", "(", "$", "key", ")", "&&", "(", "$", "trimmed", "=", "trim", "(", "$", "line", ")", ")", "!==", "''", ")", "{", "$", "headers", "[", "$", "key", "]", "=", "$", "headers", "[", "$", "key", "]", ".", "$", "trimmed", ";", "}", "}", "foreach", "(", "$", "headers", "as", "$", "headerKey", "=>", "$", "headerValue", ")", "{", "if", "(", "preg_match", "(", "'/(\\w+)=(\\S+);(?:\\s|$)/'", ",", "$", "headerValue", ")", ")", "{", "$", "headers", "[", "$", "headerKey", "]", "=", "$", "this", "->", "parseNestedKeyPairHeader", "(", "$", "headerValue", ")", ";", "}", "}", "return", "$", "headers", ";", "}" ]
Parse the email headers into array structure @param resource $stream @param int $uid @return array
[ "Parse", "the", "email", "headers", "into", "array", "structure" ]
train
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/MailFactory.php#L172-L196
david-mk/mail-map
src/MailMap/MailFactory.php
MailFactory.parseNestedKeyPairHeader
protected function parseNestedKeyPairHeader($nestedPairs) { return array_reduce(explode(';', $nestedPairs), function($result, $pair) { $keyVal = explode('=', $pair, 2); $key = trim(array_shift($keyVal)); $val = trim(implode('=', $keyVal)); if ($key !== '' && $val !== '') { $result[$key] = $val; } return $result; }, []); }
php
protected function parseNestedKeyPairHeader($nestedPairs) { return array_reduce(explode(';', $nestedPairs), function($result, $pair) { $keyVal = explode('=', $pair, 2); $key = trim(array_shift($keyVal)); $val = trim(implode('=', $keyVal)); if ($key !== '' && $val !== '') { $result[$key] = $val; } return $result; }, []); }
[ "protected", "function", "parseNestedKeyPairHeader", "(", "$", "nestedPairs", ")", "{", "return", "array_reduce", "(", "explode", "(", "';'", ",", "$", "nestedPairs", ")", ",", "function", "(", "$", "result", ",", "$", "pair", ")", "{", "$", "keyVal", "=", "explode", "(", "'='", ",", "$", "pair", ",", "2", ")", ";", "$", "key", "=", "trim", "(", "array_shift", "(", "$", "keyVal", ")", ")", ";", "$", "val", "=", "trim", "(", "implode", "(", "'='", ",", "$", "keyVal", ")", ")", ";", "if", "(", "$", "key", "!==", "''", "&&", "$", "val", "!==", "''", ")", "{", "$", "result", "[", "$", "key", "]", "=", "$", "val", ";", "}", "return", "$", "result", ";", "}", ",", "[", "]", ")", ";", "}" ]
Parse the any nested key-pair values in the header value @param string $nestedPairs @return array
[ "Parse", "the", "any", "nested", "key", "-", "pair", "values", "in", "the", "header", "value" ]
train
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/MailFactory.php#L204-L215
david-mk/mail-map
src/MailMap/MailFactory.php
MailFactory.parseBody
protected function parseBody($stream, $uid) { $struct = imap_fetchstructure($stream, $uid, static::$fetchFlags); if (!isset($struct->parts)) { return array_filter([$this->parsePart($stream, $uid, $struct)]); } $parsedParts = []; foreach ($this->flattenParts($struct->parts) as $partNo => $part) { $parsedParts[] = $this->parsePart($stream, $uid, $part, $partNo); } return array_filter($parsedParts); }
php
protected function parseBody($stream, $uid) { $struct = imap_fetchstructure($stream, $uid, static::$fetchFlags); if (!isset($struct->parts)) { return array_filter([$this->parsePart($stream, $uid, $struct)]); } $parsedParts = []; foreach ($this->flattenParts($struct->parts) as $partNo => $part) { $parsedParts[] = $this->parsePart($stream, $uid, $part, $partNo); } return array_filter($parsedParts); }
[ "protected", "function", "parseBody", "(", "$", "stream", ",", "$", "uid", ")", "{", "$", "struct", "=", "imap_fetchstructure", "(", "$", "stream", ",", "$", "uid", ",", "static", "::", "$", "fetchFlags", ")", ";", "if", "(", "!", "isset", "(", "$", "struct", "->", "parts", ")", ")", "{", "return", "array_filter", "(", "[", "$", "this", "->", "parsePart", "(", "$", "stream", ",", "$", "uid", ",", "$", "struct", ")", "]", ")", ";", "}", "$", "parsedParts", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "flattenParts", "(", "$", "struct", "->", "parts", ")", "as", "$", "partNo", "=>", "$", "part", ")", "{", "$", "parsedParts", "[", "]", "=", "$", "this", "->", "parsePart", "(", "$", "stream", ",", "$", "uid", ",", "$", "part", ",", "$", "partNo", ")", ";", "}", "return", "array_filter", "(", "$", "parsedParts", ")", ";", "}" ]
Parse the email body and its parts @param resource $stream @param int $uid @return array
[ "Parse", "the", "email", "body", "and", "its", "parts" ]
train
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/MailFactory.php#L224-L237
david-mk/mail-map
src/MailMap/MailFactory.php
MailFactory.flattenParts
protected function flattenParts(array $parts, array $flattened = [], $pre = '', $idx = 1, $full = true) { foreach ($parts as $part) { $key = $pre.$idx; $flattened[$key] = $part; if (isset($part->parts)) { if ($part->type == TYPEMULTIPART) { $flattened = $this->flattenParts($part->parts, $flattened, $key.'.', 1, false); } elseif ($full) { $flattened = $this->flattenParts($part->parts, $flattened, $key.'.'); } else { $flattened = $this->flattenParts($part->parts, $flattened, $pre); } unset($flattened[$key]->parts); } $idx++; } return $flattened; }
php
protected function flattenParts(array $parts, array $flattened = [], $pre = '', $idx = 1, $full = true) { foreach ($parts as $part) { $key = $pre.$idx; $flattened[$key] = $part; if (isset($part->parts)) { if ($part->type == TYPEMULTIPART) { $flattened = $this->flattenParts($part->parts, $flattened, $key.'.', 1, false); } elseif ($full) { $flattened = $this->flattenParts($part->parts, $flattened, $key.'.'); } else { $flattened = $this->flattenParts($part->parts, $flattened, $pre); } unset($flattened[$key]->parts); } $idx++; } return $flattened; }
[ "protected", "function", "flattenParts", "(", "array", "$", "parts", ",", "array", "$", "flattened", "=", "[", "]", ",", "$", "pre", "=", "''", ",", "$", "idx", "=", "1", ",", "$", "full", "=", "true", ")", "{", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "$", "key", "=", "$", "pre", ".", "$", "idx", ";", "$", "flattened", "[", "$", "key", "]", "=", "$", "part", ";", "if", "(", "isset", "(", "$", "part", "->", "parts", ")", ")", "{", "if", "(", "$", "part", "->", "type", "==", "TYPEMULTIPART", ")", "{", "$", "flattened", "=", "$", "this", "->", "flattenParts", "(", "$", "part", "->", "parts", ",", "$", "flattened", ",", "$", "key", ".", "'.'", ",", "1", ",", "false", ")", ";", "}", "elseif", "(", "$", "full", ")", "{", "$", "flattened", "=", "$", "this", "->", "flattenParts", "(", "$", "part", "->", "parts", ",", "$", "flattened", ",", "$", "key", ".", "'.'", ")", ";", "}", "else", "{", "$", "flattened", "=", "$", "this", "->", "flattenParts", "(", "$", "part", "->", "parts", ",", "$", "flattened", ",", "$", "pre", ")", ";", "}", "unset", "(", "$", "flattened", "[", "$", "key", "]", "->", "parts", ")", ";", "}", "$", "idx", "++", ";", "}", "return", "$", "flattened", ";", "}" ]
Flatten email structure recursively. Parts re-keyed as 1, 1.1, 2, 2.1, 2.1.1 etc @param array $parts @param array $flattened @param string $pre @param int $idx @param bool $full @return array
[ "Flatten", "email", "structure", "recursively", "." ]
train
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/MailFactory.php#L251-L270
david-mk/mail-map
src/MailMap/MailFactory.php
MailFactory.parsePart
protected function parsePart($stream, $uid, $part, $partNo = 1) { if (!in_array($part->type, [TYPETEXT, TYPEMULTIPART])) { return null; } $body = imap_fetchbody($stream, $uid, $partNo, static::$bodyFlags); $body = static::decode($body, $part->encoding); if ('' !== ($charset = $this->findCharset($part))) { $body = static::convertBodyEncoding($body, $charset, $part->encoding); } return (object) [ 'body' => $body, 'mime_type' => strtolower($part->subtype) ]; }
php
protected function parsePart($stream, $uid, $part, $partNo = 1) { if (!in_array($part->type, [TYPETEXT, TYPEMULTIPART])) { return null; } $body = imap_fetchbody($stream, $uid, $partNo, static::$bodyFlags); $body = static::decode($body, $part->encoding); if ('' !== ($charset = $this->findCharset($part))) { $body = static::convertBodyEncoding($body, $charset, $part->encoding); } return (object) [ 'body' => $body, 'mime_type' => strtolower($part->subtype) ]; }
[ "protected", "function", "parsePart", "(", "$", "stream", ",", "$", "uid", ",", "$", "part", ",", "$", "partNo", "=", "1", ")", "{", "if", "(", "!", "in_array", "(", "$", "part", "->", "type", ",", "[", "TYPETEXT", ",", "TYPEMULTIPART", "]", ")", ")", "{", "return", "null", ";", "}", "$", "body", "=", "imap_fetchbody", "(", "$", "stream", ",", "$", "uid", ",", "$", "partNo", ",", "static", "::", "$", "bodyFlags", ")", ";", "$", "body", "=", "static", "::", "decode", "(", "$", "body", ",", "$", "part", "->", "encoding", ")", ";", "if", "(", "''", "!==", "(", "$", "charset", "=", "$", "this", "->", "findCharset", "(", "$", "part", ")", ")", ")", "{", "$", "body", "=", "static", "::", "convertBodyEncoding", "(", "$", "body", ",", "$", "charset", ",", "$", "part", "->", "encoding", ")", ";", "}", "return", "(", "object", ")", "[", "'body'", "=>", "$", "body", ",", "'mime_type'", "=>", "strtolower", "(", "$", "part", "->", "subtype", ")", "]", ";", "}" ]
Parse individual part of the structure @param resource $stream @param int $uid @param stdClass $part @param int $partNo @return stdClass | null
[ "Parse", "individual", "part", "of", "the", "structure" ]
train
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/MailFactory.php#L281-L298
david-mk/mail-map
src/MailMap/MailFactory.php
MailFactory.decode
protected static function decode($body, $encoding) { if (ENCQUOTEDPRINTABLE === $encoding) { return quoted_printable_decode($body); } if (ENCBASE64 === $encoding) { return base64_decode($body); } return $body; }
php
protected static function decode($body, $encoding) { if (ENCQUOTEDPRINTABLE === $encoding) { return quoted_printable_decode($body); } if (ENCBASE64 === $encoding) { return base64_decode($body); } return $body; }
[ "protected", "static", "function", "decode", "(", "$", "body", ",", "$", "encoding", ")", "{", "if", "(", "ENCQUOTEDPRINTABLE", "===", "$", "encoding", ")", "{", "return", "quoted_printable_decode", "(", "$", "body", ")", ";", "}", "if", "(", "ENCBASE64", "===", "$", "encoding", ")", "{", "return", "base64_decode", "(", "$", "body", ")", ";", "}", "return", "$", "body", ";", "}" ]
Decode the body text @param string $body @param int $encoding @return string
[ "Decode", "the", "body", "text" ]
train
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/MailFactory.php#L307-L318
david-mk/mail-map
src/MailMap/MailFactory.php
MailFactory.convertBodyEncoding
protected static function convertBodyEncoding($body, $charset = '', $encoding = -1) { if ('' === $charset) { $charset = static::$charset; } if (!mb_check_encoding($body, $charset)) { $charset = mb_detect_encoding($body); } if ($charset === static::$charset) { return $body; } if (!in_array($charset, mb_list_encodings())) { $charset = $encoding === ENC7BIT ? 'US-ASCII' : static::$charset; } return mb_convert_encoding($body, static::$charset, $charset); }
php
protected static function convertBodyEncoding($body, $charset = '', $encoding = -1) { if ('' === $charset) { $charset = static::$charset; } if (!mb_check_encoding($body, $charset)) { $charset = mb_detect_encoding($body); } if ($charset === static::$charset) { return $body; } if (!in_array($charset, mb_list_encodings())) { $charset = $encoding === ENC7BIT ? 'US-ASCII' : static::$charset; } return mb_convert_encoding($body, static::$charset, $charset); }
[ "protected", "static", "function", "convertBodyEncoding", "(", "$", "body", ",", "$", "charset", "=", "''", ",", "$", "encoding", "=", "-", "1", ")", "{", "if", "(", "''", "===", "$", "charset", ")", "{", "$", "charset", "=", "static", "::", "$", "charset", ";", "}", "if", "(", "!", "mb_check_encoding", "(", "$", "body", ",", "$", "charset", ")", ")", "{", "$", "charset", "=", "mb_detect_encoding", "(", "$", "body", ")", ";", "}", "if", "(", "$", "charset", "===", "static", "::", "$", "charset", ")", "{", "return", "$", "body", ";", "}", "if", "(", "!", "in_array", "(", "$", "charset", ",", "mb_list_encodings", "(", ")", ")", ")", "{", "$", "charset", "=", "$", "encoding", "===", "ENC7BIT", "?", "'US-ASCII'", ":", "static", "::", "$", "charset", ";", "}", "return", "mb_convert_encoding", "(", "$", "body", ",", "static", "::", "$", "charset", ",", "$", "charset", ")", ";", "}" ]
Convert body encoding from given coding to default @param string $body @param string $charset @param int $encoding @return string
[ "Convert", "body", "encoding", "from", "given", "coding", "to", "default" ]
train
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/MailFactory.php#L328-L347
david-mk/mail-map
src/MailMap/MailFactory.php
MailFactory.findCharset
protected function findCharset($struct) { if (isset($struct->parameters)) { foreach ($struct->parameters as $param) { if (strtolower($param->attribute) === 'charset') { return strtoupper($param->value); } } } if (isset($struct->dparameters)) { foreach ($struct->dparameters as $param) { if (strtolower($param->attribute) === 'charset') { return strtoupper($param->value); } } } return ''; }
php
protected function findCharset($struct) { if (isset($struct->parameters)) { foreach ($struct->parameters as $param) { if (strtolower($param->attribute) === 'charset') { return strtoupper($param->value); } } } if (isset($struct->dparameters)) { foreach ($struct->dparameters as $param) { if (strtolower($param->attribute) === 'charset') { return strtoupper($param->value); } } } return ''; }
[ "protected", "function", "findCharset", "(", "$", "struct", ")", "{", "if", "(", "isset", "(", "$", "struct", "->", "parameters", ")", ")", "{", "foreach", "(", "$", "struct", "->", "parameters", "as", "$", "param", ")", "{", "if", "(", "strtolower", "(", "$", "param", "->", "attribute", ")", "===", "'charset'", ")", "{", "return", "strtoupper", "(", "$", "param", "->", "value", ")", ";", "}", "}", "}", "if", "(", "isset", "(", "$", "struct", "->", "dparameters", ")", ")", "{", "foreach", "(", "$", "struct", "->", "dparameters", "as", "$", "param", ")", "{", "if", "(", "strtolower", "(", "$", "param", "->", "attribute", ")", "===", "'charset'", ")", "{", "return", "strtoupper", "(", "$", "param", "->", "value", ")", ";", "}", "}", "}", "return", "''", ";", "}" ]
Locate the charset within the struct @param stdClass $struct @return string
[ "Locate", "the", "charset", "within", "the", "struct" ]
train
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/MailFactory.php#L355-L373
hametuha/wpametu
src/WPametu/UI/Admin/Screen.php
Screen.adminMenu
public function adminMenu(){ if( $this->parent ){ add_submenu_page($this->parent, $this->title, $this->menu_title, $this->caps, $this->slug, array($this, 'render')); }else{ add_menu_page($this->title, $this->menu_title, $this->caps, $this->slug, array($this, 'render'), $this->icon, $this->position); } }
php
public function adminMenu(){ if( $this->parent ){ add_submenu_page($this->parent, $this->title, $this->menu_title, $this->caps, $this->slug, array($this, 'render')); }else{ add_menu_page($this->title, $this->menu_title, $this->caps, $this->slug, array($this, 'render'), $this->icon, $this->position); } }
[ "public", "function", "adminMenu", "(", ")", "{", "if", "(", "$", "this", "->", "parent", ")", "{", "add_submenu_page", "(", "$", "this", "->", "parent", ",", "$", "this", "->", "title", ",", "$", "this", "->", "menu_title", ",", "$", "this", "->", "caps", ",", "$", "this", "->", "slug", ",", "array", "(", "$", "this", ",", "'render'", ")", ")", ";", "}", "else", "{", "add_menu_page", "(", "$", "this", "->", "title", ",", "$", "this", "->", "menu_title", ",", "$", "this", "->", "caps", ",", "$", "this", "->", "slug", ",", "array", "(", "$", "this", ",", "'render'", ")", ",", "$", "this", "->", "icon", ",", "$", "this", "->", "position", ")", ";", "}", "}" ]
Add menu
[ "Add", "menu" ]
train
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Admin/Screen.php#L101-L107
hametuha/wpametu
src/WPametu/UI/Admin/Screen.php
Screen.load
protected function load($template){ $template = get_stylesheet_directory()."/templates/admin/{$template}.php"; /** * wpametu_admin_screen_template * * @param string $template * @param string $class_name * @return string */ $template = apply_filters('wpametu_admin_screen_template', $template, get_called_class()); if( file_exists($template) ){ include $template; } }
php
protected function load($template){ $template = get_stylesheet_directory()."/templates/admin/{$template}.php"; /** * wpametu_admin_screen_template * * @param string $template * @param string $class_name * @return string */ $template = apply_filters('wpametu_admin_screen_template', $template, get_called_class()); if( file_exists($template) ){ include $template; } }
[ "protected", "function", "load", "(", "$", "template", ")", "{", "$", "template", "=", "get_stylesheet_directory", "(", ")", ".", "\"/templates/admin/{$template}.php\"", ";", "/**\n\t\t * wpametu_admin_screen_template\n\t\t *\n\t\t * @param string $template\n\t\t * @param string $class_name\n\t\t * @return string\n\t\t */", "$", "template", "=", "apply_filters", "(", "'wpametu_admin_screen_template'", ",", "$", "template", ",", "get_called_class", "(", ")", ")", ";", "if", "(", "file_exists", "(", "$", "template", ")", ")", "{", "include", "$", "template", ";", "}", "}" ]
Load template @param string $template
[ "Load", "template" ]
train
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Admin/Screen.php#L160-L173
inhere/php-librarys
src/Collections/FixedArray.php
FixedArray.offsetUnset
public function offsetUnset($offset) { $index = $this->getKeyIndex($offset); if ($index >= 0) { // change size. $this->values->setSize($index - 1); unset($this->keys[$offset], $this->values[$index]); } }
php
public function offsetUnset($offset) { $index = $this->getKeyIndex($offset); if ($index >= 0) { // change size. $this->values->setSize($index - 1); unset($this->keys[$offset], $this->values[$index]); } }
[ "public", "function", "offsetUnset", "(", "$", "offset", ")", "{", "$", "index", "=", "$", "this", "->", "getKeyIndex", "(", "$", "offset", ")", ";", "if", "(", "$", "index", ">=", "0", ")", "{", "// change size.", "$", "this", "->", "values", "->", "setSize", "(", "$", "index", "-", "1", ")", ";", "unset", "(", "$", "this", "->", "keys", "[", "$", "offset", "]", ",", "$", "this", "->", "values", "[", "$", "index", "]", ")", ";", "}", "}" ]
Unset an offset in the iterator. @param mixed $offset The array offset. @return void
[ "Unset", "an", "offset", "in", "the", "iterator", "." ]
train
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Collections/FixedArray.php#L186-L196
Innmind/neo4j-dbal
src/Clause/PathAware/PathAware.php
PathAware.linkedTo
public function linkedTo( string $variable = null, array $labels = [] ): Clause { $clause = clone $this; $clause->path = $this->path->linkedTo($variable, $labels); return $clause; }
php
public function linkedTo( string $variable = null, array $labels = [] ): Clause { $clause = clone $this; $clause->path = $this->path->linkedTo($variable, $labels); return $clause; }
[ "public", "function", "linkedTo", "(", "string", "$", "variable", "=", "null", ",", "array", "$", "labels", "=", "[", "]", ")", ":", "Clause", "{", "$", "clause", "=", "clone", "$", "this", ";", "$", "clause", "->", "path", "=", "$", "this", "->", "path", "->", "linkedTo", "(", "$", "variable", ",", "$", "labels", ")", ";", "return", "$", "clause", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/PathAware/PathAware.php#L24-L32
Innmind/neo4j-dbal
src/Clause/PathAware/PathAware.php
PathAware.through
public function through( string $variable = null, string $type = null, string $direction = Expression\Relationship::BOTH ): Clause { $clause = clone $this; $clause->path = $this->path->through($variable, $type, $direction); return $clause; }
php
public function through( string $variable = null, string $type = null, string $direction = Expression\Relationship::BOTH ): Clause { $clause = clone $this; $clause->path = $this->path->through($variable, $type, $direction); return $clause; }
[ "public", "function", "through", "(", "string", "$", "variable", "=", "null", ",", "string", "$", "type", "=", "null", ",", "string", "$", "direction", "=", "Expression", "\\", "Relationship", "::", "BOTH", ")", ":", "Clause", "{", "$", "clause", "=", "clone", "$", "this", ";", "$", "clause", "->", "path", "=", "$", "this", "->", "path", "->", "through", "(", "$", "variable", ",", "$", "type", ",", "$", "direction", ")", ";", "return", "$", "clause", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/PathAware/PathAware.php#L37-L46
Innmind/neo4j-dbal
src/Clause/PathAware/PathAware.php
PathAware.withADistanceOf
public function withADistanceOf(int $distance): Clause { $clause = clone $this; $clause->path = $this->path->withADistanceOf($distance); return $clause; }
php
public function withADistanceOf(int $distance): Clause { $clause = clone $this; $clause->path = $this->path->withADistanceOf($distance); return $clause; }
[ "public", "function", "withADistanceOf", "(", "int", "$", "distance", ")", ":", "Clause", "{", "$", "clause", "=", "clone", "$", "this", ";", "$", "clause", "->", "path", "=", "$", "this", "->", "path", "->", "withADistanceOf", "(", "$", "distance", ")", ";", "return", "$", "clause", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/PathAware/PathAware.php#L51-L57
Innmind/neo4j-dbal
src/Clause/PathAware/PathAware.php
PathAware.withADistanceBetween
public function withADistanceBetween(int $min, int $max): Clause { $clause = clone $this; $clause->path = $this->path->withADistanceBetween($min, $max); return $clause; }
php
public function withADistanceBetween(int $min, int $max): Clause { $clause = clone $this; $clause->path = $this->path->withADistanceBetween($min, $max); return $clause; }
[ "public", "function", "withADistanceBetween", "(", "int", "$", "min", ",", "int", "$", "max", ")", ":", "Clause", "{", "$", "clause", "=", "clone", "$", "this", ";", "$", "clause", "->", "path", "=", "$", "this", "->", "path", "->", "withADistanceBetween", "(", "$", "min", ",", "$", "max", ")", ";", "return", "$", "clause", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/PathAware/PathAware.php#L62-L68
Innmind/neo4j-dbal
src/Clause/PathAware/PathAware.php
PathAware.withADistanceOfAtLeast
public function withADistanceOfAtLeast(int $distance): Clause { $clause = clone $this; $clause->path = $this->path->withADistanceOfAtLeast($distance); return $clause; }
php
public function withADistanceOfAtLeast(int $distance): Clause { $clause = clone $this; $clause->path = $this->path->withADistanceOfAtLeast($distance); return $clause; }
[ "public", "function", "withADistanceOfAtLeast", "(", "int", "$", "distance", ")", ":", "Clause", "{", "$", "clause", "=", "clone", "$", "this", ";", "$", "clause", "->", "path", "=", "$", "this", "->", "path", "->", "withADistanceOfAtLeast", "(", "$", "distance", ")", ";", "return", "$", "clause", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/PathAware/PathAware.php#L73-L79
Innmind/neo4j-dbal
src/Clause/PathAware/PathAware.php
PathAware.withADistanceOfAtMost
public function withADistanceOfAtMost(int $distance): Clause { $clause = clone $this; $clause->path = $this->path->withADistanceOfAtMost($distance); return $clause; }
php
public function withADistanceOfAtMost(int $distance): Clause { $clause = clone $this; $clause->path = $this->path->withADistanceOfAtMost($distance); return $clause; }
[ "public", "function", "withADistanceOfAtMost", "(", "int", "$", "distance", ")", ":", "Clause", "{", "$", "clause", "=", "clone", "$", "this", ";", "$", "clause", "->", "path", "=", "$", "this", "->", "path", "->", "withADistanceOfAtMost", "(", "$", "distance", ")", ";", "return", "$", "clause", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/PathAware/PathAware.php#L84-L90
Innmind/neo4j-dbal
src/Clause/PathAware/PathAware.php
PathAware.withAnyDistance
public function withAnyDistance(): Clause { $clause = clone $this; $clause->path = $this->path->withAnyDistance(); return $clause; }
php
public function withAnyDistance(): Clause { $clause = clone $this; $clause->path = $this->path->withAnyDistance(); return $clause; }
[ "public", "function", "withAnyDistance", "(", ")", ":", "Clause", "{", "$", "clause", "=", "clone", "$", "this", ";", "$", "clause", "->", "path", "=", "$", "this", "->", "path", "->", "withAnyDistance", "(", ")", ";", "return", "$", "clause", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/PathAware/PathAware.php#L95-L101
Innmind/neo4j-dbal
src/Clause/PathAware/PathAware.php
PathAware.withProperty
public function withProperty( string $property, string $cypher ): Clause { $clause = clone $this; $clause->path = $this->path->withProperty($property, $cypher); return $clause; }
php
public function withProperty( string $property, string $cypher ): Clause { $clause = clone $this; $clause->path = $this->path->withProperty($property, $cypher); return $clause; }
[ "public", "function", "withProperty", "(", "string", "$", "property", ",", "string", "$", "cypher", ")", ":", "Clause", "{", "$", "clause", "=", "clone", "$", "this", ";", "$", "clause", "->", "path", "=", "$", "this", "->", "path", "->", "withProperty", "(", "$", "property", ",", "$", "cypher", ")", ";", "return", "$", "clause", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/PathAware/PathAware.php#L106-L114
Innmind/neo4j-dbal
src/Clause/PathAware/PathAware.php
PathAware.withParameter
public function withParameter(string $key, $value): Clause { $clause = clone $this; $clause->path = $this->path->withParameter($key, $value); return $clause; }
php
public function withParameter(string $key, $value): Clause { $clause = clone $this; $clause->path = $this->path->withParameter($key, $value); return $clause; }
[ "public", "function", "withParameter", "(", "string", "$", "key", ",", "$", "value", ")", ":", "Clause", "{", "$", "clause", "=", "clone", "$", "this", ";", "$", "clause", "->", "path", "=", "$", "this", "->", "path", "->", "withParameter", "(", "$", "key", ",", "$", "value", ")", ";", "return", "$", "clause", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Clause/PathAware/PathAware.php#L119-L125
php-lug/lug
src/Bundle/StorageBundle/DependencyInjection/Configuration.php
Configuration.getConfigTreeBuilder
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $treeBuilder ->root('lug_storage') ->children() ->arrayNode('cookie') ->canBeEnabled() ->end() ->arrayNode('doctrine') ->canBeEnabled() ->children() ->scalarNode('service') ->isRequired() ->cannotBeEmpty() ->end() ->end() ->end() ->arrayNode('session') ->canBeEnabled() ->end() ->end(); return $treeBuilder; }
php
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $treeBuilder ->root('lug_storage') ->children() ->arrayNode('cookie') ->canBeEnabled() ->end() ->arrayNode('doctrine') ->canBeEnabled() ->children() ->scalarNode('service') ->isRequired() ->cannotBeEmpty() ->end() ->end() ->end() ->arrayNode('session') ->canBeEnabled() ->end() ->end(); return $treeBuilder; }
[ "public", "function", "getConfigTreeBuilder", "(", ")", "{", "$", "treeBuilder", "=", "new", "TreeBuilder", "(", ")", ";", "$", "treeBuilder", "->", "root", "(", "'lug_storage'", ")", "->", "children", "(", ")", "->", "arrayNode", "(", "'cookie'", ")", "->", "canBeEnabled", "(", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'doctrine'", ")", "->", "canBeEnabled", "(", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'service'", ")", "->", "isRequired", "(", ")", "->", "cannotBeEmpty", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'session'", ")", "->", "canBeEnabled", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", ";", "return", "$", "treeBuilder", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/StorageBundle/DependencyInjection/Configuration.php#L25-L49
mainio/c5pkg_symfony_forms
src/Mainio/C5/Symfony/Form/Extension/Concrete5/DataTransformer/FileToIntegerTransformer.php
FileToIntegerTransformer.transform
public function transform($value) { if ($value === null || $value == '') { return null; } if (!($value instanceof File)) { throw new TransformationFailedException('Expected an instance of a concrete5 file object.'); } return intval($value->getFileID()); }
php
public function transform($value) { if ($value === null || $value == '') { return null; } if (!($value instanceof File)) { throw new TransformationFailedException('Expected an instance of a concrete5 file object.'); } return intval($value->getFileID()); }
[ "public", "function", "transform", "(", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", "||", "$", "value", "==", "''", ")", "{", "return", "null", ";", "}", "if", "(", "!", "(", "$", "value", "instanceof", "File", ")", ")", "{", "throw", "new", "TransformationFailedException", "(", "'Expected an instance of a concrete5 file object.'", ")", ";", "}", "return", "intval", "(", "$", "value", "->", "getFileID", "(", ")", ")", ";", "}" ]
Converts a concrete5 file object to an integer. @param \Concrete\Core\File\File $value The file object value @return int The integer value @throws TransformationFailedException If the given value is not an instance of Concrete\Core\File\File.
[ "Converts", "a", "concrete5", "file", "object", "to", "an", "integer", "." ]
train
https://github.com/mainio/c5pkg_symfony_forms/blob/41a93c293d986574ec5cade8a7c8700e083dbaaa/src/Mainio/C5/Symfony/Form/Extension/Concrete5/DataTransformer/FileToIntegerTransformer.php#L34-L43
mainio/c5pkg_symfony_forms
src/Mainio/C5/Symfony/Form/Extension/Concrete5/DataTransformer/FileToIntegerTransformer.php
FileToIntegerTransformer.reverseTransform
public function reverseTransform($fID) { if (!is_numeric($fID) || $fID == 0) { return null; } $rep = $this->entityManager->getRepository('Concrete\Core\File\File'); $f = $rep->find($fID); if (!is_object($f) || $f->isError()) { throw new TransformationFailedException('Invalid file ID.'); } return $f; }
php
public function reverseTransform($fID) { if (!is_numeric($fID) || $fID == 0) { return null; } $rep = $this->entityManager->getRepository('Concrete\Core\File\File'); $f = $rep->find($fID); if (!is_object($f) || $f->isError()) { throw new TransformationFailedException('Invalid file ID.'); } return $f; }
[ "public", "function", "reverseTransform", "(", "$", "fID", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "fID", ")", "||", "$", "fID", "==", "0", ")", "{", "return", "null", ";", "}", "$", "rep", "=", "$", "this", "->", "entityManager", "->", "getRepository", "(", "'Concrete\\Core\\File\\File'", ")", ";", "$", "f", "=", "$", "rep", "->", "find", "(", "$", "fID", ")", ";", "if", "(", "!", "is_object", "(", "$", "f", ")", "||", "$", "f", "->", "isError", "(", ")", ")", "{", "throw", "new", "TransformationFailedException", "(", "'Invalid file ID.'", ")", ";", "}", "return", "$", "f", ";", "}" ]
Converts an integer to a concrete5 file object. @param int $fID @return mixed The value @throws TransformationFailedException If the given value is not a proper concrete5 file ID.
[ "Converts", "an", "integer", "to", "a", "concrete5", "file", "object", "." ]
train
https://github.com/mainio/c5pkg_symfony_forms/blob/41a93c293d986574ec5cade8a7c8700e083dbaaa/src/Mainio/C5/Symfony/Form/Extension/Concrete5/DataTransformer/FileToIntegerTransformer.php#L53-L67
cartalyst/assetic-filters
src/SassphpFilter.php
SassphpFilter.filterLoad
public function filterLoad(AssetInterface $asset) { $root = $asset->getSourceRoot(); $path = $asset->getSourcePath(); $compiler = new \SassParser($this->presets); if ($root and $path) { $compiler->load_paths = array_merge($compiler->load_paths, array($root.'/'.$path)); } $compiler->load_paths = array_merge($compiler->load_paths, $this->importPaths); $asset->setContent($compiler->toCss($asset->getContent(), false)); }
php
public function filterLoad(AssetInterface $asset) { $root = $asset->getSourceRoot(); $path = $asset->getSourcePath(); $compiler = new \SassParser($this->presets); if ($root and $path) { $compiler->load_paths = array_merge($compiler->load_paths, array($root.'/'.$path)); } $compiler->load_paths = array_merge($compiler->load_paths, $this->importPaths); $asset->setContent($compiler->toCss($asset->getContent(), false)); }
[ "public", "function", "filterLoad", "(", "AssetInterface", "$", "asset", ")", "{", "$", "root", "=", "$", "asset", "->", "getSourceRoot", "(", ")", ";", "$", "path", "=", "$", "asset", "->", "getSourcePath", "(", ")", ";", "$", "compiler", "=", "new", "\\", "SassParser", "(", "$", "this", "->", "presets", ")", ";", "if", "(", "$", "root", "and", "$", "path", ")", "{", "$", "compiler", "->", "load_paths", "=", "array_merge", "(", "$", "compiler", "->", "load_paths", ",", "array", "(", "$", "root", ".", "'/'", ".", "$", "path", ")", ")", ";", "}", "$", "compiler", "->", "load_paths", "=", "array_merge", "(", "$", "compiler", "->", "load_paths", ",", "$", "this", "->", "importPaths", ")", ";", "$", "asset", "->", "setContent", "(", "$", "compiler", "->", "toCss", "(", "$", "asset", "->", "getContent", "(", ")", ",", "false", ")", ")", ";", "}" ]
Filters an asset after it has been loaded. @param \Assetic\Asset\AssetInterface $asset @return void
[ "Filters", "an", "asset", "after", "it", "has", "been", "loaded", "." ]
train
https://github.com/cartalyst/assetic-filters/blob/5e26328f7e46937bf1daa0bee2f744ab3493f471/src/SassphpFilter.php#L48-L62
sastrawi/string-span
src/Sastrawi/String/Span/Span.php
Span.contains
public function contains(SpanInterface $span) { return $this->start <= $span->getStart() && $span->getEnd() <= $this->end; }
php
public function contains(SpanInterface $span) { return $this->start <= $span->getStart() && $span->getEnd() <= $this->end; }
[ "public", "function", "contains", "(", "SpanInterface", "$", "span", ")", "{", "return", "$", "this", "->", "start", "<=", "$", "span", "->", "getStart", "(", ")", "&&", "$", "span", "->", "getEnd", "(", ")", "<=", "$", "this", "->", "end", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/sastrawi/string-span/blob/8e927ea4bf94fcc2f678f31aa3d0a62c74b07fbe/src/Sastrawi/String/Span/Span.php#L104-L107
sastrawi/string-span
src/Sastrawi/String/Span/Span.php
Span.startsWith
public function startsWith(SpanInterface $span) { return $this->getStart() == $span->getStart() && $this->contains($span); }
php
public function startsWith(SpanInterface $span) { return $this->getStart() == $span->getStart() && $this->contains($span); }
[ "public", "function", "startsWith", "(", "SpanInterface", "$", "span", ")", "{", "return", "$", "this", "->", "getStart", "(", ")", "==", "$", "span", "->", "getStart", "(", ")", "&&", "$", "this", "->", "contains", "(", "$", "span", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/sastrawi/string-span/blob/8e927ea4bf94fcc2f678f31aa3d0a62c74b07fbe/src/Sastrawi/String/Span/Span.php#L120-L123
sastrawi/string-span
src/Sastrawi/String/Span/Span.php
Span.intersects
public function intersects(SpanInterface $span) { $sstart = $span->getStart(); //either $span's start is in this or this' start is in $span return $this->contains($span) || $span->contains($this) || $this->getStart() <= $sstart && $sstart < $this->getEnd() || $sstart <= $this->getStart() && $this->getStart() < $span->getEnd(); }
php
public function intersects(SpanInterface $span) { $sstart = $span->getStart(); //either $span's start is in this or this' start is in $span return $this->contains($span) || $span->contains($this) || $this->getStart() <= $sstart && $sstart < $this->getEnd() || $sstart <= $this->getStart() && $this->getStart() < $span->getEnd(); }
[ "public", "function", "intersects", "(", "SpanInterface", "$", "span", ")", "{", "$", "sstart", "=", "$", "span", "->", "getStart", "(", ")", ";", "//either $span's start is in this or this' start is in $span", "return", "$", "this", "->", "contains", "(", "$", "span", ")", "||", "$", "span", "->", "contains", "(", "$", "this", ")", "||", "$", "this", "->", "getStart", "(", ")", "<=", "$", "sstart", "&&", "$", "sstart", "<", "$", "this", "->", "getEnd", "(", ")", "||", "$", "sstart", "<=", "$", "this", "->", "getStart", "(", ")", "&&", "$", "this", "->", "getStart", "(", ")", "<", "$", "span", "->", "getEnd", "(", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/sastrawi/string-span/blob/8e927ea4bf94fcc2f678f31aa3d0a62c74b07fbe/src/Sastrawi/String/Span/Span.php#L128-L136
sastrawi/string-span
src/Sastrawi/String/Span/Span.php
Span.crosses
public function crosses(SpanInterface $span) { $sstart = $span->getStart(); //either $span's start is in this or this' start is in $span return !$this->contains($span) && !$span->contains($this) && ($this->getStart() <= $sstart && $sstart < $this->getEnd() || $sstart <= $this->getStart() && $this->getStart() < $span->getEnd()); }
php
public function crosses(SpanInterface $span) { $sstart = $span->getStart(); //either $span's start is in this or this' start is in $span return !$this->contains($span) && !$span->contains($this) && ($this->getStart() <= $sstart && $sstart < $this->getEnd() || $sstart <= $this->getStart() && $this->getStart() < $span->getEnd()); }
[ "public", "function", "crosses", "(", "SpanInterface", "$", "span", ")", "{", "$", "sstart", "=", "$", "span", "->", "getStart", "(", ")", ";", "//either $span's start is in this or this' start is in $span", "return", "!", "$", "this", "->", "contains", "(", "$", "span", ")", "&&", "!", "$", "span", "->", "contains", "(", "$", "this", ")", "&&", "(", "$", "this", "->", "getStart", "(", ")", "<=", "$", "sstart", "&&", "$", "sstart", "<", "$", "this", "->", "getEnd", "(", ")", "||", "$", "sstart", "<=", "$", "this", "->", "getStart", "(", ")", "&&", "$", "this", "->", "getStart", "(", ")", "<", "$", "span", "->", "getEnd", "(", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/sastrawi/string-span/blob/8e927ea4bf94fcc2f678f31aa3d0a62c74b07fbe/src/Sastrawi/String/Span/Span.php#L141-L149
webdevvie/pheanstalk-task-queue-bundle
Command/RegenerateFailedTaskCommand.php
RegenerateFailedTaskCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $this->initialiseWorker($input, $output); $id = $input->getOption("id"); $identifier = intval($id); if (strstr($id, ",")) { $ids = explode(",", $id); foreach ($ids as $identifier) { if (intval($identifier) > 0) { $this->regenerateTaskById($identifier); } } } elseif ($identifier > 0) { $this->regenerateTaskById(intval($id)); } }
php
protected function execute(InputInterface $input, OutputInterface $output) { $this->initialiseWorker($input, $output); $id = $input->getOption("id"); $identifier = intval($id); if (strstr($id, ",")) { $ids = explode(",", $id); foreach ($ids as $identifier) { if (intval($identifier) > 0) { $this->regenerateTaskById($identifier); } } } elseif ($identifier > 0) { $this->regenerateTaskById(intval($id)); } }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "this", "->", "initialiseWorker", "(", "$", "input", ",", "$", "output", ")", ";", "$", "id", "=", "$", "input", "->", "getOption", "(", "\"id\"", ")", ";", "$", "identifier", "=", "intval", "(", "$", "id", ")", ";", "if", "(", "strstr", "(", "$", "id", ",", "\",\"", ")", ")", "{", "$", "ids", "=", "explode", "(", "\",\"", ",", "$", "id", ")", ";", "foreach", "(", "$", "ids", "as", "$", "identifier", ")", "{", "if", "(", "intval", "(", "$", "identifier", ")", ">", "0", ")", "{", "$", "this", "->", "regenerateTaskById", "(", "$", "identifier", ")", ";", "}", "}", "}", "elseif", "(", "$", "identifier", ">", "0", ")", "{", "$", "this", "->", "regenerateTaskById", "(", "intval", "(", "$", "id", ")", ")", ";", "}", "}" ]
{@inheritDoc} @param InputInterface $input @param OutputInterface $output @return void @throws \InvalidArgumentException
[ "{", "@inheritDoc", "}" ]
train
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Command/RegenerateFailedTaskCommand.php#L49-L64
webdevvie/pheanstalk-task-queue-bundle
Command/RegenerateFailedTaskCommand.php
RegenerateFailedTaskCommand.regenerateTaskById
private function regenerateTaskById($id) { try { $response = $this->taskQueueService->regenerateTask($id); if ($response) { $this->output->writeln("<info>Regeneration succes</info>"); } else { $this->output->writeln("<error>Regeneration succes</error>"); } } catch (TaskQueueServiceException $e) { $this->output->writeln("<error>Error!:</error>" . $e->getMessage()); } }
php
private function regenerateTaskById($id) { try { $response = $this->taskQueueService->regenerateTask($id); if ($response) { $this->output->writeln("<info>Regeneration succes</info>"); } else { $this->output->writeln("<error>Regeneration succes</error>"); } } catch (TaskQueueServiceException $e) { $this->output->writeln("<error>Error!:</error>" . $e->getMessage()); } }
[ "private", "function", "regenerateTaskById", "(", "$", "id", ")", "{", "try", "{", "$", "response", "=", "$", "this", "->", "taskQueueService", "->", "regenerateTask", "(", "$", "id", ")", ";", "if", "(", "$", "response", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "\"<info>Regeneration succes</info>\"", ")", ";", "}", "else", "{", "$", "this", "->", "output", "->", "writeln", "(", "\"<error>Regeneration succes</error>\"", ")", ";", "}", "}", "catch", "(", "TaskQueueServiceException", "$", "e", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "\"<error>Error!:</error>\"", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Regenerates a task that has failed @param integer $id @return void
[ "Regenerates", "a", "task", "that", "has", "failed" ]
train
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Command/RegenerateFailedTaskCommand.php#L72-L84
eghojansu/moe
src/Instance.php
Instance.__callstatic
static function __callstatic($func,array $args) { if (!self::$fw) self::$fw=Base::instance(); return call_user_func_array(array(self::$fw,$func),$args); }
php
static function __callstatic($func,array $args) { if (!self::$fw) self::$fw=Base::instance(); return call_user_func_array(array(self::$fw,$func),$args); }
[ "static", "function", "__callstatic", "(", "$", "func", ",", "array", "$", "args", ")", "{", "if", "(", "!", "self", "::", "$", "fw", ")", "self", "::", "$", "fw", "=", "Base", "::", "instance", "(", ")", ";", "return", "call_user_func_array", "(", "array", "(", "self", "::", "$", "fw", ",", "$", "func", ")", ",", "$", "args", ")", ";", "}" ]
Forward function calls to framework @return mixed @param $func callback @param $args array
[ "Forward", "function", "calls", "to", "framework" ]
train
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/Instance.php#L19-L23
OKTOTV/OktolabMediaBundle
Controller/PublicApiController.php
PublicApiController.embedEpisodeAction
public function embedEpisodeAction(Request $request) { $uniqID = $request->query->get('uniqID'); $episode = $this->get('oktolab_media')->getEpisode($uniqID); return ['episode' => $episode]; }
php
public function embedEpisodeAction(Request $request) { $uniqID = $request->query->get('uniqID'); $episode = $this->get('oktolab_media')->getEpisode($uniqID); return ['episode' => $episode]; }
[ "public", "function", "embedEpisodeAction", "(", "Request", "$", "request", ")", "{", "$", "uniqID", "=", "$", "request", "->", "query", "->", "get", "(", "'uniqID'", ")", ";", "$", "episode", "=", "$", "this", "->", "get", "(", "'oktolab_media'", ")", "->", "getEpisode", "(", "$", "uniqID", ")", ";", "return", "[", "'episode'", "=>", "$", "episode", "]", ";", "}" ]
TODO: oneOrNone result, respond with empty embed @Route("/embed/episode", name="oktolab_media_embed_episode") @Method("GET") @Template()
[ "TODO", ":", "oneOrNone", "result", "respond", "with", "empty", "embed" ]
train
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Controller/PublicApiController.php#L106-L111
php-lug/lug
src/Component/Locale/Form/Type/LocaleCodeType.php
LocaleCodeType.buildView
public function buildView(FormView $view, FormInterface $form, array $options) { $locales = array_flip(array_map(function (LocaleInterface $locale) { return (string) $locale->getCode(); }, $this->localeRepository->findAll())); foreach ($view->vars['choices'] as $index => $choiceView) { if ($view->vars['data'] !== $choiceView->data && isset($locales[$choiceView->data])) { unset($view->vars['choices'][$index]); } } }
php
public function buildView(FormView $view, FormInterface $form, array $options) { $locales = array_flip(array_map(function (LocaleInterface $locale) { return (string) $locale->getCode(); }, $this->localeRepository->findAll())); foreach ($view->vars['choices'] as $index => $choiceView) { if ($view->vars['data'] !== $choiceView->data && isset($locales[$choiceView->data])) { unset($view->vars['choices'][$index]); } } }
[ "public", "function", "buildView", "(", "FormView", "$", "view", ",", "FormInterface", "$", "form", ",", "array", "$", "options", ")", "{", "$", "locales", "=", "array_flip", "(", "array_map", "(", "function", "(", "LocaleInterface", "$", "locale", ")", "{", "return", "(", "string", ")", "$", "locale", "->", "getCode", "(", ")", ";", "}", ",", "$", "this", "->", "localeRepository", "->", "findAll", "(", ")", ")", ")", ";", "foreach", "(", "$", "view", "->", "vars", "[", "'choices'", "]", "as", "$", "index", "=>", "$", "choiceView", ")", "{", "if", "(", "$", "view", "->", "vars", "[", "'data'", "]", "!==", "$", "choiceView", "->", "data", "&&", "isset", "(", "$", "locales", "[", "$", "choiceView", "->", "data", "]", ")", ")", "{", "unset", "(", "$", "view", "->", "vars", "[", "'choices'", "]", "[", "$", "index", "]", ")", ";", "}", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Component/Locale/Form/Type/LocaleCodeType.php#L43-L54
zhouyl/mellivora
Mellivora/Database/Migrations/DatabaseMigrationRepository.php
DatabaseMigrationRepository.getMigrations
public function getMigrations($steps) { $query = $this->table()->where('batch', '>=', '1'); return $query->orderBy('migration', 'desc')->take($steps)->get()->all(); }
php
public function getMigrations($steps) { $query = $this->table()->where('batch', '>=', '1'); return $query->orderBy('migration', 'desc')->take($steps)->get()->all(); }
[ "public", "function", "getMigrations", "(", "$", "steps", ")", "{", "$", "query", "=", "$", "this", "->", "table", "(", ")", "->", "where", "(", "'batch'", ",", "'>='", ",", "'1'", ")", ";", "return", "$", "query", "->", "orderBy", "(", "'migration'", ",", "'desc'", ")", "->", "take", "(", "$", "steps", ")", "->", "get", "(", ")", "->", "all", "(", ")", ";", "}" ]
Get list of migrations. @param int $steps @return array
[ "Get", "list", "of", "migrations", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Migrations/DatabaseMigrationRepository.php#L64-L69
zhouyl/mellivora
Mellivora/Database/Migrations/DatabaseMigrationRepository.php
DatabaseMigrationRepository.getLast
public function getLast() { $query = $this->table()->where('batch', $this->getLastBatchNumber()); return $query->orderBy('migration', 'desc')->get()->all(); }
php
public function getLast() { $query = $this->table()->where('batch', $this->getLastBatchNumber()); return $query->orderBy('migration', 'desc')->get()->all(); }
[ "public", "function", "getLast", "(", ")", "{", "$", "query", "=", "$", "this", "->", "table", "(", ")", "->", "where", "(", "'batch'", ",", "$", "this", "->", "getLastBatchNumber", "(", ")", ")", ";", "return", "$", "query", "->", "orderBy", "(", "'migration'", ",", "'desc'", ")", "->", "get", "(", ")", "->", "all", "(", ")", ";", "}" ]
Get the last migration batch. @return array
[ "Get", "the", "last", "migration", "batch", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Migrations/DatabaseMigrationRepository.php#L76-L81
odiaseo/pagebuilder
src/PageBuilder/Service/LayoutService.php
LayoutService.getPageThemeLayout
public function getPageThemeLayout($pageThemeId) { /** @var $themeModel \PageBuilder\Model\PageTemplateModel */ $themeModel = $this->getServiceLocator()->get('pagebuilder\model\pageTheme'); $pageTheme = $themeModel->findObject($pageThemeId); return $this->getPageLayout($pageTheme->getPageId()->getId(), $pageTheme->getThemeId()->getId()); }
php
public function getPageThemeLayout($pageThemeId) { /** @var $themeModel \PageBuilder\Model\PageTemplateModel */ $themeModel = $this->getServiceLocator()->get('pagebuilder\model\pageTheme'); $pageTheme = $themeModel->findObject($pageThemeId); return $this->getPageLayout($pageTheme->getPageId()->getId(), $pageTheme->getThemeId()->getId()); }
[ "public", "function", "getPageThemeLayout", "(", "$", "pageThemeId", ")", "{", "/** @var $themeModel \\PageBuilder\\Model\\PageTemplateModel */", "$", "themeModel", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'pagebuilder\\model\\pageTheme'", ")", ";", "$", "pageTheme", "=", "$", "themeModel", "->", "findObject", "(", "$", "pageThemeId", ")", ";", "return", "$", "this", "->", "getPageLayout", "(", "$", "pageTheme", "->", "getPageId", "(", ")", "->", "getId", "(", ")", ",", "$", "pageTheme", "->", "getThemeId", "(", ")", "->", "getId", "(", ")", ")", ";", "}" ]
Get Page theme layout @param $pageThemeId @return array
[ "Get", "Page", "theme", "layout" ]
train
https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Service/LayoutService.php#L101-L109
odiaseo/pagebuilder
src/PageBuilder/Service/LayoutService.php
LayoutService.getPageLayout
public function getPageLayout($pageId, $pageThemeId = null) { $sections = $templateSections = []; $error = ''; $details = []; /** @var $pageModel \PageBuilder\Model\PageModel */ $pageModel = $this->getServiceLocator()->get('pagebuilder\model\page'); /** @var $themeModel \PageBuilder\Model\BaseModel */ $themeModel = $this->getServiceLocator()->get('pagebuilder\model\theme'); /** @var $templateModel \PageBuilder\Model\BaseModel */ $templateModel = $this->getServiceLocator()->get('pagebuilder\model\template'); /** @var $page \PageBuilder\Entity\Page */ if ($page = $pageModel->getRepository()->find($pageId)) { $details = [ 'id' => $page->getId(), 'title' => $page->getTitle(), 'description' => $page->getDescription(), 'template' => $page->getTemplate() ? $page->getTemplate()->getTitle() : '', 'layout' => '', 'pageTheme' => '', 'themeId' => '', 'layoutType' => 'Custom Layout', 'parent' => $page->getParent() ? $page->getParent()->getTitle() : '', ]; } $themeId = $pageTheme = null; if ($pageThemeId) { /** @var $pageThemeModel \PageBuilder\Model\BaseModel */ $pageThemeModel = $this->getServiceLocator()->get('pagebuilder\model\pageTheme'); $pageTheme = $pageThemeModel->findObject($pageThemeId); $themeId = $pageTheme->getId(); } if ($themeId and $pageTheme) { $details['themeId'] = $themeId; $details['layout'] = $pageTheme->getLayout(); $details['pageTheme'] = $pageTheme->getId(); /** @var $temp \PageBuilder\Entity\Template */ if ($temp = $page->getTemplate()) { $sections = $temp->getTemplateSections()->toArray(); } elseif ($temp = $page->getParent()->getTemplate()) { $sections = $temp->getTemplateSections()->toArray(); } } /** @var $section \PageBuilder\Entity\Join\TemplateSection */ foreach ($sections as $section) { $slug = $section->getSectionId()->getSlug(); $templateSections[$slug] = [ 'title' => $section->getSectionId()->getTitle(), 'status' => $section->getIsActive() ? 1 : 0, 'class' => $section->getIsActive() ? '' : 'in-active', ]; } if ($themeData = $themeModel->getRepository()->findAll()) { /** @var $theme \PageBuilder\Entity\Theme */ foreach ($themeData as $theme) { $details['themes'][$theme->getId()] = $theme->toArray(); } } else { $details['themes'] = []; } /** @var $templateModel \PageBuilder\Model\TemplateModel */ $templates = $templateModel->listTemplates(); $components = $this->getServiceLocator()->get('pagebuilder\model\component')->listItemsByTitle(); /** @var $widgetUtil \PageBuilder\Util\Widget */ $widgetUtil = $this->getServiceLocator()->get('util\widget'); $widgetList = $widgetUtil->getWidgetList(); $urlHelper = $this->getServiceLocator()->get('ViewHelperManager')->get('url'); $return = [ 'error' => $error, 'page' => $details, 'editUrl' => $pageThemeId ? $urlHelper('builder\theme', ['id' => $pageThemeId]) : $urlHelper( 'builder', ['id' => $pageId] ), 'sections' => $templateSections, 'title' => 'Layout Manager - ' . ($page ? $page->getTitle() : ''), 'widgets' => [ 'title' => 'Widgets', 'items' => $widgetUtil->getRegistry(), 'total' => count($widgetUtil->getRegistry()), 'list' => $widgetList, 'id' => PageBuilder::LAYOUT_WIDGET, ], 'assets' => [ PageBuilder::LAYOUT_USER_DEFINED => [ 'title' => 'User Defined', 'items' => $components, ], ], 'templates' => [ 'title' => 'Templates', 'items' => $templates, ], 'tags' => $this->_getTaglist(), ]; return $return; }
php
public function getPageLayout($pageId, $pageThemeId = null) { $sections = $templateSections = []; $error = ''; $details = []; /** @var $pageModel \PageBuilder\Model\PageModel */ $pageModel = $this->getServiceLocator()->get('pagebuilder\model\page'); /** @var $themeModel \PageBuilder\Model\BaseModel */ $themeModel = $this->getServiceLocator()->get('pagebuilder\model\theme'); /** @var $templateModel \PageBuilder\Model\BaseModel */ $templateModel = $this->getServiceLocator()->get('pagebuilder\model\template'); /** @var $page \PageBuilder\Entity\Page */ if ($page = $pageModel->getRepository()->find($pageId)) { $details = [ 'id' => $page->getId(), 'title' => $page->getTitle(), 'description' => $page->getDescription(), 'template' => $page->getTemplate() ? $page->getTemplate()->getTitle() : '', 'layout' => '', 'pageTheme' => '', 'themeId' => '', 'layoutType' => 'Custom Layout', 'parent' => $page->getParent() ? $page->getParent()->getTitle() : '', ]; } $themeId = $pageTheme = null; if ($pageThemeId) { /** @var $pageThemeModel \PageBuilder\Model\BaseModel */ $pageThemeModel = $this->getServiceLocator()->get('pagebuilder\model\pageTheme'); $pageTheme = $pageThemeModel->findObject($pageThemeId); $themeId = $pageTheme->getId(); } if ($themeId and $pageTheme) { $details['themeId'] = $themeId; $details['layout'] = $pageTheme->getLayout(); $details['pageTheme'] = $pageTheme->getId(); /** @var $temp \PageBuilder\Entity\Template */ if ($temp = $page->getTemplate()) { $sections = $temp->getTemplateSections()->toArray(); } elseif ($temp = $page->getParent()->getTemplate()) { $sections = $temp->getTemplateSections()->toArray(); } } /** @var $section \PageBuilder\Entity\Join\TemplateSection */ foreach ($sections as $section) { $slug = $section->getSectionId()->getSlug(); $templateSections[$slug] = [ 'title' => $section->getSectionId()->getTitle(), 'status' => $section->getIsActive() ? 1 : 0, 'class' => $section->getIsActive() ? '' : 'in-active', ]; } if ($themeData = $themeModel->getRepository()->findAll()) { /** @var $theme \PageBuilder\Entity\Theme */ foreach ($themeData as $theme) { $details['themes'][$theme->getId()] = $theme->toArray(); } } else { $details['themes'] = []; } /** @var $templateModel \PageBuilder\Model\TemplateModel */ $templates = $templateModel->listTemplates(); $components = $this->getServiceLocator()->get('pagebuilder\model\component')->listItemsByTitle(); /** @var $widgetUtil \PageBuilder\Util\Widget */ $widgetUtil = $this->getServiceLocator()->get('util\widget'); $widgetList = $widgetUtil->getWidgetList(); $urlHelper = $this->getServiceLocator()->get('ViewHelperManager')->get('url'); $return = [ 'error' => $error, 'page' => $details, 'editUrl' => $pageThemeId ? $urlHelper('builder\theme', ['id' => $pageThemeId]) : $urlHelper( 'builder', ['id' => $pageId] ), 'sections' => $templateSections, 'title' => 'Layout Manager - ' . ($page ? $page->getTitle() : ''), 'widgets' => [ 'title' => 'Widgets', 'items' => $widgetUtil->getRegistry(), 'total' => count($widgetUtil->getRegistry()), 'list' => $widgetList, 'id' => PageBuilder::LAYOUT_WIDGET, ], 'assets' => [ PageBuilder::LAYOUT_USER_DEFINED => [ 'title' => 'User Defined', 'items' => $components, ], ], 'templates' => [ 'title' => 'Templates', 'items' => $templates, ], 'tags' => $this->_getTaglist(), ]; return $return; }
[ "public", "function", "getPageLayout", "(", "$", "pageId", ",", "$", "pageThemeId", "=", "null", ")", "{", "$", "sections", "=", "$", "templateSections", "=", "[", "]", ";", "$", "error", "=", "''", ";", "$", "details", "=", "[", "]", ";", "/** @var $pageModel \\PageBuilder\\Model\\PageModel */", "$", "pageModel", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'pagebuilder\\model\\page'", ")", ";", "/** @var $themeModel \\PageBuilder\\Model\\BaseModel */", "$", "themeModel", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'pagebuilder\\model\\theme'", ")", ";", "/** @var $templateModel \\PageBuilder\\Model\\BaseModel */", "$", "templateModel", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'pagebuilder\\model\\template'", ")", ";", "/** @var $page \\PageBuilder\\Entity\\Page */", "if", "(", "$", "page", "=", "$", "pageModel", "->", "getRepository", "(", ")", "->", "find", "(", "$", "pageId", ")", ")", "{", "$", "details", "=", "[", "'id'", "=>", "$", "page", "->", "getId", "(", ")", ",", "'title'", "=>", "$", "page", "->", "getTitle", "(", ")", ",", "'description'", "=>", "$", "page", "->", "getDescription", "(", ")", ",", "'template'", "=>", "$", "page", "->", "getTemplate", "(", ")", "?", "$", "page", "->", "getTemplate", "(", ")", "->", "getTitle", "(", ")", ":", "''", ",", "'layout'", "=>", "''", ",", "'pageTheme'", "=>", "''", ",", "'themeId'", "=>", "''", ",", "'layoutType'", "=>", "'Custom Layout'", ",", "'parent'", "=>", "$", "page", "->", "getParent", "(", ")", "?", "$", "page", "->", "getParent", "(", ")", "->", "getTitle", "(", ")", ":", "''", ",", "]", ";", "}", "$", "themeId", "=", "$", "pageTheme", "=", "null", ";", "if", "(", "$", "pageThemeId", ")", "{", "/** @var $pageThemeModel \\PageBuilder\\Model\\BaseModel */", "$", "pageThemeModel", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'pagebuilder\\model\\pageTheme'", ")", ";", "$", "pageTheme", "=", "$", "pageThemeModel", "->", "findObject", "(", "$", "pageThemeId", ")", ";", "$", "themeId", "=", "$", "pageTheme", "->", "getId", "(", ")", ";", "}", "if", "(", "$", "themeId", "and", "$", "pageTheme", ")", "{", "$", "details", "[", "'themeId'", "]", "=", "$", "themeId", ";", "$", "details", "[", "'layout'", "]", "=", "$", "pageTheme", "->", "getLayout", "(", ")", ";", "$", "details", "[", "'pageTheme'", "]", "=", "$", "pageTheme", "->", "getId", "(", ")", ";", "/** @var $temp \\PageBuilder\\Entity\\Template */", "if", "(", "$", "temp", "=", "$", "page", "->", "getTemplate", "(", ")", ")", "{", "$", "sections", "=", "$", "temp", "->", "getTemplateSections", "(", ")", "->", "toArray", "(", ")", ";", "}", "elseif", "(", "$", "temp", "=", "$", "page", "->", "getParent", "(", ")", "->", "getTemplate", "(", ")", ")", "{", "$", "sections", "=", "$", "temp", "->", "getTemplateSections", "(", ")", "->", "toArray", "(", ")", ";", "}", "}", "/** @var $section \\PageBuilder\\Entity\\Join\\TemplateSection */", "foreach", "(", "$", "sections", "as", "$", "section", ")", "{", "$", "slug", "=", "$", "section", "->", "getSectionId", "(", ")", "->", "getSlug", "(", ")", ";", "$", "templateSections", "[", "$", "slug", "]", "=", "[", "'title'", "=>", "$", "section", "->", "getSectionId", "(", ")", "->", "getTitle", "(", ")", ",", "'status'", "=>", "$", "section", "->", "getIsActive", "(", ")", "?", "1", ":", "0", ",", "'class'", "=>", "$", "section", "->", "getIsActive", "(", ")", "?", "''", ":", "'in-active'", ",", "]", ";", "}", "if", "(", "$", "themeData", "=", "$", "themeModel", "->", "getRepository", "(", ")", "->", "findAll", "(", ")", ")", "{", "/** @var $theme \\PageBuilder\\Entity\\Theme */", "foreach", "(", "$", "themeData", "as", "$", "theme", ")", "{", "$", "details", "[", "'themes'", "]", "[", "$", "theme", "->", "getId", "(", ")", "]", "=", "$", "theme", "->", "toArray", "(", ")", ";", "}", "}", "else", "{", "$", "details", "[", "'themes'", "]", "=", "[", "]", ";", "}", "/** @var $templateModel \\PageBuilder\\Model\\TemplateModel */", "$", "templates", "=", "$", "templateModel", "->", "listTemplates", "(", ")", ";", "$", "components", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'pagebuilder\\model\\component'", ")", "->", "listItemsByTitle", "(", ")", ";", "/** @var $widgetUtil \\PageBuilder\\Util\\Widget */", "$", "widgetUtil", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'util\\widget'", ")", ";", "$", "widgetList", "=", "$", "widgetUtil", "->", "getWidgetList", "(", ")", ";", "$", "urlHelper", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'ViewHelperManager'", ")", "->", "get", "(", "'url'", ")", ";", "$", "return", "=", "[", "'error'", "=>", "$", "error", ",", "'page'", "=>", "$", "details", ",", "'editUrl'", "=>", "$", "pageThemeId", "?", "$", "urlHelper", "(", "'builder\\theme'", ",", "[", "'id'", "=>", "$", "pageThemeId", "]", ")", ":", "$", "urlHelper", "(", "'builder'", ",", "[", "'id'", "=>", "$", "pageId", "]", ")", ",", "'sections'", "=>", "$", "templateSections", ",", "'title'", "=>", "'Layout Manager - '", ".", "(", "$", "page", "?", "$", "page", "->", "getTitle", "(", ")", ":", "''", ")", ",", "'widgets'", "=>", "[", "'title'", "=>", "'Widgets'", ",", "'items'", "=>", "$", "widgetUtil", "->", "getRegistry", "(", ")", ",", "'total'", "=>", "count", "(", "$", "widgetUtil", "->", "getRegistry", "(", ")", ")", ",", "'list'", "=>", "$", "widgetList", ",", "'id'", "=>", "PageBuilder", "::", "LAYOUT_WIDGET", ",", "]", ",", "'assets'", "=>", "[", "PageBuilder", "::", "LAYOUT_USER_DEFINED", "=>", "[", "'title'", "=>", "'User Defined'", ",", "'items'", "=>", "$", "components", ",", "]", ",", "]", ",", "'templates'", "=>", "[", "'title'", "=>", "'Templates'", ",", "'items'", "=>", "$", "templates", ",", "]", ",", "'tags'", "=>", "$", "this", "->", "_getTaglist", "(", ")", ",", "]", ";", "return", "$", "return", ";", "}" ]
Get page layout @param $pageId @param null $pageThemeId @return array
[ "Get", "page", "layout" ]
train
https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Service/LayoutService.php#L119-L231
odiaseo/pagebuilder
src/PageBuilder/Service/LayoutService.php
LayoutService.resolvePageLayout
public function resolvePageLayout($pageId, $themeId = null) { /** @var $site \PageBuilder\Entity\Site */ /** @var $parent \PageBuilder\Entity\Page */ /** @var $page \PageBuilder\Entity\Page */ /** @var $templateObj \PageBuilder\Entity\Template */ /** @var PageModel $pageModel */ $layout = []; $pageModel = $this->getServiceLocator()->get('pagebuilder\model\page'); $page = $pageModel->getMainPageById($pageId); if ($page['layout']) { return $page['layout']; } elseif ($page['parentId']) { $parentPage = $pageModel->getMainPageById($page['parentId']); if ($parentPage['layout']) { return $parentPage['layout']; } } if (is_object($page) and $templateObj = $page->getTemplate()) { if ($layout = $templateObj->getLayout()) { return $layout; } } //get the sites default template's layout if ($site = $this->getServiceLocator()->get('active\site')) { if ($templateObj = $site->getDefaultTemplate()) { return $templateObj->getLayout(); } } return $layout; }
php
public function resolvePageLayout($pageId, $themeId = null) { /** @var $site \PageBuilder\Entity\Site */ /** @var $parent \PageBuilder\Entity\Page */ /** @var $page \PageBuilder\Entity\Page */ /** @var $templateObj \PageBuilder\Entity\Template */ /** @var PageModel $pageModel */ $layout = []; $pageModel = $this->getServiceLocator()->get('pagebuilder\model\page'); $page = $pageModel->getMainPageById($pageId); if ($page['layout']) { return $page['layout']; } elseif ($page['parentId']) { $parentPage = $pageModel->getMainPageById($page['parentId']); if ($parentPage['layout']) { return $parentPage['layout']; } } if (is_object($page) and $templateObj = $page->getTemplate()) { if ($layout = $templateObj->getLayout()) { return $layout; } } //get the sites default template's layout if ($site = $this->getServiceLocator()->get('active\site')) { if ($templateObj = $site->getDefaultTemplate()) { return $templateObj->getLayout(); } } return $layout; }
[ "public", "function", "resolvePageLayout", "(", "$", "pageId", ",", "$", "themeId", "=", "null", ")", "{", "/** @var $site \\PageBuilder\\Entity\\Site */", "/** @var $parent \\PageBuilder\\Entity\\Page */", "/** @var $page \\PageBuilder\\Entity\\Page */", "/** @var $templateObj \\PageBuilder\\Entity\\Template */", "/** @var PageModel $pageModel */", "$", "layout", "=", "[", "]", ";", "$", "pageModel", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'pagebuilder\\model\\page'", ")", ";", "$", "page", "=", "$", "pageModel", "->", "getMainPageById", "(", "$", "pageId", ")", ";", "if", "(", "$", "page", "[", "'layout'", "]", ")", "{", "return", "$", "page", "[", "'layout'", "]", ";", "}", "elseif", "(", "$", "page", "[", "'parentId'", "]", ")", "{", "$", "parentPage", "=", "$", "pageModel", "->", "getMainPageById", "(", "$", "page", "[", "'parentId'", "]", ")", ";", "if", "(", "$", "parentPage", "[", "'layout'", "]", ")", "{", "return", "$", "parentPage", "[", "'layout'", "]", ";", "}", "}", "if", "(", "is_object", "(", "$", "page", ")", "and", "$", "templateObj", "=", "$", "page", "->", "getTemplate", "(", ")", ")", "{", "if", "(", "$", "layout", "=", "$", "templateObj", "->", "getLayout", "(", ")", ")", "{", "return", "$", "layout", ";", "}", "}", "//get the sites default template's layout\r", "if", "(", "$", "site", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'active\\site'", ")", ")", "{", "if", "(", "$", "templateObj", "=", "$", "site", "->", "getDefaultTemplate", "(", ")", ")", "{", "return", "$", "templateObj", "->", "getLayout", "(", ")", ";", "}", "}", "return", "$", "layout", ";", "}" ]
@param $pageId @param null $themeId @return array
[ "@param", "$pageId", "@param", "null", "$themeId" ]
train
https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Service/LayoutService.php#L367-L402
ajgarlag/AjglCsv
src/Charset/MbStringConverter.php
MbStringConverter.convert
public function convert($value, $inputCharset, $outputCharset) { if ($inputCharset !== $outputCharset) { $value = mb_convert_encoding($value, $outputCharset, $inputCharset); } return $value; }
php
public function convert($value, $inputCharset, $outputCharset) { if ($inputCharset !== $outputCharset) { $value = mb_convert_encoding($value, $outputCharset, $inputCharset); } return $value; }
[ "public", "function", "convert", "(", "$", "value", ",", "$", "inputCharset", ",", "$", "outputCharset", ")", "{", "if", "(", "$", "inputCharset", "!==", "$", "outputCharset", ")", "{", "$", "value", "=", "mb_convert_encoding", "(", "$", "value", ",", "$", "outputCharset", ",", "$", "inputCharset", ")", ";", "}", "return", "$", "value", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/ajgarlag/AjglCsv/blob/28872f58b9ef864893cac6faddfcb1229c2c2047/src/Charset/MbStringConverter.php#L22-L29
devbr/html
Html.php
Html.insertStyles
public function insertStyles($list) { if (!is_array($list)) { $list = [$list]; } $this->styles = $list; return $this; }
php
public function insertStyles($list) { if (!is_array($list)) { $list = [$list]; } $this->styles = $list; return $this; }
[ "public", "function", "insertStyles", "(", "$", "list", ")", "{", "if", "(", "!", "is_array", "(", "$", "list", ")", ")", "{", "$", "list", "=", "[", "$", "list", "]", ";", "}", "$", "this", "->", "styles", "=", "$", "list", ";", "return", "$", "this", ";", "}" ]
/* Style list insert
[ "/", "*", "Style", "list", "insert" ]
train
https://github.com/devbr/html/blob/c1ff54cbdfe3a1338eb8d0cd9c13a8a435fcf7ce/Html.php#L335-L342
devbr/html
Html.php
Html.insertScripts
public function insertScripts($list) { if (!is_array($list)) { $list = [$list]; } $this->scripts = $list; return $this; }
php
public function insertScripts($list) { if (!is_array($list)) { $list = [$list]; } $this->scripts = $list; return $this; }
[ "public", "function", "insertScripts", "(", "$", "list", ")", "{", "if", "(", "!", "is_array", "(", "$", "list", ")", ")", "{", "$", "list", "=", "[", "$", "list", "]", ";", "}", "$", "this", "->", "scripts", "=", "$", "list", ";", "return", "$", "this", ";", "}" ]
/* Javascript list insert
[ "/", "*", "Javascript", "list", "insert" ]
train
https://github.com/devbr/html/blob/c1ff54cbdfe3a1338eb8d0cd9c13a8a435fcf7ce/Html.php#L346-L353
devbr/html
Html.php
Html.send
public function send() { if ($this->mode == 'pro') { ob_end_clean(); ob_start('ob_gzhandler'); } header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); header('Cache-Control: must_revalidate, public, max-age=31536000'); header('X-Server: Qzumba/0.1.8.beta');//for safety ... header('X-Powered-By: NEOS PHP FRAMEWORK/1.3.0');//for safety ... if ($this->cached && file_exists($this->pathHtmlCache.$this->name.'_cache.html')) { return $this->sendWithCach(); } else { //$timer = £TIME.' - '.microtime(true).' = '.round((microtime(true)-£TIME)*1000, 2).'ms'; exit(eval('?>'.$this->content)); } }
php
public function send() { if ($this->mode == 'pro') { ob_end_clean(); ob_start('ob_gzhandler'); } header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . ' GMT'); header('Cache-Control: must_revalidate, public, max-age=31536000'); header('X-Server: Qzumba/0.1.8.beta');//for safety ... header('X-Powered-By: NEOS PHP FRAMEWORK/1.3.0');//for safety ... if ($this->cached && file_exists($this->pathHtmlCache.$this->name.'_cache.html')) { return $this->sendWithCach(); } else { //$timer = £TIME.' - '.microtime(true).' = '.round((microtime(true)-£TIME)*1000, 2).'ms'; exit(eval('?>'.$this->content)); } }
[ "public", "function", "send", "(", ")", "{", "if", "(", "$", "this", "->", "mode", "==", "'pro'", ")", "{", "ob_end_clean", "(", ")", ";", "ob_start", "(", "'ob_gzhandler'", ")", ";", "}", "header", "(", "'Expires: '", ".", "gmdate", "(", "'D, d M Y H:i:s'", ",", "time", "(", ")", "+", "31536000", ")", ".", "' GMT'", ")", ";", "header", "(", "'Cache-Control: must_revalidate, public, max-age=31536000'", ")", ";", "header", "(", "'X-Server: Qzumba/0.1.8.beta'", ")", ";", "//for safety ...", "header", "(", "'X-Powered-By: NEOS PHP FRAMEWORK/1.3.0'", ")", ";", "//for safety ...", "if", "(", "$", "this", "->", "cached", "&&", "file_exists", "(", "$", "this", "->", "pathHtmlCache", ".", "$", "this", "->", "name", ".", "'_cache.html'", ")", ")", "{", "return", "$", "this", "->", "sendWithCach", "(", ")", ";", "}", "else", "{", "//$timer = £TIME.' - '.microtime(true).' = '.round((microtime(true)-£TIME)*1000, 2).'ms';", "exit", "(", "eval", "(", "'?>'", ".", "$", "this", "->", "content", ")", ")", ";", "}", "}" ]
/* SEND Send headers & Output tris content
[ "/", "*", "SEND", "Send", "headers", "&", "Output", "tris", "content" ]
train
https://github.com/devbr/html/blob/c1ff54cbdfe3a1338eb8d0cd9c13a8a435fcf7ce/Html.php#L435-L453
devbr/html
Html.php
Html.sendCache
public function sendCache() { if (!file_exists($this->pathHtmlCache.$this->name.'_cache.html')) { $this->cached = true; return $this; } $this->setContent(file_get_contents($this->pathHtmlCache.$this->name.'_cache.html')); $this->send(); }
php
public function sendCache() { if (!file_exists($this->pathHtmlCache.$this->name.'_cache.html')) { $this->cached = true; return $this; } $this->setContent(file_get_contents($this->pathHtmlCache.$this->name.'_cache.html')); $this->send(); }
[ "public", "function", "sendCache", "(", ")", "{", "if", "(", "!", "file_exists", "(", "$", "this", "->", "pathHtmlCache", ".", "$", "this", "->", "name", ".", "'_cache.html'", ")", ")", "{", "$", "this", "->", "cached", "=", "true", ";", "return", "$", "this", ";", "}", "$", "this", "->", "setContent", "(", "file_get_contents", "(", "$", "this", "->", "pathHtmlCache", ".", "$", "this", "->", "name", ".", "'_cache.html'", ")", ")", ";", "$", "this", "->", "send", "(", ")", ";", "}" ]
/* Send cached version of compilation
[ "/", "*", "Send", "cached", "version", "of", "compilation" ]
train
https://github.com/devbr/html/blob/c1ff54cbdfe3a1338eb8d0cd9c13a8a435fcf7ce/Html.php#L458-L467
devbr/html
Html.php
Html.sendWithCach
protected function sendWithCach() { $cache = $this->pathHtmlCache.$this->name.'_cache.html'; if (!file_exists($cache)) { file_put_contents($cache, $this->content); } include $cache; exit(); }
php
protected function sendWithCach() { $cache = $this->pathHtmlCache.$this->name.'_cache.html'; if (!file_exists($cache)) { file_put_contents($cache, $this->content); } include $cache; exit(); }
[ "protected", "function", "sendWithCach", "(", ")", "{", "$", "cache", "=", "$", "this", "->", "pathHtmlCache", ".", "$", "this", "->", "name", ".", "'_cache.html'", ";", "if", "(", "!", "file_exists", "(", "$", "cache", ")", ")", "{", "file_put_contents", "(", "$", "cache", ",", "$", "this", "->", "content", ")", ";", "}", "include", "$", "cache", ";", "exit", "(", ")", ";", "}" ]
Teste @todo testando send with CACHE in PHP!
[ "Teste" ]
train
https://github.com/devbr/html/blob/c1ff54cbdfe3a1338eb8d0cd9c13a8a435fcf7ce/Html.php#L472-L480
devbr/html
Html.php
Html.getBlock
protected function getBlock($name = null) { return ($name == null) ? $this->block : (isset($this->block[$name]) ? $this->block[$name] : false); }
php
protected function getBlock($name = null) { return ($name == null) ? $this->block : (isset($this->block[$name]) ? $this->block[$name] : false); }
[ "protected", "function", "getBlock", "(", "$", "name", "=", "null", ")", "{", "return", "(", "$", "name", "==", "null", ")", "?", "$", "this", "->", "block", ":", "(", "isset", "(", "$", "this", "->", "block", "[", "$", "name", "]", ")", "?", "$", "this", "->", "block", "[", "$", "name", "]", ":", "false", ")", ";", "}" ]
Pega o conteúdo de um block
[ "Pega", "o", "conteúdo", "de", "um", "block" ]
train
https://github.com/devbr/html/blob/c1ff54cbdfe3a1338eb8d0cd9c13a8a435fcf7ce/Html.php#L509-L512
devbr/html
Html.php
Html.jsvar
public function jsvar($name, $value = null) { if (is_string($name)) { $this->jsvalues[$name] = $value; } if (is_array($name)) { $this->jsvalues = array_merge($this->jsvalues, $name); } return $this; }
php
public function jsvar($name, $value = null) { if (is_string($name)) { $this->jsvalues[$name] = $value; } if (is_array($name)) { $this->jsvalues = array_merge($this->jsvalues, $name); } return $this; }
[ "public", "function", "jsvar", "(", "$", "name", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "name", ")", ")", "{", "$", "this", "->", "jsvalues", "[", "$", "name", "]", "=", "$", "value", ";", "}", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "$", "this", "->", "jsvalues", "=", "array_merge", "(", "$", "this", "->", "jsvalues", ",", "$", "name", ")", ";", "}", "return", "$", "this", ";", "}" ]
Registra uma variável para o Javascript
[ "Registra", "uma", "variável", "para", "o", "Javascript" ]
train
https://github.com/devbr/html/blob/c1ff54cbdfe3a1338eb8d0cd9c13a8a435fcf7ce/Html.php#L531-L540
devbr/html
Html.php
Html.produceNTag
private function produceNTag() { $ponteiro = -1; $content = $this->getContent(); //Loop de varredura para o arquivo HTML while ($ret = $this->sTag($content, $ponteiro)) { $ponteiro = 0 + $ret['-final-']; $vartemp = ''; //constant URL if ($ret['-tipo-'] == 'var' && $ret['var'] == 'url') { $vartemp = $this->url; } elseif (method_exists($this, '_' . $ret['-tipo-'])) { $vartemp = $this->{'_' . $ret['-tipo-']}($ret); } //Incluindo o bloco gerado pelas ©NeosTags $content = substr_replace($this->getContent(), $vartemp, $ret['-inicio-'], $ret['-tamanho-']); $this->setContent($content); //RE-setando o ponteiro depois de adicionar os dados acima $ponteiro = $ret['-inicio-']; }//end while //returns the processed contents return $this->getContent(); }
php
private function produceNTag() { $ponteiro = -1; $content = $this->getContent(); //Loop de varredura para o arquivo HTML while ($ret = $this->sTag($content, $ponteiro)) { $ponteiro = 0 + $ret['-final-']; $vartemp = ''; //constant URL if ($ret['-tipo-'] == 'var' && $ret['var'] == 'url') { $vartemp = $this->url; } elseif (method_exists($this, '_' . $ret['-tipo-'])) { $vartemp = $this->{'_' . $ret['-tipo-']}($ret); } //Incluindo o bloco gerado pelas ©NeosTags $content = substr_replace($this->getContent(), $vartemp, $ret['-inicio-'], $ret['-tamanho-']); $this->setContent($content); //RE-setando o ponteiro depois de adicionar os dados acima $ponteiro = $ret['-inicio-']; }//end while //returns the processed contents return $this->getContent(); }
[ "private", "function", "produceNTag", "(", ")", "{", "$", "ponteiro", "=", "-", "1", ";", "$", "content", "=", "$", "this", "->", "getContent", "(", ")", ";", "//Loop de varredura para o arquivo HTML", "while", "(", "$", "ret", "=", "$", "this", "->", "sTag", "(", "$", "content", ",", "$", "ponteiro", ")", ")", "{", "$", "ponteiro", "=", "0", "+", "$", "ret", "[", "'-final-'", "]", ";", "$", "vartemp", "=", "''", ";", "//constant URL", "if", "(", "$", "ret", "[", "'-tipo-'", "]", "==", "'var'", "&&", "$", "ret", "[", "'var'", "]", "==", "'url'", ")", "{", "$", "vartemp", "=", "$", "this", "->", "url", ";", "}", "elseif", "(", "method_exists", "(", "$", "this", ",", "'_'", ".", "$", "ret", "[", "'-tipo-'", "]", ")", ")", "{", "$", "vartemp", "=", "$", "this", "->", "{", "'_'", ".", "$", "ret", "[", "'-tipo-'", "]", "}", "(", "$", "ret", ")", ";", "}", "//Incluindo o bloco gerado pelas ©NeosTags", "$", "content", "=", "substr_replace", "(", "$", "this", "->", "getContent", "(", ")", ",", "$", "vartemp", ",", "$", "ret", "[", "'-inicio-'", "]", ",", "$", "ret", "[", "'-tamanho-'", "]", ")", ";", "$", "this", "->", "setContent", "(", "$", "content", ")", ";", "//RE-setando o ponteiro depois de adicionar os dados acima", "$", "ponteiro", "=", "$", "ret", "[", "'-inicio-'", "]", ";", "}", "//end while", "//returns the processed contents", "return", "$", "this", "->", "getContent", "(", ")", ";", "}" ]
Renderiza o arquivo html com ©NeosTags. @return void
[ "Renderiza", "o", "arquivo", "html", "com", "©NeosTags", "." ]
train
https://github.com/devbr/html/blob/c1ff54cbdfe3a1338eb8d0cd9c13a8a435fcf7ce/Html.php#L547-L574
devbr/html
Html.php
Html.clearData
public function clearData($ret) { unset($ret['var'], $ret['-inicio-'], $ret['-tamanho-'], $ret['-final-'], $ret['-tipo-'], $ret['-content-'], $ret['tag'], $ret['data']); return $ret; }
php
public function clearData($ret) { unset($ret['var'], $ret['-inicio-'], $ret['-tamanho-'], $ret['-final-'], $ret['-tipo-'], $ret['-content-'], $ret['tag'], $ret['data']); return $ret; }
[ "public", "function", "clearData", "(", "$", "ret", ")", "{", "unset", "(", "$", "ret", "[", "'var'", "]", ",", "$", "ret", "[", "'-inicio-'", "]", ",", "$", "ret", "[", "'-tamanho-'", "]", ",", "$", "ret", "[", "'-final-'", "]", ",", "$", "ret", "[", "'-tipo-'", "]", ",", "$", "ret", "[", "'-content-'", "]", ",", "$", "ret", "[", "'tag'", "]", ",", "$", "ret", "[", "'data'", "]", ")", ";", "return", "$", "ret", ";", "}" ]
ClearData :: Clear all extra data. @param array $ret Starttag data array. @return array Data array cleared.
[ "ClearData", "::", "Clear", "all", "extra", "data", "." ]
train
https://github.com/devbr/html/blob/c1ff54cbdfe3a1338eb8d0cd9c13a8a435fcf7ce/Html.php#L850-L861
oroinc/OroLayoutComponent
Extension/PreloadedExtension.php
PreloadedExtension.getLayoutUpdates
public function getLayoutUpdates(LayoutItemInterface $item) { $idOrAlias = $item->getAlias() ?: $item->getId(); return isset($this->layoutUpdates[$idOrAlias]) ? $this->layoutUpdates[$idOrAlias] : []; }
php
public function getLayoutUpdates(LayoutItemInterface $item) { $idOrAlias = $item->getAlias() ?: $item->getId(); return isset($this->layoutUpdates[$idOrAlias]) ? $this->layoutUpdates[$idOrAlias] : []; }
[ "public", "function", "getLayoutUpdates", "(", "LayoutItemInterface", "$", "item", ")", "{", "$", "idOrAlias", "=", "$", "item", "->", "getAlias", "(", ")", "?", ":", "$", "item", "->", "getId", "(", ")", ";", "return", "isset", "(", "$", "this", "->", "layoutUpdates", "[", "$", "idOrAlias", "]", ")", "?", "$", "this", "->", "layoutUpdates", "[", "$", "idOrAlias", "]", ":", "[", "]", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/PreloadedExtension.php#L144-L151
oroinc/OroLayoutComponent
Extension/PreloadedExtension.php
PreloadedExtension.hasLayoutUpdates
public function hasLayoutUpdates(LayoutItemInterface $item) { $idOrAlias = $item->getAlias() ?: $item->getId(); return !empty($this->layoutUpdates[$idOrAlias]); }
php
public function hasLayoutUpdates(LayoutItemInterface $item) { $idOrAlias = $item->getAlias() ?: $item->getId(); return !empty($this->layoutUpdates[$idOrAlias]); }
[ "public", "function", "hasLayoutUpdates", "(", "LayoutItemInterface", "$", "item", ")", "{", "$", "idOrAlias", "=", "$", "item", "->", "getAlias", "(", ")", "?", ":", "$", "item", "->", "getId", "(", ")", ";", "return", "!", "empty", "(", "$", "this", "->", "layoutUpdates", "[", "$", "idOrAlias", "]", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/PreloadedExtension.php#L156-L161
oroinc/OroLayoutComponent
Extension/PreloadedExtension.php
PreloadedExtension.getDataProvider
public function getDataProvider($name) { if (!isset($this->dataProviders[$name])) { throw new Exception\InvalidArgumentException( sprintf('The data provider "%s" can not be loaded by this extension.', $name) ); } return $this->dataProviders[$name]; }
php
public function getDataProvider($name) { if (!isset($this->dataProviders[$name])) { throw new Exception\InvalidArgumentException( sprintf('The data provider "%s" can not be loaded by this extension.', $name) ); } return $this->dataProviders[$name]; }
[ "public", "function", "getDataProvider", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "dataProviders", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'The data provider \"%s\" can not be loaded by this extension.'", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "dataProviders", "[", "$", "name", "]", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/PreloadedExtension.php#L182-L191
oroinc/OroLayoutComponent
Extension/PreloadedExtension.php
PreloadedExtension.validateTypes
protected function validateTypes(array $types) { foreach ($types as $key => $val) { if (!is_string($key)) { throw new Exception\InvalidArgumentException( 'Keys of $types array must be strings.' ); } if (!$val instanceof BlockTypeInterface) { throw new Exception\InvalidArgumentException( 'Each item of $types array must be BlockTypeInterface.' ); } } }
php
protected function validateTypes(array $types) { foreach ($types as $key => $val) { if (!is_string($key)) { throw new Exception\InvalidArgumentException( 'Keys of $types array must be strings.' ); } if (!$val instanceof BlockTypeInterface) { throw new Exception\InvalidArgumentException( 'Each item of $types array must be BlockTypeInterface.' ); } } }
[ "protected", "function", "validateTypes", "(", "array", "$", "types", ")", "{", "foreach", "(", "$", "types", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "!", "is_string", "(", "$", "key", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'Keys of $types array must be strings.'", ")", ";", "}", "if", "(", "!", "$", "val", "instanceof", "BlockTypeInterface", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'Each item of $types array must be BlockTypeInterface.'", ")", ";", "}", "}", "}" ]
@param array $types @throws Exception\InvalidArgumentException
[ "@param", "array", "$types" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/PreloadedExtension.php#L206-L220
oroinc/OroLayoutComponent
Extension/PreloadedExtension.php
PreloadedExtension.validateTypeExtensions
protected function validateTypeExtensions(array $typeExtensions) { foreach ($typeExtensions as $key => $val) { if (!is_string($key)) { throw new Exception\InvalidArgumentException( 'Keys of $typeExtensions array must be strings.' ); } if (!is_array($val)) { throw new Exception\InvalidArgumentException( 'Each item of $typeExtensions array must be array of BlockTypeExtensionInterface.' ); } foreach ($val as $subVal) { if (!$subVal instanceof BlockTypeExtensionInterface) { throw new Exception\InvalidArgumentException( 'Each item of $typeExtensions[] array must be BlockTypeExtensionInterface.' ); } } } }
php
protected function validateTypeExtensions(array $typeExtensions) { foreach ($typeExtensions as $key => $val) { if (!is_string($key)) { throw new Exception\InvalidArgumentException( 'Keys of $typeExtensions array must be strings.' ); } if (!is_array($val)) { throw new Exception\InvalidArgumentException( 'Each item of $typeExtensions array must be array of BlockTypeExtensionInterface.' ); } foreach ($val as $subVal) { if (!$subVal instanceof BlockTypeExtensionInterface) { throw new Exception\InvalidArgumentException( 'Each item of $typeExtensions[] array must be BlockTypeExtensionInterface.' ); } } } }
[ "protected", "function", "validateTypeExtensions", "(", "array", "$", "typeExtensions", ")", "{", "foreach", "(", "$", "typeExtensions", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "!", "is_string", "(", "$", "key", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'Keys of $typeExtensions array must be strings.'", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "val", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'Each item of $typeExtensions array must be array of BlockTypeExtensionInterface.'", ")", ";", "}", "foreach", "(", "$", "val", "as", "$", "subVal", ")", "{", "if", "(", "!", "$", "subVal", "instanceof", "BlockTypeExtensionInterface", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'Each item of $typeExtensions[] array must be BlockTypeExtensionInterface.'", ")", ";", "}", "}", "}", "}" ]
@param array $typeExtensions @throws Exception\InvalidArgumentException
[ "@param", "array", "$typeExtensions" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/PreloadedExtension.php#L227-L248
oroinc/OroLayoutComponent
Extension/PreloadedExtension.php
PreloadedExtension.validateLayoutUpdates
protected function validateLayoutUpdates(array $layoutUpdates) { foreach ($layoutUpdates as $key => $val) { if (!is_string($key)) { throw new Exception\InvalidArgumentException( 'Keys of $layoutUpdates array must be strings.' ); } if (!is_array($val)) { throw new Exception\InvalidArgumentException( 'Each item of $layoutUpdates array must be array of LayoutUpdateInterface.' ); } foreach ($val as $subVal) { if (!$subVal instanceof LayoutUpdateInterface) { throw new Exception\InvalidArgumentException( 'Each item of $layoutUpdates[] array must be LayoutUpdateInterface.' ); } } } }
php
protected function validateLayoutUpdates(array $layoutUpdates) { foreach ($layoutUpdates as $key => $val) { if (!is_string($key)) { throw new Exception\InvalidArgumentException( 'Keys of $layoutUpdates array must be strings.' ); } if (!is_array($val)) { throw new Exception\InvalidArgumentException( 'Each item of $layoutUpdates array must be array of LayoutUpdateInterface.' ); } foreach ($val as $subVal) { if (!$subVal instanceof LayoutUpdateInterface) { throw new Exception\InvalidArgumentException( 'Each item of $layoutUpdates[] array must be LayoutUpdateInterface.' ); } } } }
[ "protected", "function", "validateLayoutUpdates", "(", "array", "$", "layoutUpdates", ")", "{", "foreach", "(", "$", "layoutUpdates", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "!", "is_string", "(", "$", "key", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'Keys of $layoutUpdates array must be strings.'", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "val", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'Each item of $layoutUpdates array must be array of LayoutUpdateInterface.'", ")", ";", "}", "foreach", "(", "$", "val", "as", "$", "subVal", ")", "{", "if", "(", "!", "$", "subVal", "instanceof", "LayoutUpdateInterface", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'Each item of $layoutUpdates[] array must be LayoutUpdateInterface.'", ")", ";", "}", "}", "}", "}" ]
@param array $layoutUpdates @throws Exception\InvalidArgumentException
[ "@param", "array", "$layoutUpdates" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/PreloadedExtension.php#L255-L276
oroinc/OroLayoutComponent
Extension/PreloadedExtension.php
PreloadedExtension.validateDataProviders
protected function validateDataProviders(array $dataProviders) { foreach ($dataProviders as $key => $val) { if (!is_string($key)) { throw new Exception\InvalidArgumentException( 'Keys of $dataProviders array must be strings.' ); } } }
php
protected function validateDataProviders(array $dataProviders) { foreach ($dataProviders as $key => $val) { if (!is_string($key)) { throw new Exception\InvalidArgumentException( 'Keys of $dataProviders array must be strings.' ); } } }
[ "protected", "function", "validateDataProviders", "(", "array", "$", "dataProviders", ")", "{", "foreach", "(", "$", "dataProviders", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "!", "is_string", "(", "$", "key", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'Keys of $dataProviders array must be strings.'", ")", ";", "}", "}", "}" ]
@param array $dataProviders @throws Exception\InvalidArgumentException
[ "@param", "array", "$dataProviders" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/PreloadedExtension.php#L299-L308
php-comp/lite-database
src/Helper/DBHelper.php
DBHelper.handleConditions
public static function handleConditions($wheres, LitePdo $db): array { if (\is_object($wheres) && $wheres instanceof \Closure) { $wheres = $wheres($db); } if (!$wheres || $wheres === 1) { return [1, []]; } if (\is_string($wheres)) { return [$wheres, []]; } $inBrackets = false; $nodes = $bindings = []; if (\is_array($wheres)) { foreach ($wheres as $key => $val) { if (\is_object($val) && $val instanceof \Closure) { $val = $val($db); } $key = \trim($key); if ($val === '(') { $nodes[] = \preg_match('/^and|or$/i', $key) ? \strtoupper($key) : 'AND'; $nodes[] = '('; $inBrackets = true; continue; } if ($val === ')') { $nodes[] = ')'; $inBrackets = false; continue; } $valIsArray = \is_array($val); // $key is column name, $val is column value if ($key && !\is_numeric($key)) { $bool = 'AND '; if ($inBrackets) { $bool = ''; $inBrackets = false; } if ($valIsArray) { $nodes[] = $bool . self::formatArrayValue($db->qn($key), $val, 'IN'); continue; } $nodes[] = $bool . $db->qn($key) . '= ?'; $bindings[] = $val; // array: [column, operator(e.g '=', '>=', 'IN'), value, option(Is optional, e.g 'AND', 'OR')] } elseif ($valIsArray) { if (!isset($val[2])) { throw new \InvalidArgumentException('Where condition data is incomplete, at least 3 elements'); } $bool = \strtoupper($val[3] ?? 'AND'); if ($inBrackets) { $bool = ''; $inBrackets = false; } if (\is_array($val[2])) { $nodes[] = $bool . self::formatArrayValue($db->qn($val[0]), $val[2], $val[1]); continue; } $nodes[] = $bool . ' ' . $db->qn($val[0]) . " {$val[1]} ?"; if (\strtoupper($val[1]) === 'LIKE') { $bindings[] = "'{$val[2]}'"; } else { $bindings[] = $val[2]; } } elseif (\is_string($val)) { $bool = 'AND '; if ($inBrackets) { $bool = ''; $inBrackets = false; } $val = \trim($val); $nodes[] = \preg_match('/^and |or /i', $val) ? $val : $bool . $val; } } } $whereStr = \implode(' ', $nodes); unset($nodes); return [self::removeLeadingBoolean($whereStr), $bindings]; }
php
public static function handleConditions($wheres, LitePdo $db): array { if (\is_object($wheres) && $wheres instanceof \Closure) { $wheres = $wheres($db); } if (!$wheres || $wheres === 1) { return [1, []]; } if (\is_string($wheres)) { return [$wheres, []]; } $inBrackets = false; $nodes = $bindings = []; if (\is_array($wheres)) { foreach ($wheres as $key => $val) { if (\is_object($val) && $val instanceof \Closure) { $val = $val($db); } $key = \trim($key); if ($val === '(') { $nodes[] = \preg_match('/^and|or$/i', $key) ? \strtoupper($key) : 'AND'; $nodes[] = '('; $inBrackets = true; continue; } if ($val === ')') { $nodes[] = ')'; $inBrackets = false; continue; } $valIsArray = \is_array($val); // $key is column name, $val is column value if ($key && !\is_numeric($key)) { $bool = 'AND '; if ($inBrackets) { $bool = ''; $inBrackets = false; } if ($valIsArray) { $nodes[] = $bool . self::formatArrayValue($db->qn($key), $val, 'IN'); continue; } $nodes[] = $bool . $db->qn($key) . '= ?'; $bindings[] = $val; // array: [column, operator(e.g '=', '>=', 'IN'), value, option(Is optional, e.g 'AND', 'OR')] } elseif ($valIsArray) { if (!isset($val[2])) { throw new \InvalidArgumentException('Where condition data is incomplete, at least 3 elements'); } $bool = \strtoupper($val[3] ?? 'AND'); if ($inBrackets) { $bool = ''; $inBrackets = false; } if (\is_array($val[2])) { $nodes[] = $bool . self::formatArrayValue($db->qn($val[0]), $val[2], $val[1]); continue; } $nodes[] = $bool . ' ' . $db->qn($val[0]) . " {$val[1]} ?"; if (\strtoupper($val[1]) === 'LIKE') { $bindings[] = "'{$val[2]}'"; } else { $bindings[] = $val[2]; } } elseif (\is_string($val)) { $bool = 'AND '; if ($inBrackets) { $bool = ''; $inBrackets = false; } $val = \trim($val); $nodes[] = \preg_match('/^and |or /i', $val) ? $val : $bool . $val; } } } $whereStr = \implode(' ', $nodes); unset($nodes); return [self::removeLeadingBoolean($whereStr), $bindings]; }
[ "public", "static", "function", "handleConditions", "(", "$", "wheres", ",", "LitePdo", "$", "db", ")", ":", "array", "{", "if", "(", "\\", "is_object", "(", "$", "wheres", ")", "&&", "$", "wheres", "instanceof", "\\", "Closure", ")", "{", "$", "wheres", "=", "$", "wheres", "(", "$", "db", ")", ";", "}", "if", "(", "!", "$", "wheres", "||", "$", "wheres", "===", "1", ")", "{", "return", "[", "1", ",", "[", "]", "]", ";", "}", "if", "(", "\\", "is_string", "(", "$", "wheres", ")", ")", "{", "return", "[", "$", "wheres", ",", "[", "]", "]", ";", "}", "$", "inBrackets", "=", "false", ";", "$", "nodes", "=", "$", "bindings", "=", "[", "]", ";", "if", "(", "\\", "is_array", "(", "$", "wheres", ")", ")", "{", "foreach", "(", "$", "wheres", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "\\", "is_object", "(", "$", "val", ")", "&&", "$", "val", "instanceof", "\\", "Closure", ")", "{", "$", "val", "=", "$", "val", "(", "$", "db", ")", ";", "}", "$", "key", "=", "\\", "trim", "(", "$", "key", ")", ";", "if", "(", "$", "val", "===", "'('", ")", "{", "$", "nodes", "[", "]", "=", "\\", "preg_match", "(", "'/^and|or$/i'", ",", "$", "key", ")", "?", "\\", "strtoupper", "(", "$", "key", ")", ":", "'AND'", ";", "$", "nodes", "[", "]", "=", "'('", ";", "$", "inBrackets", "=", "true", ";", "continue", ";", "}", "if", "(", "$", "val", "===", "')'", ")", "{", "$", "nodes", "[", "]", "=", "')'", ";", "$", "inBrackets", "=", "false", ";", "continue", ";", "}", "$", "valIsArray", "=", "\\", "is_array", "(", "$", "val", ")", ";", "// $key is column name, $val is column value", "if", "(", "$", "key", "&&", "!", "\\", "is_numeric", "(", "$", "key", ")", ")", "{", "$", "bool", "=", "'AND '", ";", "if", "(", "$", "inBrackets", ")", "{", "$", "bool", "=", "''", ";", "$", "inBrackets", "=", "false", ";", "}", "if", "(", "$", "valIsArray", ")", "{", "$", "nodes", "[", "]", "=", "$", "bool", ".", "self", "::", "formatArrayValue", "(", "$", "db", "->", "qn", "(", "$", "key", ")", ",", "$", "val", ",", "'IN'", ")", ";", "continue", ";", "}", "$", "nodes", "[", "]", "=", "$", "bool", ".", "$", "db", "->", "qn", "(", "$", "key", ")", ".", "'= ?'", ";", "$", "bindings", "[", "]", "=", "$", "val", ";", "// array: [column, operator(e.g '=', '>=', 'IN'), value, option(Is optional, e.g 'AND', 'OR')]", "}", "elseif", "(", "$", "valIsArray", ")", "{", "if", "(", "!", "isset", "(", "$", "val", "[", "2", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Where condition data is incomplete, at least 3 elements'", ")", ";", "}", "$", "bool", "=", "\\", "strtoupper", "(", "$", "val", "[", "3", "]", "??", "'AND'", ")", ";", "if", "(", "$", "inBrackets", ")", "{", "$", "bool", "=", "''", ";", "$", "inBrackets", "=", "false", ";", "}", "if", "(", "\\", "is_array", "(", "$", "val", "[", "2", "]", ")", ")", "{", "$", "nodes", "[", "]", "=", "$", "bool", ".", "self", "::", "formatArrayValue", "(", "$", "db", "->", "qn", "(", "$", "val", "[", "0", "]", ")", ",", "$", "val", "[", "2", "]", ",", "$", "val", "[", "1", "]", ")", ";", "continue", ";", "}", "$", "nodes", "[", "]", "=", "$", "bool", ".", "' '", ".", "$", "db", "->", "qn", "(", "$", "val", "[", "0", "]", ")", ".", "\" {$val[1]} ?\"", ";", "if", "(", "\\", "strtoupper", "(", "$", "val", "[", "1", "]", ")", "===", "'LIKE'", ")", "{", "$", "bindings", "[", "]", "=", "\"'{$val[2]}'\"", ";", "}", "else", "{", "$", "bindings", "[", "]", "=", "$", "val", "[", "2", "]", ";", "}", "}", "elseif", "(", "\\", "is_string", "(", "$", "val", ")", ")", "{", "$", "bool", "=", "'AND '", ";", "if", "(", "$", "inBrackets", ")", "{", "$", "bool", "=", "''", ";", "$", "inBrackets", "=", "false", ";", "}", "$", "val", "=", "\\", "trim", "(", "$", "val", ")", ";", "$", "nodes", "[", "]", "=", "\\", "preg_match", "(", "'/^and |or /i'", ",", "$", "val", ")", "?", "$", "val", ":", "$", "bool", ".", "$", "val", ";", "}", "}", "}", "$", "whereStr", "=", "\\", "implode", "(", "' '", ",", "$", "nodes", ")", ";", "unset", "(", "$", "nodes", ")", ";", "return", "[", "self", "::", "removeLeadingBoolean", "(", "$", "whereStr", ")", ",", "$", "bindings", "]", ";", "}" ]
handle where condition @param array|string|\Closure|mixed $wheres @param LitePdo $db @example ``` $result = $db->findAll('user', [ 'userId' => 23, // ==> 'AND `userId` = 23' 'title' => 'test', // value will auto add quote, equal to "AND title = 'test'" 'status' => [1, 2], // status IN (1,2) ['publishTime', '>', '0'], // ==> 'AND `publishTime` > 0' ['createdAt', '<=', 1345665427, 'OR'], // ==> 'OR `createdAt` <= 1345665427' ['publishAt', '<=', \date('Y-m-d H:i:s')], ['id', 'IN' ,[4,5,56]], // ==> '`id` IN ('4','5','56')' ['id', 'NOT IN', [4,5,56]], // ==> '`id` NOT IN ('4','5','56')' ['t1.name', 'like', "%tom%", 'or'], // a closure function () { return 'a < 5 OR b > 6'; } ]); ``` @return array @throws \InvalidArgumentException
[ "handle", "where", "condition", "@param", "array|string|", "\\", "Closure|mixed", "$wheres", "@param", "LitePdo", "$db", "@example", "$result", "=", "$db", "-", ">", "findAll", "(", "user", "[", "userId", "=", ">", "23", "//", "==", ">", "AND", "userId", "=", "23", "title", "=", ">", "test", "//", "value", "will", "auto", "add", "quote", "equal", "to", "AND", "title", "=", "test", "status", "=", ">", "[", "1", "2", "]", "//", "status", "IN", "(", "1", "2", ")" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/Helper/DBHelper.php#L87-L187
php-comp/lite-database
src/Helper/DBHelper.php
DBHelper.formatArrayValue
private static function formatArrayValue(string $col, array $val, string $op): string { return \sprintf(" %s %s ('%s')", $col, $op, \implode("','", $val)); }
php
private static function formatArrayValue(string $col, array $val, string $op): string { return \sprintf(" %s %s ('%s')", $col, $op, \implode("','", $val)); }
[ "private", "static", "function", "formatArrayValue", "(", "string", "$", "col", ",", "array", "$", "val", ",", "string", "$", "op", ")", ":", "string", "{", "return", "\\", "sprintf", "(", "\" %s %s ('%s')\"", ",", "$", "col", ",", "$", "op", ",", "\\", "implode", "(", "\"','\"", ",", "$", "val", ")", ")", ";", "}" ]
handle IN/NOT IN @param string $col @param array $val @param string $op @return string
[ "handle", "IN", "/", "NOT", "IN" ]
train
https://github.com/php-comp/lite-database/blob/af5f73cb89e0e6cd24dd464f7a48fb5088eaafca/src/Helper/DBHelper.php#L196-L199
sciactive/nymph-server
src/Drivers/MySQLDriver.php
MySQLDriver.connect
public function connect() { // Check that the MySQLi extension is installed. if (!is_callable('mysqli_connect')) { throw new Exceptions\UnableToConnectException( 'MySQLi PHP extension is not available. It probably has not been '. 'installed. Please install and configure it in order to use MySQL.' ); } $host = $this->config['MySQL']['host']; $user = $this->config['MySQL']['user']; $password = $this->config['MySQL']['password']; $database = $this->config['MySQL']['database']; $port = $this->config['MySQL']['port']; // If we think we're connected, try pinging the server. if ($this->connected && !mysqli_ping($this->link)) { $this->connected = false; } // Connecting, selecting database if (!$this->connected) { $link = is_callable($this->config['MySQL']['link']) ? $this->config['MySQL']['link']() : null; if ($this->link = $link ?? mysqli_connect( $host, $user, $password, $database, $port )) { $this->connected = true; } else { $this->connected = false; if ($host === 'localhost' && $user === 'nymph' && $password === 'password' && $database === 'nymph' && $link === null) { throw new Exceptions\NotConfiguredException(); } else { throw new Exceptions\UnableToConnectException( 'Could not connect: '. mysqli_error($this->link) ); } } } return $this->connected; }
php
public function connect() { // Check that the MySQLi extension is installed. if (!is_callable('mysqli_connect')) { throw new Exceptions\UnableToConnectException( 'MySQLi PHP extension is not available. It probably has not been '. 'installed. Please install and configure it in order to use MySQL.' ); } $host = $this->config['MySQL']['host']; $user = $this->config['MySQL']['user']; $password = $this->config['MySQL']['password']; $database = $this->config['MySQL']['database']; $port = $this->config['MySQL']['port']; // If we think we're connected, try pinging the server. if ($this->connected && !mysqli_ping($this->link)) { $this->connected = false; } // Connecting, selecting database if (!$this->connected) { $link = is_callable($this->config['MySQL']['link']) ? $this->config['MySQL']['link']() : null; if ($this->link = $link ?? mysqli_connect( $host, $user, $password, $database, $port )) { $this->connected = true; } else { $this->connected = false; if ($host === 'localhost' && $user === 'nymph' && $password === 'password' && $database === 'nymph' && $link === null) { throw new Exceptions\NotConfiguredException(); } else { throw new Exceptions\UnableToConnectException( 'Could not connect: '. mysqli_error($this->link) ); } } } return $this->connected; }
[ "public", "function", "connect", "(", ")", "{", "// Check that the MySQLi extension is installed.", "if", "(", "!", "is_callable", "(", "'mysqli_connect'", ")", ")", "{", "throw", "new", "Exceptions", "\\", "UnableToConnectException", "(", "'MySQLi PHP extension is not available. It probably has not been '", ".", "'installed. Please install and configure it in order to use MySQL.'", ")", ";", "}", "$", "host", "=", "$", "this", "->", "config", "[", "'MySQL'", "]", "[", "'host'", "]", ";", "$", "user", "=", "$", "this", "->", "config", "[", "'MySQL'", "]", "[", "'user'", "]", ";", "$", "password", "=", "$", "this", "->", "config", "[", "'MySQL'", "]", "[", "'password'", "]", ";", "$", "database", "=", "$", "this", "->", "config", "[", "'MySQL'", "]", "[", "'database'", "]", ";", "$", "port", "=", "$", "this", "->", "config", "[", "'MySQL'", "]", "[", "'port'", "]", ";", "// If we think we're connected, try pinging the server.", "if", "(", "$", "this", "->", "connected", "&&", "!", "mysqli_ping", "(", "$", "this", "->", "link", ")", ")", "{", "$", "this", "->", "connected", "=", "false", ";", "}", "// Connecting, selecting database", "if", "(", "!", "$", "this", "->", "connected", ")", "{", "$", "link", "=", "is_callable", "(", "$", "this", "->", "config", "[", "'MySQL'", "]", "[", "'link'", "]", ")", "?", "$", "this", "->", "config", "[", "'MySQL'", "]", "[", "'link'", "]", "(", ")", ":", "null", ";", "if", "(", "$", "this", "->", "link", "=", "$", "link", "??", "mysqli_connect", "(", "$", "host", ",", "$", "user", ",", "$", "password", ",", "$", "database", ",", "$", "port", ")", ")", "{", "$", "this", "->", "connected", "=", "true", ";", "}", "else", "{", "$", "this", "->", "connected", "=", "false", ";", "if", "(", "$", "host", "===", "'localhost'", "&&", "$", "user", "===", "'nymph'", "&&", "$", "password", "===", "'password'", "&&", "$", "database", "===", "'nymph'", "&&", "$", "link", "===", "null", ")", "{", "throw", "new", "Exceptions", "\\", "NotConfiguredException", "(", ")", ";", "}", "else", "{", "throw", "new", "Exceptions", "\\", "UnableToConnectException", "(", "'Could not connect: '", ".", "mysqli_error", "(", "$", "this", "->", "link", ")", ")", ";", "}", "}", "}", "return", "$", "this", "->", "connected", ";", "}" ]
Connect to the MySQL database. @return bool Whether this instance is connected to a MySQL database after the method has run.
[ "Connect", "to", "the", "MySQL", "database", "." ]
train
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Drivers/MySQLDriver.php#L46-L97
sciactive/nymph-server
src/Drivers/MySQLDriver.php
MySQLDriver.disconnect
public function disconnect() { if ($this->connected) { if (is_a($this->link, 'mysqli')) { unset($this->link); } $this->link = null; $this->connected = false; } return $this->connected; }
php
public function disconnect() { if ($this->connected) { if (is_a($this->link, 'mysqli')) { unset($this->link); } $this->link = null; $this->connected = false; } return $this->connected; }
[ "public", "function", "disconnect", "(", ")", "{", "if", "(", "$", "this", "->", "connected", ")", "{", "if", "(", "is_a", "(", "$", "this", "->", "link", ",", "'mysqli'", ")", ")", "{", "unset", "(", "$", "this", "->", "link", ")", ";", "}", "$", "this", "->", "link", "=", "null", ";", "$", "this", "->", "connected", "=", "false", ";", "}", "return", "$", "this", "->", "connected", ";", "}" ]
Disconnect from the MySQL database. @return bool Whether this instance is connected to a MySQL database after the method has run.
[ "Disconnect", "from", "the", "MySQL", "database", "." ]
train
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Drivers/MySQLDriver.php#L105-L114