repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/SelectHandler.php
SelectHandler.handleEditAllAction
private function handleEditAllAction(EnvironmentInterface $environment, Action $action) { $this->clearClipboard($environment); $this->handleGlobalCommands($environment); $this->handleSessionOverrideEditAll( $this->getModelIds($environment, $action, $this->getSubmitAction($environment)), 'properties', $environment ); return $this->callAction($environment, 'editAll', ['mode' => 'edit']); }
php
private function handleEditAllAction(EnvironmentInterface $environment, Action $action) { $this->clearClipboard($environment); $this->handleGlobalCommands($environment); $this->handleSessionOverrideEditAll( $this->getModelIds($environment, $action, $this->getSubmitAction($environment)), 'properties', $environment ); return $this->callAction($environment, 'editAll', ['mode' => 'edit']); }
[ "private", "function", "handleEditAllAction", "(", "EnvironmentInterface", "$", "environment", ",", "Action", "$", "action", ")", "{", "$", "this", "->", "clearClipboard", "(", "$", "environment", ")", ";", "$", "this", "->", "handleGlobalCommands", "(", "$", ...
Handle the edit all action. @param EnvironmentInterface $environment The environment. @param Action $action The action. @return string @SuppressWarnings(PHPMD.UnusedFormalParameter) @SuppressWarnings(PHPMD.UnusedPrivateMethod)
[ "Handle", "the", "edit", "all", "action", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/SelectHandler.php#L379-L390
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/SelectHandler.php
SelectHandler.handleGlobalCommands
private function handleGlobalCommands(EnvironmentInterface $environment) { $dataDefinition = $environment->getDataDefinition(); $backendView = $dataDefinition->getDefinition(Contao2BackendViewDefinitionInterface::NAME); $backButton = null; if ($backendView->getGlobalCommands()->hasCommandNamed('back_button')) { $backButton = $backendView->getGlobalCommands()->getCommandNamed('back_button'); } if (!$backButton) { return; } $parametersBackButton = $backButton->getParameters(); if (\in_array($this->getSelectAction($environment), ['properties', 'edit'])) { $parametersBackButton->offsetSet('act', 'select'); $parametersBackButton->offsetSet( 'select', ('edit' === $this->getSelectAction($environment)) ? 'properties' : 'models' ); $parametersBackButton->offsetSet('mode', $this->getSubmitAction($environment, true)); } $closeCommand = new Command(); $backendView->getGlobalCommands()->addCommand($closeCommand); $closeExtra = [ 'href' => $this->getReferrerUrl($environment), 'class' => 'header_icon header_stop', 'accessKey' => 'x', 'attributes' => 'onclick="Backend.getScrollOffset();"' ]; $closeCommand ->setName('close_all_button') ->setLabel('MSC.closeAll.0') ->setDescription('MSC.closeAll.1') ->setParameters(new \ArrayObject()) ->setExtra(new \ArrayObject($closeExtra)) ->setDisabled(false); }
php
private function handleGlobalCommands(EnvironmentInterface $environment) { $dataDefinition = $environment->getDataDefinition(); $backendView = $dataDefinition->getDefinition(Contao2BackendViewDefinitionInterface::NAME); $backButton = null; if ($backendView->getGlobalCommands()->hasCommandNamed('back_button')) { $backButton = $backendView->getGlobalCommands()->getCommandNamed('back_button'); } if (!$backButton) { return; } $parametersBackButton = $backButton->getParameters(); if (\in_array($this->getSelectAction($environment), ['properties', 'edit'])) { $parametersBackButton->offsetSet('act', 'select'); $parametersBackButton->offsetSet( 'select', ('edit' === $this->getSelectAction($environment)) ? 'properties' : 'models' ); $parametersBackButton->offsetSet('mode', $this->getSubmitAction($environment, true)); } $closeCommand = new Command(); $backendView->getGlobalCommands()->addCommand($closeCommand); $closeExtra = [ 'href' => $this->getReferrerUrl($environment), 'class' => 'header_icon header_stop', 'accessKey' => 'x', 'attributes' => 'onclick="Backend.getScrollOffset();"' ]; $closeCommand ->setName('close_all_button') ->setLabel('MSC.closeAll.0') ->setDescription('MSC.closeAll.1') ->setParameters(new \ArrayObject()) ->setExtra(new \ArrayObject($closeExtra)) ->setDisabled(false); }
[ "private", "function", "handleGlobalCommands", "(", "EnvironmentInterface", "$", "environment", ")", "{", "$", "dataDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", ";", "$", "backendView", "=", "$", "dataDefinition", "->", "getDefinition",...
Handle the global commands. @param EnvironmentInterface $environment The environment. @return void
[ "Handle", "the", "global", "commands", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/SelectHandler.php#L423-L465
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/SelectHandler.php
SelectHandler.clearClipboard
private function clearClipboard(EnvironmentInterface $environment) { $basicDefinition = $environment->getDataDefinition()->getBasicDefinition(); $filter = new Filter(); $filter->andModelIsFromProvider($basicDefinition->getDataProvider()); if ($basicDefinition->getParentDataProvider()) { $filter->andParentIsFromProvider($basicDefinition->getParentDataProvider()); } else { $filter->andHasNoParent(); } $clipboard = $environment->getClipboard(); $items = $clipboard->fetch($filter); if (\count($items) < 1) { return; } foreach ($items as $item) { $clipboard->remove($item); } }
php
private function clearClipboard(EnvironmentInterface $environment) { $basicDefinition = $environment->getDataDefinition()->getBasicDefinition(); $filter = new Filter(); $filter->andModelIsFromProvider($basicDefinition->getDataProvider()); if ($basicDefinition->getParentDataProvider()) { $filter->andParentIsFromProvider($basicDefinition->getParentDataProvider()); } else { $filter->andHasNoParent(); } $clipboard = $environment->getClipboard(); $items = $clipboard->fetch($filter); if (\count($items) < 1) { return; } foreach ($items as $item) { $clipboard->remove($item); } }
[ "private", "function", "clearClipboard", "(", "EnvironmentInterface", "$", "environment", ")", "{", "$", "basicDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getBasicDefinition", "(", ")", ";", "$", "filter", "=", "new", "Filte...
Clear the clipboard if has items. @param EnvironmentInterface $environment The environment. @return void
[ "Clear", "the", "clipboard", "if", "has", "items", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/SelectHandler.php#L507-L529
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/SelectHandler.php
SelectHandler.getSelectCollection
private function getSelectCollection(EnvironmentInterface $environment) { $sessionStorage = $environment->getSessionStorage(); $dataDefinition = $environment->getDataDefinition(); $dataProvider = $environment->getDataProvider(); $session = $sessionStorage->get($dataDefinition->getName() . '.' . $this->getSubmitAction($environment, true)); $modelIds = []; foreach ($session['models'] as $modelId) { $modelIds[] = ModelId::fromSerialized($modelId)->getId(); } $idProperty = \method_exists($dataProvider, 'getIdProperty') ? $dataProvider->getIdProperty() : 'id'; return $dataProvider->fetchAll( $dataProvider->getEmptyConfig()->setFilter( [ [ 'operation' => 'IN', 'property' => $idProperty, 'values' => $modelIds ] ] ) ); }
php
private function getSelectCollection(EnvironmentInterface $environment) { $sessionStorage = $environment->getSessionStorage(); $dataDefinition = $environment->getDataDefinition(); $dataProvider = $environment->getDataProvider(); $session = $sessionStorage->get($dataDefinition->getName() . '.' . $this->getSubmitAction($environment, true)); $modelIds = []; foreach ($session['models'] as $modelId) { $modelIds[] = ModelId::fromSerialized($modelId)->getId(); } $idProperty = \method_exists($dataProvider, 'getIdProperty') ? $dataProvider->getIdProperty() : 'id'; return $dataProvider->fetchAll( $dataProvider->getEmptyConfig()->setFilter( [ [ 'operation' => 'IN', 'property' => $idProperty, 'values' => $modelIds ] ] ) ); }
[ "private", "function", "getSelectCollection", "(", "EnvironmentInterface", "$", "environment", ")", "{", "$", "sessionStorage", "=", "$", "environment", "->", "getSessionStorage", "(", ")", ";", "$", "dataDefinition", "=", "$", "environment", "->", "getDataDefinitio...
Get all select models in a collection. @param EnvironmentInterface $environment The environment. @return CollectionInterface
[ "Get", "all", "select", "models", "in", "a", "collection", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/SelectHandler.php#L538-L563
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/SelectHandler.php
SelectHandler.collectIntersectModelProperties
private function collectIntersectModelProperties(CollectionInterface $collection, EnvironmentInterface $environment) { $palettesDefinition = $environment->getDataDefinition()->getPalettesDefinition(); $properties = []; foreach ($collection->getIterator() as $model) { $palette = $palettesDefinition->findPalette($model); $modelProperties = $this->getVisibleAndEditAbleProperties($palette, $model); foreach ($modelProperties as $modelProperty) { if (!$properties[$modelProperty]) { $properties[$modelProperty] = 0; } ++$properties[$modelProperty]; } } return \array_filter( $properties, function ($count) use ($collection) { return $count === $collection->count(); } ); }
php
private function collectIntersectModelProperties(CollectionInterface $collection, EnvironmentInterface $environment) { $palettesDefinition = $environment->getDataDefinition()->getPalettesDefinition(); $properties = []; foreach ($collection->getIterator() as $model) { $palette = $palettesDefinition->findPalette($model); $modelProperties = $this->getVisibleAndEditAbleProperties($palette, $model); foreach ($modelProperties as $modelProperty) { if (!$properties[$modelProperty]) { $properties[$modelProperty] = 0; } ++$properties[$modelProperty]; } } return \array_filter( $properties, function ($count) use ($collection) { return $count === $collection->count(); } ); }
[ "private", "function", "collectIntersectModelProperties", "(", "CollectionInterface", "$", "collection", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "palettesDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getPalette...
Collecting intersect properties from the collection of models. @param CollectionInterface $collection The collection of models. @param EnvironmentInterface $environment The environment. @return array
[ "Collecting", "intersect", "properties", "from", "the", "collection", "of", "models", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/SelectHandler.php#L616-L640
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/SelectHandler.php
SelectHandler.collectIntersectValues
private function collectIntersectValues(CollectionInterface $collection, EnvironmentInterface $environment) { $sessionStorage = $environment->getSessionStorage(); $dataDefinition = $environment->getDataDefinition(); $session = $sessionStorage->get($dataDefinition->getName() . '.' . $this->getSubmitAction($environment, true)); $values = []; foreach ($collection->getIterator() as $model) { $modelValues = \array_intersect_key($model->getPropertiesAsArray(), $session['intersectProperties']); foreach ($modelValues as $modelProperty => $modelValue) { if (1 === $collection->count()) { $values[$modelProperty] = $modelValue; continue; } $values[$modelProperty][] = $modelValue; } } if (1 === $collection->count()) { return $values; } $intersectValues = []; foreach ($values as $propertyName => $propertyValues) { if (!($value = $this->getUniqueValueFromArray($propertyValues))) { continue; } $intersectValues[$propertyName] = $value; } return $intersectValues; }
php
private function collectIntersectValues(CollectionInterface $collection, EnvironmentInterface $environment) { $sessionStorage = $environment->getSessionStorage(); $dataDefinition = $environment->getDataDefinition(); $session = $sessionStorage->get($dataDefinition->getName() . '.' . $this->getSubmitAction($environment, true)); $values = []; foreach ($collection->getIterator() as $model) { $modelValues = \array_intersect_key($model->getPropertiesAsArray(), $session['intersectProperties']); foreach ($modelValues as $modelProperty => $modelValue) { if (1 === $collection->count()) { $values[$modelProperty] = $modelValue; continue; } $values[$modelProperty][] = $modelValue; } } if (1 === $collection->count()) { return $values; } $intersectValues = []; foreach ($values as $propertyName => $propertyValues) { if (!($value = $this->getUniqueValueFromArray($propertyValues))) { continue; } $intersectValues[$propertyName] = $value; } return $intersectValues; }
[ "private", "function", "collectIntersectValues", "(", "CollectionInterface", "$", "collection", ",", "EnvironmentInterface", "$", "environment", ")", "{", "$", "sessionStorage", "=", "$", "environment", "->", "getSessionStorage", "(", ")", ";", "$", "dataDefinition", ...
Collect the intersect values from the model collection. @param CollectionInterface $collection The collection. @param EnvironmentInterface $environment The environment. @return array
[ "Collect", "the", "intersect", "values", "from", "the", "model", "collection", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/SelectHandler.php#L650-L685
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/SelectHandler.php
SelectHandler.getVisibleAndEditAbleProperties
private function getVisibleAndEditAbleProperties(PaletteInterface $palette, ModelInterface $model) { return \array_intersect( \array_map( function (PropertyInterface $property) { return $property->getName(); }, $palette->getVisibleProperties($model) ), \array_map( function (PropertyInterface $property) { return $property->getName(); }, $palette->getEditableProperties($model) ) ); }
php
private function getVisibleAndEditAbleProperties(PaletteInterface $palette, ModelInterface $model) { return \array_intersect( \array_map( function (PropertyInterface $property) { return $property->getName(); }, $palette->getVisibleProperties($model) ), \array_map( function (PropertyInterface $property) { return $property->getName(); }, $palette->getEditableProperties($model) ) ); }
[ "private", "function", "getVisibleAndEditAbleProperties", "(", "PaletteInterface", "$", "palette", ",", "ModelInterface", "$", "model", ")", "{", "return", "\\", "array_intersect", "(", "\\", "array_map", "(", "function", "(", "PropertyInterface", "$", "property", "...
Get the palette properties their are visible and editable. @param PaletteInterface $palette The palette. @param ModelInterface $model The model. @return array
[ "Get", "the", "palette", "properties", "their", "are", "visible", "and", "editable", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/SelectHandler.php#L695-L711
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ActionHandler/SelectHandler.php
SelectHandler.getUniqueValueFromArray
private function getUniqueValueFromArray(array $values) { $serializedValues = false; foreach ($values as $key => $value) { if (!\is_array($value)) { continue; } $values[$key] = \serialize($value); $serializedValues = true; } if (!$serializedValues) { return 1 === \count(\array_unique($values)) ? $values[0] : null; } return 1 === \count(\array_unique($values)) ? \unserialize($values[0], ['allowed_classes' => true]) : null; }
php
private function getUniqueValueFromArray(array $values) { $serializedValues = false; foreach ($values as $key => $value) { if (!\is_array($value)) { continue; } $values[$key] = \serialize($value); $serializedValues = true; } if (!$serializedValues) { return 1 === \count(\array_unique($values)) ? $values[0] : null; } return 1 === \count(\array_unique($values)) ? \unserialize($values[0], ['allowed_classes' => true]) : null; }
[ "private", "function", "getUniqueValueFromArray", "(", "array", "$", "values", ")", "{", "$", "serializedValues", "=", "false", ";", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "\\", "is_array", "(", "...
Get the unique value from a array. The value will return if the all values in the array the same. @param array $values The values. @return string|array|null
[ "Get", "the", "unique", "value", "from", "a", "array", ".", "The", "value", "will", "return", "if", "the", "all", "values", "in", "the", "array", "the", "same", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ActionHandler/SelectHandler.php#L720-L738
train
contao-community-alliance/dc-general
src/Panel/DefaultSortElement.php
DefaultSortElement.getGroupAndSortingDefinition
protected function getGroupAndSortingDefinition() { /** @var Contao2BackendViewDefinitionInterface $view */ $view = $this->getEnvironment() ->getDataDefinition() ->getDefinition(Contao2BackendViewDefinitionInterface::NAME); return $view ->getListingConfig() ->getGroupAndSortingDefinition(); }
php
protected function getGroupAndSortingDefinition() { /** @var Contao2BackendViewDefinitionInterface $view */ $view = $this->getEnvironment() ->getDataDefinition() ->getDefinition(Contao2BackendViewDefinitionInterface::NAME); return $view ->getListingConfig() ->getGroupAndSortingDefinition(); }
[ "protected", "function", "getGroupAndSortingDefinition", "(", ")", "{", "/** @var Contao2BackendViewDefinitionInterface $view */", "$", "view", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", "getDataDefinition", "(", ")", "->", "getDefinition", "(", "Contao2B...
Retrieve the group and sorting definition. @return GroupAndSortingDefinitionCollectionInterface|GroupAndSortingDefinitionInterface[]
[ "Retrieve", "the", "group", "and", "sorting", "definition", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Panel/DefaultSortElement.php#L50-L60
train
contao-community-alliance/dc-general
src/Panel/DefaultSortElement.php
DefaultSortElement.searchDefinitionByName
protected function searchDefinitionByName($name) { foreach ($this->getGroupAndSortingDefinition() as $definition) { if ($name === $definition->getName()) { return $definition; } } return null; }
php
protected function searchDefinitionByName($name) { foreach ($this->getGroupAndSortingDefinition() as $definition) { if ($name === $definition->getName()) { return $definition; } } return null; }
[ "protected", "function", "searchDefinitionByName", "(", "$", "name", ")", "{", "foreach", "(", "$", "this", "->", "getGroupAndSortingDefinition", "(", ")", "as", "$", "definition", ")", "{", "if", "(", "$", "name", "===", "$", "definition", "->", "getName", ...
Search a definition by it's name. @param string $name The name. @return GroupAndSortingDefinitionInterface|null
[ "Search", "a", "definition", "by", "it", "s", "name", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Panel/DefaultSortElement.php#L69-L78
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.setUp
protected function setUp(General $dataContainer = null) { $this->dataContainer = $dataContainer ?: $this->objDca; if (!$this->dataContainer) { return; } $environment = $this->dataContainer->getEnvironment(); if (!$this->sourceName) { $property = $environment ->getDataDefinition() ->getPropertiesDefinition() ->getProperty($environment->getInputProvider()->getValue('name')); foreach ($property->getExtra() as $k => $v) { $this->$k = $v; } $name = $environment->getInputProvider()->getValue('name'); $this->strField = $name; $this->strName = $name; $this->strId = $name; $this->label = $property->getLabel() ?: $name; $this->strTable = $environment->getDataDefinition()->getName(); } $this->itemContainer = (new DcGeneralFactory()) ->setContainerName($this->sourceName) ->setTranslator($environment->getTranslator()) ->setEventDispatcher($environment->getEventDispatcher()) ->createDcGeneral(); }
php
protected function setUp(General $dataContainer = null) { $this->dataContainer = $dataContainer ?: $this->objDca; if (!$this->dataContainer) { return; } $environment = $this->dataContainer->getEnvironment(); if (!$this->sourceName) { $property = $environment ->getDataDefinition() ->getPropertiesDefinition() ->getProperty($environment->getInputProvider()->getValue('name')); foreach ($property->getExtra() as $k => $v) { $this->$k = $v; } $name = $environment->getInputProvider()->getValue('name'); $this->strField = $name; $this->strName = $name; $this->strId = $name; $this->label = $property->getLabel() ?: $name; $this->strTable = $environment->getDataDefinition()->getName(); } $this->itemContainer = (new DcGeneralFactory()) ->setContainerName($this->sourceName) ->setTranslator($environment->getTranslator()) ->setEventDispatcher($environment->getEventDispatcher()) ->createDcGeneral(); }
[ "protected", "function", "setUp", "(", "General", "$", "dataContainer", "=", "null", ")", "{", "$", "this", "->", "dataContainer", "=", "$", "dataContainer", "?", ":", "$", "this", "->", "objDca", ";", "if", "(", "!", "$", "this", "->", "dataContainer", ...
Setup all local values and create the dc instance for the referenced data source. @param General $dataContainer The data container to use. @return void
[ "Setup", "all", "local", "values", "and", "create", "the", "dc", "instance", "for", "the", "referenced", "data", "source", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L217-L250
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.convertValue
private function convertValue($value) { if (empty($value)) { return null; } if (\is_array($value)) { return $value; } switch ($this->fieldType) { case 'radio': return $value; case 'checkbox': $delimiter = (false !== \stripos($value, "\t")) ? "\t" : ','; return StringUtil::trimsplit($delimiter, $value); default: } throw new \RuntimeException('Unknown field type encountered: ' . $this->fieldType); }
php
private function convertValue($value) { if (empty($value)) { return null; } if (\is_array($value)) { return $value; } switch ($this->fieldType) { case 'radio': return $value; case 'checkbox': $delimiter = (false !== \stripos($value, "\t")) ? "\t" : ','; return StringUtil::trimsplit($delimiter, $value); default: } throw new \RuntimeException('Unknown field type encountered: ' . $this->fieldType); }
[ "private", "function", "convertValue", "(", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "return", "null", ";", "}", "if", "(", "\\", "is_array", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}",...
Convert the value according to the configured fieldtype. @param mixed $value The value to convert. @return mixed @throws \RuntimeException When an unknown field type is encountered.
[ "Convert", "the", "value", "according", "to", "the", "configured", "fieldtype", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L400-L420
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.validator
protected function validator($value) { $convertValue = $this->widgetToValue($value); if ((null === $convertValue) && $this->mandatory) { $translator = $this->getEnvironment()->getTranslator(); $message = empty($this->label) ? $translator->translate('ERR.mdtryNoLabel') : \sprintf( $translator->translate('ERR.mandatory'), $this->strLabel ); $this->addError($message); } return $convertValue; }
php
protected function validator($value) { $convertValue = $this->widgetToValue($value); if ((null === $convertValue) && $this->mandatory) { $translator = $this->getEnvironment()->getTranslator(); $message = empty($this->label) ? $translator->translate('ERR.mdtryNoLabel') : \sprintf( $translator->translate('ERR.mandatory'), $this->strLabel ); $this->addError($message); } return $convertValue; }
[ "protected", "function", "validator", "(", "$", "value", ")", "{", "$", "convertValue", "=", "$", "this", "->", "widgetToValue", "(", "$", "value", ")", ";", "if", "(", "(", "null", "===", "$", "convertValue", ")", "&&", "$", "this", "->", "mandatory",...
Skip the field if "change selection" is not checked. @param array $value The current value. @return array|string
[ "Skip", "the", "field", "if", "change", "selection", "is", "not", "checked", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L469-L487
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.renderItemsPlain
public function renderItemsPlain() { $values = []; $value = $this->varValue; $idProperty = $this->idProperty ?: 'id'; if ('radio' === $this->fieldType && !empty($value)) { $value = (array) $value; } if (\is_array($value) && !empty($value)) { $environment = $this->getEnvironment(); $dataDriver = $environment->getDataProvider(); $config = $environment->getBaseConfigRegistry()->getBaseConfig(); $filter = FilterBuilder::fromArrayForRoot() ->getFilter() ->andPropertyValueIn($idProperty, $value) ->getAllAsArray(); $config->setFilter($filter); // Set the sort field. if ($this->orderField && $dataDriver->fieldExists($this->orderField)) { $config->setSorting([$this->orderField => 'ASC']); } foreach ($dataDriver->fetchAll($config) as $model) { $formatted = $this->formatModel($model, false); $idValue = $model->getProperty($idProperty); $values[$idValue] = $formatted[0]['content']; } // Apply a custom sort order. $values = $this->sortValues($values); } return $values; }
php
public function renderItemsPlain() { $values = []; $value = $this->varValue; $idProperty = $this->idProperty ?: 'id'; if ('radio' === $this->fieldType && !empty($value)) { $value = (array) $value; } if (\is_array($value) && !empty($value)) { $environment = $this->getEnvironment(); $dataDriver = $environment->getDataProvider(); $config = $environment->getBaseConfigRegistry()->getBaseConfig(); $filter = FilterBuilder::fromArrayForRoot() ->getFilter() ->andPropertyValueIn($idProperty, $value) ->getAllAsArray(); $config->setFilter($filter); // Set the sort field. if ($this->orderField && $dataDriver->fieldExists($this->orderField)) { $config->setSorting([$this->orderField => 'ASC']); } foreach ($dataDriver->fetchAll($config) as $model) { $formatted = $this->formatModel($model, false); $idValue = $model->getProperty($idProperty); $values[$idValue] = $formatted[0]['content']; } // Apply a custom sort order. $values = $this->sortValues($values); } return $values; }
[ "public", "function", "renderItemsPlain", "(", ")", "{", "$", "values", "=", "[", "]", ";", "$", "value", "=", "$", "this", "->", "varValue", ";", "$", "idProperty", "=", "$", "this", "->", "idProperty", "?", ":", "'id'", ";", "if", "(", "'radio'", ...
Render the current values for listing. @return array @SuppressWarnings(PHPMD.CyclomaticComplexity)
[ "Render", "the", "current", "values", "for", "listing", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L496-L533
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.generatePickerUrl
protected function generatePickerUrl() { $parameter = [ 'fieldType' => $this->fieldType, 'sourceName' => $this->sourceName, 'modelId' => ModelId::fromModel($this->dataContainer->getModel())->getSerialized(), 'orderField' => $this->orderField, 'propertyName' => $this->name ]; if ($this->pickerOrderProperty && $this->pickerSortDirection) { $parameter = \array_merge( $parameter, [ 'orderProperty' => $this->pickerOrderProperty, 'sortDirection' => $this->pickerSortDirection ] ); } return System::getContainer()->get('contao.picker.builder')->getUrl('cca_tree', $parameter); }
php
protected function generatePickerUrl() { $parameter = [ 'fieldType' => $this->fieldType, 'sourceName' => $this->sourceName, 'modelId' => ModelId::fromModel($this->dataContainer->getModel())->getSerialized(), 'orderField' => $this->orderField, 'propertyName' => $this->name ]; if ($this->pickerOrderProperty && $this->pickerSortDirection) { $parameter = \array_merge( $parameter, [ 'orderProperty' => $this->pickerOrderProperty, 'sortDirection' => $this->pickerSortDirection ] ); } return System::getContainer()->get('contao.picker.builder')->getUrl('cca_tree', $parameter); }
[ "protected", "function", "generatePickerUrl", "(", ")", "{", "$", "parameter", "=", "[", "'fieldType'", "=>", "$", "this", "->", "fieldType", ",", "'sourceName'", "=>", "$", "this", "->", "sourceName", ",", "'modelId'", "=>", "ModelId", "::", "fromModel", "(...
Generate the picker url. @return string
[ "Generate", "the", "picker", "url", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L612-L633
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.valueToWidget
public function valueToWidget($value) { if (!\in_array($this->fieldType, ['radio', 'checkbox'])) { throw new \RuntimeException('Unknown field type encountered: ' . $this->fieldType); } if (null === $value) { return ''; } return ('radio' === $this->fieldType) ? $value : \implode(',', $value); }
php
public function valueToWidget($value) { if (!\in_array($this->fieldType, ['radio', 'checkbox'])) { throw new \RuntimeException('Unknown field type encountered: ' . $this->fieldType); } if (null === $value) { return ''; } return ('radio' === $this->fieldType) ? $value : \implode(',', $value); }
[ "public", "function", "valueToWidget", "(", "$", "value", ")", "{", "if", "(", "!", "\\", "in_array", "(", "$", "this", "->", "fieldType", ",", "[", "'radio'", ",", "'checkbox'", "]", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Unkn...
Convert the value for the widget. @param mixed $value The input value. @return string @throws \RuntimeException Throws an exception, if unknown field type encountered.
[ "Convert", "the", "value", "for", "the", "widget", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L656-L667
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.generateUpdateUrl
protected function generateUpdateUrl() { $request = System::getContainer()->get('request_stack')->getCurrentRequest(); $configPicker = new PickerConfig( 'cca_tree', [ 'fieldType' => $this->fieldType, 'sourceName' => $this->sourceName, 'modelId' => ModelId::fromModel($this->dataContainer->getModel())->getSerialized(), 'orderField' => $this->orderField, 'propertyName' => $this->name ], $this->valueToWidget($this->value) ); return System::getContainer()->get('router')->generate( 'cca_dc_general_tree_update', [ 'picker' => $configPicker->cloneForCurrent((string) $request->query->get('context'))->urlEncode() ], UrlGenerator::ABSOLUTE_URL ); }
php
protected function generateUpdateUrl() { $request = System::getContainer()->get('request_stack')->getCurrentRequest(); $configPicker = new PickerConfig( 'cca_tree', [ 'fieldType' => $this->fieldType, 'sourceName' => $this->sourceName, 'modelId' => ModelId::fromModel($this->dataContainer->getModel())->getSerialized(), 'orderField' => $this->orderField, 'propertyName' => $this->name ], $this->valueToWidget($this->value) ); return System::getContainer()->get('router')->generate( 'cca_dc_general_tree_update', [ 'picker' => $configPicker->cloneForCurrent((string) $request->query->get('context'))->urlEncode() ], UrlGenerator::ABSOLUTE_URL ); }
[ "protected", "function", "generateUpdateUrl", "(", ")", "{", "$", "request", "=", "System", "::", "getContainer", "(", ")", "->", "get", "(", "'request_stack'", ")", "->", "getCurrentRequest", "(", ")", ";", "$", "configPicker", "=", "new", "PickerConfig", "...
Generate the update url. @return string
[ "Generate", "the", "update", "url", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L674-L697
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.generateToggleUrl
private function generateToggleUrl(ModelInterface $model) { $toggleUrlEvent = new AddToUrlEvent( 'ptg=' . $model->getId() . '&amp;provider=' . $model->getProviderName() ); $this->getEnvironment()->getEventDispatcher()->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, $toggleUrlEvent); return System::getContainer()->get('router')->generate( 'cca_dc_general_tree_toggle', $this->getQueryParameterFromUrl($toggleUrlEvent->getUrl()), UrlGenerator::ABSOLUTE_URL ); }
php
private function generateToggleUrl(ModelInterface $model) { $toggleUrlEvent = new AddToUrlEvent( 'ptg=' . $model->getId() . '&amp;provider=' . $model->getProviderName() ); $this->getEnvironment()->getEventDispatcher()->dispatch(ContaoEvents::BACKEND_ADD_TO_URL, $toggleUrlEvent); return System::getContainer()->get('router')->generate( 'cca_dc_general_tree_toggle', $this->getQueryParameterFromUrl($toggleUrlEvent->getUrl()), UrlGenerator::ABSOLUTE_URL ); }
[ "private", "function", "generateToggleUrl", "(", "ModelInterface", "$", "model", ")", "{", "$", "toggleUrlEvent", "=", "new", "AddToUrlEvent", "(", "'ptg='", ".", "$", "model", "->", "getId", "(", ")", ".", "'&amp;provider='", ".", "$", "model", "->", "getPr...
Generate the toggle url. @param ModelInterface $model The model. @return string
[ "Generate", "the", "toggle", "url", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L729-L741
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.getQueryParameterFromUrl
private function getQueryParameterFromUrl($url) { $parameters = array(); foreach (\preg_split('/&(amp;)?/i', \preg_split('/[?]/ui', $url)[1]) as $value) { $chunks = \explode('=', $value); $parameters[$chunks[0]] = $chunks[1]; } return $parameters; }
php
private function getQueryParameterFromUrl($url) { $parameters = array(); foreach (\preg_split('/&(amp;)?/i', \preg_split('/[?]/ui', $url)[1]) as $value) { $chunks = \explode('=', $value); $parameters[$chunks[0]] = $chunks[1]; } return $parameters; }
[ "private", "function", "getQueryParameterFromUrl", "(", "$", "url", ")", "{", "$", "parameters", "=", "array", "(", ")", ";", "foreach", "(", "\\", "preg_split", "(", "'/&(amp;)?/i'", ",", "\\", "preg_split", "(", "'/[?]/ui'", ",", "$", "url", ")", "[", ...
Get the query parameters from url. @param string $url The url. @return array
[ "Get", "the", "query", "parameters", "from", "url", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L750-L759
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.addOrderFieldToTemplate
private function addOrderFieldToTemplate(ContaoBackendViewTemplate $template) { if (!$this->orderField) { return; } $translator = $this->getEnvironment()->getTranslator(); $template ->set('hasOrder', true) ->set('orderId', $this->orderField) ->set('orderName', $this->orderName) ->set('orderValue', \implode(',', (array) $this->value)) ->set('changeSelection', $translator->translate('MSC.changeSelection')) ->set('dragItemsHint', $translator->translate('MSC.dragItemsHint')); }
php
private function addOrderFieldToTemplate(ContaoBackendViewTemplate $template) { if (!$this->orderField) { return; } $translator = $this->getEnvironment()->getTranslator(); $template ->set('hasOrder', true) ->set('orderId', $this->orderField) ->set('orderName', $this->orderName) ->set('orderValue', \implode(',', (array) $this->value)) ->set('changeSelection', $translator->translate('MSC.changeSelection')) ->set('dragItemsHint', $translator->translate('MSC.dragItemsHint')); }
[ "private", "function", "addOrderFieldToTemplate", "(", "ContaoBackendViewTemplate", "$", "template", ")", "{", "if", "(", "!", "$", "this", "->", "orderField", ")", "{", "return", ";", "}", "$", "translator", "=", "$", "this", "->", "getEnvironment", "(", ")...
Add the order field to the template, if the picker has order. @param ContaoBackendViewTemplate $template The template. @return void
[ "Add", "the", "order", "field", "to", "the", "template", "if", "the", "picker", "has", "order", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L768-L783
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.generatePopup
public function generatePopup() { $GLOBALS['TL_JAVASCRIPT']['cca.dc-general.vanillaGeneral'] = 'bundles/ccadcgeneral/js/vanillaGeneral.js'; $environment = $this->getEnvironment(); $translator = $environment->getTranslator(); $template = new ContaoBackendViewTemplate('widget_treepicker_popup'); $icon = new GenerateHtmlEvent($this->titleIcon); $environment->getEventDispatcher()->dispatch(ContaoEvents::IMAGE_GET_HTML, $icon); $template ->setTranslator($translator) ->set('id', 'tl_listing') ->set('name', $this->strName) ->set('class', ($this->strClass ? ' ' . $this->strClass : '')) ->set('icon', $icon->getHtml()) ->set('title', $translator->translate($this->title ?: 'MSC.treePicker', '', [$this->sourceName])) ->set('fieldType', $this->fieldType) ->set('resetSelected', $translator->translate('MSC.resetSelected')) ->set('selectAll', $translator->translate('MSC.selectAll')) ->set('values', StringUtil::deserialize($this->varValue, true)); // Create Tree Render with custom root points. $tree = ''; foreach ($this->getRootIds() as $pid) { $tree .= $this->generateTreeView($this->loadCollection($pid), 'tree'); } $template->set('tree', $tree); // Load the fonts for the drag hint. $GLOBALS['TL_CONFIG']['loadGoogleFonts'] = true; return $template->parse(); }
php
public function generatePopup() { $GLOBALS['TL_JAVASCRIPT']['cca.dc-general.vanillaGeneral'] = 'bundles/ccadcgeneral/js/vanillaGeneral.js'; $environment = $this->getEnvironment(); $translator = $environment->getTranslator(); $template = new ContaoBackendViewTemplate('widget_treepicker_popup'); $icon = new GenerateHtmlEvent($this->titleIcon); $environment->getEventDispatcher()->dispatch(ContaoEvents::IMAGE_GET_HTML, $icon); $template ->setTranslator($translator) ->set('id', 'tl_listing') ->set('name', $this->strName) ->set('class', ($this->strClass ? ' ' . $this->strClass : '')) ->set('icon', $icon->getHtml()) ->set('title', $translator->translate($this->title ?: 'MSC.treePicker', '', [$this->sourceName])) ->set('fieldType', $this->fieldType) ->set('resetSelected', $translator->translate('MSC.resetSelected')) ->set('selectAll', $translator->translate('MSC.selectAll')) ->set('values', StringUtil::deserialize($this->varValue, true)); // Create Tree Render with custom root points. $tree = ''; foreach ($this->getRootIds() as $pid) { $tree .= $this->generateTreeView($this->loadCollection($pid), 'tree'); } $template->set('tree', $tree); // Load the fonts for the drag hint. $GLOBALS['TL_CONFIG']['loadGoogleFonts'] = true; return $template->parse(); }
[ "public", "function", "generatePopup", "(", ")", "{", "$", "GLOBALS", "[", "'TL_JAVASCRIPT'", "]", "[", "'cca.dc-general.vanillaGeneral'", "]", "=", "'bundles/ccadcgeneral/js/vanillaGeneral.js'", ";", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ...
Generate when being called from within a popup. @return string @SuppressWarnings(PHPMD.Superglobals) @SuppressWarnings(PHPMD.CamelCaseVariableName)
[ "Generate", "when", "being", "called", "from", "within", "a", "popup", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L793-L828
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.getRootIds
private function getRootIds() { $root = $this->root; $root = \is_array($root) ? $root : ((\is_numeric($root) && $root > 0) ? [$root] : []); $root = \array_merge($root, [0]); return $root; }
php
private function getRootIds() { $root = $this->root; $root = \is_array($root) ? $root : ((\is_numeric($root) && $root > 0) ? [$root] : []); $root = \array_merge($root, [0]); return $root; }
[ "private", "function", "getRootIds", "(", ")", "{", "$", "root", "=", "$", "this", "->", "root", ";", "$", "root", "=", "\\", "is_array", "(", "$", "root", ")", "?", "$", "root", ":", "(", "(", "\\", "is_numeric", "(", "$", "root", ")", "&&", "...
Determine the root ids. @return array
[ "Determine", "the", "root", "ids", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L835-L842
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.generateAjax
public function generateAjax() { $input = $this->getEnvironment()->getInputProvider(); if ($input->hasValue('action') && ('DcGeneralLoadSubTree' === $input->getValue('action')) ) { $provider = $input->getValue('providerName'); $rootId = $input->getValue('id'); $this->getEnvironment()->getSessionStorage()->set( $this->getToggleId(), $this->getTreeNodeStates()->toggleModel($provider, $rootId)->getStates() ); $collection = $this->loadCollection($rootId, ((int) $input->getValue('level') + 1)); return $this->generateTreeView($collection, 'tree'); } return ''; }
php
public function generateAjax() { $input = $this->getEnvironment()->getInputProvider(); if ($input->hasValue('action') && ('DcGeneralLoadSubTree' === $input->getValue('action')) ) { $provider = $input->getValue('providerName'); $rootId = $input->getValue('id'); $this->getEnvironment()->getSessionStorage()->set( $this->getToggleId(), $this->getTreeNodeStates()->toggleModel($provider, $rootId)->getStates() ); $collection = $this->loadCollection($rootId, ((int) $input->getValue('level') + 1)); return $this->generateTreeView($collection, 'tree'); } return ''; }
[ "public", "function", "generateAjax", "(", ")", "{", "$", "input", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", "getInputProvider", "(", ")", ";", "if", "(", "$", "input", "->", "hasValue", "(", "'action'", ")", "&&", "(", "'DcGeneralLoadSub...
Generate a particular sub part of the page tree and return it as HTML string. @return string
[ "Generate", "a", "particular", "sub", "part", "of", "the", "page", "tree", "and", "return", "it", "as", "HTML", "string", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L849-L867
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.determineModelState
protected function determineModelState(ModelInterface $model, $level) { $model->setMeta(DCGE::TREE_VIEW_LEVEL, $level); $model->setMeta( $model::SHOW_CHILDREN, $this->getTreeNodeStates()->isModelOpen( $model->getProviderName(), $model->getId() ) ); }
php
protected function determineModelState(ModelInterface $model, $level) { $model->setMeta(DCGE::TREE_VIEW_LEVEL, $level); $model->setMeta( $model::SHOW_CHILDREN, $this->getTreeNodeStates()->isModelOpen( $model->getProviderName(), $model->getId() ) ); }
[ "protected", "function", "determineModelState", "(", "ModelInterface", "$", "model", ",", "$", "level", ")", "{", "$", "model", "->", "setMeta", "(", "DCGE", "::", "TREE_VIEW_LEVEL", ",", "$", "level", ")", ";", "$", "model", "->", "setMeta", "(", "$", "...
Check the state of a model and set the metadata accordingly. @param ModelInterface $model The model of which the state shall be checked of. @param int $level The tree level the model is contained within. @return void
[ "Check", "the", "state", "of", "a", "model", "and", "set", "the", "metadata", "accordingly", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L907-L917
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.treeWalkChildCollection
private function treeWalkChildCollection(CollectionInterface $childCollection, ModelInterface $model, $level) { $relationships = $this->getEnvironment()->getDataDefinition()->getModelRelationshipDefinition(); foreach ($childCollection as $childModel) { // Let the child know about it's parent. $model->setMeta($model::PARENT_ID, $model->getId()); $model->setMeta($model::PARENT_PROVIDER_NAME, $model->getProviderName()); $mySubTables = []; foreach ($relationships->getChildConditions($model->getProviderName()) as $condition) { $mySubTables[] = $condition->getDestinationName(); } $this->treeWalkModel($childModel, ($level + 1), $mySubTables); } }
php
private function treeWalkChildCollection(CollectionInterface $childCollection, ModelInterface $model, $level) { $relationships = $this->getEnvironment()->getDataDefinition()->getModelRelationshipDefinition(); foreach ($childCollection as $childModel) { // Let the child know about it's parent. $model->setMeta($model::PARENT_ID, $model->getId()); $model->setMeta($model::PARENT_PROVIDER_NAME, $model->getProviderName()); $mySubTables = []; foreach ($relationships->getChildConditions($model->getProviderName()) as $condition) { $mySubTables[] = $condition->getDestinationName(); } $this->treeWalkModel($childModel, ($level + 1), $mySubTables); } }
[ "private", "function", "treeWalkChildCollection", "(", "CollectionInterface", "$", "childCollection", ",", "ModelInterface", "$", "model", ",", "$", "level", ")", "{", "$", "relationships", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", "getDataDefiniti...
Walk in the child collection for the tree. @param CollectionInterface $childCollection The child collection. @param ModelInterface $model The model to render. @param int $level The current level in the tree hierarchy. @return void
[ "Walk", "in", "the", "child", "collection", "for", "the", "tree", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L990-L1006
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.prepareFilterForRootCondition
private function prepareFilterForRootCondition() { $environment = $this->getEnvironment(); $rootCondition = $environment->getDataDefinition()->getModelRelationshipDefinition()->getRootCondition(); $baseConfig = $environment->getBaseConfigRegistry()->getBaseConfig(); if (!$rootCondition) { return $baseConfig; } $baseFilter = $baseConfig->getFilter(); $filter = $rootCondition->getFilterArray(); if ($baseFilter) { $filter = \array_merge($baseFilter, $filter); } $baseConfig->setFilter($filter); return $baseConfig; }
php
private function prepareFilterForRootCondition() { $environment = $this->getEnvironment(); $rootCondition = $environment->getDataDefinition()->getModelRelationshipDefinition()->getRootCondition(); $baseConfig = $environment->getBaseConfigRegistry()->getBaseConfig(); if (!$rootCondition) { return $baseConfig; } $baseFilter = $baseConfig->getFilter(); $filter = $rootCondition->getFilterArray(); if ($baseFilter) { $filter = \array_merge($baseFilter, $filter); } $baseConfig->setFilter($filter); return $baseConfig; }
[ "private", "function", "prepareFilterForRootCondition", "(", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "rootCondition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "->", "getModelRelationshipDefin...
Prepare filter if has root condition. @return ConfigInterface
[ "Prepare", "filter", "if", "has", "root", "condition", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L1053-L1073
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.pushRootModelToTreeCollection
private function pushRootModelToTreeCollection( DataProviderInterface $dataProvider, CollectionInterface $treeCollection, $level ) { $environment = $this->getEnvironment(); $inputProvider = $environment->getInputProvider(); $baseConfig = $this->prepareFilterForRootCondition(); $relationships = $environment->getDataDefinition()->getModelRelationshipDefinition(); if ($inputProvider->hasParameter('orderProperty') && $inputProvider->hasParameter('sortDirection')) { $orderProperty = $inputProvider->getParameter('orderProperty'); $sortDirection = $inputProvider->getParameter('sortDirection'); $baseConfig->setSorting([$orderProperty => $sortDirection]); } // Fetch all root elements. $collection = $dataProvider->fetchAll($baseConfig); if (!$collection->count()) { return; } $mySubTables = []; foreach ($relationships->getChildConditions($collection->get(0)->getProviderName()) as $condition) { $mySubTables[] = $condition->getDestinationName(); } foreach ($collection as $model) { /** @var ModelInterface $model */ $treeCollection->push($model); $this->treeWalkModel($model, ($level + 1), $mySubTables); } }
php
private function pushRootModelToTreeCollection( DataProviderInterface $dataProvider, CollectionInterface $treeCollection, $level ) { $environment = $this->getEnvironment(); $inputProvider = $environment->getInputProvider(); $baseConfig = $this->prepareFilterForRootCondition(); $relationships = $environment->getDataDefinition()->getModelRelationshipDefinition(); if ($inputProvider->hasParameter('orderProperty') && $inputProvider->hasParameter('sortDirection')) { $orderProperty = $inputProvider->getParameter('orderProperty'); $sortDirection = $inputProvider->getParameter('sortDirection'); $baseConfig->setSorting([$orderProperty => $sortDirection]); } // Fetch all root elements. $collection = $dataProvider->fetchAll($baseConfig); if (!$collection->count()) { return; } $mySubTables = []; foreach ($relationships->getChildConditions($collection->get(0)->getProviderName()) as $condition) { $mySubTables[] = $condition->getDestinationName(); } foreach ($collection as $model) { /** @var ModelInterface $model */ $treeCollection->push($model); $this->treeWalkModel($model, ($level + 1), $mySubTables); } }
[ "private", "function", "pushRootModelToTreeCollection", "(", "DataProviderInterface", "$", "dataProvider", ",", "CollectionInterface", "$", "treeCollection", ",", "$", "level", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", ...
Push root model to the tree collection. @param DataProviderInterface $dataProvider The data provider. @param CollectionInterface $treeCollection The tree collection. @param int $level The level the items are residing on. @return void
[ "Push", "root", "model", "to", "the", "tree", "collection", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L1084-L1117
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.getFormatter
protected function getFormatter(ModelInterface $model, $treeMode) { /** @var ListingConfigInterface $listing */ $definition = $this->getEnvironment()->getDataDefinition(); $listing = $definition->getDefinition(Contao2BackendViewDefinitionInterface::NAME)->getListingConfig(); if ($listing->hasLabelFormatter($model->getProviderName())) { return $listing->getLabelFormatter($model->getProviderName()); } // If not in tree mode and custom label has been defined, use it. if (!$treeMode && $this->itemLabel) { $label = (array) $this->itemLabel; $formatter = new DefaultModelFormatterConfig(); $formatter->setPropertyNames($label['fields']); $formatter->setFormat($label['format']); $formatter->setMaxLength($label['maxCharacters']); return $formatter; } // If no label has been defined, use some default. $properties = []; foreach ($definition->getPropertiesDefinition()->getProperties() as $property) { if ('text' === $property->getWidgetType()) { $properties[] = $property->getName(); } } return (new DefaultModelFormatterConfig()) ->setPropertyNames($properties) ->setFormat(\str_repeat('%s ', \count($properties))); }
php
protected function getFormatter(ModelInterface $model, $treeMode) { /** @var ListingConfigInterface $listing */ $definition = $this->getEnvironment()->getDataDefinition(); $listing = $definition->getDefinition(Contao2BackendViewDefinitionInterface::NAME)->getListingConfig(); if ($listing->hasLabelFormatter($model->getProviderName())) { return $listing->getLabelFormatter($model->getProviderName()); } // If not in tree mode and custom label has been defined, use it. if (!$treeMode && $this->itemLabel) { $label = (array) $this->itemLabel; $formatter = new DefaultModelFormatterConfig(); $formatter->setPropertyNames($label['fields']); $formatter->setFormat($label['format']); $formatter->setMaxLength($label['maxCharacters']); return $formatter; } // If no label has been defined, use some default. $properties = []; foreach ($definition->getPropertiesDefinition()->getProperties() as $property) { if ('text' === $property->getWidgetType()) { $properties[] = $property->getName(); } } return (new DefaultModelFormatterConfig()) ->setPropertyNames($properties) ->setFormat(\str_repeat('%s ', \count($properties))); }
[ "protected", "function", "getFormatter", "(", "ModelInterface", "$", "model", ",", "$", "treeMode", ")", "{", "/** @var ListingConfigInterface $listing */", "$", "definition", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", "getDataDefinition", "(", ")", ...
Retrieve the formatter for the given model. @param ModelInterface $model The model for which the formatter shall be retrieved. @param bool $treeMode Flag if we are running in tree mode or not. @return ModelFormatterConfigInterface
[ "Retrieve", "the", "formatter", "for", "the", "given", "model", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L1156-L1187
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.formatModel
public function formatModel(ModelInterface $model, $treeMode = true) { /** @var ListingConfigInterface $listing */ $environment = $this->getEnvironment(); $definition = $environment->getDataDefinition(); $listing = $definition->getDefinition(Contao2BackendViewDefinitionInterface::NAME)->getListingConfig(); $properties = $definition->getPropertiesDefinition(); $firstSorting = \reset(\array_keys((array) $listing->getDefaultSortingFields())); $formatter = $this->getFormatter($model, $treeMode); $arguments = []; foreach ($formatter->getPropertyNames() as $propertyName) { if ($properties->hasProperty($propertyName)) { $arguments[$propertyName] = (string) $model->getProperty($propertyName); } else { $arguments[$propertyName] = '-'; } } $event = new ModelToLabelEvent($environment, $model); $event ->setArgs($arguments) ->setLabel($formatter->getFormat()) ->setFormatter($formatter); $environment->getEventDispatcher()->dispatch($event::NAME, $event); $labelList = []; $this->prepareLabelWithDisplayedProperties($formatter, $event->getArgs(), $firstSorting, $labelList); $this->prepareLabelWithOutDisplayedProperties($formatter, $event->getArgs(), $event->getLabel(), $labelList); return $labelList; }
php
public function formatModel(ModelInterface $model, $treeMode = true) { /** @var ListingConfigInterface $listing */ $environment = $this->getEnvironment(); $definition = $environment->getDataDefinition(); $listing = $definition->getDefinition(Contao2BackendViewDefinitionInterface::NAME)->getListingConfig(); $properties = $definition->getPropertiesDefinition(); $firstSorting = \reset(\array_keys((array) $listing->getDefaultSortingFields())); $formatter = $this->getFormatter($model, $treeMode); $arguments = []; foreach ($formatter->getPropertyNames() as $propertyName) { if ($properties->hasProperty($propertyName)) { $arguments[$propertyName] = (string) $model->getProperty($propertyName); } else { $arguments[$propertyName] = '-'; } } $event = new ModelToLabelEvent($environment, $model); $event ->setArgs($arguments) ->setLabel($formatter->getFormat()) ->setFormatter($formatter); $environment->getEventDispatcher()->dispatch($event::NAME, $event); $labelList = []; $this->prepareLabelWithDisplayedProperties($formatter, $event->getArgs(), $firstSorting, $labelList); $this->prepareLabelWithOutDisplayedProperties($formatter, $event->getArgs(), $event->getLabel(), $labelList); return $labelList; }
[ "public", "function", "formatModel", "(", "ModelInterface", "$", "model", ",", "$", "treeMode", "=", "true", ")", "{", "/** @var ListingConfigInterface $listing */", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "definition", ...
Format a model accordingly to the current configuration. Returns either an array when in tree mode or a string in (parented) list mode. @param ModelInterface $model The model that shall be formatted. @param bool $treeMode Flag if we are running in tree mode or not (optional, default: true). @return array
[ "Format", "a", "model", "accordingly", "to", "the", "current", "configuration", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L1199-L1231
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.prepareLabelWithDisplayedProperties
private function prepareLabelWithDisplayedProperties( ModelFormatterConfigInterface $formatter, array $arguments, $firstSorting, array &$labelList ) { $definition = $this->getEnvironment()->getDataDefinition(); $listing = $definition->getDefinition(Contao2BackendViewDefinitionInterface::NAME)->getListingConfig(); if (!$listing->getShowColumns()) { return; } $fieldList = $formatter->getPropertyNames(); if (!\is_array($arguments)) { $labelList[] = [ 'colspan' => \count($fieldList), 'class' => 'tl_file_list col_1', 'content' => $arguments ]; } else { foreach ($fieldList as $j => $propertyName) { $labelList[] = [ 'colspan' => 1, 'class' => 'tl_file_list col_' . $j . (($propertyName === $firstSorting) ? ' ordered_by' : ''), 'content' => ('' !== $arguments[$propertyName]) ? $arguments[$propertyName] : '-' ]; } } }
php
private function prepareLabelWithDisplayedProperties( ModelFormatterConfigInterface $formatter, array $arguments, $firstSorting, array &$labelList ) { $definition = $this->getEnvironment()->getDataDefinition(); $listing = $definition->getDefinition(Contao2BackendViewDefinitionInterface::NAME)->getListingConfig(); if (!$listing->getShowColumns()) { return; } $fieldList = $formatter->getPropertyNames(); if (!\is_array($arguments)) { $labelList[] = [ 'colspan' => \count($fieldList), 'class' => 'tl_file_list col_1', 'content' => $arguments ]; } else { foreach ($fieldList as $j => $propertyName) { $labelList[] = [ 'colspan' => 1, 'class' => 'tl_file_list col_' . $j . (($propertyName === $firstSorting) ? ' ordered_by' : ''), 'content' => ('' !== $arguments[$propertyName]) ? $arguments[$propertyName] : '-' ]; } } }
[ "private", "function", "prepareLabelWithDisplayedProperties", "(", "ModelFormatterConfigInterface", "$", "formatter", ",", "array", "$", "arguments", ",", "$", "firstSorting", ",", "array", "&", "$", "labelList", ")", "{", "$", "definition", "=", "$", "this", "->"...
Prepare labels for display with properties. @param ModelFormatterConfigInterface $formatter The model formatter. @param array $arguments The model label arguments. @param string|bool $firstSorting The first sorting. @param array $labelList The label list. @return void
[ "Prepare", "labels", "for", "display", "with", "properties", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L1243-L1272
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.prepareLabelWithOutDisplayedProperties
private function prepareLabelWithOutDisplayedProperties( ModelFormatterConfigInterface $formatter, array $arguments, $label, array &$labelList ) { $definition = $this->getEnvironment()->getDataDefinition(); $listing = $definition->getDefinition(Contao2BackendViewDefinitionInterface::NAME)->getListingConfig(); if ($listing->getShowColumns()) { return; } if (!\is_array($arguments)) { $string = $arguments; } else { $string = \vsprintf($label, $arguments); } if (($maxLength = null !== $formatter->getMaxLength()) && \strlen($string) > $maxLength) { $string = \substr($string, 0, $maxLength); } $labelList[] = [ 'colspan' => null, 'class' => 'tl_file_list', 'content' => $string ]; }
php
private function prepareLabelWithOutDisplayedProperties( ModelFormatterConfigInterface $formatter, array $arguments, $label, array &$labelList ) { $definition = $this->getEnvironment()->getDataDefinition(); $listing = $definition->getDefinition(Contao2BackendViewDefinitionInterface::NAME)->getListingConfig(); if ($listing->getShowColumns()) { return; } if (!\is_array($arguments)) { $string = $arguments; } else { $string = \vsprintf($label, $arguments); } if (($maxLength = null !== $formatter->getMaxLength()) && \strlen($string) > $maxLength) { $string = \substr($string, 0, $maxLength); } $labelList[] = [ 'colspan' => null, 'class' => 'tl_file_list', 'content' => $string ]; }
[ "private", "function", "prepareLabelWithOutDisplayedProperties", "(", "ModelFormatterConfigInterface", "$", "formatter", ",", "array", "$", "arguments", ",", "$", "label", ",", "array", "&", "$", "labelList", ")", "{", "$", "definition", "=", "$", "this", "->", ...
Prepare labels for display without properties. @param ModelFormatterConfigInterface $formatter The model formatter. @param array $arguments The model label arguments. @param string $label The label for format. @param array $labelList The label list. @return void
[ "Prepare", "labels", "for", "display", "without", "properties", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L1284-L1311
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.generateTreeView
protected function generateTreeView($collection, $treeClass) { $content = []; foreach ($collection as $model) { /** @var ModelInterface $model */ $toggleID = $model->getProviderName() . '_' . $treeClass . '_' . $model->getId(); $content[] = $this->parseModel($model, $toggleID); if ($model->getMeta($model::HAS_CHILDREN) && $model->getMeta($model::SHOW_CHILDREN)) { $template = new ContaoBackendViewTemplate('widget_treepicker_child'); $subHtml = ''; foreach ($model->getMeta($model::CHILD_COLLECTIONS) as $objChildCollection) { $subHtml .= $this->generateTreeView($objChildCollection, $treeClass); } $template ->setTranslator($this->getEnvironment()->getTranslator()) ->set('objParentModel', $model) ->set('strToggleID', $toggleID) ->set('strHTML', $subHtml) ->set('strTable', $model->getProviderName()); $content[] = $template->parse(); } } return \implode("\n", $content); }
php
protected function generateTreeView($collection, $treeClass) { $content = []; foreach ($collection as $model) { /** @var ModelInterface $model */ $toggleID = $model->getProviderName() . '_' . $treeClass . '_' . $model->getId(); $content[] = $this->parseModel($model, $toggleID); if ($model->getMeta($model::HAS_CHILDREN) && $model->getMeta($model::SHOW_CHILDREN)) { $template = new ContaoBackendViewTemplate('widget_treepicker_child'); $subHtml = ''; foreach ($model->getMeta($model::CHILD_COLLECTIONS) as $objChildCollection) { $subHtml .= $this->generateTreeView($objChildCollection, $treeClass); } $template ->setTranslator($this->getEnvironment()->getTranslator()) ->set('objParentModel', $model) ->set('strToggleID', $toggleID) ->set('strHTML', $subHtml) ->set('strTable', $model->getProviderName()); $content[] = $template->parse(); } } return \implode("\n", $content); }
[ "protected", "function", "generateTreeView", "(", "$", "collection", ",", "$", "treeClass", ")", "{", "$", "content", "=", "[", "]", ";", "foreach", "(", "$", "collection", "as", "$", "model", ")", "{", "/** @var ModelInterface $model */", "$", "toggleID", "...
Generate the tree view for a given collection. @param CollectionInterface $collection The collection to iterate over. @param string $treeClass The class to use for the tree. @return string
[ "Generate", "the", "tree", "view", "for", "a", "given", "collection", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L1376-L1406
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.parentsOf
private function parentsOf($model, &$parents) { $environment = $this->getEnvironment(); $dataDefinition = $environment->getDataDefinition(); $collector = new ModelCollector($this->getEnvironment()); $relationships = new RelationshipManager( $dataDefinition->getModelRelationshipDefinition(), $dataDefinition->getBasicDefinition()->getMode() ); if (!$relationships->isRoot($model)) { $parent = $collector->searchParentOf($model); if (!isset($parents[$model->getProviderName()][$parent->getId()])) { $this->parentsOf($parent, $parents); } } $parents[$model->getProviderName()][$model->getId()] = 1; }
php
private function parentsOf($model, &$parents) { $environment = $this->getEnvironment(); $dataDefinition = $environment->getDataDefinition(); $collector = new ModelCollector($this->getEnvironment()); $relationships = new RelationshipManager( $dataDefinition->getModelRelationshipDefinition(), $dataDefinition->getBasicDefinition()->getMode() ); if (!$relationships->isRoot($model)) { $parent = $collector->searchParentOf($model); if (!isset($parents[$model->getProviderName()][$parent->getId()])) { $this->parentsOf($parent, $parents); } } $parents[$model->getProviderName()][$model->getId()] = 1; }
[ "private", "function", "parentsOf", "(", "$", "model", ",", "&", "$", "parents", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "dataDefinition", "=", "$", "environment", "->", "getDataDefinition", "(", ")", "...
Fetch all parents of the passed model. @param ModelInterface $model The model. @param string[] $parents The ids of all detected parents so far. @return void
[ "Fetch", "all", "parents", "of", "the", "passed", "model", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L1417-L1435
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.determineParentsOfValues
private function determineParentsOfValues() { $parents = []; $environment = $this->getEnvironment(); $mode = $environment->getDataDefinition()->getBasicDefinition()->getMode(); if (BasicDefinitionInterface::MODE_HIERARCHICAL !== $mode) { return []; } foreach ((array) $this->varValue as $value) { $dataDriver = $environment->getDataProvider(); $this->parentsOf($dataDriver->fetch($dataDriver->getEmptyConfig()->setId($value)), $parents); } return $parents; }
php
private function determineParentsOfValues() { $parents = []; $environment = $this->getEnvironment(); $mode = $environment->getDataDefinition()->getBasicDefinition()->getMode(); if (BasicDefinitionInterface::MODE_HIERARCHICAL !== $mode) { return []; } foreach ((array) $this->varValue as $value) { $dataDriver = $environment->getDataProvider(); $this->parentsOf($dataDriver->fetch($dataDriver->getEmptyConfig()->setId($value)), $parents); } return $parents; }
[ "private", "function", "determineParentsOfValues", "(", ")", "{", "$", "parents", "=", "[", "]", ";", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "mode", "=", "$", "environment", "->", "getDataDefinition", "(", ")", ...
Determine all parents of all selected values. @return array
[ "Determine", "all", "parents", "of", "all", "selected", "values", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L1442-L1457
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/TreePicker.php
TreePicker.handleInputNameForEditAll
private function handleInputNameForEditAll() { if (('select' !== $this->getEnvironment()->getInputProvider()->getParameter('act')) && ('edit' !== $this->getEnvironment()->getInputProvider()->getParameter('select')) && ('edit' !== $this->getEnvironment()->getInputProvider()->getParameter('mode')) ) { return; } $tableName = \explode('____', $this->getEnvironment()->getInputProvider()->getValue('name'))[0]; $sessionKey = 'DC_GENERAL_' . \strtoupper($tableName); $sessionStorage = System::getContainer()->get('cca.dc-general.session_factory')->createService()->setScope($sessionKey); $selectAction = $this->getEnvironment()->getInputProvider()->getParameter('select'); $session = $sessionStorage->get($tableName . '.' . $selectAction); $originalPropertyName = null; foreach ((array) $session['models'] as $modelId) { if (null !== $originalPropertyName) { break; } $propertyNamePrefix = \str_replace('::', '____', $modelId) . '_'; if (0 !== strpos($this->strName, $propertyNamePrefix)) { continue; } $originalPropertyName = \substr($this->strName, \strlen($propertyNamePrefix)); } if (!$originalPropertyName) { return; } $this->arrConfiguration['originalField'] = $originalPropertyName; $this->strName = $propertyNamePrefix . '[' . $originalPropertyName . ']'; }
php
private function handleInputNameForEditAll() { if (('select' !== $this->getEnvironment()->getInputProvider()->getParameter('act')) && ('edit' !== $this->getEnvironment()->getInputProvider()->getParameter('select')) && ('edit' !== $this->getEnvironment()->getInputProvider()->getParameter('mode')) ) { return; } $tableName = \explode('____', $this->getEnvironment()->getInputProvider()->getValue('name'))[0]; $sessionKey = 'DC_GENERAL_' . \strtoupper($tableName); $sessionStorage = System::getContainer()->get('cca.dc-general.session_factory')->createService()->setScope($sessionKey); $selectAction = $this->getEnvironment()->getInputProvider()->getParameter('select'); $session = $sessionStorage->get($tableName . '.' . $selectAction); $originalPropertyName = null; foreach ((array) $session['models'] as $modelId) { if (null !== $originalPropertyName) { break; } $propertyNamePrefix = \str_replace('::', '____', $modelId) . '_'; if (0 !== strpos($this->strName, $propertyNamePrefix)) { continue; } $originalPropertyName = \substr($this->strName, \strlen($propertyNamePrefix)); } if (!$originalPropertyName) { return; } $this->arrConfiguration['originalField'] = $originalPropertyName; $this->strName = $propertyNamePrefix . '[' . $originalPropertyName . ']'; }
[ "private", "function", "handleInputNameForEditAll", "(", ")", "{", "if", "(", "(", "'select'", "!==", "$", "this", "->", "getEnvironment", "(", ")", "->", "getInputProvider", "(", ")", "->", "getParameter", "(", "'act'", ")", ")", "&&", "(", "'edit'", "!==...
Handle the input name for edit all mode. @return void
[ "Handle", "the", "input", "name", "for", "edit", "all", "mode", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/TreePicker.php#L1464-L1503
train
yiisoft/cache
src/Dependencies/Dependency.php
Dependency.isChanged
public function isChanged($cache): bool { if ($this->reusable) { $hash = $this->generateReusableHash(); if (!array_key_exists($hash, self::$_reusableData)) { self::$_reusableData[$hash] = $this->generateDependencyData($cache); } $data = self::$_reusableData[$hash]; } else { $data = $this->generateDependencyData($cache); } return $data !== $this->data; }
php
public function isChanged($cache): bool { if ($this->reusable) { $hash = $this->generateReusableHash(); if (!array_key_exists($hash, self::$_reusableData)) { self::$_reusableData[$hash] = $this->generateDependencyData($cache); } $data = self::$_reusableData[$hash]; } else { $data = $this->generateDependencyData($cache); } return $data !== $this->data; }
[ "public", "function", "isChanged", "(", "$", "cache", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "reusable", ")", "{", "$", "hash", "=", "$", "this", "->", "generateReusableHash", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$",...
Checks whether the dependency is changed. @param \Yiisoft\Cache\CacheInterface $cache the cache component that is currently evaluating this dependency @return bool whether the dependency has changed.
[ "Checks", "whether", "the", "dependency", "is", "changed", "." ]
d3ffe8436270481e34842705817a5cf8025d947f
https://github.com/yiisoft/cache/blob/d3ffe8436270481e34842705817a5cf8025d947f/src/Dependencies/Dependency.php#L61-L74
train
yiisoft/cache
src/Dependencies/Dependency.php
Dependency.generateReusableHash
protected function generateReusableHash(): string { $data = $this->data; $this->data = null; // https://github.com/yiisoft/yii2/issues/3052 $key = sha1(serialize($this)); $this->data = $data; return $key; }
php
protected function generateReusableHash(): string { $data = $this->data; $this->data = null; // https://github.com/yiisoft/yii2/issues/3052 $key = sha1(serialize($this)); $this->data = $data; return $key; }
[ "protected", "function", "generateReusableHash", "(", ")", ":", "string", "{", "$", "data", "=", "$", "this", "->", "data", ";", "$", "this", "->", "data", "=", "null", ";", "// https://github.com/yiisoft/yii2/issues/3052", "$", "key", "=", "sha1", "(", "ser...
Generates a unique hash that can be used for retrieving reusable dependency data. @return string a unique hash value for this cache dependency. @see reusable
[ "Generates", "a", "unique", "hash", "that", "can", "be", "used", "for", "retrieving", "reusable", "dependency", "data", "." ]
d3ffe8436270481e34842705817a5cf8025d947f
https://github.com/yiisoft/cache/blob/d3ffe8436270481e34842705817a5cf8025d947f/src/Dependencies/Dependency.php#L89-L96
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/BaseView.php
BaseView.handleAction
public function handleAction(ActionEvent $event) { $GLOBALS['TL_CSS']['cca.dc-general.generalDriver'] = 'bundles/ccadcgeneral/css/generalDriver.css'; if ((null !== $event->getResponse()) || $event->getEnvironment()->getDataDefinition()->getName() !== $this->environment->getDataDefinition()->getName() ) { return; } $action = $event->getAction(); $name = $action->getName(); if ('show' === $name) { $handler = new ShowHandler($this->scopeDeterminator); $handler->handleEvent($event); return; } if ('showAll' === $name) { $response = \call_user_func_array( [$this, $name], \array_merge([$action], $action->getArguments()) ); $event->setResponse($response); return; } if ('select' === $name) { $response = \call_user_func_array( [$this, $name], \array_merge([$action], $action->getArguments()) ); $event->setResponse($response); return; } if (!\in_array($name, ['create', 'move', 'undo', 'edit'])) { return; } $response = \call_user_func_array( [$this, $name], \array_merge([$action], $action->getArguments()) ); $event->setResponse($response); }
php
public function handleAction(ActionEvent $event) { $GLOBALS['TL_CSS']['cca.dc-general.generalDriver'] = 'bundles/ccadcgeneral/css/generalDriver.css'; if ((null !== $event->getResponse()) || $event->getEnvironment()->getDataDefinition()->getName() !== $this->environment->getDataDefinition()->getName() ) { return; } $action = $event->getAction(); $name = $action->getName(); if ('show' === $name) { $handler = new ShowHandler($this->scopeDeterminator); $handler->handleEvent($event); return; } if ('showAll' === $name) { $response = \call_user_func_array( [$this, $name], \array_merge([$action], $action->getArguments()) ); $event->setResponse($response); return; } if ('select' === $name) { $response = \call_user_func_array( [$this, $name], \array_merge([$action], $action->getArguments()) ); $event->setResponse($response); return; } if (!\in_array($name, ['create', 'move', 'undo', 'edit'])) { return; } $response = \call_user_func_array( [$this, $name], \array_merge([$action], $action->getArguments()) ); $event->setResponse($response); }
[ "public", "function", "handleAction", "(", "ActionEvent", "$", "event", ")", "{", "$", "GLOBALS", "[", "'TL_CSS'", "]", "[", "'cca.dc-general.generalDriver'", "]", "=", "'bundles/ccadcgeneral/css/generalDriver.css'", ";", "if", "(", "(", "null", "!==", "$", "event...
Handle the given action. @param ActionEvent $event The event. @return void @SuppressWarnings(PHPMD.Superglobals) @SuppressWarnings(PHPMD.CamelCaseVariableName)
[ "Handle", "the", "given", "action", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/BaseView.php#L115-L165
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/BaseView.php
BaseView.handleAjaxCall
public function handleAjaxCall() { $environment = $this->getEnvironment(); $input = $environment->getInputProvider(); if (true === ($input->hasParameter('id'))) { // Redefine the parameter id if this isn´t model id conform. if (false === \strpos($input->getParameter('id'), '::')) { $modelId = new ModelId($input->getParameter('table'), $input->getParameter('id')); $input->setParameter('id', $modelId->getSerialized()); } $modelId = ModelId::fromSerialized($input->getParameter('id')); $dataProvider = $environment->getDataProvider($modelId->getDataProviderName()); $model = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId())); } $this->addAjaxPropertyForEditAll(); $handler = new Ajax3X(); $handler->executePostActions(new DcCompat($environment, ($model ?? null))); }
php
public function handleAjaxCall() { $environment = $this->getEnvironment(); $input = $environment->getInputProvider(); if (true === ($input->hasParameter('id'))) { // Redefine the parameter id if this isn´t model id conform. if (false === \strpos($input->getParameter('id'), '::')) { $modelId = new ModelId($input->getParameter('table'), $input->getParameter('id')); $input->setParameter('id', $modelId->getSerialized()); } $modelId = ModelId::fromSerialized($input->getParameter('id')); $dataProvider = $environment->getDataProvider($modelId->getDataProviderName()); $model = $dataProvider->fetch($dataProvider->getEmptyConfig()->setId($modelId->getId())); } $this->addAjaxPropertyForEditAll(); $handler = new Ajax3X(); $handler->executePostActions(new DcCompat($environment, ($model ?? null))); }
[ "public", "function", "handleAjaxCall", "(", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "input", "=", "$", "environment", "->", "getInputProvider", "(", ")", ";", "if", "(", "true", "===", "(", "$", "inp...
Handle an ajax call by passing it to the relevant handler class. The handler class might(!) exit the script. @return void
[ "Handle", "an", "ajax", "call", "by", "passing", "it", "to", "the", "relevant", "handler", "class", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/BaseView.php#L358-L378
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/BaseView.php
BaseView.breadcrumb
public function breadcrumb() { $environment = $this->getEnvironment(); $event = new GetBreadcrumbEvent($environment); $environment->getEventDispatcher()->dispatch($event::NAME, $event); $elements = $event->getElements(); if (!\is_array($elements) || !\count($elements)) { return null; } $GLOBALS['TL_CSS']['cca.dc-general.generalBreadcrumb'] = 'bundles/ccadcgeneral/css/generalBreadcrumb.css'; return $this->getTemplate('dcbe_general_breadcrumb') ->set('elements', $elements) ->parse(); }
php
public function breadcrumb() { $environment = $this->getEnvironment(); $event = new GetBreadcrumbEvent($environment); $environment->getEventDispatcher()->dispatch($event::NAME, $event); $elements = $event->getElements(); if (!\is_array($elements) || !\count($elements)) { return null; } $GLOBALS['TL_CSS']['cca.dc-general.generalBreadcrumb'] = 'bundles/ccadcgeneral/css/generalBreadcrumb.css'; return $this->getTemplate('dcbe_general_breadcrumb') ->set('elements', $elements) ->parse(); }
[ "public", "function", "breadcrumb", "(", ")", "{", "$", "environment", "=", "$", "this", "->", "getEnvironment", "(", ")", ";", "$", "event", "=", "new", "GetBreadcrumbEvent", "(", "$", "environment", ")", ";", "$", "environment", "->", "getEventDispatcher",...
Get the breadcrumb navigation via event. @return string @SuppressWarnings(PHPMD.Superglobals) @SuppressWarnings(PHPMD.CamelCaseVariableName)
[ "Get", "the", "breadcrumb", "navigation", "via", "event", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/BaseView.php#L505-L523
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/BaseView.php
BaseView.addAjaxPropertyForEditAll
private function addAjaxPropertyForEditAll() { $inputProvider = $this->getEnvironment()->getInputProvider(); if (('select' !== $inputProvider->getParameter('act')) && ('edit' !== $inputProvider->getParameter('select')) && ('edit' !== $inputProvider->getParameter('mode')) ) { return; } $originalProperty = $this->findOriginalPropertyByModelId($inputProvider->getValue('name')); if (null === $originalProperty) { return; } $propertiesDefinition = $this->getEnvironment()->getDataDefinition()->getPropertiesDefinition(); $propertyClass = \get_class($originalProperty); $property = new $propertyClass($inputProvider->getValue('name')); $property->setLabel($originalProperty->getLabel()); $property->setDescription($originalProperty->getDescription()); $property->setDefaultValue($originalProperty->getDefaultValue()); $property->setExcluded($originalProperty->isExcluded()); $property->setSearchable($originalProperty->isSearchable()); $property->setFilterable($originalProperty->isFilterable()); $property->setWidgetType($originalProperty->getWidgetType()); $property->setExplanation($originalProperty->getExplanation()); $property->setExtra($originalProperty->getExtra()); $propertiesDefinition->addProperty($property); }
php
private function addAjaxPropertyForEditAll() { $inputProvider = $this->getEnvironment()->getInputProvider(); if (('select' !== $inputProvider->getParameter('act')) && ('edit' !== $inputProvider->getParameter('select')) && ('edit' !== $inputProvider->getParameter('mode')) ) { return; } $originalProperty = $this->findOriginalPropertyByModelId($inputProvider->getValue('name')); if (null === $originalProperty) { return; } $propertiesDefinition = $this->getEnvironment()->getDataDefinition()->getPropertiesDefinition(); $propertyClass = \get_class($originalProperty); $property = new $propertyClass($inputProvider->getValue('name')); $property->setLabel($originalProperty->getLabel()); $property->setDescription($originalProperty->getDescription()); $property->setDefaultValue($originalProperty->getDefaultValue()); $property->setExcluded($originalProperty->isExcluded()); $property->setSearchable($originalProperty->isSearchable()); $property->setFilterable($originalProperty->isFilterable()); $property->setWidgetType($originalProperty->getWidgetType()); $property->setExplanation($originalProperty->getExplanation()); $property->setExtra($originalProperty->getExtra()); $propertiesDefinition->addProperty($property); }
[ "private", "function", "addAjaxPropertyForEditAll", "(", ")", "{", "$", "inputProvider", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", "getInputProvider", "(", ")", ";", "if", "(", "(", "'select'", "!==", "$", "inputProvider", "->", "getParameter",...
Add the ajax property for edit all mode. @return void
[ "Add", "the", "ajax", "property", "for", "edit", "all", "mode", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/BaseView.php#L530-L562
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/BaseView.php
BaseView.findOriginalPropertyByModelId
private function findOriginalPropertyByModelId($propertyName) { if (null === $propertyName) { return null; } $inputProvider = $this->getEnvironment()->getInputProvider(); $sessionStorage = $this->getEnvironment()->getSessionStorage(); $selectAction = $inputProvider->getParameter('select'); $session = $sessionStorage->get($this->getEnvironment()->getDataDefinition()->getName() . '.' . $selectAction); $originalPropertyName = null; foreach ($session['models'] as $modelId) { if (null !== $originalPropertyName) { break; } $propertyNamePrefix = \str_replace('::', '____', $modelId) . '_'; if (0 !== strpos($propertyName, $propertyNamePrefix)) { continue; } $originalPropertyName = \substr($propertyName, \strlen($propertyNamePrefix)); } $propertiesDefinition = $this->getEnvironment()->getDataDefinition()->getPropertiesDefinition(); if (!$propertiesDefinition->hasProperty($originalPropertyName)) { return null; } return $propertiesDefinition->getProperty($originalPropertyName); }
php
private function findOriginalPropertyByModelId($propertyName) { if (null === $propertyName) { return null; } $inputProvider = $this->getEnvironment()->getInputProvider(); $sessionStorage = $this->getEnvironment()->getSessionStorage(); $selectAction = $inputProvider->getParameter('select'); $session = $sessionStorage->get($this->getEnvironment()->getDataDefinition()->getName() . '.' . $selectAction); $originalPropertyName = null; foreach ($session['models'] as $modelId) { if (null !== $originalPropertyName) { break; } $propertyNamePrefix = \str_replace('::', '____', $modelId) . '_'; if (0 !== strpos($propertyName, $propertyNamePrefix)) { continue; } $originalPropertyName = \substr($propertyName, \strlen($propertyNamePrefix)); } $propertiesDefinition = $this->getEnvironment()->getDataDefinition()->getPropertiesDefinition(); if (!$propertiesDefinition->hasProperty($originalPropertyName)) { return null; } return $propertiesDefinition->getProperty($originalPropertyName); }
[ "private", "function", "findOriginalPropertyByModelId", "(", "$", "propertyName", ")", "{", "if", "(", "null", "===", "$", "propertyName", ")", "{", "return", "null", ";", "}", "$", "inputProvider", "=", "$", "this", "->", "getEnvironment", "(", ")", "->", ...
Find the original property by the modelId. @param string $propertyName The property name. @return PropertyInterface|null
[ "Find", "the", "original", "property", "by", "the", "modelId", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/BaseView.php#L571-L604
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ViewHelpers.php
ViewHelpers.getCurrentSorting
public static function getCurrentSorting(EnvironmentInterface $environment) { /** @var BackendViewInterface $view */ $view = $environment->getView(); foreach ($view->getPanel() as $panel) { /** @var PanelInterface $panel */ $sort = $panel->getElement('sort'); if ($sort) { /** @var SortElementInterface $sort */ return $sort->getSelectedDefinition(); } } /** @var Contao2BackendViewDefinitionInterface $viewSection */ $viewSection = $environment->getDataDefinition()->getDefinition(Contao2BackendViewDefinitionInterface::NAME); $definition = $viewSection->getListingConfig()->getGroupAndSortingDefinition(); if ($definition->hasDefault()) { return $definition->getDefault(); } return null; }
php
public static function getCurrentSorting(EnvironmentInterface $environment) { /** @var BackendViewInterface $view */ $view = $environment->getView(); foreach ($view->getPanel() as $panel) { /** @var PanelInterface $panel */ $sort = $panel->getElement('sort'); if ($sort) { /** @var SortElementInterface $sort */ return $sort->getSelectedDefinition(); } } /** @var Contao2BackendViewDefinitionInterface $viewSection */ $viewSection = $environment->getDataDefinition()->getDefinition(Contao2BackendViewDefinitionInterface::NAME); $definition = $viewSection->getListingConfig()->getGroupAndSortingDefinition(); if ($definition->hasDefault()) { return $definition->getDefault(); } return null; }
[ "public", "static", "function", "getCurrentSorting", "(", "EnvironmentInterface", "$", "environment", ")", "{", "/** @var BackendViewInterface $view */", "$", "view", "=", "$", "environment", "->", "getView", "(", ")", ";", "foreach", "(", "$", "view", "->", "getP...
Retrieve the currently active sorting. @param EnvironmentInterface $environment The environment. @return GroupAndSortingDefinitionInterface
[ "Retrieve", "the", "currently", "active", "sorting", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ViewHelpers.php#L53-L75
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ViewHelpers.php
ViewHelpers.initializeSorting
public static function initializeSorting($panel, $dataConfig, $listingConfig) { // Store default sorting start initializing the panel with an empty sorting. $sorting = $dataConfig->getSorting(); $dataConfig->setSorting([]); $panel->initialize($dataConfig); // Restore default sorting if panel did not set any. if ($sorting && !$dataConfig->getSorting()) { $dataConfig->setSorting($sorting); } // Initialize sorting if not present yet. if (!$dataConfig->getSorting() && $listingConfig->getGroupAndSortingDefinition()->hasDefault()) { $newSorting = []; foreach ($listingConfig->getGroupAndSortingDefinition()->getDefault() as $information) { /** @var GroupAndSortingInformationInterface $information */ $newSorting[$information->getProperty()] = \strtoupper($information->getSortingMode()); } $dataConfig->setSorting($newSorting); } }
php
public static function initializeSorting($panel, $dataConfig, $listingConfig) { // Store default sorting start initializing the panel with an empty sorting. $sorting = $dataConfig->getSorting(); $dataConfig->setSorting([]); $panel->initialize($dataConfig); // Restore default sorting if panel did not set any. if ($sorting && !$dataConfig->getSorting()) { $dataConfig->setSorting($sorting); } // Initialize sorting if not present yet. if (!$dataConfig->getSorting() && $listingConfig->getGroupAndSortingDefinition()->hasDefault()) { $newSorting = []; foreach ($listingConfig->getGroupAndSortingDefinition()->getDefault() as $information) { /** @var GroupAndSortingInformationInterface $information */ $newSorting[$information->getProperty()] = \strtoupper($information->getSortingMode()); } $dataConfig->setSorting($newSorting); } }
[ "public", "static", "function", "initializeSorting", "(", "$", "panel", ",", "$", "dataConfig", ",", "$", "listingConfig", ")", "{", "// Store default sorting start initializing the panel with an empty sorting.", "$", "sorting", "=", "$", "dataConfig", "->", "getSorting",...
Initialize the sorting from the panel. Fallback to default sorting if nothing given. @param PanelContainerInterface $panel The current panel. @param ConfigInterface $dataConfig The current config. @param ListingConfigInterface $listingConfig The listing config. @return void
[ "Initialize", "the", "sorting", "from", "the", "panel", ".", "Fallback", "to", "default", "sorting", "if", "nothing", "given", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ViewHelpers.php#L126-L147
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ViewHelpers.php
ViewHelpers.getGroupingMode
public static function getGroupingMode(EnvironmentInterface $environment) { $sorting = static::getCurrentSorting($environment); // If no sorting defined, exit. if ((!$sorting) || (!$sorting->getCount()) || $sorting->get(0)->getSortingMode() === GroupAndSortingInformationInterface::SORT_RANDOM ) { return null; } $firstSorting = $sorting->get(0); // Use the information from the property, if given. if ('' !== $firstSorting->getGroupingMode()) { $groupMode = $firstSorting->getGroupingMode(); $groupLength = $firstSorting->getGroupingLength(); } else { // No sorting? No grouping! $groupMode = GroupAndSortingInformationInterface::GROUP_NONE; $groupLength = 0; } return [ 'mode' => $groupMode, 'length' => $groupLength, 'property' => $firstSorting->getProperty(), 'sorting' => $sorting ]; }
php
public static function getGroupingMode(EnvironmentInterface $environment) { $sorting = static::getCurrentSorting($environment); // If no sorting defined, exit. if ((!$sorting) || (!$sorting->getCount()) || $sorting->get(0)->getSortingMode() === GroupAndSortingInformationInterface::SORT_RANDOM ) { return null; } $firstSorting = $sorting->get(0); // Use the information from the property, if given. if ('' !== $firstSorting->getGroupingMode()) { $groupMode = $firstSorting->getGroupingMode(); $groupLength = $firstSorting->getGroupingLength(); } else { // No sorting? No grouping! $groupMode = GroupAndSortingInformationInterface::GROUP_NONE; $groupLength = 0; } return [ 'mode' => $groupMode, 'length' => $groupLength, 'property' => $firstSorting->getProperty(), 'sorting' => $sorting ]; }
[ "public", "static", "function", "getGroupingMode", "(", "EnvironmentInterface", "$", "environment", ")", "{", "$", "sorting", "=", "static", "::", "getCurrentSorting", "(", "$", "environment", ")", ";", "// If no sorting defined, exit.", "if", "(", "(", "!", "$", ...
Retrieve the currently active grouping mode. @param EnvironmentInterface $environment The environment. @return array|null
[ "Retrieve", "the", "currently", "active", "grouping", "mode", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ViewHelpers.php#L156-L185
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ViewHelpers.php
ViewHelpers.getReadableFieldValue
public static function getReadableFieldValue( EnvironmentInterface $environment, PropertyInterface $property, ModelInterface $model ) { $event = new RenderReadablePropertyValueEvent( $environment, $model, $property, $model->getProperty($property->getName()) ); $environment->getEventDispatcher()->dispatch($event::NAME, $event); if (null !== $event->getRendered()) { return $event->getRendered(); } return $event->getValue(); }
php
public static function getReadableFieldValue( EnvironmentInterface $environment, PropertyInterface $property, ModelInterface $model ) { $event = new RenderReadablePropertyValueEvent( $environment, $model, $property, $model->getProperty($property->getName()) ); $environment->getEventDispatcher()->dispatch($event::NAME, $event); if (null !== $event->getRendered()) { return $event->getRendered(); } return $event->getValue(); }
[ "public", "static", "function", "getReadableFieldValue", "(", "EnvironmentInterface", "$", "environment", ",", "PropertyInterface", "$", "property", ",", "ModelInterface", "$", "model", ")", "{", "$", "event", "=", "new", "RenderReadablePropertyValueEvent", "(", "$", ...
Get for a field the readable value. @param EnvironmentInterface $environment The environment. @param PropertyInterface $property The property to be rendered. @param ModelInterface $model The model from which the property value shall be retrieved from. @return mixed
[ "Get", "for", "a", "field", "the", "readable", "value", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ViewHelpers.php#L196-L215
train
contao-community-alliance/dc-general
src/Contao/View/Contao2BackendView/ViewHelpers.php
ViewHelpers.redirectHome
public static function redirectHome(EnvironmentInterface $environment) { $input = $environment->getInputProvider(); if ($input->hasParameter('table') && ($hasParentId = $input->hasParameter('pid'))) { if ($hasParentId) { $event = new RedirectEvent( \sprintf( 'contao?do=%s&table=%s&pid=%s', $input->getParameter('do'), $input->getParameter('table'), $input->getParameter('pid') ) ); } else { $event = new RedirectEvent( \sprintf( 'contao?do=%s&table=%s', $input->getParameter('do'), $input->getParameter('table') ) ); } } else { $event = new RedirectEvent( \sprintf( 'contao?do=%s', $input->getParameter('do') ) ); } $environment->getEventDispatcher()->dispatch(ContaoEvents::CONTROLLER_REDIRECT, $event); }
php
public static function redirectHome(EnvironmentInterface $environment) { $input = $environment->getInputProvider(); if ($input->hasParameter('table') && ($hasParentId = $input->hasParameter('pid'))) { if ($hasParentId) { $event = new RedirectEvent( \sprintf( 'contao?do=%s&table=%s&pid=%s', $input->getParameter('do'), $input->getParameter('table'), $input->getParameter('pid') ) ); } else { $event = new RedirectEvent( \sprintf( 'contao?do=%s&table=%s', $input->getParameter('do'), $input->getParameter('table') ) ); } } else { $event = new RedirectEvent( \sprintf( 'contao?do=%s', $input->getParameter('do') ) ); } $environment->getEventDispatcher()->dispatch(ContaoEvents::CONTROLLER_REDIRECT, $event); }
[ "public", "static", "function", "redirectHome", "(", "EnvironmentInterface", "$", "environment", ")", "{", "$", "input", "=", "$", "environment", "->", "getInputProvider", "(", ")", ";", "if", "(", "$", "input", "->", "hasParameter", "(", "'table'", ")", "&&...
Redirects to the real back end module. @param EnvironmentInterface $environment The environment. @return void
[ "Redirects", "to", "the", "real", "back", "end", "module", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/View/Contao2BackendView/ViewHelpers.php#L224-L257
train
contao-community-alliance/dc-general
src/Contao/Picker/AbstractAwarePickerProvider.php
AbstractAwarePickerProvider.generateUrl
private function generateUrl(PickerConfig $config, $ignoreValue) { $params = \array_merge( $this->getRouteParameters($ignoreValue ? null : $config), [ 'popup' => '1', 'picker' => $config->cloneForCurrent($this->getName())->urlEncode(), ] ); return $this->router->generate('cca_dc_general_tree', $params); }
php
private function generateUrl(PickerConfig $config, $ignoreValue) { $params = \array_merge( $this->getRouteParameters($ignoreValue ? null : $config), [ 'popup' => '1', 'picker' => $config->cloneForCurrent($this->getName())->urlEncode(), ] ); return $this->router->generate('cca_dc_general_tree', $params); }
[ "private", "function", "generateUrl", "(", "PickerConfig", "$", "config", ",", "$", "ignoreValue", ")", "{", "$", "params", "=", "\\", "array_merge", "(", "$", "this", "->", "getRouteParameters", "(", "$", "ignoreValue", "?", "null", ":", "$", "config", ")...
Generates the URL for the picker. @param PickerConfig $config The configuration. @param bool $ignoreValue Determine by get the route parameter the picker config ignore. @return string
[ "Generates", "the", "URL", "for", "the", "picker", "." ]
bf59fc2085cc848c564e40324dee14ef2897faa6
https://github.com/contao-community-alliance/dc-general/blob/bf59fc2085cc848c564e40324dee14ef2897faa6/src/Contao/Picker/AbstractAwarePickerProvider.php#L167-L178
train
blockcypher/php-client
lib/BlockCypher/Client/MicroTXClient.php
MicroTXClient.create
public function create(MicroTX $microTX, $apiContext = null, $restCall = null) { $payLoad = $microTX->toJSON(); $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall( "$chainUrlPrefix/txs/micro", "POST", $payLoad, null, $apiContext, $restCall ); $microTX->fromJson($json); return $microTX; }
php
public function create(MicroTX $microTX, $apiContext = null, $restCall = null) { $payLoad = $microTX->toJSON(); $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall( "$chainUrlPrefix/txs/micro", "POST", $payLoad, null, $apiContext, $restCall ); $microTX->fromJson($json); return $microTX; }
[ "public", "function", "create", "(", "MicroTX", "$", "microTX", ",", "$", "apiContext", "=", "null", ",", "$", "restCall", "=", "null", ")", "{", "$", "payLoad", "=", "$", "microTX", "->", "toJSON", "(", ")", ";", "$", "chainUrlPrefix", "=", "$", "th...
Create a new MicroTX. @param MicroTX $microTX @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls @return MicroTX
[ "Create", "a", "new", "MicroTX", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Client/MicroTXClient.php#L55-L71
train
blockcypher/php-client
lib/BlockCypher/Validation/ArgumentGetParamsValidator.php
ArgumentGetParamsValidator.validate
public static function validate($argument, $argumentName = null) { if (!is_array($argument)) { throw new \InvalidArgumentException("Argument with name $argumentName is not an array"); } foreach ($argument as $item) { if ($item === null) { // Error if Object Null throw new \InvalidArgumentException("Argument with name $argumentName item cannot be null"); } else if (gettype($item) == 'string' && trim($item) == '') { // Error if String Empty throw new \InvalidArgumentException("Argument with name $argumentName item string cannot be empty"); } } return true; }
php
public static function validate($argument, $argumentName = null) { if (!is_array($argument)) { throw new \InvalidArgumentException("Argument with name $argumentName is not an array"); } foreach ($argument as $item) { if ($item === null) { // Error if Object Null throw new \InvalidArgumentException("Argument with name $argumentName item cannot be null"); } else if (gettype($item) == 'string' && trim($item) == '') { // Error if String Empty throw new \InvalidArgumentException("Argument with name $argumentName item string cannot be empty"); } } return true; }
[ "public", "static", "function", "validate", "(", "$", "argument", ",", "$", "argumentName", "=", "null", ")", "{", "if", "(", "!", "is_array", "(", "$", "argument", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Argument with name $...
Helper method for validating an argument if it is an array of GET params @param mixed $argument @param string|null $argumentName @return bool
[ "Helper", "method", "for", "validating", "an", "argument", "if", "it", "is", "an", "array", "of", "GET", "params" ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Validation/ArgumentGetParamsValidator.php#L23-L39
train
blockcypher/php-client
lib/BlockCypher/Api/AddressList.php
AddressList.fromAddressesArray
public static function fromAddressesArray($addresses) { ArgumentArrayValidator::validate($addresses, 'addresses'); $addressList = new self(); $addressList->setAddresses($addresses); return $addressList; }
php
public static function fromAddressesArray($addresses) { ArgumentArrayValidator::validate($addresses, 'addresses'); $addressList = new self(); $addressList->setAddresses($addresses); return $addressList; }
[ "public", "static", "function", "fromAddressesArray", "(", "$", "addresses", ")", "{", "ArgumentArrayValidator", "::", "validate", "(", "$", "addresses", ",", "'addresses'", ")", ";", "$", "addressList", "=", "new", "self", "(", ")", ";", "$", "addressList", ...
Constructor passing addresses array. Default constructor can not be overridden @param string[] $addresses @return AddressList
[ "Constructor", "passing", "addresses", "array", ".", "Default", "constructor", "can", "not", "be", "overridden" ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Api/AddressList.php#L25-L31
train
blockcypher/php-client
lib/BlockCypher/Api/AddressList.php
AddressList.addAddress
public function addAddress($address) { if (!$this->getAddresses()) { return $this->setAddresses(array($address)); } else { return $this->setAddresses( array_merge($this->getAddresses(), array($address)) ); } }
php
public function addAddress($address) { if (!$this->getAddresses()) { return $this->setAddresses(array($address)); } else { return $this->setAddresses( array_merge($this->getAddresses(), array($address)) ); } }
[ "public", "function", "addAddress", "(", "$", "address", ")", "{", "if", "(", "!", "$", "this", "->", "getAddresses", "(", ")", ")", "{", "return", "$", "this", "->", "setAddresses", "(", "array", "(", "$", "address", ")", ")", ";", "}", "else", "{...
Append Address to the list. @param string $address @return $this
[ "Append", "Address", "to", "the", "list", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Api/AddressList.php#L49-L58
train
blockcypher/php-client
lib/BlockCypher/Core/BlockCypherHttpConnection.php
BlockCypherHttpConnection.getHttpHeaders
private function getHttpHeaders() { $ret = array(); foreach ($this->httpConfig->getHeaders() as $k => $v) { $ret[] = "$k: $v"; } return $ret; }
php
private function getHttpHeaders() { $ret = array(); foreach ($this->httpConfig->getHeaders() as $k => $v) { $ret[] = "$k: $v"; } return $ret; }
[ "private", "function", "getHttpHeaders", "(", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "httpConfig", "->", "getHeaders", "(", ")", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "ret", "[", "]", "=", ...
Gets all Http Headers @return array
[ "Gets", "all", "Http", "Headers" ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Core/BlockCypherHttpConnection.php#L179-L186
train
blockcypher/php-client
lib/BlockCypher/Core/BlockCypherHttpConfig.php
BlockCypherHttpConfig.getHttpConstantsFromConfigs
public function getHttpConstantsFromConfigs($configs = array(), $prefix) { $arr = array(); if ($prefix != null && is_array($configs)) { foreach ($configs as $k => $v) { // Check if it startsWith if (substr($k, 0, strlen($prefix)) === $prefix) { $newKey = ltrim($k, $prefix); if (defined($newKey)) { $arr[constant($newKey)] = $v; } } } } return $arr; }
php
public function getHttpConstantsFromConfigs($configs = array(), $prefix) { $arr = array(); if ($prefix != null && is_array($configs)) { foreach ($configs as $k => $v) { // Check if it startsWith if (substr($k, 0, strlen($prefix)) === $prefix) { $newKey = ltrim($k, $prefix); if (defined($newKey)) { $arr[constant($newKey)] = $v; } } } } return $arr; }
[ "public", "function", "getHttpConstantsFromConfigs", "(", "$", "configs", "=", "array", "(", ")", ",", "$", "prefix", ")", "{", "$", "arr", "=", "array", "(", ")", ";", "if", "(", "$", "prefix", "!=", "null", "&&", "is_array", "(", "$", "configs", ")...
Retrieves an array of constant key, and value based on Prefix @param array $configs @param $prefix @return array
[ "Retrieves", "an", "array", "of", "constant", "key", "and", "value", "based", "on", "Prefix" ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Core/BlockCypherHttpConfig.php#L79-L94
train
blockcypher/php-client
lib/BlockCypher/Core/BlockCypherHttpConfig.php
BlockCypherHttpConfig.getHeader
public function getHeader($name) { if (array_key_exists($name, $this->headers)) { return $this->headers[$name]; } return null; }
php
public function getHeader($name) { if (array_key_exists($name, $this->headers)) { return $this->headers[$name]; } return null; }
[ "public", "function", "getHeader", "(", "$", "name", ")", "{", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "headers", ")", ")", "{", "return", "$", "this", "->", "headers", "[", "$", "name", "]", ";", "}", "return", "nu...
Get Header by Name @param $name @return string|null
[ "Get", "Header", "by", "Name" ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Core/BlockCypherHttpConfig.php#L162-L168
train
blockcypher/php-client
lib/BlockCypher/Core/BlockCypherHttpConfig.php
BlockCypherHttpConfig.addHeader
public function addHeader($name, $value, $overWrite = true) { if (!array_key_exists($name, $this->headers) || $overWrite) { $this->headers[$name] = $value; } else { $this->headers[$name] = $this->headers[$name] . self::HEADER_SEPARATOR . $value; } }
php
public function addHeader($name, $value, $overWrite = true) { if (!array_key_exists($name, $this->headers) || $overWrite) { $this->headers[$name] = $value; } else { $this->headers[$name] = $this->headers[$name] . self::HEADER_SEPARATOR . $value; } }
[ "public", "function", "addHeader", "(", "$", "name", ",", "$", "value", ",", "$", "overWrite", "=", "true", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "headers", ")", "||", "$", "overWrite", ")", "{", "$...
Adds a Header @param $name @param $value @param bool $overWrite allows you to override header value
[ "Adds", "a", "Header" ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Core/BlockCypherHttpConfig.php#L177-L184
train
blockcypher/php-client
lib/BlockCypher/Api/Wallet.php
Wallet.removeAddresses
public function removeAddresses($addressList, $params = array(), $apiContext = null, $restCall = null) { ArgumentValidator::validate($addressList, 'addressList'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); // DEPRECATED: Using DELETE Body //$payLoad = $addressList->toJSON(); $payLoad = ''; // Using 'address' url parameter if (!isset($params['address'])) { $params['address'] = implode(';', $addressList->getAddresses()); } else { $params['address'] .= ';' . implode(';', $addressList->getAddresses()); } $chainUrlPrefix = self::getChainUrlPrefix($apiContext); $json = self::executeCall( //"$chainUrlPrefix/wallets/{$this->name}/addresses?" . http_build_query($params), // With DELETE body "$chainUrlPrefix/wallets/{$this->name}/addresses?" . http_build_query($params), // Without DELETE body "DELETE", $payLoad, null, $apiContext, $restCall ); $this->fromJson($json); return $this; }
php
public function removeAddresses($addressList, $params = array(), $apiContext = null, $restCall = null) { ArgumentValidator::validate($addressList, 'addressList'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); // DEPRECATED: Using DELETE Body //$payLoad = $addressList->toJSON(); $payLoad = ''; // Using 'address' url parameter if (!isset($params['address'])) { $params['address'] = implode(';', $addressList->getAddresses()); } else { $params['address'] .= ';' . implode(';', $addressList->getAddresses()); } $chainUrlPrefix = self::getChainUrlPrefix($apiContext); $json = self::executeCall( //"$chainUrlPrefix/wallets/{$this->name}/addresses?" . http_build_query($params), // With DELETE body "$chainUrlPrefix/wallets/{$this->name}/addresses?" . http_build_query($params), // Without DELETE body "DELETE", $payLoad, null, $apiContext, $restCall ); $this->fromJson($json); return $this; }
[ "public", "function", "removeAddresses", "(", "$", "addressList", ",", "$", "params", "=", "array", "(", ")", ",", "$", "apiContext", "=", "null", ",", "$", "restCall", "=", "null", ")", "{", "ArgumentValidator", "::", "validate", "(", "$", "addressList", ...
Remove Addresses to the Wallet. Addresses will no longer be associated with the wallet. @deprecated since version 1.2. Use WalletClient. @param AddressList $addressList @param array $params Parameters @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls @return Wallet
[ "Remove", "Addresses", "to", "the", "Wallet", ".", "Addresses", "will", "no", "longer", "be", "associated", "with", "the", "wallet", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Api/Wallet.php#L204-L235
train
blockcypher/php-client
lib/BlockCypher/Rest/ApiContext.php
ApiContext.create
public static function create( $chain = 'main', $coin = 'btc', $version = 'v1', $credential = null, $config = null, $blockCypherPartnerAttributionId = null) { // ### Api context // Use an ApiContext object to authenticate // API calls. The Token for the // SimpleTokenCredential class can be retrieved from // https://accounts.blockcypher.com/ $apiContext = new ApiContext($credential, $chain, $coin, $version); if (is_array($config)) { $apiContext->setConfig($config); } else { // BC_CONFIG_PATH should be defined if (!defined("BC_CONFIG_PATH")) { throw new BlockCypherConfigurationException('BC_CONFIG_PATH should be defined with the path of sdk_config.ini file if no config array is given'); } } // Partner Attribution Id. For the time being it is not used. if ($blockCypherPartnerAttributionId !== null) { $apiContext->addRequestHeader('BlockCypher-Partner-Attribution-Id', $blockCypherPartnerAttributionId); } return $apiContext; }
php
public static function create( $chain = 'main', $coin = 'btc', $version = 'v1', $credential = null, $config = null, $blockCypherPartnerAttributionId = null) { // ### Api context // Use an ApiContext object to authenticate // API calls. The Token for the // SimpleTokenCredential class can be retrieved from // https://accounts.blockcypher.com/ $apiContext = new ApiContext($credential, $chain, $coin, $version); if (is_array($config)) { $apiContext->setConfig($config); } else { // BC_CONFIG_PATH should be defined if (!defined("BC_CONFIG_PATH")) { throw new BlockCypherConfigurationException('BC_CONFIG_PATH should be defined with the path of sdk_config.ini file if no config array is given'); } } // Partner Attribution Id. For the time being it is not used. if ($blockCypherPartnerAttributionId !== null) { $apiContext->addRequestHeader('BlockCypher-Partner-Attribution-Id', $blockCypherPartnerAttributionId); } return $apiContext; }
[ "public", "static", "function", "create", "(", "$", "chain", "=", "'main'", ",", "$", "coin", "=", "'btc'", ",", "$", "version", "=", "'v1'", ",", "$", "credential", "=", "null", ",", "$", "config", "=", "null", ",", "$", "blockCypherPartnerAttributionId...
Create new default ApiContext. @param string $chain @param string $coin @param string $version @param TokenCredential $credential @param array|null $config @param string $blockCypherPartnerAttributionId @return ApiContext @throws BlockCypherConfigurationException
[ "Create", "new", "default", "ApiContext", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Rest/ApiContext.php#L97-L128
train
blockcypher/php-client
lib/BlockCypher/Rest/ApiContext.php
ApiContext.generateRequestId
private function generateRequestId() { static $pid = -1; static $addr = -1; if ($pid == -1) { $pid = getmypid(); } if ($addr == -1) { if (array_key_exists('SERVER_ADDR', $_SERVER)) { $addr = ip2long($_SERVER['SERVER_ADDR']); } else { $addr = php_uname('n'); } } return $addr . $pid . $_SERVER['REQUEST_TIME'] . mt_rand(0, 0xffff); }
php
private function generateRequestId() { static $pid = -1; static $addr = -1; if ($pid == -1) { $pid = getmypid(); } if ($addr == -1) { if (array_key_exists('SERVER_ADDR', $_SERVER)) { $addr = ip2long($_SERVER['SERVER_ADDR']); } else { $addr = php_uname('n'); } } return $addr . $pid . $_SERVER['REQUEST_TIME'] . mt_rand(0, 0xffff); }
[ "private", "function", "generateRequestId", "(", ")", "{", "static", "$", "pid", "=", "-", "1", ";", "static", "$", "addr", "=", "-", "1", ";", "if", "(", "$", "pid", "==", "-", "1", ")", "{", "$", "pid", "=", "getmypid", "(", ")", ";", "}", ...
Generates a unique per request id that can be used to set the BlockCypher-Request-Id header that is used for idempotency @return string
[ "Generates", "a", "unique", "per", "request", "id", "that", "can", "be", "used", "to", "set", "the", "BlockCypher", "-", "Request", "-", "Id", "header", "that", "is", "used", "for", "idempotency" ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Rest/ApiContext.php#L212-L230
train
blockcypher/php-client
lib/BlockCypher/Rest/ApiContext.php
ApiContext.getRequestId
public function getRequestId() { if ($this->requestId == null) { $this->requestId = $this->generateRequestId(); } return $this->requestId; }
php
public function getRequestId() { if ($this->requestId == null) { $this->requestId = $this->generateRequestId(); } return $this->requestId; }
[ "public", "function", "getRequestId", "(", ")", "{", "if", "(", "$", "this", "->", "requestId", "==", "null", ")", "{", "$", "this", "->", "requestId", "=", "$", "this", "->", "generateRequestId", "(", ")", ";", "}", "return", "$", "this", "->", "req...
Get Request ID @return string
[ "Get", "Request", "ID" ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Rest/ApiContext.php#L237-L244
train
blockcypher/php-client
lib/BlockCypher/Api/TXSkeleton.php
TXSkeleton.getInputsAddresses
public function getInputsAddresses() { $addresses = array(); foreach ($this->getTx()->getInputs() as $txInput) { $inputAddresses = $txInput->getAddresses(); if (is_array($inputAddresses)) { $addresses = array_merge($addresses, $inputAddresses); } } return $addresses; }
php
public function getInputsAddresses() { $addresses = array(); foreach ($this->getTx()->getInputs() as $txInput) { $inputAddresses = $txInput->getAddresses(); if (is_array($inputAddresses)) { $addresses = array_merge($addresses, $inputAddresses); } } return $addresses; }
[ "public", "function", "getInputsAddresses", "(", ")", "{", "$", "addresses", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getTx", "(", ")", "->", "getInputs", "(", ")", "as", "$", "txInput", ")", "{", "$", "inputAddresses", "=", "...
Return an array of all inputs addresses in the same order they are in the json tx skeleton @return \string[]
[ "Return", "an", "array", "of", "all", "inputs", "addresses", "in", "the", "same", "order", "they", "are", "in", "the", "json", "tx", "skeleton" ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Api/TXSkeleton.php#L190-L200
train
blockcypher/php-client
lib/BlockCypher/Api/TXSkeleton.php
TXSkeleton.addTosign
public function addTosign($tosign) { if (!$this->getTosign()) { return $this->setTosign(array($tosign)); } else { return $this->setTosign( array_merge($this->getTosign(), array($tosign)) ); } }
php
public function addTosign($tosign) { if (!$this->getTosign()) { return $this->setTosign(array($tosign)); } else { return $this->setTosign( array_merge($this->getTosign(), array($tosign)) ); } }
[ "public", "function", "addTosign", "(", "$", "tosign", ")", "{", "if", "(", "!", "$", "this", "->", "getTosign", "(", ")", ")", "{", "return", "$", "this", "->", "setTosign", "(", "array", "(", "$", "tosign", ")", ")", ";", "}", "else", "{", "ret...
Append Tosign to the list. @param string $tosign @return $this
[ "Append", "Tosign", "to", "the", "list", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Api/TXSkeleton.php#L220-L229
train
blockcypher/php-client
lib/BlockCypher/Api/TXSkeleton.php
TXSkeleton.addSignature
public function addSignature($signature) { if (!$this->getSignatures()) { return $this->setSignatures(array($signature)); } else { return $this->setSignatures( array_merge($this->getSignatures(), array($signature)) ); } }
php
public function addSignature($signature) { if (!$this->getSignatures()) { return $this->setSignatures(array($signature)); } else { return $this->setSignatures( array_merge($this->getSignatures(), array($signature)) ); } }
[ "public", "function", "addSignature", "(", "$", "signature", ")", "{", "if", "(", "!", "$", "this", "->", "getSignatures", "(", ")", ")", "{", "return", "$", "this", "->", "setSignatures", "(", "array", "(", "$", "signature", ")", ")", ";", "}", "els...
Append Signature to the list. @param string $signature @return $this
[ "Append", "Signature", "to", "the", "list", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Api/TXSkeleton.php#L272-L281
train
blockcypher/php-client
lib/BlockCypher/Api/TXSkeleton.php
TXSkeleton.addPubkey
public function addPubkey($pubkey) { if (!$this->getPubkeys()) { return $this->setPubkeys(array($pubkey)); } else { return $this->setPubkeys( array_merge($this->getPubkeys(), array($pubkey)) ); } }
php
public function addPubkey($pubkey) { if (!$this->getPubkeys()) { return $this->setPubkeys(array($pubkey)); } else { return $this->setPubkeys( array_merge($this->getPubkeys(), array($pubkey)) ); } }
[ "public", "function", "addPubkey", "(", "$", "pubkey", ")", "{", "if", "(", "!", "$", "this", "->", "getPubkeys", "(", ")", ")", "{", "return", "$", "this", "->", "setPubkeys", "(", "array", "(", "$", "pubkey", ")", ")", ";", "}", "else", "{", "r...
Append Pubkey to the list. @param string $pubkey @return $this
[ "Append", "Pubkey", "to", "the", "list", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Api/TXSkeleton.php#L324-L333
train
blockcypher/php-client
lib/BlockCypher/Crypto/Cipher.php
Cipher.encrypt
function encrypt($input) { // Create a random IV. Not using mcrypt to generate one, as to not have a dependency on it. $iv = substr(uniqid("", true), 0, Cipher::IV_SIZE); // Encrypt the data $encrypted = openssl_encrypt($input, "AES-256-CBC", $this->secretKey, 0, $iv); // Encode the data with IV as prefix return base64_encode($iv . $encrypted); }
php
function encrypt($input) { // Create a random IV. Not using mcrypt to generate one, as to not have a dependency on it. $iv = substr(uniqid("", true), 0, Cipher::IV_SIZE); // Encrypt the data $encrypted = openssl_encrypt($input, "AES-256-CBC", $this->secretKey, 0, $iv); // Encode the data with IV as prefix return base64_encode($iv . $encrypted); }
[ "function", "encrypt", "(", "$", "input", ")", "{", "// Create a random IV. Not using mcrypt to generate one, as to not have a dependency on it.", "$", "iv", "=", "substr", "(", "uniqid", "(", "\"\"", ",", "true", ")", ",", "0", ",", "Cipher", "::", "IV_SIZE", ")", ...
Encrypts the input text using the cipher key @param $input @return string
[ "Encrypts", "the", "input", "text", "using", "the", "cipher", "key" ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Crypto/Cipher.php#L31-L39
train
blockcypher/php-client
lib/BlockCypher/Cache/AuthorizationCache.php
AuthorizationCache.getConfigValue
private static function getConfigValue($key, $config) { $config = ($config && is_array($config)) ? $config : BlockCypherConfigManager::getInstance()->getConfigHashmap(); return (array_key_exists($key, $config)) ? trim($config[$key]) : null; }
php
private static function getConfigValue($key, $config) { $config = ($config && is_array($config)) ? $config : BlockCypherConfigManager::getInstance()->getConfigHashmap(); return (array_key_exists($key, $config)) ? trim($config[$key]) : null; }
[ "private", "static", "function", "getConfigValue", "(", "$", "key", ",", "$", "config", ")", "{", "$", "config", "=", "(", "$", "config", "&&", "is_array", "(", "$", "config", ")", ")", "?", "$", "config", ":", "BlockCypherConfigManager", "::", "getInsta...
Returns the Value of the key if found in given config, or from BlockCypher Config Manager Returns null if not found @param $key @param $config @return null|string
[ "Returns", "the", "Value", "of", "the", "key", "if", "found", "in", "given", "config", "or", "from", "BlockCypher", "Config", "Manager", "Returns", "null", "if", "not", "found" ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Cache/AuthorizationCache.php#L72-L76
train
blockcypher/php-client
lib/BlockCypher/Cache/AuthorizationCache.php
AuthorizationCache.cachePath
public static function cachePath($config) { $cachePath = self::getConfigValue('cache.FileName', $config); return empty($cachePath) ? __DIR__ . self::$CACHE_PATH : $cachePath; }
php
public static function cachePath($config) { $cachePath = self::getConfigValue('cache.FileName', $config); return empty($cachePath) ? __DIR__ . self::$CACHE_PATH : $cachePath; }
[ "public", "static", "function", "cachePath", "(", "$", "config", ")", "{", "$", "cachePath", "=", "self", "::", "getConfigValue", "(", "'cache.FileName'", ",", "$", "config", ")", ";", "return", "empty", "(", "$", "cachePath", ")", "?", "__DIR__", ".", "...
Returns the cache file path @param $config @return string
[ "Returns", "the", "cache", "file", "path" ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Cache/AuthorizationCache.php#L84-L88
train
blockcypher/php-client
lib/BlockCypher/Cache/AuthorizationCache.php
AuthorizationCache.pull
public static function pull($config = null, $clientId = null) { // Return if not enabled if (!self::isEnabled($config)) { return null; } $tokens = null; $cachePath = self::cachePath($config); if (file_exists($cachePath)) { // Read from the file $cachedToken = file_get_contents($cachePath); if ($cachedToken && JsonValidator::validate($cachedToken, true)) { $tokens = json_decode($cachedToken, true); if ($clientId && is_array($tokens) && array_key_exists($clientId, $tokens)) { // If client Id is found, just send in that data only return $tokens[$clientId]; } else if ($clientId) { // If client Id is provided, but no key in persisted data found matching it. return null; } } } return $tokens; }
php
public static function pull($config = null, $clientId = null) { // Return if not enabled if (!self::isEnabled($config)) { return null; } $tokens = null; $cachePath = self::cachePath($config); if (file_exists($cachePath)) { // Read from the file $cachedToken = file_get_contents($cachePath); if ($cachedToken && JsonValidator::validate($cachedToken, true)) { $tokens = json_decode($cachedToken, true); if ($clientId && is_array($tokens) && array_key_exists($clientId, $tokens)) { // If client Id is found, just send in that data only return $tokens[$clientId]; } else if ($clientId) { // If client Id is provided, but no key in persisted data found matching it. return null; } } } return $tokens; }
[ "public", "static", "function", "pull", "(", "$", "config", "=", "null", ",", "$", "clientId", "=", "null", ")", "{", "// Return if not enabled", "if", "(", "!", "self", "::", "isEnabled", "(", "$", "config", ")", ")", "{", "return", "null", ";", "}", ...
A pull method which would read the persisted data based on clientId. If clientId is not provided, an array with all the tokens would be passed. @param array|null $config @param string $clientId @return mixed|null
[ "A", "pull", "method", "which", "would", "read", "the", "persisted", "data", "based", "on", "clientId", ".", "If", "clientId", "is", "not", "provided", "an", "array", "with", "all", "the", "tokens", "would", "be", "passed", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Cache/AuthorizationCache.php#L98-L122
train
blockcypher/php-client
lib/BlockCypher/Validation/JsonValidator.php
JsonValidator.validate
public static function validate($string, $silent = false) { @json_decode($string); if (json_last_error() != JSON_ERROR_NONE) { if ($silent == false) { //Throw an Exception for string or array throw new \InvalidArgumentException("Invalid JSON String"); } return false; } return true; }
php
public static function validate($string, $silent = false) { @json_decode($string); if (json_last_error() != JSON_ERROR_NONE) { if ($silent == false) { //Throw an Exception for string or array throw new \InvalidArgumentException("Invalid JSON String"); } return false; } return true; }
[ "public", "static", "function", "validate", "(", "$", "string", ",", "$", "silent", "=", "false", ")", "{", "@", "json_decode", "(", "$", "string", ")", ";", "if", "(", "json_last_error", "(", ")", "!=", "JSON_ERROR_NONE", ")", "{", "if", "(", "$", "...
Helper method for validating if string provided is a valid json. @param string $string String representation of Json object @param bool $silent Flag to not throw \InvalidArgumentException @return bool
[ "Helper", "method", "for", "validating", "if", "string", "provided", "is", "a", "valid", "json", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Validation/JsonValidator.php#L20-L31
train
blockcypher/php-client
lib/BlockCypher/Client/BlockchainClient.php
BlockchainClient.get
public function get($name, $params = array(), $apiContext = null, $restCall = null) { ArgumentValidator::validate($name, 'name'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); if (strpos($name, '.') === FALSE) { throw new \InvalidArgumentException("Invalid chain name $name. FORMAT: COIN.chain e.g. BTC.main"); } $payLoad = ""; if ($apiContext === null) { $apiContext = $this->getApiContext(); } $version = $apiContext->getVersion(); list($coin, $chain) = explode(".", $name); $coin = strtolower($coin); $json = $this->executeCall( "/$version/$coin/$chain" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall ); $ret = new Blockchain(); $ret->fromJson($json); return $ret; }
php
public function get($name, $params = array(), $apiContext = null, $restCall = null) { ArgumentValidator::validate($name, 'name'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); if (strpos($name, '.') === FALSE) { throw new \InvalidArgumentException("Invalid chain name $name. FORMAT: COIN.chain e.g. BTC.main"); } $payLoad = ""; if ($apiContext === null) { $apiContext = $this->getApiContext(); } $version = $apiContext->getVersion(); list($coin, $chain) = explode(".", $name); $coin = strtolower($coin); $json = $this->executeCall( "/$version/$coin/$chain" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall ); $ret = new Blockchain(); $ret->fromJson($json); return $ret; }
[ "public", "function", "get", "(", "$", "name", ",", "$", "params", "=", "array", "(", ")", ",", "$", "apiContext", "=", "null", ",", "$", "restCall", "=", "null", ")", "{", "ArgumentValidator", "::", "validate", "(", "$", "name", ",", "'name'", ")", ...
Obtain the Blockchain resource for the given identifier. @param string $name @param array $params Parameters @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls @return Blockchain
[ "Obtain", "the", "Blockchain", "resource", "for", "the", "given", "identifier", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Client/BlockchainClient.php#L28-L60
train
blockcypher/php-client
lib/BlockCypher/Client/BlockchainClient.php
BlockchainClient.getFeature
public function getFeature($featureName, $params = array(), $apiContext = null, $restCall = null) { ArgumentValidator::validate($featureName, 'featureName'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = ""; $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall( "$chainUrlPrefix/feature/$featureName?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall ); return $json; }
php
public function getFeature($featureName, $params = array(), $apiContext = null, $restCall = null) { ArgumentValidator::validate($featureName, 'featureName'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = ""; $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall( "$chainUrlPrefix/feature/$featureName?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall ); return $json; }
[ "public", "function", "getFeature", "(", "$", "featureName", ",", "$", "params", "=", "array", "(", ")", ",", "$", "apiContext", "=", "null", ",", "$", "restCall", "=", "null", ")", "{", "ArgumentValidator", "::", "validate", "(", "$", "featureName", ","...
Obtain the information about the adoption of upgrade features on a blockchain. @param string $featureName @param array $params Parameters. Options: txstart, and limit @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls @return string
[ "Obtain", "the", "information", "about", "the", "adoption", "of", "upgrade", "features", "on", "a", "blockchain", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Client/BlockchainClient.php#L71-L91
train
blockcypher/php-client
lib/BlockCypher/Crypto/Signer.php
Signer.signMultiple
public static function signMultiple($hexDataToSign, $privateKey) { ArgumentArrayValidator::validate($hexDataToSign, 'hexDataToSign'); $signatures = array(); foreach ($hexDataToSign as $tosign) { $signatures[] = self::sign($tosign, $privateKey); } return $signatures; }
php
public static function signMultiple($hexDataToSign, $privateKey) { ArgumentArrayValidator::validate($hexDataToSign, 'hexDataToSign'); $signatures = array(); foreach ($hexDataToSign as $tosign) { $signatures[] = self::sign($tosign, $privateKey); } return $signatures; }
[ "public", "static", "function", "signMultiple", "(", "$", "hexDataToSign", ",", "$", "privateKey", ")", "{", "ArgumentArrayValidator", "::", "validate", "(", "$", "hexDataToSign", ",", "'hexDataToSign'", ")", ";", "$", "signatures", "=", "array", "(", ")", ";"...
Sign array of hex data deterministically using deterministic k. @param string[] $hexDataToSign @param PrivateKeyInterface|string $privateKey @return string[]
[ "Sign", "array", "of", "hex", "data", "deterministically", "using", "deterministic", "k", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Crypto/Signer.php#L25-L34
train
blockcypher/php-client
lib/BlockCypher/Crypto/Signer.php
Signer.sign
public static function sign($hexDataToSign, $privateKey) { if (is_string($privateKey)) { $privateKey = PrivateKeyManipulator::importPrivateKey($privateKey); } // Convert hex data to buffer $data = Buffer::hex($hexDataToSign); /** @var EcAdapterInterface $ecAdapter */ $ecAdapter = Bitcoin::getEcAdapter(); // Deterministic digital signature generation $k = new Rfc6979($ecAdapter, $privateKey, $data, 'sha256'); $sig = $ecAdapter->sign($data, $privateKey, $k); // DEBUG //echo "hexDataToSign: <br/>"; //var_dump($hexDataToSign); //echo "sig: <br/>"; //var_dump($sig->getHex()); return $sig->getHex(); }
php
public static function sign($hexDataToSign, $privateKey) { if (is_string($privateKey)) { $privateKey = PrivateKeyManipulator::importPrivateKey($privateKey); } // Convert hex data to buffer $data = Buffer::hex($hexDataToSign); /** @var EcAdapterInterface $ecAdapter */ $ecAdapter = Bitcoin::getEcAdapter(); // Deterministic digital signature generation $k = new Rfc6979($ecAdapter, $privateKey, $data, 'sha256'); $sig = $ecAdapter->sign($data, $privateKey, $k); // DEBUG //echo "hexDataToSign: <br/>"; //var_dump($hexDataToSign); //echo "sig: <br/>"; //var_dump($sig->getHex()); return $sig->getHex(); }
[ "public", "static", "function", "sign", "(", "$", "hexDataToSign", ",", "$", "privateKey", ")", "{", "if", "(", "is_string", "(", "$", "privateKey", ")", ")", "{", "$", "privateKey", "=", "PrivateKeyManipulator", "::", "importPrivateKey", "(", "$", "privateK...
Sign hex data deterministically using deterministic k. @param string $hexDataToSign @param PrivateKeyInterface|string $privateKey @return string
[ "Sign", "hex", "data", "deterministically", "using", "deterministic", "k", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Crypto/Signer.php#L43-L67
train
blockcypher/php-client
lib/BlockCypher/Api/TX.php
TX.push
public static function push($hexRawTx, $params = array(), $apiContext = null, $restCall = null) { ArgumentValidator::validate($hexRawTx, 'hexRawTx'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $txHex = new TXHex(); $txHex->setTx($hexRawTx); $payLoad = $txHex->toJSON(); $chainUrlPrefix = self::getChainUrlPrefix($apiContext); $json = self::executeCall( "$chainUrlPrefix/txs/push?" . http_build_query($params), "POST", $payLoad, null, $apiContext, $restCall ); $ret = new TX(); $ret->fromJson($json); return $ret; }
php
public static function push($hexRawTx, $params = array(), $apiContext = null, $restCall = null) { ArgumentValidator::validate($hexRawTx, 'hexRawTx'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $txHex = new TXHex(); $txHex->setTx($hexRawTx); $payLoad = $txHex->toJSON(); $chainUrlPrefix = self::getChainUrlPrefix($apiContext); $json = self::executeCall( "$chainUrlPrefix/txs/push?" . http_build_query($params), "POST", $payLoad, null, $apiContext, $restCall ); $ret = new TX(); $ret->fromJson($json); return $ret; }
[ "public", "static", "function", "push", "(", "$", "hexRawTx", ",", "$", "params", "=", "array", "(", ")", ",", "$", "apiContext", "=", "null", ",", "$", "restCall", "=", "null", ")", "{", "ArgumentValidator", "::", "validate", "(", "$", "hexRawTx", ","...
Push the raw transaction to the network. @deprecated since version 1.2. Use TXClient. @param string $hexRawTx @param array $params Parameters. Options: instart, outstart and limit @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls @return TX
[ "Push", "the", "raw", "transaction", "to", "the", "network", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Api/TX.php#L206-L230
train
blockcypher/php-client
lib/BlockCypher/Api/TX.php
TX.addInput
public function addInput($input) { if (!$this->getInputs()) { return $this->setInputs(array($input)); } else { return $this->setInputs( array_merge($this->getInputs(), array($input)) ); } }
php
public function addInput($input) { if (!$this->getInputs()) { return $this->setInputs(array($input)); } else { return $this->setInputs( array_merge($this->getInputs(), array($input)) ); } }
[ "public", "function", "addInput", "(", "$", "input", ")", "{", "if", "(", "!", "$", "this", "->", "getInputs", "(", ")", ")", "{", "return", "$", "this", "->", "setInputs", "(", "array", "(", "$", "input", ")", ")", ";", "}", "else", "{", "return...
Append TXInput to the list. @param \BlockCypher\Api\TXInput $input @return \BlockCypher\Api\TXInput[]
[ "Append", "TXInput", "to", "the", "list", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Api/TX.php#L671-L680
train
blockcypher/php-client
lib/BlockCypher/Api/TX.php
TX.addOutput
public function addOutput($output) { if (!$this->getOutputs()) { return $this->setOutputs(array($output)); } else { return $this->setOutputs( array_merge($this->getOutputs(), array($output)) ); } }
php
public function addOutput($output) { if (!$this->getOutputs()) { return $this->setOutputs(array($output)); } else { return $this->setOutputs( array_merge($this->getOutputs(), array($output)) ); } }
[ "public", "function", "addOutput", "(", "$", "output", ")", "{", "if", "(", "!", "$", "this", "->", "getOutputs", "(", ")", ")", "{", "return", "$", "this", "->", "setOutputs", "(", "array", "(", "$", "output", ")", ")", ";", "}", "else", "{", "r...
Append TXOutput to the list. @param \BlockCypher\Api\TXOutput $output @return \BlockCypher\Api\TXOutput[]
[ "Append", "TXOutput", "to", "the", "list", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Api/TX.php#L725-L734
train
blockcypher/php-client
lib/BlockCypher/Common/BlockCypherModel.php
BlockCypherModel._convertToArray
private function _convertToArray($param) { $ret = array(); foreach ($param as $k => $v) { if ($v instanceof BlockCypherModel) { $ret[$k] = $v->toArray(); } else if (sizeof($v) <= 0 && is_array($v)) { $ret[$k] = array(); } else if (is_array($v)) { $ret[$k] = $this->_convertToArray($v); } else { $ret[$k] = $v; } } // If the array is empty, which means an empty object, // we need to convert array to StdClass object to properly // represent JSON String if (sizeof($ret) <= 0) { $ret = new BlockCypherModel(); } return $ret; }
php
private function _convertToArray($param) { $ret = array(); foreach ($param as $k => $v) { if ($v instanceof BlockCypherModel) { $ret[$k] = $v->toArray(); } else if (sizeof($v) <= 0 && is_array($v)) { $ret[$k] = array(); } else if (is_array($v)) { $ret[$k] = $this->_convertToArray($v); } else { $ret[$k] = $v; } } // If the array is empty, which means an empty object, // we need to convert array to StdClass object to properly // represent JSON String if (sizeof($ret) <= 0) { $ret = new BlockCypherModel(); } return $ret; }
[ "private", "function", "_convertToArray", "(", "$", "param", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "foreach", "(", "$", "param", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "$", "v", "instanceof", "BlockCypherModel", ")", "{",...
Converts Params to Array @param $param @return array
[ "Converts", "Params", "to", "Array" ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Common/BlockCypherModel.php#L309-L330
train
blockcypher/php-client
lib/BlockCypher/Common/ReflectionUtil.php
ReflectionUtil.propertyAnnotations
public static function propertyAnnotations($class, $propertyName) { $class = is_object($class) ? get_class($class) : $class; if (!class_exists('ReflectionProperty')) { throw new \RuntimeException("Property type of " . $class . "::{$propertyName} cannot be resolved"); } if ($annotations =& self::$propertiesType[$class][$propertyName]) { return $annotations; } if (!($refl =& self::$propertiesRefl[$class][$propertyName])) { $getter = self::getter($class, $propertyName); $refl = new \ReflectionMethod($class, $getter); self::$propertiesRefl[$class][$propertyName] = $refl; } // todo: smarter regexp if (!preg_match_all( '~\@([^\s@\(]+)[\t ]*(?:\(?([^\n@]+)\)?)?~i', $refl->getDocComment(), $annots, PREG_PATTERN_ORDER) ) { return null; } foreach ($annots[1] as $i => $annot) { $annotations[strtolower($annot)] = empty($annots[2][$i]) ? TRUE : rtrim($annots[2][$i], " \t\n\r)"); } return $annotations; }
php
public static function propertyAnnotations($class, $propertyName) { $class = is_object($class) ? get_class($class) : $class; if (!class_exists('ReflectionProperty')) { throw new \RuntimeException("Property type of " . $class . "::{$propertyName} cannot be resolved"); } if ($annotations =& self::$propertiesType[$class][$propertyName]) { return $annotations; } if (!($refl =& self::$propertiesRefl[$class][$propertyName])) { $getter = self::getter($class, $propertyName); $refl = new \ReflectionMethod($class, $getter); self::$propertiesRefl[$class][$propertyName] = $refl; } // todo: smarter regexp if (!preg_match_all( '~\@([^\s@\(]+)[\t ]*(?:\(?([^\n@]+)\)?)?~i', $refl->getDocComment(), $annots, PREG_PATTERN_ORDER) ) { return null; } foreach ($annots[1] as $i => $annot) { $annotations[strtolower($annot)] = empty($annots[2][$i]) ? TRUE : rtrim($annots[2][$i], " \t\n\r)"); } return $annotations; }
[ "public", "static", "function", "propertyAnnotations", "(", "$", "class", ",", "$", "propertyName", ")", "{", "$", "class", "=", "is_object", "(", "$", "class", ")", "?", "get_class", "(", "$", "class", ")", ":", "$", "class", ";", "if", "(", "!", "c...
Retrieves Annotations of each property @param $class @param $propertyName @throws \RuntimeException @return mixed
[ "Retrieves", "Annotations", "of", "each", "property" ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Common/ReflectionUtil.php#L102-L133
train
blockcypher/php-client
lib/BlockCypher/Common/ReflectionUtil.php
ReflectionUtil.isPropertyClassArray
public static function isPropertyClassArray($class, $propertyName) { // If the class doesn't exist, or the method doesn't exist, return null. if (!class_exists($class) || !method_exists($class, self::getter($class, $propertyName))) { return null; } if (($annotations = self::propertyAnnotations($class, $propertyName)) && isset($annotations['return'])) { $param = $annotations['return']; } if (isset($param)) { return substr($param, -strlen('[]')) === '[]'; } else { throw new BlockCypherConfigurationException("Getter function for '$propertyName' in '$class' class should have a proper return type."); } }
php
public static function isPropertyClassArray($class, $propertyName) { // If the class doesn't exist, or the method doesn't exist, return null. if (!class_exists($class) || !method_exists($class, self::getter($class, $propertyName))) { return null; } if (($annotations = self::propertyAnnotations($class, $propertyName)) && isset($annotations['return'])) { $param = $annotations['return']; } if (isset($param)) { return substr($param, -strlen('[]')) === '[]'; } else { throw new BlockCypherConfigurationException("Getter function for '$propertyName' in '$class' class should have a proper return type."); } }
[ "public", "static", "function", "isPropertyClassArray", "(", "$", "class", ",", "$", "propertyName", ")", "{", "// If the class doesn't exist, or the method doesn't exist, return null.", "if", "(", "!", "class_exists", "(", "$", "class", ")", "||", "!", "method_exists",...
Checks if the Property is of type array or an object @param $class @param $propertyName @return null|boolean @throws BlockCypherConfigurationException
[ "Checks", "if", "the", "Property", "is", "of", "type", "array", "or", "an", "object" ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Common/ReflectionUtil.php#L143-L159
train
blockcypher/php-client
lib/BlockCypher/Core/BlockCypherCredentialManager.php
BlockCypherCredentialManager.initCredential
private function initCredential($config) { $suffix = 1; $prefix = "acct"; $arr = array(); foreach ($config as $k => $v) { if (strstr($k, $prefix)) { $arr[$k] = $v; } } $credArr = $arr; $arr = array(); foreach ($config as $key => $value) { $pos = strpos($key, '.'); if (strstr($key, "acct")) { $arr[] = substr($key, 0, $pos); } } $arrayPartKeys = array_unique($arr); $key = $prefix . $suffix; $userName = null; while (in_array($key, $arrayPartKeys)) { if (isset($credArr[$key . ".AccessToken"]) && isset($credArr[$key . ".AccessToken"])) { $userName = $key; $this->credentialHashmap[$userName] = new SimpleTokenCredential($credArr[$key . ".AccessToken"]); } if ($userName && $this->defaultAccountName == null) { if (array_key_exists($key . '.UserName', $credArr)) { $this->defaultAccountName = $credArr[$key . '.UserName']; } else { $this->defaultAccountName = $key; } } $suffix++; $key = $prefix . $suffix; } }
php
private function initCredential($config) { $suffix = 1; $prefix = "acct"; $arr = array(); foreach ($config as $k => $v) { if (strstr($k, $prefix)) { $arr[$k] = $v; } } $credArr = $arr; $arr = array(); foreach ($config as $key => $value) { $pos = strpos($key, '.'); if (strstr($key, "acct")) { $arr[] = substr($key, 0, $pos); } } $arrayPartKeys = array_unique($arr); $key = $prefix . $suffix; $userName = null; while (in_array($key, $arrayPartKeys)) { if (isset($credArr[$key . ".AccessToken"]) && isset($credArr[$key . ".AccessToken"])) { $userName = $key; $this->credentialHashmap[$userName] = new SimpleTokenCredential($credArr[$key . ".AccessToken"]); } if ($userName && $this->defaultAccountName == null) { if (array_key_exists($key . '.UserName', $credArr)) { $this->defaultAccountName = $credArr[$key . '.UserName']; } else { $this->defaultAccountName = $key; } } $suffix++; $key = $prefix . $suffix; } }
[ "private", "function", "initCredential", "(", "$", "config", ")", "{", "$", "suffix", "=", "1", ";", "$", "prefix", "=", "\"acct\"", ";", "$", "arr", "=", "array", "(", ")", ";", "foreach", "(", "$", "config", "as", "$", "k", "=>", "$", "v", ")",...
Load credentials for multiple accounts, with priority given to Signature credential. @param array $config
[ "Load", "credentials", "for", "multiple", "accounts", "with", "priority", "given", "to", "Signature", "credential", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Core/BlockCypherCredentialManager.php#L61-L101
train
blockcypher/php-client
lib/BlockCypher/Core/BlockCypherCredentialManager.php
BlockCypherCredentialManager.getCredentialObject
public function getCredentialObject($userId = null) { if ($userId == null && array_key_exists($this->defaultAccountName, $this->credentialHashmap)) { $credObj = $this->credentialHashmap[$this->defaultAccountName]; } else if (array_key_exists($userId, $this->credentialHashmap)) { $credObj = $this->credentialHashmap[$userId]; } if (empty($credObj)) { throw new BlockCypherInvalidCredentialException("Credential not found for " . ($userId ? $userId : " default user") . ". Please make sure your configuration/APIContext has credential information"); } return $credObj; }
php
public function getCredentialObject($userId = null) { if ($userId == null && array_key_exists($this->defaultAccountName, $this->credentialHashmap)) { $credObj = $this->credentialHashmap[$this->defaultAccountName]; } else if (array_key_exists($userId, $this->credentialHashmap)) { $credObj = $this->credentialHashmap[$userId]; } if (empty($credObj)) { throw new BlockCypherInvalidCredentialException("Credential not found for " . ($userId ? $userId : " default user") . ". Please make sure your configuration/APIContext has credential information"); } return $credObj; }
[ "public", "function", "getCredentialObject", "(", "$", "userId", "=", "null", ")", "{", "if", "(", "$", "userId", "==", "null", "&&", "array_key_exists", "(", "$", "this", "->", "defaultAccountName", ",", "$", "this", "->", "credentialHashmap", ")", ")", "...
Obtain Credential Object based on UserId provided. @param null $userId @return SimpleTokenCredential @throws BlockCypherInvalidCredentialException
[ "Obtain", "Credential", "Object", "based", "on", "UserId", "provided", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Core/BlockCypherCredentialManager.php#L142-L155
train
blockcypher/php-client
lib/BlockCypher/Api/FullAddress.php
FullAddress.addTx
public function addTx($tx) { if (!$this->getTxs()) { return $this->setTxs(array($tx)); } else { return $this->setTxs( array_merge($this->getTxs(), array($tx)) ); } }
php
public function addTx($tx) { if (!$this->getTxs()) { return $this->setTxs(array($tx)); } else { return $this->setTxs( array_merge($this->getTxs(), array($tx)) ); } }
[ "public", "function", "addTx", "(", "$", "tx", ")", "{", "if", "(", "!", "$", "this", "->", "getTxs", "(", ")", ")", "{", "return", "$", "this", "->", "setTxs", "(", "array", "(", "$", "tx", ")", ")", ";", "}", "else", "{", "return", "$", "th...
Append TX to the list. @param \BlockCypher\Api\TX $tx @return $this
[ "Append", "TX", "to", "the", "list", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Api/FullAddress.php#L372-L381
train
blockcypher/php-client
lib/BlockCypher/Api/MicroTX.php
MicroTX.sign
public function sign($hexPrivateKey) { $this->setSignatures(Signer::signMultiple($this->tosign, $hexPrivateKey)); return $this; }
php
public function sign($hexPrivateKey) { $this->setSignatures(Signer::signMultiple($this->tosign, $hexPrivateKey)); return $this; }
[ "public", "function", "sign", "(", "$", "hexPrivateKey", ")", "{", "$", "this", "->", "setSignatures", "(", "Signer", "::", "signMultiple", "(", "$", "this", "->", "tosign", ",", "$", "hexPrivateKey", ")", ")", ";", "return", "$", "this", ";", "}" ]
Signs MicroTX. @param string[]|string $hexPrivateKey @return $this @throws \Exception
[ "Signs", "MicroTX", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Api/MicroTX.php#L74-L78
train
blockcypher/php-client
lib/BlockCypher/Validation/TokenValidator.php
TokenValidator.validate
public static function validate($token) { if ($token === null) { return false; } if (gettype($token) == 'string' && trim($token) == '') { // False if String Empty return false; } if (strlen($token) < 20) return false; if (strlen($token) > 50) return false; // Type 0: c0afcccdde5081d6429de37d16166ead $type0RegExpression = '/(^[a-z0-9]+$)/i'; // Type 1: de305d54-75b4-431b-adb2-eb6b9e546014 // UUID strict: http://en.wikipedia.org/wiki/Universally_unique_identifier#Definition $type1RegExpression = '/(^[a-f0-9]{8}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{12}$)/i'; if (preg_match($type0RegExpression, $token) == false && preg_match($type1RegExpression, $token) == false ) { return false; } return true; }
php
public static function validate($token) { if ($token === null) { return false; } if (gettype($token) == 'string' && trim($token) == '') { // False if String Empty return false; } if (strlen($token) < 20) return false; if (strlen($token) > 50) return false; // Type 0: c0afcccdde5081d6429de37d16166ead $type0RegExpression = '/(^[a-z0-9]+$)/i'; // Type 1: de305d54-75b4-431b-adb2-eb6b9e546014 // UUID strict: http://en.wikipedia.org/wiki/Universally_unique_identifier#Definition $type1RegExpression = '/(^[a-f0-9]{8}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{12}$)/i'; if (preg_match($type0RegExpression, $token) == false && preg_match($type1RegExpression, $token) == false ) { return false; } return true; }
[ "public", "static", "function", "validate", "(", "$", "token", ")", "{", "if", "(", "$", "token", "===", "null", ")", "{", "return", "false", ";", "}", "if", "(", "gettype", "(", "$", "token", ")", "==", "'string'", "&&", "trim", "(", "$", "token",...
Helper method for validating tokens. @param string $token @return bool
[ "Helper", "method", "for", "validating", "tokens", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Validation/TokenValidator.php#L18-L46
train
blockcypher/php-client
lib/BlockCypher/Client/WebHookClient.php
WebHookClient.getAll
public function getAll($params = array(), $apiContext = null, $restCall = null) { ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array( 'token' => 1, ); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = ""; $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall( "$chainUrlPrefix/hooks?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall ); return WebHook::getList($json); }
php
public function getAll($params = array(), $apiContext = null, $restCall = null) { ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array( 'token' => 1, ); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = ""; $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall( "$chainUrlPrefix/hooks?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall ); return WebHook::getList($json); }
[ "public", "function", "getAll", "(", "$", "params", "=", "array", "(", ")", ",", "$", "apiContext", "=", "null", ",", "$", "restCall", "=", "null", ")", "{", "ArgumentGetParamsValidator", "::", "validate", "(", "$", "params", ",", "'params'", ")", ";", ...
Obtain all WebHook resources for the provided token. @param array $params Parameters. Options: token @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls @return WebHook[]
[ "Obtain", "all", "WebHook", "resources", "for", "the", "provided", "token", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Client/WebHookClient.php#L94-L115
train
blockcypher/php-client
lib/BlockCypher/Core/BlockCypherConfigManager.php
BlockCypherConfigManager.get
public function get($searchKey) { if (array_key_exists($searchKey, $this->configs)) { return $this->configs[$searchKey]; } else { $arr = array(); foreach ($this->configs as $k => $v) { if (strstr($k, $searchKey)) { $arr[$k] = $v; } } return $arr; } }
php
public function get($searchKey) { if (array_key_exists($searchKey, $this->configs)) { return $this->configs[$searchKey]; } else { $arr = array(); foreach ($this->configs as $k => $v) { if (strstr($k, $searchKey)) { $arr[$k] = $v; } } return $arr; } }
[ "public", "function", "get", "(", "$", "searchKey", ")", "{", "if", "(", "array_key_exists", "(", "$", "searchKey", ",", "$", "this", "->", "configs", ")", ")", "{", "return", "$", "this", "->", "configs", "[", "$", "searchKey", "]", ";", "}", "else"...
Simple getter for configuration params If an exact match for key is not found, does a "contains" search on the key @param string $searchKey @return array
[ "Simple", "getter", "for", "configuration", "params", "If", "an", "exact", "match", "for", "key", "is", "not", "found", "does", "a", "contains", "search", "on", "the", "key" ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Core/BlockCypherConfigManager.php#L94-L108
train
blockcypher/php-client
lib/BlockCypher/Client/TXClient.php
TXClient.create
public function create(TX $tx, $apiContext = null, $restCall = null) { // TODO: change signature. Add $params = array() after TX $tx //ArgumentGetParamsValidator::validate($params, 'params'); //$allowedParams = array( // 'includeToSignTx' => 1, //); //$params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = $tx->toJSON(); $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall( "$chainUrlPrefix/txs/new", "POST", $payLoad, null, $apiContext, $restCall ); $txSkeleton = new TXSkeleton(); $txSkeleton->fromJson($json); return $txSkeleton; }
php
public function create(TX $tx, $apiContext = null, $restCall = null) { // TODO: change signature. Add $params = array() after TX $tx //ArgumentGetParamsValidator::validate($params, 'params'); //$allowedParams = array( // 'includeToSignTx' => 1, //); //$params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = $tx->toJSON(); $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall( "$chainUrlPrefix/txs/new", "POST", $payLoad, null, $apiContext, $restCall ); $txSkeleton = new TXSkeleton(); $txSkeleton->fromJson($json); return $txSkeleton; }
[ "public", "function", "create", "(", "TX", "$", "tx", ",", "$", "apiContext", "=", "null", ",", "$", "restCall", "=", "null", ")", "{", "// TODO: change signature. Add $params = array() after TX $tx", "//ArgumentGetParamsValidator::validate($params, 'params');", "//$allowed...
Create a new TX. @param TX $tx @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls @return TXSkeleton
[ "Create", "a", "new", "TX", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Client/TXClient.php#L224-L249
train
blockcypher/php-client
lib/BlockCypher/Client/TXClient.php
TXClient.send
public function send(TXSkeleton $txSkeleton, $apiContext = null, $restCall = null) { $payLoad = $txSkeleton->toJSON(); $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall( "$chainUrlPrefix/txs/send", "POST", $payLoad, null, $apiContext, $restCall ); $returnedTXSkeleton = new TXSkeleton(); $returnedTXSkeleton->fromJson($json); return $returnedTXSkeleton; }
php
public function send(TXSkeleton $txSkeleton, $apiContext = null, $restCall = null) { $payLoad = $txSkeleton->toJSON(); $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall( "$chainUrlPrefix/txs/send", "POST", $payLoad, null, $apiContext, $restCall ); $returnedTXSkeleton = new TXSkeleton(); $returnedTXSkeleton->fromJson($json); return $returnedTXSkeleton; }
[ "public", "function", "send", "(", "TXSkeleton", "$", "txSkeleton", ",", "$", "apiContext", "=", "null", ",", "$", "restCall", "=", "null", ")", "{", "$", "payLoad", "=", "$", "txSkeleton", "->", "toJSON", "(", ")", ";", "$", "chainUrlPrefix", "=", "$"...
Send the transaction to the network. @param TXSkeleton $txSkeleton @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls @return TXSkeleton
[ "Send", "the", "transaction", "to", "the", "network", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Client/TXClient.php#L259-L277
train
blockcypher/php-client
lib/BlockCypher/Client/TXClient.php
TXClient.getConfidence
public function getConfidence($txhash, $params = array(), $apiContext = null, $restCall = null) { ArgumentValidator::validate($txhash, 'txhash'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = ""; $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall( "$chainUrlPrefix/txs/$txhash/confidence" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall ); $txConfidence = new TXConfidence(); $txConfidence->fromJson($json); return $txConfidence; }
php
public function getConfidence($txhash, $params = array(), $apiContext = null, $restCall = null) { ArgumentValidator::validate($txhash, 'txhash'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = ""; $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall( "$chainUrlPrefix/txs/$txhash/confidence" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall ); $txConfidence = new TXConfidence(); $txConfidence->fromJson($json); return $txConfidence; }
[ "public", "function", "getConfidence", "(", "$", "txhash", ",", "$", "params", "=", "array", "(", ")", ",", "$", "apiContext", "=", "null", ",", "$", "restCall", "=", "null", ")", "{", "ArgumentValidator", "::", "validate", "(", "$", "txhash", ",", "'t...
Obtain the TXConfidence resource for the given identifier. @param string $txhash @param array $params Parameters @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls @return TXConfidence
[ "Obtain", "the", "TXConfidence", "resource", "for", "the", "given", "identifier", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Client/TXClient.php#L288-L310
train
blockcypher/php-client
lib/BlockCypher/Client/TXClient.php
TXClient.getMultipleConfidences
public function getMultipleConfidences($array, $params = array(), $apiContext = null, $restCall = null) { ArgumentArrayValidator::validate($array, 'array'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = ""; $txhashList = implode(";", $array); $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall( "$chainUrlPrefix/txs/$txhashList/confidence" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall ); return TXConfidence::getList($json); }
php
public function getMultipleConfidences($array, $params = array(), $apiContext = null, $restCall = null) { ArgumentArrayValidator::validate($array, 'array'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = ""; $txhashList = implode(";", $array); $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall( "$chainUrlPrefix/txs/$txhashList/confidence" . http_build_query(array_intersect_key($params, $allowedParams)), "GET", $payLoad, null, $apiContext, $restCall ); return TXConfidence::getList($json); }
[ "public", "function", "getMultipleConfidences", "(", "$", "array", ",", "$", "params", "=", "array", "(", ")", ",", "$", "apiContext", "=", "null", ",", "$", "restCall", "=", "null", ")", "{", "ArgumentArrayValidator", "::", "validate", "(", "$", "array", ...
Obtain multiple TransactionConfidences resources for the given identifiers. @param string[] $array @param array $params Parameters @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls @return TXConfidence[]
[ "Obtain", "multiple", "TransactionConfidences", "resources", "for", "the", "given", "identifiers", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Client/TXClient.php#L321-L343
train
blockcypher/php-client
lib/BlockCypher/Common/BlockCypherBaseModel.php
BlockCypherBaseModel.addError
public function addError($error) { if (!$this->getErrors()) { return $this->setErrors(array($error)); } else { return $this->setErrors( array_merge($this->getErrors(), array($error)) ); } }
php
public function addError($error) { if (!$this->getErrors()) { return $this->setErrors(array($error)); } else { return $this->setErrors( array_merge($this->getErrors(), array($error)) ); } }
[ "public", "function", "addError", "(", "$", "error", ")", "{", "if", "(", "!", "$", "this", "->", "getErrors", "(", ")", ")", "{", "return", "$", "this", "->", "setErrors", "(", "array", "(", "$", "error", ")", ")", ";", "}", "else", "{", "return...
Append error to the list. @param \BlockCypher\Api\Error $error @return $this
[ "Append", "error", "to", "the", "list", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Common/BlockCypherBaseModel.php#L40-L49
train
blockcypher/php-client
lib/BlockCypher/Client/WalletClient.php
WalletClient.getOnlyAddresses
public function getOnlyAddresses($walletName, $params = array(), $apiContext = null, $restCall = null) { return $this->getWalletAddresses($walletName, $params, $apiContext, $restCall); }
php
public function getOnlyAddresses($walletName, $params = array(), $apiContext = null, $restCall = null) { return $this->getWalletAddresses($walletName, $params, $apiContext, $restCall); }
[ "public", "function", "getOnlyAddresses", "(", "$", "walletName", ",", "$", "params", "=", "array", "(", ")", ",", "$", "apiContext", "=", "null", ",", "$", "restCall", "=", "null", ")", "{", "return", "$", "this", "->", "getWalletAddresses", "(", "$", ...
Get all addresses in a given wallet. @deprecated changed name to getWalletAddresses. @param string $walletName @param array $params Parameters. @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls @return AddressList
[ "Get", "all", "addresses", "in", "a", "given", "wallet", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Client/WalletClient.php#L97-L100
train
blockcypher/php-client
lib/BlockCypher/Client/HDWalletClient.php
HDWalletClient.getMultiple
public function getMultiple($walletNames, $params = array(), $apiContext = null, $restCall = null) { ArgumentArrayValidator::validate($walletNames, 'walletNames'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $walletList = implode(";", $walletNames); $payLoad = ""; $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall( "$chainUrlPrefix/wallets/hd/$walletList?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall ); return HDWallet::getList($json); }
php
public function getMultiple($walletNames, $params = array(), $apiContext = null, $restCall = null) { ArgumentArrayValidator::validate($walletNames, 'walletNames'); ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $walletList = implode(";", $walletNames); $payLoad = ""; $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $json = $this->executeCall( "$chainUrlPrefix/wallets/hd/$walletList?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall ); return HDWallet::getList($json); }
[ "public", "function", "getMultiple", "(", "$", "walletNames", ",", "$", "params", "=", "array", "(", ")", ",", "$", "apiContext", "=", "null", ",", "$", "restCall", "=", "null", ")", "{", "ArgumentArrayValidator", "::", "validate", "(", "$", "walletNames",...
Obtain multiple HDWallet resources for the given wallet names list. @param string[] $walletNames @param array $params Parameters. Options: txstart, and limit @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls @return HDWallet[]
[ "Obtain", "multiple", "HDWallet", "resources", "for", "the", "given", "wallet", "names", "list", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Client/HDWalletClient.php#L64-L85
train
blockcypher/php-client
lib/BlockCypher/Client/HDWalletClient.php
HDWalletClient.delete
public function delete($walletName, $params = array(), $apiContext = null, $restCall = null) { ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = ""; $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $this->executeCall( "$chainUrlPrefix/wallets/hd/$walletName" . http_build_query($params), "DELETE", $payLoad, null, $apiContext, $restCall ); return true; }
php
public function delete($walletName, $params = array(), $apiContext = null, $restCall = null) { ArgumentGetParamsValidator::validate($params, 'params'); $allowedParams = array(); $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams); $payLoad = ""; $chainUrlPrefix = $this->getChainUrlPrefix($apiContext); $this->executeCall( "$chainUrlPrefix/wallets/hd/$walletName" . http_build_query($params), "DELETE", $payLoad, null, $apiContext, $restCall ); return true; }
[ "public", "function", "delete", "(", "$", "walletName", ",", "$", "params", "=", "array", "(", ")", ",", "$", "apiContext", "=", "null", ",", "$", "restCall", "=", "null", ")", "{", "ArgumentGetParamsValidator", "::", "validate", "(", "$", "params", ",",...
Deletes the HDWallet identified by wallet_id for the application associated with access token. @param string $walletName @param array $params Parameters @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls @return bool
[ "Deletes", "the", "HDWallet", "identified", "by", "wallet_id", "for", "the", "application", "associated", "with", "access", "token", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Client/HDWalletClient.php#L181-L200
train
blockcypher/php-client
lib/BlockCypher/Validation/CoinSymbolValidator.php
CoinSymbolValidator.validate
public static function validate($argument, $argumentName = null) { // DEBUG //echo "Argument: $argument\n"; //echo "Argument name: $argumentName\n"; if ($argument === null) { self::throwException($argument, $argumentName); } if (gettype($argument) != 'string') { self::throwException($argument, $argumentName); } if (gettype($argument) == 'string' && trim($argument) == '') { self::throwException($argument, $argumentName); } if (!in_array($argument, BlockCypherCoinSymbolConstants::COIN_SYMBOL_LIST())) { self::throwException($argument, $argumentName); } return true; }
php
public static function validate($argument, $argumentName = null) { // DEBUG //echo "Argument: $argument\n"; //echo "Argument name: $argumentName\n"; if ($argument === null) { self::throwException($argument, $argumentName); } if (gettype($argument) != 'string') { self::throwException($argument, $argumentName); } if (gettype($argument) == 'string' && trim($argument) == '') { self::throwException($argument, $argumentName); } if (!in_array($argument, BlockCypherCoinSymbolConstants::COIN_SYMBOL_LIST())) { self::throwException($argument, $argumentName); } return true; }
[ "public", "static", "function", "validate", "(", "$", "argument", ",", "$", "argumentName", "=", "null", ")", "{", "// DEBUG", "//echo \"Argument: $argument\\n\";", "//echo \"Argument name: $argumentName\\n\";", "if", "(", "$", "argument", "===", "null", ")", "{", "...
Helper method for validating an argument if it is valid coin symbol @param mixed $argument @param string|null $argumentName @return bool
[ "Helper", "method", "for", "validating", "an", "argument", "if", "it", "is", "valid", "coin", "symbol" ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Validation/CoinSymbolValidator.php#L21-L44
train
blockcypher/php-client
lib/BlockCypher/Client/PaymentForwardClient.php
PaymentForwardClient.createForwardingAddress
public function createForwardingAddress($destination, $options = array(), $apiContext = null, $restCall = null) { ArgumentValidator::validate($destination, 'destination'); ArgumentArrayValidator::validate($options, 'options'); $paymentForward = new PaymentForward(); $paymentForward->setDestination($destination); // All options correspond to a setter foreach ($options as $option => $optionValue) { if (ModelAccessorValidator::validate($paymentForward, $this->convertToCamelCase($option))) { $setter = "set" . $this->convertToCamelCase($option); $paymentForward->$setter($optionValue); } else { throw new \InvalidArgumentException("Invalid option $option"); } } return $this->create($paymentForward, $apiContext, $restCall); }
php
public function createForwardingAddress($destination, $options = array(), $apiContext = null, $restCall = null) { ArgumentValidator::validate($destination, 'destination'); ArgumentArrayValidator::validate($options, 'options'); $paymentForward = new PaymentForward(); $paymentForward->setDestination($destination); // All options correspond to a setter foreach ($options as $option => $optionValue) { if (ModelAccessorValidator::validate($paymentForward, $this->convertToCamelCase($option))) { $setter = "set" . $this->convertToCamelCase($option); $paymentForward->$setter($optionValue); } else { throw new \InvalidArgumentException("Invalid option $option"); } } return $this->create($paymentForward, $apiContext, $restCall); }
[ "public", "function", "createForwardingAddress", "(", "$", "destination", ",", "$", "options", "=", "array", "(", ")", ",", "$", "apiContext", "=", "null", ",", "$", "restCall", "=", "null", ")", "{", "ArgumentValidator", "::", "validate", "(", "$", "desti...
Create a new PaymentForward. OPTIONS: process_fees_address (string): Address to forward processing fees, if specified. Allows you to receive a fee for your own services. process_fees_satoshis (int): Fixed processing fee amount to be sent to the fee address. A fixed satoshi amount or a percentage is required if a process_fees_address has been specified. process_fees_percent (float): Percentage of the transaction to be sent to the fee address. A fixed satoshi amount or a percentage is required if a process_fees_address has been specified. callback_url (url): The URL to call anytime a new payment is forwarded. enable_confirmations (bool): Whether to also call the callback_url with subsequent confirmations of the forwarding transactions. Automatically sets up a WebHook. mining_fees_satoshis (int): Mining fee amount to include in the forwarding transaction, in satoshis. If not set, defaults to 10,000. transactions array[string]: History of forwarding transaction hashes for this payment forwarding request. @param string $destination @param array $options @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls @return PaymentForward
[ "Create", "a", "new", "PaymentForward", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Client/PaymentForwardClient.php#L45-L64
train
blockcypher/php-client
lib/BlockCypher/Client/PaymentForwardClient.php
PaymentForwardClient.getForwardingAddress
public function getForwardingAddress($paymentForwardId, $params = array(), $apiContext = null, $restCall = null) { return $this->get($paymentForwardId, $params, $apiContext, $restCall); }
php
public function getForwardingAddress($paymentForwardId, $params = array(), $apiContext = null, $restCall = null) { return $this->get($paymentForwardId, $params, $apiContext, $restCall); }
[ "public", "function", "getForwardingAddress", "(", "$", "paymentForwardId", ",", "$", "params", "=", "array", "(", ")", ",", "$", "apiContext", "=", "null", ",", "$", "restCall", "=", "null", ")", "{", "return", "$", "this", "->", "get", "(", "$", "pay...
Obtain the PaymentForward resource for the given identifier. @param string $paymentForwardId @param array $params Parameters. @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls @return PaymentForward
[ "Obtain", "the", "PaymentForward", "resource", "for", "the", "given", "identifier", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Client/PaymentForwardClient.php#L112-L115
train
blockcypher/php-client
lib/BlockCypher/Client/PaymentForwardClient.php
PaymentForwardClient.listForwardingAddresses
public function listForwardingAddresses($params = array(), $apiContext = null, $restCall = null) { return $this->getAll($params, $apiContext, $restCall); }
php
public function listForwardingAddresses($params = array(), $apiContext = null, $restCall = null) { return $this->getAll($params, $apiContext, $restCall); }
[ "public", "function", "listForwardingAddresses", "(", "$", "params", "=", "array", "(", ")", ",", "$", "apiContext", "=", "null", ",", "$", "restCall", "=", "null", ")", "{", "return", "$", "this", "->", "getAll", "(", "$", "params", ",", "$", "apiCont...
Obtain all PaymentForward resources for the provided token. @param array $params Parameters. Options: token @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials. @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls @return PaymentForward[]
[ "Obtain", "all", "PaymentForward", "resources", "for", "the", "provided", "token", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Client/PaymentForwardClient.php#L198-L201
train
blockcypher/php-client
lib/BlockCypher/Core/BlockCypherCoinSymbolConstants.php
BlockCypherCoinSymbolConstants.getCoinSymbolFrom
public static function getCoinSymbolFrom($code, $network) { foreach (self::COIN_SYMBOL_MAPPINGS() as $coinSymbol => $coinSymbolMapping) { if ($coinSymbolMapping['blockcypher_code'] == $code && $coinSymbolMapping['blockcypher_network'] == $network ) { // Found return $coinSymbol; } } return null; }
php
public static function getCoinSymbolFrom($code, $network) { foreach (self::COIN_SYMBOL_MAPPINGS() as $coinSymbol => $coinSymbolMapping) { if ($coinSymbolMapping['blockcypher_code'] == $code && $coinSymbolMapping['blockcypher_network'] == $network ) { // Found return $coinSymbol; } } return null; }
[ "public", "static", "function", "getCoinSymbolFrom", "(", "$", "code", ",", "$", "network", ")", "{", "foreach", "(", "self", "::", "COIN_SYMBOL_MAPPINGS", "(", ")", "as", "$", "coinSymbol", "=>", "$", "coinSymbolMapping", ")", "{", "if", "(", "$", "coinSy...
Reverse mapping. @param $code @param $network @return string|null
[ "Reverse", "mapping", "." ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Core/BlockCypherCoinSymbolConstants.php#L345-L356
train
blockcypher/php-client
lib/BlockCypher/Client/BlockCypherClient.php
BlockCypherClient.executeCall
public function executeCall( $url, $method, $payLoad, $headers = array(), $apiContext = null, $restCall = null, $handlers = array('BlockCypher\Handler\TokenRestHandler') ) { if ($apiContext === null) { $apiContext = $this->getApiContext(); } $restCall = $restCall ? $restCall : new BlockCypherRestCall($apiContext); // Make the execution call $json = $restCall->execute($handlers, $url, $method, $payLoad, $headers); return $json; }
php
public function executeCall( $url, $method, $payLoad, $headers = array(), $apiContext = null, $restCall = null, $handlers = array('BlockCypher\Handler\TokenRestHandler') ) { if ($apiContext === null) { $apiContext = $this->getApiContext(); } $restCall = $restCall ? $restCall : new BlockCypherRestCall($apiContext); // Make the execution call $json = $restCall->execute($handlers, $url, $method, $payLoad, $headers); return $json; }
[ "public", "function", "executeCall", "(", "$", "url", ",", "$", "method", ",", "$", "payLoad", ",", "$", "headers", "=", "array", "(", ")", ",", "$", "apiContext", "=", "null", ",", "$", "restCall", "=", "null", ",", "$", "handlers", "=", "array", ...
Execute SDK Call to BlockCypher services @param string $url @param string $method @param string $payLoad @param array $headers @param ApiContext $apiContext @param BlockCypherRestCall $restCall @param array $handlers @return string json response of the object
[ "Execute", "SDK", "Call", "to", "BlockCypher", "services" ]
c1f875cdbad4e0e19fa697749309e5d7c28b7b4a
https://github.com/blockcypher/php-client/blob/c1f875cdbad4e0e19fa697749309e5d7c28b7b4a/lib/BlockCypher/Client/BlockCypherClient.php#L50-L69
train