id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
222,400
codefog/tags-bundle
src/Model/TagModel.php
TagModel.findByCriteria
public static function findByCriteria(array $criteria): ?Model\Collection { try { list($columns, $values, $options) = static::parseCriteria($criteria); } catch (NoTagsException $e) { return null; } if (\count($columns) < 1) { return static::findAll($options); } return static::findBy($columns, $values, $options); }
php
public static function findByCriteria(array $criteria): ?Model\Collection { try { list($columns, $values, $options) = static::parseCriteria($criteria); } catch (NoTagsException $e) { return null; } if (\count($columns) < 1) { return static::findAll($options); } return static::findBy($columns, $values, $options); }
[ "public", "static", "function", "findByCriteria", "(", "array", "$", "criteria", ")", ":", "?", "Model", "\\", "Collection", "{", "try", "{", "list", "(", "$", "columns", ",", "$", "values", ",", "$", "options", ")", "=", "static", "::", "parseCriteria", "(", "$", "criteria", ")", ";", "}", "catch", "(", "NoTagsException", "$", "e", ")", "{", "return", "null", ";", "}", "if", "(", "\\", "count", "(", "$", "columns", ")", "<", "1", ")", "{", "return", "static", "::", "findAll", "(", "$", "options", ")", ";", "}", "return", "static", "::", "findBy", "(", "$", "columns", ",", "$", "values", ",", "$", "options", ")", ";", "}" ]
Find the records by criteria. @param array $criteria @return Model\Collection|null
[ "Find", "the", "records", "by", "criteria", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/Model/TagModel.php#L37-L50
222,401
codefog/tags-bundle
src/Model/TagModel.php
TagModel.findOneByCriteria
public static function findOneByCriteria(array $criteria): ?self { try { list($columns, $values, $options) = static::parseCriteria($criteria); } catch (NoTagsException $e) { return null; } if (\count($columns) < 1) { return null; } return static::findOneBy($columns, $values, $options); }
php
public static function findOneByCriteria(array $criteria): ?self { try { list($columns, $values, $options) = static::parseCriteria($criteria); } catch (NoTagsException $e) { return null; } if (\count($columns) < 1) { return null; } return static::findOneBy($columns, $values, $options); }
[ "public", "static", "function", "findOneByCriteria", "(", "array", "$", "criteria", ")", ":", "?", "self", "{", "try", "{", "list", "(", "$", "columns", ",", "$", "values", ",", "$", "options", ")", "=", "static", "::", "parseCriteria", "(", "$", "criteria", ")", ";", "}", "catch", "(", "NoTagsException", "$", "e", ")", "{", "return", "null", ";", "}", "if", "(", "\\", "count", "(", "$", "columns", ")", "<", "1", ")", "{", "return", "null", ";", "}", "return", "static", "::", "findOneBy", "(", "$", "columns", ",", "$", "values", ",", "$", "options", ")", ";", "}" ]
Find the record by criteria. @param array $criteria @return TagModel|null
[ "Find", "the", "record", "by", "criteria", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/Model/TagModel.php#L59-L72
222,402
codefog/tags-bundle
src/Model/TagModel.php
TagModel.parseCriteria
protected static function parseCriteria(array $criteria): array { $columns = []; $values = []; $options = ['order' => 'name']; // Find by source if ($criteria['source']) { $columns[] = 'source=?'; $values[] = $criteria['source']; } // Find by alias if ($criteria['alias']) { $columns[] = 'alias=?'; $values[] = $criteria['alias']; } // Find only the used tags if ($criteria['usedOnly']) { $ids = \Haste\Model\Model::getRelatedValues($criteria['sourceTable'], $criteria['sourceField']); if (\count($ids) < 1) { throw new NoTagsException(); } $columns[] = 'id IN ('.\implode(',', \array_map('intval', \array_unique($ids))).')'; } // Find the tags by values/IDs if (\is_array($criteria['values'])) { if (\count($criteria['values']) < 1) { throw new NoTagsException(); } $columns[] = 'id IN ('.\implode(',', \array_map('intval', $criteria['values'])).')'; } // Find the tags by aliases if (\is_array($criteria['aliases'])) { if (\count($criteria['aliases']) < 1) { throw new NoTagsException(); } $columns[] = "alias IN ('".\implode("','", $criteria['values'])."')'"; } return [$columns, $values, $options]; }
php
protected static function parseCriteria(array $criteria): array { $columns = []; $values = []; $options = ['order' => 'name']; // Find by source if ($criteria['source']) { $columns[] = 'source=?'; $values[] = $criteria['source']; } // Find by alias if ($criteria['alias']) { $columns[] = 'alias=?'; $values[] = $criteria['alias']; } // Find only the used tags if ($criteria['usedOnly']) { $ids = \Haste\Model\Model::getRelatedValues($criteria['sourceTable'], $criteria['sourceField']); if (\count($ids) < 1) { throw new NoTagsException(); } $columns[] = 'id IN ('.\implode(',', \array_map('intval', \array_unique($ids))).')'; } // Find the tags by values/IDs if (\is_array($criteria['values'])) { if (\count($criteria['values']) < 1) { throw new NoTagsException(); } $columns[] = 'id IN ('.\implode(',', \array_map('intval', $criteria['values'])).')'; } // Find the tags by aliases if (\is_array($criteria['aliases'])) { if (\count($criteria['aliases']) < 1) { throw new NoTagsException(); } $columns[] = "alias IN ('".\implode("','", $criteria['values'])."')'"; } return [$columns, $values, $options]; }
[ "protected", "static", "function", "parseCriteria", "(", "array", "$", "criteria", ")", ":", "array", "{", "$", "columns", "=", "[", "]", ";", "$", "values", "=", "[", "]", ";", "$", "options", "=", "[", "'order'", "=>", "'name'", "]", ";", "// Find by source", "if", "(", "$", "criteria", "[", "'source'", "]", ")", "{", "$", "columns", "[", "]", "=", "'source=?'", ";", "$", "values", "[", "]", "=", "$", "criteria", "[", "'source'", "]", ";", "}", "// Find by alias", "if", "(", "$", "criteria", "[", "'alias'", "]", ")", "{", "$", "columns", "[", "]", "=", "'alias=?'", ";", "$", "values", "[", "]", "=", "$", "criteria", "[", "'alias'", "]", ";", "}", "// Find only the used tags", "if", "(", "$", "criteria", "[", "'usedOnly'", "]", ")", "{", "$", "ids", "=", "\\", "Haste", "\\", "Model", "\\", "Model", "::", "getRelatedValues", "(", "$", "criteria", "[", "'sourceTable'", "]", ",", "$", "criteria", "[", "'sourceField'", "]", ")", ";", "if", "(", "\\", "count", "(", "$", "ids", ")", "<", "1", ")", "{", "throw", "new", "NoTagsException", "(", ")", ";", "}", "$", "columns", "[", "]", "=", "'id IN ('", ".", "\\", "implode", "(", "','", ",", "\\", "array_map", "(", "'intval'", ",", "\\", "array_unique", "(", "$", "ids", ")", ")", ")", ".", "')'", ";", "}", "// Find the tags by values/IDs", "if", "(", "\\", "is_array", "(", "$", "criteria", "[", "'values'", "]", ")", ")", "{", "if", "(", "\\", "count", "(", "$", "criteria", "[", "'values'", "]", ")", "<", "1", ")", "{", "throw", "new", "NoTagsException", "(", ")", ";", "}", "$", "columns", "[", "]", "=", "'id IN ('", ".", "\\", "implode", "(", "','", ",", "\\", "array_map", "(", "'intval'", ",", "$", "criteria", "[", "'values'", "]", ")", ")", ".", "')'", ";", "}", "// Find the tags by aliases", "if", "(", "\\", "is_array", "(", "$", "criteria", "[", "'aliases'", "]", ")", ")", "{", "if", "(", "\\", "count", "(", "$", "criteria", "[", "'aliases'", "]", ")", "<", "1", ")", "{", "throw", "new", "NoTagsException", "(", ")", ";", "}", "$", "columns", "[", "]", "=", "\"alias IN ('\"", ".", "\\", "implode", "(", "\"','\"", ",", "$", "criteria", "[", "'values'", "]", ")", ".", "\"')'\"", ";", "}", "return", "[", "$", "columns", ",", "$", "values", ",", "$", "options", "]", ";", "}" ]
Parse the criteria. @param array $criteria @throws NoTagsException @return array
[ "Parse", "the", "criteria", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/Model/TagModel.php#L83-L131
222,403
php-soft/laravel-users
packages/Users/Middleware/Authenticate.php
Authenticate.respond
protected function respond($event, $error, $status, $payload = []) { $response = $this->events->fire($event, $payload, true); return $response ?: $this->response->json(arrayView('phpsoft.users::errors/authenticate', [ 'error' => $error ]), $status); }
php
protected function respond($event, $error, $status, $payload = []) { $response = $this->events->fire($event, $payload, true); return $response ?: $this->response->json(arrayView('phpsoft.users::errors/authenticate', [ 'error' => $error ]), $status); }
[ "protected", "function", "respond", "(", "$", "event", ",", "$", "error", ",", "$", "status", ",", "$", "payload", "=", "[", "]", ")", "{", "$", "response", "=", "$", "this", "->", "events", "->", "fire", "(", "$", "event", ",", "$", "payload", ",", "true", ")", ";", "return", "$", "response", "?", ":", "$", "this", "->", "response", "->", "json", "(", "arrayView", "(", "'phpsoft.users::errors/authenticate'", ",", "[", "'error'", "=>", "$", "error", "]", ")", ",", "$", "status", ")", ";", "}" ]
Fire event and return the response @param string $event @param string $error @param integer $status @param array $payload @return mixed
[ "Fire", "event", "and", "return", "the", "response" ]
cd8d696dbf7337002188576d8a143cbc19d86b40
https://github.com/php-soft/laravel-users/blob/cd8d696dbf7337002188576d8a143cbc19d86b40/packages/Users/Middleware/Authenticate.php#L84-L91
222,404
justinrainbow/epub
src/ePub/Loader/ZipFileLoader.php
ZipFileLoader.load
public function load($file) { $resource = new ZipFileResource($file); $package = $resource->getXML('META-INF/container.xml'); if (!$opfFile = (string) $package->rootfiles->rootfile['full-path']) { $ns = $package->getNamespaces(); foreach ($ns as $key => $value) { $package->registerXPathNamespace($key, $value); $items = $package->xpath('//'. $key .':rootfile/@full-path'); $opfFile = (string) $items[0]['full-path']; } } $data = $resource->get($opfFile); // all files referenced in the OPF are relative to it's directory if ('.' !== $dir = dirname($opfFile)) { $resource->setDirectory($dir); } $opfResource = new OpfResource($data, $resource); $package = $opfResource->bind(); $package->opfDirectory = dirname($opfFile); if ($package->navigation->src->href) { $ncx = $resource->get($package->navigation->src->href); $ncxResource = new NcxResource($ncx); $package = $ncxResource->bind($package); } return $package; }
php
public function load($file) { $resource = new ZipFileResource($file); $package = $resource->getXML('META-INF/container.xml'); if (!$opfFile = (string) $package->rootfiles->rootfile['full-path']) { $ns = $package->getNamespaces(); foreach ($ns as $key => $value) { $package->registerXPathNamespace($key, $value); $items = $package->xpath('//'. $key .':rootfile/@full-path'); $opfFile = (string) $items[0]['full-path']; } } $data = $resource->get($opfFile); // all files referenced in the OPF are relative to it's directory if ('.' !== $dir = dirname($opfFile)) { $resource->setDirectory($dir); } $opfResource = new OpfResource($data, $resource); $package = $opfResource->bind(); $package->opfDirectory = dirname($opfFile); if ($package->navigation->src->href) { $ncx = $resource->get($package->navigation->src->href); $ncxResource = new NcxResource($ncx); $package = $ncxResource->bind($package); } return $package; }
[ "public", "function", "load", "(", "$", "file", ")", "{", "$", "resource", "=", "new", "ZipFileResource", "(", "$", "file", ")", ";", "$", "package", "=", "$", "resource", "->", "getXML", "(", "'META-INF/container.xml'", ")", ";", "if", "(", "!", "$", "opfFile", "=", "(", "string", ")", "$", "package", "->", "rootfiles", "->", "rootfile", "[", "'full-path'", "]", ")", "{", "$", "ns", "=", "$", "package", "->", "getNamespaces", "(", ")", ";", "foreach", "(", "$", "ns", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "package", "->", "registerXPathNamespace", "(", "$", "key", ",", "$", "value", ")", ";", "$", "items", "=", "$", "package", "->", "xpath", "(", "'//'", ".", "$", "key", ".", "':rootfile/@full-path'", ")", ";", "$", "opfFile", "=", "(", "string", ")", "$", "items", "[", "0", "]", "[", "'full-path'", "]", ";", "}", "}", "$", "data", "=", "$", "resource", "->", "get", "(", "$", "opfFile", ")", ";", "// all files referenced in the OPF are relative to it's directory", "if", "(", "'.'", "!==", "$", "dir", "=", "dirname", "(", "$", "opfFile", ")", ")", "{", "$", "resource", "->", "setDirectory", "(", "$", "dir", ")", ";", "}", "$", "opfResource", "=", "new", "OpfResource", "(", "$", "data", ",", "$", "resource", ")", ";", "$", "package", "=", "$", "opfResource", "->", "bind", "(", ")", ";", "$", "package", "->", "opfDirectory", "=", "dirname", "(", "$", "opfFile", ")", ";", "if", "(", "$", "package", "->", "navigation", "->", "src", "->", "href", ")", "{", "$", "ncx", "=", "$", "resource", "->", "get", "(", "$", "package", "->", "navigation", "->", "src", "->", "href", ")", ";", "$", "ncxResource", "=", "new", "NcxResource", "(", "$", "ncx", ")", ";", "$", "package", "=", "$", "ncxResource", "->", "bind", "(", "$", "package", ")", ";", "}", "return", "$", "package", ";", "}" ]
Reads in a ePub file and builds the Package definition @param string $file @return \ePub\Definition\Package
[ "Reads", "in", "a", "ePub", "file", "and", "builds", "the", "Package", "definition" ]
fbdc795f74907066283418bf1c5022b707a2abe8
https://github.com/justinrainbow/epub/blob/fbdc795f74907066283418bf1c5022b707a2abe8/src/ePub/Loader/ZipFileLoader.php#L30-L64
222,405
codete/FormGeneratorBundle
AdjusterRegistry.php
AdjusterRegistry.addFormConfigurationModifier
public function addFormConfigurationModifier(FormConfigurationModifierInterface $modifier, $priority = 0) { $this->formConfigurationModifiers[$priority][] = $modifier; $this->needsSorting = true; }
php
public function addFormConfigurationModifier(FormConfigurationModifierInterface $modifier, $priority = 0) { $this->formConfigurationModifiers[$priority][] = $modifier; $this->needsSorting = true; }
[ "public", "function", "addFormConfigurationModifier", "(", "FormConfigurationModifierInterface", "$", "modifier", ",", "$", "priority", "=", "0", ")", "{", "$", "this", "->", "formConfigurationModifiers", "[", "$", "priority", "]", "[", "]", "=", "$", "modifier", ";", "$", "this", "->", "needsSorting", "=", "true", ";", "}" ]
Adds modifier for form's configuration @param FormConfigurationModifierInterface $modifier @param int $priority
[ "Adds", "modifier", "for", "form", "s", "configuration" ]
c0bc3704d3f6df505ec232aa32b345159fffd980
https://github.com/codete/FormGeneratorBundle/blob/c0bc3704d3f6df505ec232aa32b345159fffd980/AdjusterRegistry.php#L39-L43
222,406
codete/FormGeneratorBundle
AdjusterRegistry.php
AdjusterRegistry.addFormFieldResolver
public function addFormFieldResolver(FormFieldResolverInterface $resolver, $priority = 0) { $this->formFieldResolvers[$priority][] = $resolver; $this->needsSorting = true; }
php
public function addFormFieldResolver(FormFieldResolverInterface $resolver, $priority = 0) { $this->formFieldResolvers[$priority][] = $resolver; $this->needsSorting = true; }
[ "public", "function", "addFormFieldResolver", "(", "FormFieldResolverInterface", "$", "resolver", ",", "$", "priority", "=", "0", ")", "{", "$", "this", "->", "formFieldResolvers", "[", "$", "priority", "]", "[", "]", "=", "$", "resolver", ";", "$", "this", "->", "needsSorting", "=", "true", ";", "}" ]
Adds resolver for form's fields @param FormFieldResolverInterface $resolver @param int $priority
[ "Adds", "resolver", "for", "form", "s", "fields" ]
c0bc3704d3f6df505ec232aa32b345159fffd980
https://github.com/codete/FormGeneratorBundle/blob/c0bc3704d3f6df505ec232aa32b345159fffd980/AdjusterRegistry.php#L51-L55
222,407
codete/FormGeneratorBundle
AdjusterRegistry.php
AdjusterRegistry.addFormViewProvider
public function addFormViewProvider(FormViewProviderInterface $provider, $priority = 0) { $this->formViewProviders[$priority][] = $provider; $this->needsSorting = true; }
php
public function addFormViewProvider(FormViewProviderInterface $provider, $priority = 0) { $this->formViewProviders[$priority][] = $provider; $this->needsSorting = true; }
[ "public", "function", "addFormViewProvider", "(", "FormViewProviderInterface", "$", "provider", ",", "$", "priority", "=", "0", ")", "{", "$", "this", "->", "formViewProviders", "[", "$", "priority", "]", "[", "]", "=", "$", "provider", ";", "$", "this", "->", "needsSorting", "=", "true", ";", "}" ]
Adds provider for defining default fields for form @param FormViewProviderInterface $provider @param int $priority
[ "Adds", "provider", "for", "defining", "default", "fields", "for", "form" ]
c0bc3704d3f6df505ec232aa32b345159fffd980
https://github.com/codete/FormGeneratorBundle/blob/c0bc3704d3f6df505ec232aa32b345159fffd980/AdjusterRegistry.php#L63-L67
222,408
codete/FormGeneratorBundle
AdjusterRegistry.php
AdjusterRegistry.sortRegisteredServices
private function sortRegisteredServices() { krsort($this->formConfigurationModifiers); if ( ! empty($this->formConfigurationModifiers)) { $this->sortedFormConfigurationModifiers = call_user_func_array('array_merge', $this->formConfigurationModifiers); } krsort($this->formFieldResolvers); if ( ! empty($this->formFieldResolvers)) { $this->sortedFormFieldResolvers = call_user_func_array('array_merge', $this->formFieldResolvers); } krsort($this->formViewProviders); if ( ! empty($this->formViewProviders)) { $this->sortedFormViewProviders = call_user_func_array('array_merge', $this->formViewProviders); } }
php
private function sortRegisteredServices() { krsort($this->formConfigurationModifiers); if ( ! empty($this->formConfigurationModifiers)) { $this->sortedFormConfigurationModifiers = call_user_func_array('array_merge', $this->formConfigurationModifiers); } krsort($this->formFieldResolvers); if ( ! empty($this->formFieldResolvers)) { $this->sortedFormFieldResolvers = call_user_func_array('array_merge', $this->formFieldResolvers); } krsort($this->formViewProviders); if ( ! empty($this->formViewProviders)) { $this->sortedFormViewProviders = call_user_func_array('array_merge', $this->formViewProviders); } }
[ "private", "function", "sortRegisteredServices", "(", ")", "{", "krsort", "(", "$", "this", "->", "formConfigurationModifiers", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "formConfigurationModifiers", ")", ")", "{", "$", "this", "->", "sortedFormConfigurationModifiers", "=", "call_user_func_array", "(", "'array_merge'", ",", "$", "this", "->", "formConfigurationModifiers", ")", ";", "}", "krsort", "(", "$", "this", "->", "formFieldResolvers", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "formFieldResolvers", ")", ")", "{", "$", "this", "->", "sortedFormFieldResolvers", "=", "call_user_func_array", "(", "'array_merge'", ",", "$", "this", "->", "formFieldResolvers", ")", ";", "}", "krsort", "(", "$", "this", "->", "formViewProviders", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "formViewProviders", ")", ")", "{", "$", "this", "->", "sortedFormViewProviders", "=", "call_user_func_array", "(", "'array_merge'", ",", "$", "this", "->", "formViewProviders", ")", ";", "}", "}" ]
Sorts all registered adjusters by priority.
[ "Sorts", "all", "registered", "adjusters", "by", "priority", "." ]
c0bc3704d3f6df505ec232aa32b345159fffd980
https://github.com/codete/FormGeneratorBundle/blob/c0bc3704d3f6df505ec232aa32b345159fffd980/AdjusterRegistry.php#L111-L125
222,409
ramsey/twig-codeblock
src/Node/CodeBlockNode.php
CodeBlockNode.compile
public function compile(\Twig_Compiler $compiler) { $compiler->addDebugInfo($this); $compiler ->write('$highlighter = \Ramsey\Twig\CodeBlock\Highlighter\HighlighterFactory::getHighlighter(') ->string($this->getHighlighterName()) ->raw(', ') ->repr($this->getHighlighterArgs()) ->raw(");\n"); $compiler ->write('$highlightedCode = $highlighter->highlight(') ->string($this->getNode('body')->getAttribute('data')) ->raw(', ') ->repr($this->attributes) ->raw(");\n"); if ($this->hasAttribute('format') && strtolower($this->getAttribute('format')) === 'html') { $classnames = 'code-highlight-figure'; if ($this->hasAttribute('class')) { $classnames .= ' ' . $this->getAttribute('class'); } $compiler ->write('$figcaption = ') ->string($this->getFigcaption()) ->raw(";\n") ->write('echo sprintf(') ->raw('"<figure class=\"' . $classnames . '\">%s%s</figure>\n",') ->raw(' $figcaption, $highlightedCode') ->raw(");\n"); } else { $compiler->write('echo $highlightedCode;' . "\n"); } }
php
public function compile(\Twig_Compiler $compiler) { $compiler->addDebugInfo($this); $compiler ->write('$highlighter = \Ramsey\Twig\CodeBlock\Highlighter\HighlighterFactory::getHighlighter(') ->string($this->getHighlighterName()) ->raw(', ') ->repr($this->getHighlighterArgs()) ->raw(");\n"); $compiler ->write('$highlightedCode = $highlighter->highlight(') ->string($this->getNode('body')->getAttribute('data')) ->raw(', ') ->repr($this->attributes) ->raw(");\n"); if ($this->hasAttribute('format') && strtolower($this->getAttribute('format')) === 'html') { $classnames = 'code-highlight-figure'; if ($this->hasAttribute('class')) { $classnames .= ' ' . $this->getAttribute('class'); } $compiler ->write('$figcaption = ') ->string($this->getFigcaption()) ->raw(";\n") ->write('echo sprintf(') ->raw('"<figure class=\"' . $classnames . '\">%s%s</figure>\n",') ->raw(' $figcaption, $highlightedCode') ->raw(");\n"); } else { $compiler->write('echo $highlightedCode;' . "\n"); } }
[ "public", "function", "compile", "(", "\\", "Twig_Compiler", "$", "compiler", ")", "{", "$", "compiler", "->", "addDebugInfo", "(", "$", "this", ")", ";", "$", "compiler", "->", "write", "(", "'$highlighter = \\Ramsey\\Twig\\CodeBlock\\Highlighter\\HighlighterFactory::getHighlighter('", ")", "->", "string", "(", "$", "this", "->", "getHighlighterName", "(", ")", ")", "->", "raw", "(", "', '", ")", "->", "repr", "(", "$", "this", "->", "getHighlighterArgs", "(", ")", ")", "->", "raw", "(", "\");\\n\"", ")", ";", "$", "compiler", "->", "write", "(", "'$highlightedCode = $highlighter->highlight('", ")", "->", "string", "(", "$", "this", "->", "getNode", "(", "'body'", ")", "->", "getAttribute", "(", "'data'", ")", ")", "->", "raw", "(", "', '", ")", "->", "repr", "(", "$", "this", "->", "attributes", ")", "->", "raw", "(", "\");\\n\"", ")", ";", "if", "(", "$", "this", "->", "hasAttribute", "(", "'format'", ")", "&&", "strtolower", "(", "$", "this", "->", "getAttribute", "(", "'format'", ")", ")", "===", "'html'", ")", "{", "$", "classnames", "=", "'code-highlight-figure'", ";", "if", "(", "$", "this", "->", "hasAttribute", "(", "'class'", ")", ")", "{", "$", "classnames", ".=", "' '", ".", "$", "this", "->", "getAttribute", "(", "'class'", ")", ";", "}", "$", "compiler", "->", "write", "(", "'$figcaption = '", ")", "->", "string", "(", "$", "this", "->", "getFigcaption", "(", ")", ")", "->", "raw", "(", "\";\\n\"", ")", "->", "write", "(", "'echo sprintf('", ")", "->", "raw", "(", "'\"<figure class=\\\"'", ".", "$", "classnames", ".", "'\\\">%s%s</figure>\\n\",'", ")", "->", "raw", "(", "' $figcaption, $highlightedCode'", ")", "->", "raw", "(", "\");\\n\"", ")", ";", "}", "else", "{", "$", "compiler", "->", "write", "(", "'echo $highlightedCode;'", ".", "\"\\n\"", ")", ";", "}", "}" ]
Compiles the node into PHP code for execution by Twig @param \Twig_Compiler $compiler The compiler to which we add the node's PHP code
[ "Compiles", "the", "node", "into", "PHP", "code", "for", "execution", "by", "Twig" ]
bf3a940af4c5d5a66b1e66e9464fccc29579b23f
https://github.com/ramsey/twig-codeblock/blob/bf3a940af4c5d5a66b1e66e9464fccc29579b23f/src/Node/CodeBlockNode.php#L64-L99
222,410
ramsey/twig-codeblock
src/Node/CodeBlockNode.php
CodeBlockNode.getFigcaption
protected function getFigcaption() { $figcaption = ''; if ($this->hasAttribute('title')) { $figcaption = '<figcaption class="code-highlight-caption">'; $figcaption .= '<span class="code-highlight-caption-title">'; $figcaption .= $this->getAttribute('title'); $figcaption .= '</span>'; $figcaption .= $this->getFigcaptionLink(); $figcaption .= '</figcaption>'; } return $figcaption; }
php
protected function getFigcaption() { $figcaption = ''; if ($this->hasAttribute('title')) { $figcaption = '<figcaption class="code-highlight-caption">'; $figcaption .= '<span class="code-highlight-caption-title">'; $figcaption .= $this->getAttribute('title'); $figcaption .= '</span>'; $figcaption .= $this->getFigcaptionLink(); $figcaption .= '</figcaption>'; } return $figcaption; }
[ "protected", "function", "getFigcaption", "(", ")", "{", "$", "figcaption", "=", "''", ";", "if", "(", "$", "this", "->", "hasAttribute", "(", "'title'", ")", ")", "{", "$", "figcaption", "=", "'<figcaption class=\"code-highlight-caption\">'", ";", "$", "figcaption", ".=", "'<span class=\"code-highlight-caption-title\">'", ";", "$", "figcaption", ".=", "$", "this", "->", "getAttribute", "(", "'title'", ")", ";", "$", "figcaption", ".=", "'</span>'", ";", "$", "figcaption", ".=", "$", "this", "->", "getFigcaptionLink", "(", ")", ";", "$", "figcaption", ".=", "'</figcaption>'", ";", "}", "return", "$", "figcaption", ";", "}" ]
Returns the figcaption HTML element for the codeblock @return string
[ "Returns", "the", "figcaption", "HTML", "element", "for", "the", "codeblock" ]
bf3a940af4c5d5a66b1e66e9464fccc29579b23f
https://github.com/ramsey/twig-codeblock/blob/bf3a940af4c5d5a66b1e66e9464fccc29579b23f/src/Node/CodeBlockNode.php#L126-L140
222,411
ramsey/twig-codeblock
src/Node/CodeBlockNode.php
CodeBlockNode.getFigcaptionLink
protected function getFigcaptionLink() { $link = ''; if ($this->hasAttribute('linkUrl')) { $link = '<a class="code-highlight-caption-link" href="' . $this->getAttribute('linkUrl') . '">'; $link .= $this->getFigcaptionLinkText(); $link .= '</a>'; } return $link; }
php
protected function getFigcaptionLink() { $link = ''; if ($this->hasAttribute('linkUrl')) { $link = '<a class="code-highlight-caption-link" href="' . $this->getAttribute('linkUrl') . '">'; $link .= $this->getFigcaptionLinkText(); $link .= '</a>'; } return $link; }
[ "protected", "function", "getFigcaptionLink", "(", ")", "{", "$", "link", "=", "''", ";", "if", "(", "$", "this", "->", "hasAttribute", "(", "'linkUrl'", ")", ")", "{", "$", "link", "=", "'<a class=\"code-highlight-caption-link\" href=\"'", ".", "$", "this", "->", "getAttribute", "(", "'linkUrl'", ")", ".", "'\">'", ";", "$", "link", ".=", "$", "this", "->", "getFigcaptionLinkText", "(", ")", ";", "$", "link", ".=", "'</a>'", ";", "}", "return", "$", "link", ";", "}" ]
Returns the link for the figcaption, if applicable @return string
[ "Returns", "the", "link", "for", "the", "figcaption", "if", "applicable" ]
bf3a940af4c5d5a66b1e66e9464fccc29579b23f
https://github.com/ramsey/twig-codeblock/blob/bf3a940af4c5d5a66b1e66e9464fccc29579b23f/src/Node/CodeBlockNode.php#L147-L160
222,412
codefog/tags-bundle
src/Widget/TagsWidget.php
TagsWidget.generateConfig
protected function generateConfig(): array { $config = [ 'addLabel' => $GLOBALS['TL_LANG']['MSC']['cfg_tags.add'], 'allowCreate' => isset($this->tagsCreate) ? (bool) $this->tagsCreate : true, ]; // Maximum number of items if (isset($this->maxItems)) { $config['maxItems'] = (int) $this->maxItems; } return $config; }
php
protected function generateConfig(): array { $config = [ 'addLabel' => $GLOBALS['TL_LANG']['MSC']['cfg_tags.add'], 'allowCreate' => isset($this->tagsCreate) ? (bool) $this->tagsCreate : true, ]; // Maximum number of items if (isset($this->maxItems)) { $config['maxItems'] = (int) $this->maxItems; } return $config; }
[ "protected", "function", "generateConfig", "(", ")", ":", "array", "{", "$", "config", "=", "[", "'addLabel'", "=>", "$", "GLOBALS", "[", "'TL_LANG'", "]", "[", "'MSC'", "]", "[", "'cfg_tags.add'", "]", ",", "'allowCreate'", "=>", "isset", "(", "$", "this", "->", "tagsCreate", ")", "?", "(", "bool", ")", "$", "this", "->", "tagsCreate", ":", "true", ",", "]", ";", "// Maximum number of items", "if", "(", "isset", "(", "$", "this", "->", "maxItems", ")", ")", "{", "$", "config", "[", "'maxItems'", "]", "=", "(", "int", ")", "$", "this", "->", "maxItems", ";", "}", "return", "$", "config", ";", "}" ]
Generate the widget configuration. @return array
[ "Generate", "the", "widget", "configuration", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/Widget/TagsWidget.php#L122-L135
222,413
codefog/tags-bundle
src/Widget/TagsWidget.php
TagsWidget.getValueTags
protected function getValueTags(): CollectionInterface { return $this->tagsManager->findMultiple(['values' => \is_array($this->varValue) ? $this->varValue : []]); }
php
protected function getValueTags(): CollectionInterface { return $this->tagsManager->findMultiple(['values' => \is_array($this->varValue) ? $this->varValue : []]); }
[ "protected", "function", "getValueTags", "(", ")", ":", "CollectionInterface", "{", "return", "$", "this", "->", "tagsManager", "->", "findMultiple", "(", "[", "'values'", "=>", "\\", "is_array", "(", "$", "this", "->", "varValue", ")", "?", "$", "this", "->", "varValue", ":", "[", "]", "]", ")", ";", "}" ]
Get the value tags. @return CollectionInterface
[ "Get", "the", "value", "tags", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/Widget/TagsWidget.php#L142-L145
222,414
codefog/tags-bundle
src/Widget/TagsWidget.php
TagsWidget.generateAllTags
private function generateAllTags(CollectionInterface $tags): array { $return = []; /** @var Tag $tag */ foreach ($tags as $tag) { $return[] = ['value' => $tag->getValue(), 'text' => StringUtil::decodeEntities($tag->getName())]; } return $return; }
php
private function generateAllTags(CollectionInterface $tags): array { $return = []; /** @var Tag $tag */ foreach ($tags as $tag) { $return[] = ['value' => $tag->getValue(), 'text' => StringUtil::decodeEntities($tag->getName())]; } return $return; }
[ "private", "function", "generateAllTags", "(", "CollectionInterface", "$", "tags", ")", ":", "array", "{", "$", "return", "=", "[", "]", ";", "/** @var Tag $tag */", "foreach", "(", "$", "tags", "as", "$", "tag", ")", "{", "$", "return", "[", "]", "=", "[", "'value'", "=>", "$", "tag", "->", "getValue", "(", ")", ",", "'text'", "=>", "StringUtil", "::", "decodeEntities", "(", "$", "tag", "->", "getName", "(", ")", ")", "]", ";", "}", "return", "$", "return", ";", "}" ]
Generate all tags. @param CollectionInterface $tags @return array
[ "Generate", "all", "tags", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/Widget/TagsWidget.php#L183-L193
222,415
php-soft/laravel-users
packages/Users/Controllers/RoutePermissionController.php
RoutePermissionController.store
public function store(Request $request) { // validate $this->registerValidators(); $validator = Validator::make($request->all(), [ 'route' => 'required|max:255|string|unique:route_permission,route', 'permissions' => 'required|max:255|array|rolePermission', 'roles' => 'required|max:255|array|rolePermission' ]); if ($validator->fails()) { return response()->json(arrayView('phpsoft.users::errors/validation', [ 'errors' => $validator->errors() ]), 400); } // check current user is admin if (!(Auth::user() && Auth::user()->hasRole('admin'))) { return response()->json(null, 403); } // add permissions and roles for the route $routePermission = RoutePermission::setRoutePermissionsRoles( $request['route'], $request['permissions'], $request['roles'] ); return response()->json(arrayView('phpsoft.users::routePermission/read', [ 'routePermission' => $routePermission ]), 201); }
php
public function store(Request $request) { // validate $this->registerValidators(); $validator = Validator::make($request->all(), [ 'route' => 'required|max:255|string|unique:route_permission,route', 'permissions' => 'required|max:255|array|rolePermission', 'roles' => 'required|max:255|array|rolePermission' ]); if ($validator->fails()) { return response()->json(arrayView('phpsoft.users::errors/validation', [ 'errors' => $validator->errors() ]), 400); } // check current user is admin if (!(Auth::user() && Auth::user()->hasRole('admin'))) { return response()->json(null, 403); } // add permissions and roles for the route $routePermission = RoutePermission::setRoutePermissionsRoles( $request['route'], $request['permissions'], $request['roles'] ); return response()->json(arrayView('phpsoft.users::routePermission/read', [ 'routePermission' => $routePermission ]), 201); }
[ "public", "function", "store", "(", "Request", "$", "request", ")", "{", "// validate", "$", "this", "->", "registerValidators", "(", ")", ";", "$", "validator", "=", "Validator", "::", "make", "(", "$", "request", "->", "all", "(", ")", ",", "[", "'route'", "=>", "'required|max:255|string|unique:route_permission,route'", ",", "'permissions'", "=>", "'required|max:255|array|rolePermission'", ",", "'roles'", "=>", "'required|max:255|array|rolePermission'", "]", ")", ";", "if", "(", "$", "validator", "->", "fails", "(", ")", ")", "{", "return", "response", "(", ")", "->", "json", "(", "arrayView", "(", "'phpsoft.users::errors/validation'", ",", "[", "'errors'", "=>", "$", "validator", "->", "errors", "(", ")", "]", ")", ",", "400", ")", ";", "}", "// check current user is admin", "if", "(", "!", "(", "Auth", "::", "user", "(", ")", "&&", "Auth", "::", "user", "(", ")", "->", "hasRole", "(", "'admin'", ")", ")", ")", "{", "return", "response", "(", ")", "->", "json", "(", "null", ",", "403", ")", ";", "}", "// add permissions and roles for the route", "$", "routePermission", "=", "RoutePermission", "::", "setRoutePermissionsRoles", "(", "$", "request", "[", "'route'", "]", ",", "$", "request", "[", "'permissions'", "]", ",", "$", "request", "[", "'roles'", "]", ")", ";", "return", "response", "(", ")", "->", "json", "(", "arrayView", "(", "'phpsoft.users::routePermission/read'", ",", "[", "'routePermission'", "=>", "$", "routePermission", "]", ")", ",", "201", ")", ";", "}" ]
Create route permission action @param Request $request @return Response
[ "Create", "route", "permission", "action" ]
cd8d696dbf7337002188576d8a143cbc19d86b40
https://github.com/php-soft/laravel-users/blob/cd8d696dbf7337002188576d8a143cbc19d86b40/packages/Users/Controllers/RoutePermissionController.php#L52-L84
222,416
php-soft/laravel-users
packages/Users/Controllers/RoutePermissionController.php
RoutePermissionController.update
public function update($id, Request $request) { $routePermission = RoutePermission::find($id); if ($routePermission == null) { return response()->json(null, 404); } // validate $this->registerValidators(); $validator = Validator::make($request->all(), [ 'route' => 'sometimes|required|string|max:255|unique:route_permission,route,'.$id, 'permissions' => 'sometimes|required|array|max:255|rolePermission', 'roles' => 'sometimes|required|array|max:255|rolePermission' ]); if ($validator->fails()) { return response()->json(arrayView('phpsoft.users::errors/validation', [ 'errors' => $validator->errors() ]), 400); } $request['permissions'] = isset($request['permissions']) ? json_encode($request['permissions']) : $routePermission->permissions; $request['roles'] = isset($request['roles']) ? json_encode($request['roles']) : $routePermission->roles; // check current user is admin if (!(Auth::user() && Auth::user()->hasRole('admin'))) { return response()->json(null, 403); } // update permissions and roles for the route $routePermission = $routePermission->update($request->all()); return response()->json(arrayView('phpsoft.users::routePermission/read', [ 'routePermission' => $routePermission ]), 200); }
php
public function update($id, Request $request) { $routePermission = RoutePermission::find($id); if ($routePermission == null) { return response()->json(null, 404); } // validate $this->registerValidators(); $validator = Validator::make($request->all(), [ 'route' => 'sometimes|required|string|max:255|unique:route_permission,route,'.$id, 'permissions' => 'sometimes|required|array|max:255|rolePermission', 'roles' => 'sometimes|required|array|max:255|rolePermission' ]); if ($validator->fails()) { return response()->json(arrayView('phpsoft.users::errors/validation', [ 'errors' => $validator->errors() ]), 400); } $request['permissions'] = isset($request['permissions']) ? json_encode($request['permissions']) : $routePermission->permissions; $request['roles'] = isset($request['roles']) ? json_encode($request['roles']) : $routePermission->roles; // check current user is admin if (!(Auth::user() && Auth::user()->hasRole('admin'))) { return response()->json(null, 403); } // update permissions and roles for the route $routePermission = $routePermission->update($request->all()); return response()->json(arrayView('phpsoft.users::routePermission/read', [ 'routePermission' => $routePermission ]), 200); }
[ "public", "function", "update", "(", "$", "id", ",", "Request", "$", "request", ")", "{", "$", "routePermission", "=", "RoutePermission", "::", "find", "(", "$", "id", ")", ";", "if", "(", "$", "routePermission", "==", "null", ")", "{", "return", "response", "(", ")", "->", "json", "(", "null", ",", "404", ")", ";", "}", "// validate", "$", "this", "->", "registerValidators", "(", ")", ";", "$", "validator", "=", "Validator", "::", "make", "(", "$", "request", "->", "all", "(", ")", ",", "[", "'route'", "=>", "'sometimes|required|string|max:255|unique:route_permission,route,'", ".", "$", "id", ",", "'permissions'", "=>", "'sometimes|required|array|max:255|rolePermission'", ",", "'roles'", "=>", "'sometimes|required|array|max:255|rolePermission'", "]", ")", ";", "if", "(", "$", "validator", "->", "fails", "(", ")", ")", "{", "return", "response", "(", ")", "->", "json", "(", "arrayView", "(", "'phpsoft.users::errors/validation'", ",", "[", "'errors'", "=>", "$", "validator", "->", "errors", "(", ")", "]", ")", ",", "400", ")", ";", "}", "$", "request", "[", "'permissions'", "]", "=", "isset", "(", "$", "request", "[", "'permissions'", "]", ")", "?", "json_encode", "(", "$", "request", "[", "'permissions'", "]", ")", ":", "$", "routePermission", "->", "permissions", ";", "$", "request", "[", "'roles'", "]", "=", "isset", "(", "$", "request", "[", "'roles'", "]", ")", "?", "json_encode", "(", "$", "request", "[", "'roles'", "]", ")", ":", "$", "routePermission", "->", "roles", ";", "// check current user is admin", "if", "(", "!", "(", "Auth", "::", "user", "(", ")", "&&", "Auth", "::", "user", "(", ")", "->", "hasRole", "(", "'admin'", ")", ")", ")", "{", "return", "response", "(", ")", "->", "json", "(", "null", ",", "403", ")", ";", "}", "// update permissions and roles for the route", "$", "routePermission", "=", "$", "routePermission", "->", "update", "(", "$", "request", "->", "all", "(", ")", ")", ";", "return", "response", "(", ")", "->", "json", "(", "arrayView", "(", "'phpsoft.users::routePermission/read'", ",", "[", "'routePermission'", "=>", "$", "routePermission", "]", ")", ",", "200", ")", ";", "}" ]
Update permissions and roles for a route @param Request $request @return Response
[ "Update", "permissions", "and", "roles", "for", "a", "route" ]
cd8d696dbf7337002188576d8a143cbc19d86b40
https://github.com/php-soft/laravel-users/blob/cd8d696dbf7337002188576d8a143cbc19d86b40/packages/Users/Controllers/RoutePermissionController.php#L92-L131
222,417
php-soft/laravel-users
packages/Users/Controllers/RoutePermissionController.php
RoutePermissionController.destroy
public function destroy($id) { // get route permission by id $routePermission = RoutePermission::find($id); if (!$routePermission) { return response()->json(null, 404); } // check current user is admin if (!(Auth::user() && Auth::user()->hasRole('admin'))) { return response()->json(null, 403); } // delete route permission $deleteRoutePermission = $routePermission->delete(); if (!$deleteRoutePermission) { return response()->json(null, 500); // @codeCoverageIgnore } return response()->json(null, 204); }
php
public function destroy($id) { // get route permission by id $routePermission = RoutePermission::find($id); if (!$routePermission) { return response()->json(null, 404); } // check current user is admin if (!(Auth::user() && Auth::user()->hasRole('admin'))) { return response()->json(null, 403); } // delete route permission $deleteRoutePermission = $routePermission->delete(); if (!$deleteRoutePermission) { return response()->json(null, 500); // @codeCoverageIgnore } return response()->json(null, 204); }
[ "public", "function", "destroy", "(", "$", "id", ")", "{", "// get route permission by id", "$", "routePermission", "=", "RoutePermission", "::", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "routePermission", ")", "{", "return", "response", "(", ")", "->", "json", "(", "null", ",", "404", ")", ";", "}", "// check current user is admin", "if", "(", "!", "(", "Auth", "::", "user", "(", ")", "&&", "Auth", "::", "user", "(", ")", "->", "hasRole", "(", "'admin'", ")", ")", ")", "{", "return", "response", "(", ")", "->", "json", "(", "null", ",", "403", ")", ";", "}", "// delete route permission", "$", "deleteRoutePermission", "=", "$", "routePermission", "->", "delete", "(", ")", ";", "if", "(", "!", "$", "deleteRoutePermission", ")", "{", "return", "response", "(", ")", "->", "json", "(", "null", ",", "500", ")", ";", "// @codeCoverageIgnore", "}", "return", "response", "(", ")", "->", "json", "(", "null", ",", "204", ")", ";", "}" ]
Delete route permission @param int $id @return Response
[ "Delete", "route", "permission" ]
cd8d696dbf7337002188576d8a143cbc19d86b40
https://github.com/php-soft/laravel-users/blob/cd8d696dbf7337002188576d8a143cbc19d86b40/packages/Users/Controllers/RoutePermissionController.php#L138-L160
222,418
php-soft/laravel-users
packages/Users/Controllers/RoutePermissionController.php
RoutePermissionController.show
public function show($id) { // get permissions and roles of a route by id $routePermission = RoutePermission::find($id); if (!$routePermission) { return response()->json(null, 404); } return response()->json(arrayView('phpsoft.users::routePermission/read', [ 'routePermission' => $routePermission ]), 200); }
php
public function show($id) { // get permissions and roles of a route by id $routePermission = RoutePermission::find($id); if (!$routePermission) { return response()->json(null, 404); } return response()->json(arrayView('phpsoft.users::routePermission/read', [ 'routePermission' => $routePermission ]), 200); }
[ "public", "function", "show", "(", "$", "id", ")", "{", "// get permissions and roles of a route by id", "$", "routePermission", "=", "RoutePermission", "::", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "routePermission", ")", "{", "return", "response", "(", ")", "->", "json", "(", "null", ",", "404", ")", ";", "}", "return", "response", "(", ")", "->", "json", "(", "arrayView", "(", "'phpsoft.users::routePermission/read'", ",", "[", "'routePermission'", "=>", "$", "routePermission", "]", ")", ",", "200", ")", ";", "}" ]
View route permission @param int $id @return Response
[ "View", "route", "permission" ]
cd8d696dbf7337002188576d8a143cbc19d86b40
https://github.com/php-soft/laravel-users/blob/cd8d696dbf7337002188576d8a143cbc19d86b40/packages/Users/Controllers/RoutePermissionController.php#L167-L179
222,419
php-soft/laravel-users
packages/Users/Controllers/RoutePermissionController.php
RoutePermissionController.getAllRoutes
public function getAllRoutes() { $routes = Route::getRoutes(); $results = []; if ($routes != null) { foreach ($routes as $route) { $route = array( 'method' => $route->getMethods(), 'uri' => $route->getPath() ); $results[] = (object)$route; } } return response()->json(arrayView('phpsoft.users::route/browse', [ 'routes' => $results, ]), 200); }
php
public function getAllRoutes() { $routes = Route::getRoutes(); $results = []; if ($routes != null) { foreach ($routes as $route) { $route = array( 'method' => $route->getMethods(), 'uri' => $route->getPath() ); $results[] = (object)$route; } } return response()->json(arrayView('phpsoft.users::route/browse', [ 'routes' => $results, ]), 200); }
[ "public", "function", "getAllRoutes", "(", ")", "{", "$", "routes", "=", "Route", "::", "getRoutes", "(", ")", ";", "$", "results", "=", "[", "]", ";", "if", "(", "$", "routes", "!=", "null", ")", "{", "foreach", "(", "$", "routes", "as", "$", "route", ")", "{", "$", "route", "=", "array", "(", "'method'", "=>", "$", "route", "->", "getMethods", "(", ")", ",", "'uri'", "=>", "$", "route", "->", "getPath", "(", ")", ")", ";", "$", "results", "[", "]", "=", "(", "object", ")", "$", "route", ";", "}", "}", "return", "response", "(", ")", "->", "json", "(", "arrayView", "(", "'phpsoft.users::route/browse'", ",", "[", "'routes'", "=>", "$", "results", ",", "]", ")", ",", "200", ")", ";", "}" ]
List all routes in app @param @return Response
[ "List", "all", "routes", "in", "app" ]
cd8d696dbf7337002188576d8a143cbc19d86b40
https://github.com/php-soft/laravel-users/blob/cd8d696dbf7337002188576d8a143cbc19d86b40/packages/Users/Controllers/RoutePermissionController.php#L205-L223
222,420
ramsey/twig-codeblock
src/TokenParser/CodeBlockParser.php
CodeBlockParser.parse
public function parse(\Twig_Token $token) { $this->parseCodeBlock(); return new CodeBlockNode( $this->highlighterName, $this->highlighterArgs, $this->getAttributes(), $this->getBody(), $token->getLine(), $this->getTag() ); }
php
public function parse(\Twig_Token $token) { $this->parseCodeBlock(); return new CodeBlockNode( $this->highlighterName, $this->highlighterArgs, $this->getAttributes(), $this->getBody(), $token->getLine(), $this->getTag() ); }
[ "public", "function", "parse", "(", "\\", "Twig_Token", "$", "token", ")", "{", "$", "this", "->", "parseCodeBlock", "(", ")", ";", "return", "new", "CodeBlockNode", "(", "$", "this", "->", "highlighterName", ",", "$", "this", "->", "highlighterArgs", ",", "$", "this", "->", "getAttributes", "(", ")", ",", "$", "this", "->", "getBody", "(", ")", ",", "$", "token", "->", "getLine", "(", ")", ",", "$", "this", "->", "getTag", "(", ")", ")", ";", "}" ]
Parses the codeblock tag and returns a node for Twig to use @param \Twig_Token $token The codeblock tag to parse @return CodeBlockNode
[ "Parses", "the", "codeblock", "tag", "and", "returns", "a", "node", "for", "Twig", "to", "use" ]
bf3a940af4c5d5a66b1e66e9464fccc29579b23f
https://github.com/ramsey/twig-codeblock/blob/bf3a940af4c5d5a66b1e66e9464fccc29579b23f/src/TokenParser/CodeBlockParser.php#L75-L87
222,421
ramsey/twig-codeblock
src/TokenParser/CodeBlockParser.php
CodeBlockParser.parseCodeBlock
protected function parseCodeBlock() { $stream = $this->parser->getStream(); while (!$stream->getCurrent()->test(\Twig_Token::BLOCK_END_TYPE)) { $this->parseEncounteredToken($stream->getCurrent(), $stream); } $stream->expect(\Twig_Token::BLOCK_END_TYPE); $this->body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); $stream->expect(\Twig_Token::BLOCK_END_TYPE); }
php
protected function parseCodeBlock() { $stream = $this->parser->getStream(); while (!$stream->getCurrent()->test(\Twig_Token::BLOCK_END_TYPE)) { $this->parseEncounteredToken($stream->getCurrent(), $stream); } $stream->expect(\Twig_Token::BLOCK_END_TYPE); $this->body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); $stream->expect(\Twig_Token::BLOCK_END_TYPE); }
[ "protected", "function", "parseCodeBlock", "(", ")", "{", "$", "stream", "=", "$", "this", "->", "parser", "->", "getStream", "(", ")", ";", "while", "(", "!", "$", "stream", "->", "getCurrent", "(", ")", "->", "test", "(", "\\", "Twig_Token", "::", "BLOCK_END_TYPE", ")", ")", "{", "$", "this", "->", "parseEncounteredToken", "(", "$", "stream", "->", "getCurrent", "(", ")", ",", "$", "stream", ")", ";", "}", "$", "stream", "->", "expect", "(", "\\", "Twig_Token", "::", "BLOCK_END_TYPE", ")", ";", "$", "this", "->", "body", "=", "$", "this", "->", "parser", "->", "subparse", "(", "array", "(", "$", "this", ",", "'decideBlockEnd'", ")", ",", "true", ")", ";", "$", "stream", "->", "expect", "(", "\\", "Twig_Token", "::", "BLOCK_END_TYPE", ")", ";", "}" ]
Parses the options found on the codeblock tag for use by the node
[ "Parses", "the", "options", "found", "on", "the", "codeblock", "tag", "for", "use", "by", "the", "node" ]
bf3a940af4c5d5a66b1e66e9464fccc29579b23f
https://github.com/ramsey/twig-codeblock/blob/bf3a940af4c5d5a66b1e66e9464fccc29579b23f/src/TokenParser/CodeBlockParser.php#L134-L145
222,422
ramsey/twig-codeblock
src/TokenParser/CodeBlockParser.php
CodeBlockParser.parseEncounteredToken
protected function parseEncounteredToken(\Twig_Token $token, \Twig_TokenStream $stream) { switch ($token->getValue()) { case 'lang': $this->attributes['lang'] = $this->parseLangOption($token, $stream); break; case 'format': $this->attributes['format'] = $this->parseFormatOption($token, $stream); break; case 'start': $this->attributes['start'] = $this->parseStartOption($token, $stream); break; case 'mark': $this->attributes['mark'] = $this->parseMarkOption($token, $stream); break; case 'linenos': $this->attributes['linenos'] = $this->parseLinenosOption($token, $stream); break; case 'class': $this->attributes['class'] = $this->parseClassOption($token, $stream); break; case 'title': $this->attributes['title'] = $this->parseTitleOption($token, $stream); break; case 'link': $this->attributes['linkUrl'] = $this->parseLinkOption($token, $stream); break; case 'link_text': $this->attributes['linkText'] = $this->parseLinkTextOption($token, $stream); break; } }
php
protected function parseEncounteredToken(\Twig_Token $token, \Twig_TokenStream $stream) { switch ($token->getValue()) { case 'lang': $this->attributes['lang'] = $this->parseLangOption($token, $stream); break; case 'format': $this->attributes['format'] = $this->parseFormatOption($token, $stream); break; case 'start': $this->attributes['start'] = $this->parseStartOption($token, $stream); break; case 'mark': $this->attributes['mark'] = $this->parseMarkOption($token, $stream); break; case 'linenos': $this->attributes['linenos'] = $this->parseLinenosOption($token, $stream); break; case 'class': $this->attributes['class'] = $this->parseClassOption($token, $stream); break; case 'title': $this->attributes['title'] = $this->parseTitleOption($token, $stream); break; case 'link': $this->attributes['linkUrl'] = $this->parseLinkOption($token, $stream); break; case 'link_text': $this->attributes['linkText'] = $this->parseLinkTextOption($token, $stream); break; } }
[ "protected", "function", "parseEncounteredToken", "(", "\\", "Twig_Token", "$", "token", ",", "\\", "Twig_TokenStream", "$", "stream", ")", "{", "switch", "(", "$", "token", "->", "getValue", "(", ")", ")", "{", "case", "'lang'", ":", "$", "this", "->", "attributes", "[", "'lang'", "]", "=", "$", "this", "->", "parseLangOption", "(", "$", "token", ",", "$", "stream", ")", ";", "break", ";", "case", "'format'", ":", "$", "this", "->", "attributes", "[", "'format'", "]", "=", "$", "this", "->", "parseFormatOption", "(", "$", "token", ",", "$", "stream", ")", ";", "break", ";", "case", "'start'", ":", "$", "this", "->", "attributes", "[", "'start'", "]", "=", "$", "this", "->", "parseStartOption", "(", "$", "token", ",", "$", "stream", ")", ";", "break", ";", "case", "'mark'", ":", "$", "this", "->", "attributes", "[", "'mark'", "]", "=", "$", "this", "->", "parseMarkOption", "(", "$", "token", ",", "$", "stream", ")", ";", "break", ";", "case", "'linenos'", ":", "$", "this", "->", "attributes", "[", "'linenos'", "]", "=", "$", "this", "->", "parseLinenosOption", "(", "$", "token", ",", "$", "stream", ")", ";", "break", ";", "case", "'class'", ":", "$", "this", "->", "attributes", "[", "'class'", "]", "=", "$", "this", "->", "parseClassOption", "(", "$", "token", ",", "$", "stream", ")", ";", "break", ";", "case", "'title'", ":", "$", "this", "->", "attributes", "[", "'title'", "]", "=", "$", "this", "->", "parseTitleOption", "(", "$", "token", ",", "$", "stream", ")", ";", "break", ";", "case", "'link'", ":", "$", "this", "->", "attributes", "[", "'linkUrl'", "]", "=", "$", "this", "->", "parseLinkOption", "(", "$", "token", ",", "$", "stream", ")", ";", "break", ";", "case", "'link_text'", ":", "$", "this", "->", "attributes", "[", "'linkText'", "]", "=", "$", "this", "->", "parseLinkTextOption", "(", "$", "token", ",", "$", "stream", ")", ";", "break", ";", "}", "}" ]
Parses each specific token found when looping through the codeblock tag @param \Twig_Token $token The token being parsed @param \Twig_TokenStream $stream The token stream being traversed
[ "Parses", "each", "specific", "token", "found", "when", "looping", "through", "the", "codeblock", "tag" ]
bf3a940af4c5d5a66b1e66e9464fccc29579b23f
https://github.com/ramsey/twig-codeblock/blob/bf3a940af4c5d5a66b1e66e9464fccc29579b23f/src/TokenParser/CodeBlockParser.php#L153-L192
222,423
ramsey/twig-codeblock
src/TokenParser/CodeBlockParser.php
CodeBlockParser.parseLangOption
protected function parseLangOption(\Twig_Token $token, \Twig_TokenStream $stream) { $this->testToken('lang', $token, $stream); return $this->getNextExpectedStringValueFromStream($stream, \Twig_Token::STRING_TYPE); }
php
protected function parseLangOption(\Twig_Token $token, \Twig_TokenStream $stream) { $this->testToken('lang', $token, $stream); return $this->getNextExpectedStringValueFromStream($stream, \Twig_Token::STRING_TYPE); }
[ "protected", "function", "parseLangOption", "(", "\\", "Twig_Token", "$", "token", ",", "\\", "Twig_TokenStream", "$", "stream", ")", "{", "$", "this", "->", "testToken", "(", "'lang'", ",", "$", "token", ",", "$", "stream", ")", ";", "return", "$", "this", "->", "getNextExpectedStringValueFromStream", "(", "$", "stream", ",", "\\", "Twig_Token", "::", "STRING_TYPE", ")", ";", "}" ]
Returns the programming language option value from the lang token @param \Twig_Token $token The token to parse @param \Twig_TokenStream $stream The token stream being traversed @return string
[ "Returns", "the", "programming", "language", "option", "value", "from", "the", "lang", "token" ]
bf3a940af4c5d5a66b1e66e9464fccc29579b23f
https://github.com/ramsey/twig-codeblock/blob/bf3a940af4c5d5a66b1e66e9464fccc29579b23f/src/TokenParser/CodeBlockParser.php#L222-L227
222,424
ramsey/twig-codeblock
src/TokenParser/CodeBlockParser.php
CodeBlockParser.parseStartOption
protected function parseStartOption(\Twig_Token $token, \Twig_TokenStream $stream) { $this->testToken('start', $token, $stream); return $this->getNextExpectedStringValueFromStream($stream, \Twig_Token::NUMBER_TYPE); }
php
protected function parseStartOption(\Twig_Token $token, \Twig_TokenStream $stream) { $this->testToken('start', $token, $stream); return $this->getNextExpectedStringValueFromStream($stream, \Twig_Token::NUMBER_TYPE); }
[ "protected", "function", "parseStartOption", "(", "\\", "Twig_Token", "$", "token", ",", "\\", "Twig_TokenStream", "$", "stream", ")", "{", "$", "this", "->", "testToken", "(", "'start'", ",", "$", "token", ",", "$", "stream", ")", ";", "return", "$", "this", "->", "getNextExpectedStringValueFromStream", "(", "$", "stream", ",", "\\", "Twig_Token", "::", "NUMBER_TYPE", ")", ";", "}" ]
Returns the start option value from the start token @param \Twig_Token $token The token to parse @param \Twig_TokenStream $stream The token stream being traversed @return integer
[ "Returns", "the", "start", "option", "value", "from", "the", "start", "token" ]
bf3a940af4c5d5a66b1e66e9464fccc29579b23f
https://github.com/ramsey/twig-codeblock/blob/bf3a940af4c5d5a66b1e66e9464fccc29579b23f/src/TokenParser/CodeBlockParser.php#L250-L255
222,425
ramsey/twig-codeblock
src/TokenParser/CodeBlockParser.php
CodeBlockParser.parseMarkOption
protected function parseMarkOption(\Twig_Token $token, \Twig_TokenStream $stream) { $this->testToken('mark', $token, $stream); $markValue = $this->getNextExpectedStringValueFromStream($stream, \Twig_Token::NUMBER_TYPE); while ($stream->test(\Twig_Token::OPERATOR_TYPE) || $stream->test(\Twig_Token::PUNCTUATION_TYPE) || $stream->test(\Twig_Token::NUMBER_TYPE) ) { $markValue .= $stream->getCurrent()->getValue(); $stream->next(); } return $markValue; }
php
protected function parseMarkOption(\Twig_Token $token, \Twig_TokenStream $stream) { $this->testToken('mark', $token, $stream); $markValue = $this->getNextExpectedStringValueFromStream($stream, \Twig_Token::NUMBER_TYPE); while ($stream->test(\Twig_Token::OPERATOR_TYPE) || $stream->test(\Twig_Token::PUNCTUATION_TYPE) || $stream->test(\Twig_Token::NUMBER_TYPE) ) { $markValue .= $stream->getCurrent()->getValue(); $stream->next(); } return $markValue; }
[ "protected", "function", "parseMarkOption", "(", "\\", "Twig_Token", "$", "token", ",", "\\", "Twig_TokenStream", "$", "stream", ")", "{", "$", "this", "->", "testToken", "(", "'mark'", ",", "$", "token", ",", "$", "stream", ")", ";", "$", "markValue", "=", "$", "this", "->", "getNextExpectedStringValueFromStream", "(", "$", "stream", ",", "\\", "Twig_Token", "::", "NUMBER_TYPE", ")", ";", "while", "(", "$", "stream", "->", "test", "(", "\\", "Twig_Token", "::", "OPERATOR_TYPE", ")", "||", "$", "stream", "->", "test", "(", "\\", "Twig_Token", "::", "PUNCTUATION_TYPE", ")", "||", "$", "stream", "->", "test", "(", "\\", "Twig_Token", "::", "NUMBER_TYPE", ")", ")", "{", "$", "markValue", ".=", "$", "stream", "->", "getCurrent", "(", ")", "->", "getValue", "(", ")", ";", "$", "stream", "->", "next", "(", ")", ";", "}", "return", "$", "markValue", ";", "}" ]
Returns the mark option value from the mark token @param \Twig_Token $token The token to parse @param \Twig_TokenStream $stream The token stream being traversed @return string
[ "Returns", "the", "mark", "option", "value", "from", "the", "mark", "token" ]
bf3a940af4c5d5a66b1e66e9464fccc29579b23f
https://github.com/ramsey/twig-codeblock/blob/bf3a940af4c5d5a66b1e66e9464fccc29579b23f/src/TokenParser/CodeBlockParser.php#L264-L279
222,426
ramsey/twig-codeblock
src/TokenParser/CodeBlockParser.php
CodeBlockParser.parseLinenosOption
protected function parseLinenosOption(\Twig_Token $token, \Twig_TokenStream $stream) { $this->testToken('linenos', $token, $stream); return $this->getNextExpectedBoolValueFromStream($stream, 'linenos'); }
php
protected function parseLinenosOption(\Twig_Token $token, \Twig_TokenStream $stream) { $this->testToken('linenos', $token, $stream); return $this->getNextExpectedBoolValueFromStream($stream, 'linenos'); }
[ "protected", "function", "parseLinenosOption", "(", "\\", "Twig_Token", "$", "token", ",", "\\", "Twig_TokenStream", "$", "stream", ")", "{", "$", "this", "->", "testToken", "(", "'linenos'", ",", "$", "token", ",", "$", "stream", ")", ";", "return", "$", "this", "->", "getNextExpectedBoolValueFromStream", "(", "$", "stream", ",", "'linenos'", ")", ";", "}" ]
Returns the linenos option value from the linenos token @param \Twig_Token $token The token to parse @param \Twig_TokenStream $stream The token stream being traversed @return boolean
[ "Returns", "the", "linenos", "option", "value", "from", "the", "linenos", "token" ]
bf3a940af4c5d5a66b1e66e9464fccc29579b23f
https://github.com/ramsey/twig-codeblock/blob/bf3a940af4c5d5a66b1e66e9464fccc29579b23f/src/TokenParser/CodeBlockParser.php#L288-L293
222,427
ramsey/twig-codeblock
src/TokenParser/CodeBlockParser.php
CodeBlockParser.getNextExpectedStringValueFromStream
protected function getNextExpectedStringValueFromStream( \Twig_TokenStream $stream, $type ) { $stream->next(); $stream->expect(\Twig_Token::PUNCTUATION_TYPE); return $stream->expect($type)->getValue(); }
php
protected function getNextExpectedStringValueFromStream( \Twig_TokenStream $stream, $type ) { $stream->next(); $stream->expect(\Twig_Token::PUNCTUATION_TYPE); return $stream->expect($type)->getValue(); }
[ "protected", "function", "getNextExpectedStringValueFromStream", "(", "\\", "Twig_TokenStream", "$", "stream", ",", "$", "type", ")", "{", "$", "stream", "->", "next", "(", ")", ";", "$", "stream", "->", "expect", "(", "\\", "Twig_Token", "::", "PUNCTUATION_TYPE", ")", ";", "return", "$", "stream", "->", "expect", "(", "$", "type", ")", "->", "getValue", "(", ")", ";", "}" ]
Helper method for the common operation of grabbing the next string value from the stream @param \Twig_TokenStream $stream @param int $type @return string
[ "Helper", "method", "for", "the", "common", "operation", "of", "grabbing", "the", "next", "string", "value", "from", "the", "stream" ]
bf3a940af4c5d5a66b1e66e9464fccc29579b23f
https://github.com/ramsey/twig-codeblock/blob/bf3a940af4c5d5a66b1e66e9464fccc29579b23f/src/TokenParser/CodeBlockParser.php#L359-L367
222,428
ramsey/twig-codeblock
src/TokenParser/CodeBlockParser.php
CodeBlockParser.getNextExpectedBoolValueFromStream
protected function getNextExpectedBoolValueFromStream( \Twig_TokenStream $stream, $optionName ) { $stream->next(); $stream->expect(\Twig_Token::PUNCTUATION_TYPE); $expr = $this->parser->getExpressionParser()->parseExpression(); if (!($expr instanceof \Twig_Node_Expression_Constant) || !is_bool($expr->getAttribute('value'))) { throw new SyntaxException( sprintf( 'The %s option must be boolean true or false (i.e. %s:false).', $optionName, $optionName ), $stream->getCurrent()->getLine(), $this->getStreamFilename($stream) ); } return $expr->getAttribute('value'); }
php
protected function getNextExpectedBoolValueFromStream( \Twig_TokenStream $stream, $optionName ) { $stream->next(); $stream->expect(\Twig_Token::PUNCTUATION_TYPE); $expr = $this->parser->getExpressionParser()->parseExpression(); if (!($expr instanceof \Twig_Node_Expression_Constant) || !is_bool($expr->getAttribute('value'))) { throw new SyntaxException( sprintf( 'The %s option must be boolean true or false (i.e. %s:false).', $optionName, $optionName ), $stream->getCurrent()->getLine(), $this->getStreamFilename($stream) ); } return $expr->getAttribute('value'); }
[ "protected", "function", "getNextExpectedBoolValueFromStream", "(", "\\", "Twig_TokenStream", "$", "stream", ",", "$", "optionName", ")", "{", "$", "stream", "->", "next", "(", ")", ";", "$", "stream", "->", "expect", "(", "\\", "Twig_Token", "::", "PUNCTUATION_TYPE", ")", ";", "$", "expr", "=", "$", "this", "->", "parser", "->", "getExpressionParser", "(", ")", "->", "parseExpression", "(", ")", ";", "if", "(", "!", "(", "$", "expr", "instanceof", "\\", "Twig_Node_Expression_Constant", ")", "||", "!", "is_bool", "(", "$", "expr", "->", "getAttribute", "(", "'value'", ")", ")", ")", "{", "throw", "new", "SyntaxException", "(", "sprintf", "(", "'The %s option must be boolean true or false (i.e. %s:false).'", ",", "$", "optionName", ",", "$", "optionName", ")", ",", "$", "stream", "->", "getCurrent", "(", ")", "->", "getLine", "(", ")", ",", "$", "this", "->", "getStreamFilename", "(", "$", "stream", ")", ")", ";", "}", "return", "$", "expr", "->", "getAttribute", "(", "'value'", ")", ";", "}" ]
Helper method for the common operation of grabbing the next boolean value from the stream @param \Twig_TokenStream $stream @param string $optionName @return string
[ "Helper", "method", "for", "the", "common", "operation", "of", "grabbing", "the", "next", "boolean", "value", "from", "the", "stream" ]
bf3a940af4c5d5a66b1e66e9464fccc29579b23f
https://github.com/ramsey/twig-codeblock/blob/bf3a940af4c5d5a66b1e66e9464fccc29579b23f/src/TokenParser/CodeBlockParser.php#L377-L398
222,429
ramsey/twig-codeblock
src/TokenParser/CodeBlockParser.php
CodeBlockParser.getStreamFilename
private function getStreamFilename(\Twig_TokenStream $stream) { if (method_exists($stream, 'getFilename')) { // Support for 1.x versions of Twig. // @codeCoverageIgnoreStart return $stream->getFilename(); // @codeCoverageIgnoreEnd } return $stream->getSourceContext()->getName(); }
php
private function getStreamFilename(\Twig_TokenStream $stream) { if (method_exists($stream, 'getFilename')) { // Support for 1.x versions of Twig. // @codeCoverageIgnoreStart return $stream->getFilename(); // @codeCoverageIgnoreEnd } return $stream->getSourceContext()->getName(); }
[ "private", "function", "getStreamFilename", "(", "\\", "Twig_TokenStream", "$", "stream", ")", "{", "if", "(", "method_exists", "(", "$", "stream", ",", "'getFilename'", ")", ")", "{", "// Support for 1.x versions of Twig.", "// @codeCoverageIgnoreStart", "return", "$", "stream", "->", "getFilename", "(", ")", ";", "// @codeCoverageIgnoreEnd", "}", "return", "$", "stream", "->", "getSourceContext", "(", ")", "->", "getName", "(", ")", ";", "}" ]
Returns the filename for the given stream @param \Twig_TokenStream $stream @return string
[ "Returns", "the", "filename", "for", "the", "given", "stream" ]
bf3a940af4c5d5a66b1e66e9464fccc29579b23f
https://github.com/ramsey/twig-codeblock/blob/bf3a940af4c5d5a66b1e66e9464fccc29579b23f/src/TokenParser/CodeBlockParser.php#L406-L416
222,430
joomla-framework/di
src/Container.php
Container.tag
public function tag($tag, array $keys) { foreach ($keys as $key) { $resolvedKey = $this->resolveAlias($key); if (!isset($this->tags[$tag])) { $this->tags[$tag] = array(); } $this->tags[$tag][] = $resolvedKey; } // Prune duplicates $this->tags[$tag] = array_unique($this->tags[$tag]); return $this; }
php
public function tag($tag, array $keys) { foreach ($keys as $key) { $resolvedKey = $this->resolveAlias($key); if (!isset($this->tags[$tag])) { $this->tags[$tag] = array(); } $this->tags[$tag][] = $resolvedKey; } // Prune duplicates $this->tags[$tag] = array_unique($this->tags[$tag]); return $this; }
[ "public", "function", "tag", "(", "$", "tag", ",", "array", "$", "keys", ")", "{", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "resolvedKey", "=", "$", "this", "->", "resolveAlias", "(", "$", "key", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "tags", "[", "$", "tag", "]", ")", ")", "{", "$", "this", "->", "tags", "[", "$", "tag", "]", "=", "array", "(", ")", ";", "}", "$", "this", "->", "tags", "[", "$", "tag", "]", "[", "]", "=", "$", "resolvedKey", ";", "}", "// Prune duplicates", "$", "this", "->", "tags", "[", "$", "tag", "]", "=", "array_unique", "(", "$", "this", "->", "tags", "[", "$", "tag", "]", ")", ";", "return", "$", "this", ";", "}" ]
Assign a tag to services. @param string $tag The tag name @param array $keys The service keys to tag @return Container This object for chaining. @since 1.5.0
[ "Assign", "a", "tag", "to", "services", "." ]
f3098a4f6528098d48e6d694ae3ee79dd8fe6b92
https://github.com/joomla-framework/di/blob/f3098a4f6528098d48e6d694ae3ee79dd8fe6b92/src/Container.php#L127-L145
222,431
joomla-framework/di
src/Container.php
Container.getTagged
public function getTagged($tag) { $services = array(); if (isset($this->tags[$tag])) { foreach ($this->tags[$tag] as $service) { $services[] = $this->get($service); } } return $services; }
php
public function getTagged($tag) { $services = array(); if (isset($this->tags[$tag])) { foreach ($this->tags[$tag] as $service) { $services[] = $this->get($service); } } return $services; }
[ "public", "function", "getTagged", "(", "$", "tag", ")", "{", "$", "services", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "tags", "[", "$", "tag", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "tags", "[", "$", "tag", "]", "as", "$", "service", ")", "{", "$", "services", "[", "]", "=", "$", "this", "->", "get", "(", "$", "service", ")", ";", "}", "}", "return", "$", "services", ";", "}" ]
Fetch all services registered to the given tag. @param string $tag The tag name @return array The resolved services for the given tag @since 1.5.0
[ "Fetch", "all", "services", "registered", "to", "the", "given", "tag", "." ]
f3098a4f6528098d48e6d694ae3ee79dd8fe6b92
https://github.com/joomla-framework/di/blob/f3098a4f6528098d48e6d694ae3ee79dd8fe6b92/src/Container.php#L156-L169
222,432
joomla-framework/di
src/Container.php
Container.has
public function has($key) { $key = $this->resolveAlias($key); $exists = (bool) $this->getRaw($key); if ($exists === false && $this->parent instanceof ContainerInterface) { $exists = $this->parent->has($key); } return $exists; }
php
public function has($key) { $key = $this->resolveAlias($key); $exists = (bool) $this->getRaw($key); if ($exists === false && $this->parent instanceof ContainerInterface) { $exists = $this->parent->has($key); } return $exists; }
[ "public", "function", "has", "(", "$", "key", ")", "{", "$", "key", "=", "$", "this", "->", "resolveAlias", "(", "$", "key", ")", ";", "$", "exists", "=", "(", "bool", ")", "$", "this", "->", "getRaw", "(", "$", "key", ")", ";", "if", "(", "$", "exists", "===", "false", "&&", "$", "this", "->", "parent", "instanceof", "ContainerInterface", ")", "{", "$", "exists", "=", "$", "this", "->", "parent", "->", "has", "(", "$", "key", ")", ";", "}", "return", "$", "exists", ";", "}" ]
Method to check if specified dataStore key exists. @param string $key Name of the dataStore key to check. @return boolean True for success @since 1.5.0
[ "Method", "to", "check", "if", "specified", "dataStore", "key", "exists", "." ]
f3098a4f6528098d48e6d694ae3ee79dd8fe6b92
https://github.com/joomla-framework/di/blob/f3098a4f6528098d48e6d694ae3ee79dd8fe6b92/src/Container.php#L481-L493
222,433
codefog/tags-bundle
src/ManagerRegistry.php
ManagerRegistry.add
public function add(ManagerInterface $manager, string $alias): void { $manager->setAlias($alias); // @todo – change this in 3.0 if ($manager instanceof DefaultManager) { $manager->setDatabase($this->db); } $this->managers[$alias] = $manager; }
php
public function add(ManagerInterface $manager, string $alias): void { $manager->setAlias($alias); // @todo – change this in 3.0 if ($manager instanceof DefaultManager) { $manager->setDatabase($this->db); } $this->managers[$alias] = $manager; }
[ "public", "function", "add", "(", "ManagerInterface", "$", "manager", ",", "string", "$", "alias", ")", ":", "void", "{", "$", "manager", "->", "setAlias", "(", "$", "alias", ")", ";", "// @todo – change this in 3.0", "if", "(", "$", "manager", "instanceof", "DefaultManager", ")", "{", "$", "manager", "->", "setDatabase", "(", "$", "this", "->", "db", ")", ";", "}", "$", "this", "->", "managers", "[", "$", "alias", "]", "=", "$", "manager", ";", "}" ]
Add the manager. @param ManagerInterface $manager @param string $alias
[ "Add", "the", "manager", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/ManagerRegistry.php#L49-L59
222,434
codefog/tags-bundle
src/ManagerRegistry.php
ManagerRegistry.get
public function get(string $alias): ManagerInterface { if (!\array_key_exists($alias, $this->managers)) { throw new \InvalidArgumentException(\sprintf('The manager "%s" does not exist', $alias)); } return $this->managers[$alias]; }
php
public function get(string $alias): ManagerInterface { if (!\array_key_exists($alias, $this->managers)) { throw new \InvalidArgumentException(\sprintf('The manager "%s" does not exist', $alias)); } return $this->managers[$alias]; }
[ "public", "function", "get", "(", "string", "$", "alias", ")", ":", "ManagerInterface", "{", "if", "(", "!", "\\", "array_key_exists", "(", "$", "alias", ",", "$", "this", "->", "managers", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\\", "sprintf", "(", "'The manager \"%s\" does not exist'", ",", "$", "alias", ")", ")", ";", "}", "return", "$", "this", "->", "managers", "[", "$", "alias", "]", ";", "}" ]
Get the manager. @param string $alias @throws \InvalidArgumentException @return ManagerInterface
[ "Get", "the", "manager", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/ManagerRegistry.php#L70-L77
222,435
justinrainbow/epub
src/ePub/Resource/OpfResource.php
OpfResource.getXmlAttributes
private function getXmlAttributes($xml) { $attributes = array(); foreach ($this->namespaces as $prefix => $namespace) { foreach ($xml->attributes($namespace) as $attr => $value) { if ($prefix !== "") { $attr = "{$prefix}:{$attr}"; } $attributes[$attr] = $value; } } return $attributes; }
php
private function getXmlAttributes($xml) { $attributes = array(); foreach ($this->namespaces as $prefix => $namespace) { foreach ($xml->attributes($namespace) as $attr => $value) { if ($prefix !== "") { $attr = "{$prefix}:{$attr}"; } $attributes[$attr] = $value; } } return $attributes; }
[ "private", "function", "getXmlAttributes", "(", "$", "xml", ")", "{", "$", "attributes", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "namespaces", "as", "$", "prefix", "=>", "$", "namespace", ")", "{", "foreach", "(", "$", "xml", "->", "attributes", "(", "$", "namespace", ")", "as", "$", "attr", "=>", "$", "value", ")", "{", "if", "(", "$", "prefix", "!==", "\"\"", ")", "{", "$", "attr", "=", "\"{$prefix}:{$attr}\"", ";", "}", "$", "attributes", "[", "$", "attr", "]", "=", "$", "value", ";", "}", "}", "return", "$", "attributes", ";", "}" ]
Builds an array from XML attributes For instance: <tag xmlns:opf="http://www.idpf.org/2007/opf" opf:file-as="Some Guy" id="name"/> Will become: array('opf:file-as' => 'Some Guy', 'id' => 'name') **NOTE**: Namespaced attributes will have the namespace prefix prepended to the attribute name @param \SimpleXMLElement $xml The XML tag to grab attributes from @return array
[ "Builds", "an", "array", "from", "XML", "attributes" ]
fbdc795f74907066283418bf1c5022b707a2abe8
https://github.com/justinrainbow/epub/blob/fbdc795f74907066283418bf1c5022b707a2abe8/src/ePub/Resource/OpfResource.php#L189-L203
222,436
codete/FormGeneratorBundle
FormGenerator.php
FormGenerator.createFormBuilder
public function createFormBuilder($model, $form = 'default', $context = [], $options=[]) { $fb = $this->formFactory->createBuilder(FormType::class, $model, $options); $this->populateFormBuilder($fb, $model, $form, $context); return $fb; }
php
public function createFormBuilder($model, $form = 'default', $context = [], $options=[]) { $fb = $this->formFactory->createBuilder(FormType::class, $model, $options); $this->populateFormBuilder($fb, $model, $form, $context); return $fb; }
[ "public", "function", "createFormBuilder", "(", "$", "model", ",", "$", "form", "=", "'default'", ",", "$", "context", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "$", "fb", "=", "$", "this", "->", "formFactory", "->", "createBuilder", "(", "FormType", "::", "class", ",", "$", "model", ",", "$", "options", ")", ";", "$", "this", "->", "populateFormBuilder", "(", "$", "fb", ",", "$", "model", ",", "$", "form", ",", "$", "context", ")", ";", "return", "$", "fb", ";", "}" ]
Creates FormBuilder and populates it. @param object $model data object @param string $form view to generate @param array $context @param array $options @return FormBuilderInterface
[ "Creates", "FormBuilder", "and", "populates", "it", "." ]
c0bc3704d3f6df505ec232aa32b345159fffd980
https://github.com/codete/FormGeneratorBundle/blob/c0bc3704d3f6df505ec232aa32b345159fffd980/FormGenerator.php#L77-L83
222,437
codete/FormGeneratorBundle
FormGenerator.php
FormGenerator.createNamedFormBuilder
public function createNamedFormBuilder($name, $model, $form = 'default', $context = [], $options=[]) { $fb = $this->formFactory->createNamedBuilder($name, FormType::class, $model, $options); $this->populateFormBuilder($fb, $model, $form, $context); return $fb; }
php
public function createNamedFormBuilder($name, $model, $form = 'default', $context = [], $options=[]) { $fb = $this->formFactory->createNamedBuilder($name, FormType::class, $model, $options); $this->populateFormBuilder($fb, $model, $form, $context); return $fb; }
[ "public", "function", "createNamedFormBuilder", "(", "$", "name", ",", "$", "model", ",", "$", "form", "=", "'default'", ",", "$", "context", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "$", "fb", "=", "$", "this", "->", "formFactory", "->", "createNamedBuilder", "(", "$", "name", ",", "FormType", "::", "class", ",", "$", "model", ",", "$", "options", ")", ";", "$", "this", "->", "populateFormBuilder", "(", "$", "fb", ",", "$", "model", ",", "$", "form", ",", "$", "context", ")", ";", "return", "$", "fb", ";", "}" ]
Creates named FormBuilder and populates it. @param string $name @param object $model data object @param string $form view to generate @param array $context @param array $options @return FormBuilderInterface
[ "Creates", "named", "FormBuilder", "and", "populates", "it", "." ]
c0bc3704d3f6df505ec232aa32b345159fffd980
https://github.com/codete/FormGeneratorBundle/blob/c0bc3704d3f6df505ec232aa32b345159fffd980/FormGenerator.php#L95-L101
222,438
codete/FormGeneratorBundle
FormGenerator.php
FormGenerator.populateFormBuilder
public function populateFormBuilder(FormBuilderInterface $fb, $model, $form = 'default', $context = []) { $configuration = $this->formConfigurationFactory->getConfiguration($form, $model, $context); foreach ($this->adjusterRegistry->getFormConfigurationModifiers() as $modifier) { if ($modifier->supports($model, $configuration, $context)) { $configuration = $modifier->modify($model, $configuration, $context); } } foreach ($configuration as $field => $options) { $type = null; if (isset($options['type'])) { $type = $options['type']; unset($options['type']); } foreach ($this->adjusterRegistry->getFormFieldResolvers() as $resolver) { if ($resolver->supports($model, $field, $type, $options, $context)) { $fb->add($resolver->getFormField($fb, $field, $type, $options, $context)); continue 2; } } if (isset($options['options'])) { $options = $options['options']; } $fb->add($field, $type, $options); } }
php
public function populateFormBuilder(FormBuilderInterface $fb, $model, $form = 'default', $context = []) { $configuration = $this->formConfigurationFactory->getConfiguration($form, $model, $context); foreach ($this->adjusterRegistry->getFormConfigurationModifiers() as $modifier) { if ($modifier->supports($model, $configuration, $context)) { $configuration = $modifier->modify($model, $configuration, $context); } } foreach ($configuration as $field => $options) { $type = null; if (isset($options['type'])) { $type = $options['type']; unset($options['type']); } foreach ($this->adjusterRegistry->getFormFieldResolvers() as $resolver) { if ($resolver->supports($model, $field, $type, $options, $context)) { $fb->add($resolver->getFormField($fb, $field, $type, $options, $context)); continue 2; } } if (isset($options['options'])) { $options = $options['options']; } $fb->add($field, $type, $options); } }
[ "public", "function", "populateFormBuilder", "(", "FormBuilderInterface", "$", "fb", ",", "$", "model", ",", "$", "form", "=", "'default'", ",", "$", "context", "=", "[", "]", ")", "{", "$", "configuration", "=", "$", "this", "->", "formConfigurationFactory", "->", "getConfiguration", "(", "$", "form", ",", "$", "model", ",", "$", "context", ")", ";", "foreach", "(", "$", "this", "->", "adjusterRegistry", "->", "getFormConfigurationModifiers", "(", ")", "as", "$", "modifier", ")", "{", "if", "(", "$", "modifier", "->", "supports", "(", "$", "model", ",", "$", "configuration", ",", "$", "context", ")", ")", "{", "$", "configuration", "=", "$", "modifier", "->", "modify", "(", "$", "model", ",", "$", "configuration", ",", "$", "context", ")", ";", "}", "}", "foreach", "(", "$", "configuration", "as", "$", "field", "=>", "$", "options", ")", "{", "$", "type", "=", "null", ";", "if", "(", "isset", "(", "$", "options", "[", "'type'", "]", ")", ")", "{", "$", "type", "=", "$", "options", "[", "'type'", "]", ";", "unset", "(", "$", "options", "[", "'type'", "]", ")", ";", "}", "foreach", "(", "$", "this", "->", "adjusterRegistry", "->", "getFormFieldResolvers", "(", ")", "as", "$", "resolver", ")", "{", "if", "(", "$", "resolver", "->", "supports", "(", "$", "model", ",", "$", "field", ",", "$", "type", ",", "$", "options", ",", "$", "context", ")", ")", "{", "$", "fb", "->", "add", "(", "$", "resolver", "->", "getFormField", "(", "$", "fb", ",", "$", "field", ",", "$", "type", ",", "$", "options", ",", "$", "context", ")", ")", ";", "continue", "2", ";", "}", "}", "if", "(", "isset", "(", "$", "options", "[", "'options'", "]", ")", ")", "{", "$", "options", "=", "$", "options", "[", "'options'", "]", ";", "}", "$", "fb", "->", "add", "(", "$", "field", ",", "$", "type", ",", "$", "options", ")", ";", "}", "}" ]
Populates FormBuilder. @param FormBuilderInterface $fb @param object $model @param string $form view to generate @param array $context
[ "Populates", "FormBuilder", "." ]
c0bc3704d3f6df505ec232aa32b345159fffd980
https://github.com/codete/FormGeneratorBundle/blob/c0bc3704d3f6df505ec232aa32b345159fffd980/FormGenerator.php#L111-L136
222,439
codefog/tags-bundle
src/EventListener/InsertTagsListener.php
InsertTagsListener.replaceInsertTag
private function replaceInsertTag(array $elements): string { if (3 !== \count($elements)) { return ''; } list($source, $value, $property) = $elements; $tag = $this->registry->get($source)->find($value); if (null === $tag) { return ''; } if ('name' === $property) { return $tag->getName(); } $data = $tag->getData(); return isset($data[$property]) ? (string) $data[$property] : ''; }
php
private function replaceInsertTag(array $elements): string { if (3 !== \count($elements)) { return ''; } list($source, $value, $property) = $elements; $tag = $this->registry->get($source)->find($value); if (null === $tag) { return ''; } if ('name' === $property) { return $tag->getName(); } $data = $tag->getData(); return isset($data[$property]) ? (string) $data[$property] : ''; }
[ "private", "function", "replaceInsertTag", "(", "array", "$", "elements", ")", ":", "string", "{", "if", "(", "3", "!==", "\\", "count", "(", "$", "elements", ")", ")", "{", "return", "''", ";", "}", "list", "(", "$", "source", ",", "$", "value", ",", "$", "property", ")", "=", "$", "elements", ";", "$", "tag", "=", "$", "this", "->", "registry", "->", "get", "(", "$", "source", ")", "->", "find", "(", "$", "value", ")", ";", "if", "(", "null", "===", "$", "tag", ")", "{", "return", "''", ";", "}", "if", "(", "'name'", "===", "$", "property", ")", "{", "return", "$", "tag", "->", "getName", "(", ")", ";", "}", "$", "data", "=", "$", "tag", "->", "getData", "(", ")", ";", "return", "isset", "(", "$", "data", "[", "$", "property", "]", ")", "?", "(", "string", ")", "$", "data", "[", "$", "property", "]", ":", "''", ";", "}" ]
Replace the insert tag. @param array $elements @return string
[ "Replace", "the", "insert", "tag", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/EventListener/InsertTagsListener.php#L60-L81
222,440
codefog/tags-bundle
src/Collection/ModelCollection.php
ModelCollection.createTagFromModel
public static function createTagFromModel(Model $model) { return new Tag((string) $model->id, $model->name, $model->row()); }
php
public static function createTagFromModel(Model $model) { return new Tag((string) $model->id, $model->name, $model->row()); }
[ "public", "static", "function", "createTagFromModel", "(", "Model", "$", "model", ")", "{", "return", "new", "Tag", "(", "(", "string", ")", "$", "model", "->", "id", ",", "$", "model", "->", "name", ",", "$", "model", "->", "row", "(", ")", ")", ";", "}" ]
Create the tag from model. @param Model $model @return Tag
[ "Create", "the", "tag", "from", "model", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/Collection/ModelCollection.php#L40-L43
222,441
codefog/tags-bundle
src/Collection/ModelCollection.php
ModelCollection.createTags
private function createTags(Collection $models): array { $tags = []; /** @var Model $model */ foreach ($models as $model) { $tags[] = static::createTagFromModel($model); } return $tags; }
php
private function createTags(Collection $models): array { $tags = []; /** @var Model $model */ foreach ($models as $model) { $tags[] = static::createTagFromModel($model); } return $tags; }
[ "private", "function", "createTags", "(", "Collection", "$", "models", ")", ":", "array", "{", "$", "tags", "=", "[", "]", ";", "/** @var Model $model */", "foreach", "(", "$", "models", "as", "$", "model", ")", "{", "$", "tags", "[", "]", "=", "static", "::", "createTagFromModel", "(", "$", "model", ")", ";", "}", "return", "$", "tags", ";", "}" ]
Create the tags. @param Collection $models @return array
[ "Create", "the", "tags", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/Collection/ModelCollection.php#L52-L62
222,442
ramsey/twig-codeblock
src/Highlighter/HighlighterFactory.php
HighlighterFactory.getHighlighter
public static function getHighlighter($highlighter = null, array $arguments = []) { if ($highlighter instanceof HighlighterInterface) { return $highlighter; } switch ($highlighter) { case 'pygments': case null: $highlighterClass = PygmentsHighlighter::class; break; default: // A different class name must have been specified $highlighterClass = (string) $highlighter; break; } try { $reflection = new \ReflectionClass($highlighterClass); } catch (\ReflectionException $e) { throw new \RuntimeException($e->getMessage()); } if ($reflection->implementsInterface(HighlighterInterface::class)) { return $reflection->newInstanceArgs($arguments); } throw new \RuntimeException( sprintf( "'%s' must be an instance of '%s'.", $highlighterClass, HighlighterInterface::class ) ); }
php
public static function getHighlighter($highlighter = null, array $arguments = []) { if ($highlighter instanceof HighlighterInterface) { return $highlighter; } switch ($highlighter) { case 'pygments': case null: $highlighterClass = PygmentsHighlighter::class; break; default: // A different class name must have been specified $highlighterClass = (string) $highlighter; break; } try { $reflection = new \ReflectionClass($highlighterClass); } catch (\ReflectionException $e) { throw new \RuntimeException($e->getMessage()); } if ($reflection->implementsInterface(HighlighterInterface::class)) { return $reflection->newInstanceArgs($arguments); } throw new \RuntimeException( sprintf( "'%s' must be an instance of '%s'.", $highlighterClass, HighlighterInterface::class ) ); }
[ "public", "static", "function", "getHighlighter", "(", "$", "highlighter", "=", "null", ",", "array", "$", "arguments", "=", "[", "]", ")", "{", "if", "(", "$", "highlighter", "instanceof", "HighlighterInterface", ")", "{", "return", "$", "highlighter", ";", "}", "switch", "(", "$", "highlighter", ")", "{", "case", "'pygments'", ":", "case", "null", ":", "$", "highlighterClass", "=", "PygmentsHighlighter", "::", "class", ";", "break", ";", "default", ":", "// A different class name must have been specified", "$", "highlighterClass", "=", "(", "string", ")", "$", "highlighter", ";", "break", ";", "}", "try", "{", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "highlighterClass", ")", ";", "}", "catch", "(", "\\", "ReflectionException", "$", "e", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "if", "(", "$", "reflection", "->", "implementsInterface", "(", "HighlighterInterface", "::", "class", ")", ")", "{", "return", "$", "reflection", "->", "newInstanceArgs", "(", "$", "arguments", ")", ";", "}", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "\"'%s' must be an instance of '%s'.\"", ",", "$", "highlighterClass", ",", "HighlighterInterface", "::", "class", ")", ")", ";", "}" ]
Returns an instance of a highlighter by name or fully-qualified classname @param string $highlighter Name or fully-qualified classname of the highlighter @param array $arguments Array of arguments to pass to the highlighter upon instantiation @return HighlighterInterface @throws \RuntimeException if highlighter class does not exist or is not an instance of HighlighterInterface
[ "Returns", "an", "instance", "of", "a", "highlighter", "by", "name", "or", "fully", "-", "qualified", "classname" ]
bf3a940af4c5d5a66b1e66e9464fccc29579b23f
https://github.com/ramsey/twig-codeblock/blob/bf3a940af4c5d5a66b1e66e9464fccc29579b23f/src/Highlighter/HighlighterFactory.php#L27-L61
222,443
php-soft/laravel-users
packages/Users/Middleware/RoutePermission.php
RoutePermission.user
protected function user($request) { if (!$token = $this->auth->setRequest($request)->getToken()) { return 401; } try { $user = $this->auth->authenticate($token); } catch (JWTException $e) { return 401; } if (!$user) { return 401; } return $user; }
php
protected function user($request) { if (!$token = $this->auth->setRequest($request)->getToken()) { return 401; } try { $user = $this->auth->authenticate($token); } catch (JWTException $e) { return 401; } if (!$user) { return 401; } return $user; }
[ "protected", "function", "user", "(", "$", "request", ")", "{", "if", "(", "!", "$", "token", "=", "$", "this", "->", "auth", "->", "setRequest", "(", "$", "request", ")", "->", "getToken", "(", ")", ")", "{", "return", "401", ";", "}", "try", "{", "$", "user", "=", "$", "this", "->", "auth", "->", "authenticate", "(", "$", "token", ")", ";", "}", "catch", "(", "JWTException", "$", "e", ")", "{", "return", "401", ";", "}", "if", "(", "!", "$", "user", ")", "{", "return", "401", ";", "}", "return", "$", "user", ";", "}" ]
Get the currently authenticated user or null. @return Illuminate\Auth\UserInterface|null
[ "Get", "the", "currently", "authenticated", "user", "or", "null", "." ]
cd8d696dbf7337002188576d8a143cbc19d86b40
https://github.com/php-soft/laravel-users/blob/cd8d696dbf7337002188576d8a143cbc19d86b40/packages/Users/Middleware/RoutePermission.php#L92-L109
222,444
codete/FormGeneratorBundle
FormConfigurationFactory.php
FormConfigurationFactory.getConfiguration
public function getConfiguration($form, $model, $context) { $fields = null; foreach ($this->adjusterRegistry->getFormViewProviders() as $provider) { if ($provider->supports($form, $model, $context)) { $fields = $provider->getFields($model, $context); break; } } if ($fields === null) { $fields = $this->getFields($model, $form); } $fields = $this->normalizeFields($fields); return $this->getFieldsConfiguration($model, $fields); }
php
public function getConfiguration($form, $model, $context) { $fields = null; foreach ($this->adjusterRegistry->getFormViewProviders() as $provider) { if ($provider->supports($form, $model, $context)) { $fields = $provider->getFields($model, $context); break; } } if ($fields === null) { $fields = $this->getFields($model, $form); } $fields = $this->normalizeFields($fields); return $this->getFieldsConfiguration($model, $fields); }
[ "public", "function", "getConfiguration", "(", "$", "form", ",", "$", "model", ",", "$", "context", ")", "{", "$", "fields", "=", "null", ";", "foreach", "(", "$", "this", "->", "adjusterRegistry", "->", "getFormViewProviders", "(", ")", "as", "$", "provider", ")", "{", "if", "(", "$", "provider", "->", "supports", "(", "$", "form", ",", "$", "model", ",", "$", "context", ")", ")", "{", "$", "fields", "=", "$", "provider", "->", "getFields", "(", "$", "model", ",", "$", "context", ")", ";", "break", ";", "}", "}", "if", "(", "$", "fields", "===", "null", ")", "{", "$", "fields", "=", "$", "this", "->", "getFields", "(", "$", "model", ",", "$", "form", ")", ";", "}", "$", "fields", "=", "$", "this", "->", "normalizeFields", "(", "$", "fields", ")", ";", "return", "$", "this", "->", "getFieldsConfiguration", "(", "$", "model", ",", "$", "fields", ")", ";", "}" ]
Generates initial form configuration. @param string $form @param object $model @param array $context @return array
[ "Generates", "initial", "form", "configuration", "." ]
c0bc3704d3f6df505ec232aa32b345159fffd980
https://github.com/codete/FormGeneratorBundle/blob/c0bc3704d3f6df505ec232aa32b345159fffd980/FormConfigurationFactory.php#L52-L66
222,445
codefog/tags-bundle
src/EventListener/TagManagerListener.php
TagManagerListener.onLoadDataContainer
public function onLoadDataContainer(string $table): void { if (!isset($GLOBALS['TL_DCA'][$table]['fields']) || !\is_array($GLOBALS['TL_DCA'][$table]['fields'])) { return; } $hasTagsFields = false; foreach ($GLOBALS['TL_DCA'][$table]['fields'] as $name => &$field) { if ('cfgTags' !== $field['inputType']) { continue; } $hasTagsFields = true; $manager = $this->registry->get($field['eval']['tagsManager']); if ($manager instanceof DcaAwareInterface) { $manager->updateDcaField($field); } } // Add assets for backend if (TL_MODE === 'BE' && $hasTagsFields) { $this->addAssets(); } }
php
public function onLoadDataContainer(string $table): void { if (!isset($GLOBALS['TL_DCA'][$table]['fields']) || !\is_array($GLOBALS['TL_DCA'][$table]['fields'])) { return; } $hasTagsFields = false; foreach ($GLOBALS['TL_DCA'][$table]['fields'] as $name => &$field) { if ('cfgTags' !== $field['inputType']) { continue; } $hasTagsFields = true; $manager = $this->registry->get($field['eval']['tagsManager']); if ($manager instanceof DcaAwareInterface) { $manager->updateDcaField($field); } } // Add assets for backend if (TL_MODE === 'BE' && $hasTagsFields) { $this->addAssets(); } }
[ "public", "function", "onLoadDataContainer", "(", "string", "$", "table", ")", ":", "void", "{", "if", "(", "!", "isset", "(", "$", "GLOBALS", "[", "'TL_DCA'", "]", "[", "$", "table", "]", "[", "'fields'", "]", ")", "||", "!", "\\", "is_array", "(", "$", "GLOBALS", "[", "'TL_DCA'", "]", "[", "$", "table", "]", "[", "'fields'", "]", ")", ")", "{", "return", ";", "}", "$", "hasTagsFields", "=", "false", ";", "foreach", "(", "$", "GLOBALS", "[", "'TL_DCA'", "]", "[", "$", "table", "]", "[", "'fields'", "]", "as", "$", "name", "=>", "&", "$", "field", ")", "{", "if", "(", "'cfgTags'", "!==", "$", "field", "[", "'inputType'", "]", ")", "{", "continue", ";", "}", "$", "hasTagsFields", "=", "true", ";", "$", "manager", "=", "$", "this", "->", "registry", "->", "get", "(", "$", "field", "[", "'eval'", "]", "[", "'tagsManager'", "]", ")", ";", "if", "(", "$", "manager", "instanceof", "DcaAwareInterface", ")", "{", "$", "manager", "->", "updateDcaField", "(", "$", "field", ")", ";", "}", "}", "// Add assets for backend", "if", "(", "TL_MODE", "===", "'BE'", "&&", "$", "hasTagsFields", ")", "{", "$", "this", "->", "addAssets", "(", ")", ";", "}", "}" ]
On load the data container. @param string $table
[ "On", "load", "the", "data", "container", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/EventListener/TagManagerListener.php#L44-L69
222,446
codefog/tags-bundle
src/EventListener/TagManagerListener.php
TagManagerListener.onFieldSave
public function onFieldSave(string $value, DataContainer $dc): string { $manager = $this->getManagerFromDca($dc); if ($manager instanceof DcaAwareInterface) { $value = $manager->saveDcaField($value, $dc); } return $value; }
php
public function onFieldSave(string $value, DataContainer $dc): string { $manager = $this->getManagerFromDca($dc); if ($manager instanceof DcaAwareInterface) { $value = $manager->saveDcaField($value, $dc); } return $value; }
[ "public", "function", "onFieldSave", "(", "string", "$", "value", ",", "DataContainer", "$", "dc", ")", ":", "string", "{", "$", "manager", "=", "$", "this", "->", "getManagerFromDca", "(", "$", "dc", ")", ";", "if", "(", "$", "manager", "instanceof", "DcaAwareInterface", ")", "{", "$", "value", "=", "$", "manager", "->", "saveDcaField", "(", "$", "value", ",", "$", "dc", ")", ";", "}", "return", "$", "value", ";", "}" ]
On the field save. @param string $value @param DataContainer $dc @return string
[ "On", "the", "field", "save", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/EventListener/TagManagerListener.php#L79-L88
222,447
codefog/tags-bundle
src/EventListener/TagManagerListener.php
TagManagerListener.onOptionsCallback
public function onOptionsCallback(DataContainer $dc): array { $value = []; $manager = $this->getManagerFromDca($dc); if ($manager instanceof DcaFilterAwareInterface) { $value = $manager->getFilterOptions($dc); } return $value; }
php
public function onOptionsCallback(DataContainer $dc): array { $value = []; $manager = $this->getManagerFromDca($dc); if ($manager instanceof DcaFilterAwareInterface) { $value = $manager->getFilterOptions($dc); } return $value; }
[ "public", "function", "onOptionsCallback", "(", "DataContainer", "$", "dc", ")", ":", "array", "{", "$", "value", "=", "[", "]", ";", "$", "manager", "=", "$", "this", "->", "getManagerFromDca", "(", "$", "dc", ")", ";", "if", "(", "$", "manager", "instanceof", "DcaFilterAwareInterface", ")", "{", "$", "value", "=", "$", "manager", "->", "getFilterOptions", "(", "$", "dc", ")", ";", "}", "return", "$", "value", ";", "}" ]
On options callback. @param DataContainer $dc @return array
[ "On", "options", "callback", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/EventListener/TagManagerListener.php#L97-L107
222,448
codefog/tags-bundle
src/EventListener/TagManagerListener.php
TagManagerListener.getManagerFromDca
private function getManagerFromDca(DataContainer $dc): ManagerInterface { return $this->registry->get($GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['tagsManager']); }
php
private function getManagerFromDca(DataContainer $dc): ManagerInterface { return $this->registry->get($GLOBALS['TL_DCA'][$dc->table]['fields'][$dc->field]['eval']['tagsManager']); }
[ "private", "function", "getManagerFromDca", "(", "DataContainer", "$", "dc", ")", ":", "ManagerInterface", "{", "return", "$", "this", "->", "registry", "->", "get", "(", "$", "GLOBALS", "[", "'TL_DCA'", "]", "[", "$", "dc", "->", "table", "]", "[", "'fields'", "]", "[", "$", "dc", "->", "field", "]", "[", "'eval'", "]", "[", "'tagsManager'", "]", ")", ";", "}" ]
Get the manager from DCA. @param DataContainer $dc @return ManagerInterface
[ "Get", "the", "manager", "from", "DCA", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/EventListener/TagManagerListener.php#L116-L119
222,449
codefog/tags-bundle
src/EventListener/TagManagerListener.php
TagManagerListener.addAssets
private function addAssets(): void { $GLOBALS['TL_CSS'][] = Debug::uncompressedFile('bundles/codefogtags/selectize.min.css'); $GLOBALS['TL_CSS'][] = Debug::uncompressedFile('bundles/codefogtags/backend.min.css'); if (!\in_array('assets/jquery/js/jquery.min.js', (array) $GLOBALS['TL_JAVASCRIPT'], true) && !\in_array('assets/jquery/js/jquery.js', (array) $GLOBALS['TL_JAVASCRIPT'], true) ) { $GLOBALS['TL_JAVASCRIPT'][] = Debug::uncompressedFile('assets/jquery/js/jquery.min.js'); } $GLOBALS['TL_JAVASCRIPT'][] = Debug::uncompressedFile('bundles/codefogtags/selectize.min.js'); $GLOBALS['TL_JAVASCRIPT'][] = Debug::uncompressedFile('bundles/codefogtags/widget.min.js'); $GLOBALS['TL_JAVASCRIPT'][] = Debug::uncompressedFile('bundles/codefogtags/backend.min.js'); }
php
private function addAssets(): void { $GLOBALS['TL_CSS'][] = Debug::uncompressedFile('bundles/codefogtags/selectize.min.css'); $GLOBALS['TL_CSS'][] = Debug::uncompressedFile('bundles/codefogtags/backend.min.css'); if (!\in_array('assets/jquery/js/jquery.min.js', (array) $GLOBALS['TL_JAVASCRIPT'], true) && !\in_array('assets/jquery/js/jquery.js', (array) $GLOBALS['TL_JAVASCRIPT'], true) ) { $GLOBALS['TL_JAVASCRIPT'][] = Debug::uncompressedFile('assets/jquery/js/jquery.min.js'); } $GLOBALS['TL_JAVASCRIPT'][] = Debug::uncompressedFile('bundles/codefogtags/selectize.min.js'); $GLOBALS['TL_JAVASCRIPT'][] = Debug::uncompressedFile('bundles/codefogtags/widget.min.js'); $GLOBALS['TL_JAVASCRIPT'][] = Debug::uncompressedFile('bundles/codefogtags/backend.min.js'); }
[ "private", "function", "addAssets", "(", ")", ":", "void", "{", "$", "GLOBALS", "[", "'TL_CSS'", "]", "[", "]", "=", "Debug", "::", "uncompressedFile", "(", "'bundles/codefogtags/selectize.min.css'", ")", ";", "$", "GLOBALS", "[", "'TL_CSS'", "]", "[", "]", "=", "Debug", "::", "uncompressedFile", "(", "'bundles/codefogtags/backend.min.css'", ")", ";", "if", "(", "!", "\\", "in_array", "(", "'assets/jquery/js/jquery.min.js'", ",", "(", "array", ")", "$", "GLOBALS", "[", "'TL_JAVASCRIPT'", "]", ",", "true", ")", "&&", "!", "\\", "in_array", "(", "'assets/jquery/js/jquery.js'", ",", "(", "array", ")", "$", "GLOBALS", "[", "'TL_JAVASCRIPT'", "]", ",", "true", ")", ")", "{", "$", "GLOBALS", "[", "'TL_JAVASCRIPT'", "]", "[", "]", "=", "Debug", "::", "uncompressedFile", "(", "'assets/jquery/js/jquery.min.js'", ")", ";", "}", "$", "GLOBALS", "[", "'TL_JAVASCRIPT'", "]", "[", "]", "=", "Debug", "::", "uncompressedFile", "(", "'bundles/codefogtags/selectize.min.js'", ")", ";", "$", "GLOBALS", "[", "'TL_JAVASCRIPT'", "]", "[", "]", "=", "Debug", "::", "uncompressedFile", "(", "'bundles/codefogtags/widget.min.js'", ")", ";", "$", "GLOBALS", "[", "'TL_JAVASCRIPT'", "]", "[", "]", "=", "Debug", "::", "uncompressedFile", "(", "'bundles/codefogtags/backend.min.js'", ")", ";", "}" ]
Add the widget assets.
[ "Add", "the", "widget", "assets", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/EventListener/TagManagerListener.php#L124-L138
222,450
codefog/tags-bundle
src/EventListener/DataContainer/TagListener.php
TagListener.onLoadCallback
public function onLoadCallback(DataContainer $dc): void { if (!($dc instanceof Driver)) { return; } $ids = []; // Collect the top tags from all registries foreach ($this->registry->getAliases() as $alias) { $manager = $this->registry->get($alias); if ($manager instanceof DefaultManager) { foreach ($manager->getTopTagIds([], null, true) as $id => $count) { $ids[$id] = $count; } } } // Append all other tags foreach ($this->db->executeQuery("SELECT id FROM {$dc->table}")->fetchAll(\PDO::FETCH_COLUMN, 0) as $id) { if (!\array_key_exists($id, $ids)) { $ids[$id] = 0; } } /** @var AttributeBagInterface $bag */ $bag = $this->session->getBag('contao_backend'); $session = $bag->all(); // Handle the sorting selection switch ($session['sorting'][$dc->table]) { case 'total_asc': \asort($ids); break; case 'total_desc': \arsort($ids); break; default: $session['sorting'][$dc->table] = null; $bag->replace($session); return; } /** @var Database $db */ $db = $this->framework->createInstance(Database::class); $dc->setOrderBy([$db->findInSet('id', \array_keys($ids))]); // Prevent adding an extra column to the listing $dc->setFirstOrderBy('name'); }
php
public function onLoadCallback(DataContainer $dc): void { if (!($dc instanceof Driver)) { return; } $ids = []; // Collect the top tags from all registries foreach ($this->registry->getAliases() as $alias) { $manager = $this->registry->get($alias); if ($manager instanceof DefaultManager) { foreach ($manager->getTopTagIds([], null, true) as $id => $count) { $ids[$id] = $count; } } } // Append all other tags foreach ($this->db->executeQuery("SELECT id FROM {$dc->table}")->fetchAll(\PDO::FETCH_COLUMN, 0) as $id) { if (!\array_key_exists($id, $ids)) { $ids[$id] = 0; } } /** @var AttributeBagInterface $bag */ $bag = $this->session->getBag('contao_backend'); $session = $bag->all(); // Handle the sorting selection switch ($session['sorting'][$dc->table]) { case 'total_asc': \asort($ids); break; case 'total_desc': \arsort($ids); break; default: $session['sorting'][$dc->table] = null; $bag->replace($session); return; } /** @var Database $db */ $db = $this->framework->createInstance(Database::class); $dc->setOrderBy([$db->findInSet('id', \array_keys($ids))]); // Prevent adding an extra column to the listing $dc->setFirstOrderBy('name'); }
[ "public", "function", "onLoadCallback", "(", "DataContainer", "$", "dc", ")", ":", "void", "{", "if", "(", "!", "(", "$", "dc", "instanceof", "Driver", ")", ")", "{", "return", ";", "}", "$", "ids", "=", "[", "]", ";", "// Collect the top tags from all registries", "foreach", "(", "$", "this", "->", "registry", "->", "getAliases", "(", ")", "as", "$", "alias", ")", "{", "$", "manager", "=", "$", "this", "->", "registry", "->", "get", "(", "$", "alias", ")", ";", "if", "(", "$", "manager", "instanceof", "DefaultManager", ")", "{", "foreach", "(", "$", "manager", "->", "getTopTagIds", "(", "[", "]", ",", "null", ",", "true", ")", "as", "$", "id", "=>", "$", "count", ")", "{", "$", "ids", "[", "$", "id", "]", "=", "$", "count", ";", "}", "}", "}", "// Append all other tags", "foreach", "(", "$", "this", "->", "db", "->", "executeQuery", "(", "\"SELECT id FROM {$dc->table}\"", ")", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_COLUMN", ",", "0", ")", "as", "$", "id", ")", "{", "if", "(", "!", "\\", "array_key_exists", "(", "$", "id", ",", "$", "ids", ")", ")", "{", "$", "ids", "[", "$", "id", "]", "=", "0", ";", "}", "}", "/** @var AttributeBagInterface $bag */", "$", "bag", "=", "$", "this", "->", "session", "->", "getBag", "(", "'contao_backend'", ")", ";", "$", "session", "=", "$", "bag", "->", "all", "(", ")", ";", "// Handle the sorting selection", "switch", "(", "$", "session", "[", "'sorting'", "]", "[", "$", "dc", "->", "table", "]", ")", "{", "case", "'total_asc'", ":", "\\", "asort", "(", "$", "ids", ")", ";", "break", ";", "case", "'total_desc'", ":", "\\", "arsort", "(", "$", "ids", ")", ";", "break", ";", "default", ":", "$", "session", "[", "'sorting'", "]", "[", "$", "dc", "->", "table", "]", "=", "null", ";", "$", "bag", "->", "replace", "(", "$", "session", ")", ";", "return", ";", "}", "/** @var Database $db */", "$", "db", "=", "$", "this", "->", "framework", "->", "createInstance", "(", "Database", "::", "class", ")", ";", "$", "dc", "->", "setOrderBy", "(", "[", "$", "db", "->", "findInSet", "(", "'id'", ",", "\\", "array_keys", "(", "$", "ids", ")", ")", "]", ")", ";", "// Prevent adding an extra column to the listing", "$", "dc", "->", "setFirstOrderBy", "(", "'name'", ")", ";", "}" ]
On load callback. @param DataContainer $dc
[ "On", "load", "callback", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/EventListener/DataContainer/TagListener.php#L87-L138
222,451
codefog/tags-bundle
src/EventListener/DataContainer/TagListener.php
TagListener.onPanelCallback
public function onPanelCallback(DataContainer $dc): string { /** @var AttributeBagInterface $bag */ $bag = $this->session->getBag('contao_backend'); $session = $bag->all(); $sorting = ['_default', 'total_asc', 'total_desc']; $request = $this->requestStack->getCurrentRequest(); // Store the sorting in the session if ('tl_filters' === $request->request->get('FORM_SUBMIT')) { $sort = $request->request->get('tl_sort'); if ('_default' !== $sort && \in_array($sort, $sorting, true)) { $session['sorting'][$dc->table] = $sort; } else { $session['sorting'][$dc->table] = null; } $bag->replace($session); } $options = []; // Generate the markup options foreach ($sorting as $option) { $options[] = \sprintf( '<option value="%s"%s>%s</option>', StringUtil::specialchars($option), ($session['sorting'][$dc->table] === $option) ? ' selected="selected"' : '', ('_default' === $option) ? $GLOBALS['TL_DCA'][$dc->table]['fields'][$GLOBALS['TL_DCA'][$dc->table]['list']['sorting']['fields'][0]]['label'][0] : $GLOBALS['TL_LANG'][$dc->table]['sortRef'][$option] ); } return ' <div class="tl_sorting tl_subpanel"> <strong>'.$GLOBALS['TL_LANG']['MSC']['sortBy'].':</strong> <select name="tl_sort" id="tl_sort" class="tl_select"> '.\implode("\n", $options).' </select> </div>'; }
php
public function onPanelCallback(DataContainer $dc): string { /** @var AttributeBagInterface $bag */ $bag = $this->session->getBag('contao_backend'); $session = $bag->all(); $sorting = ['_default', 'total_asc', 'total_desc']; $request = $this->requestStack->getCurrentRequest(); // Store the sorting in the session if ('tl_filters' === $request->request->get('FORM_SUBMIT')) { $sort = $request->request->get('tl_sort'); if ('_default' !== $sort && \in_array($sort, $sorting, true)) { $session['sorting'][$dc->table] = $sort; } else { $session['sorting'][$dc->table] = null; } $bag->replace($session); } $options = []; // Generate the markup options foreach ($sorting as $option) { $options[] = \sprintf( '<option value="%s"%s>%s</option>', StringUtil::specialchars($option), ($session['sorting'][$dc->table] === $option) ? ' selected="selected"' : '', ('_default' === $option) ? $GLOBALS['TL_DCA'][$dc->table]['fields'][$GLOBALS['TL_DCA'][$dc->table]['list']['sorting']['fields'][0]]['label'][0] : $GLOBALS['TL_LANG'][$dc->table]['sortRef'][$option] ); } return ' <div class="tl_sorting tl_subpanel"> <strong>'.$GLOBALS['TL_LANG']['MSC']['sortBy'].':</strong> <select name="tl_sort" id="tl_sort" class="tl_select"> '.\implode("\n", $options).' </select> </div>'; }
[ "public", "function", "onPanelCallback", "(", "DataContainer", "$", "dc", ")", ":", "string", "{", "/** @var AttributeBagInterface $bag */", "$", "bag", "=", "$", "this", "->", "session", "->", "getBag", "(", "'contao_backend'", ")", ";", "$", "session", "=", "$", "bag", "->", "all", "(", ")", ";", "$", "sorting", "=", "[", "'_default'", ",", "'total_asc'", ",", "'total_desc'", "]", ";", "$", "request", "=", "$", "this", "->", "requestStack", "->", "getCurrentRequest", "(", ")", ";", "// Store the sorting in the session", "if", "(", "'tl_filters'", "===", "$", "request", "->", "request", "->", "get", "(", "'FORM_SUBMIT'", ")", ")", "{", "$", "sort", "=", "$", "request", "->", "request", "->", "get", "(", "'tl_sort'", ")", ";", "if", "(", "'_default'", "!==", "$", "sort", "&&", "\\", "in_array", "(", "$", "sort", ",", "$", "sorting", ",", "true", ")", ")", "{", "$", "session", "[", "'sorting'", "]", "[", "$", "dc", "->", "table", "]", "=", "$", "sort", ";", "}", "else", "{", "$", "session", "[", "'sorting'", "]", "[", "$", "dc", "->", "table", "]", "=", "null", ";", "}", "$", "bag", "->", "replace", "(", "$", "session", ")", ";", "}", "$", "options", "=", "[", "]", ";", "// Generate the markup options", "foreach", "(", "$", "sorting", "as", "$", "option", ")", "{", "$", "options", "[", "]", "=", "\\", "sprintf", "(", "'<option value=\"%s\"%s>%s</option>'", ",", "StringUtil", "::", "specialchars", "(", "$", "option", ")", ",", "(", "$", "session", "[", "'sorting'", "]", "[", "$", "dc", "->", "table", "]", "===", "$", "option", ")", "?", "' selected=\"selected\"'", ":", "''", ",", "(", "'_default'", "===", "$", "option", ")", "?", "$", "GLOBALS", "[", "'TL_DCA'", "]", "[", "$", "dc", "->", "table", "]", "[", "'fields'", "]", "[", "$", "GLOBALS", "[", "'TL_DCA'", "]", "[", "$", "dc", "->", "table", "]", "[", "'list'", "]", "[", "'sorting'", "]", "[", "'fields'", "]", "[", "0", "]", "]", "[", "'label'", "]", "[", "0", "]", ":", "$", "GLOBALS", "[", "'TL_LANG'", "]", "[", "$", "dc", "->", "table", "]", "[", "'sortRef'", "]", "[", "$", "option", "]", ")", ";", "}", "return", "'\n\n<div class=\"tl_sorting tl_subpanel\">\n<strong>'", ".", "$", "GLOBALS", "[", "'TL_LANG'", "]", "[", "'MSC'", "]", "[", "'sortBy'", "]", ".", "':</strong>\n<select name=\"tl_sort\" id=\"tl_sort\" class=\"tl_select\">\n'", ".", "\\", "implode", "(", "\"\\n\"", ",", "$", "options", ")", ".", "'\n</select>\n</div>'", ";", "}" ]
On generate panel callback. @param DataContainer $dc @return string
[ "On", "generate", "panel", "callback", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/EventListener/DataContainer/TagListener.php#L147-L189
222,452
codefog/tags-bundle
src/EventListener/DataContainer/TagListener.php
TagListener.generateLabel
public function generateLabel(array $row, $label, DataContainer $dc, array $args): array { $manager = $this->getManager($row['source']); if (null !== ($tag = $manager->find($row['id']))) { $args[2] = $manager->countSourceRecords($tag); } return $args; }
php
public function generateLabel(array $row, $label, DataContainer $dc, array $args): array { $manager = $this->getManager($row['source']); if (null !== ($tag = $manager->find($row['id']))) { $args[2] = $manager->countSourceRecords($tag); } return $args; }
[ "public", "function", "generateLabel", "(", "array", "$", "row", ",", "$", "label", ",", "DataContainer", "$", "dc", ",", "array", "$", "args", ")", ":", "array", "{", "$", "manager", "=", "$", "this", "->", "getManager", "(", "$", "row", "[", "'source'", "]", ")", ";", "if", "(", "null", "!==", "(", "$", "tag", "=", "$", "manager", "->", "find", "(", "$", "row", "[", "'id'", "]", ")", ")", ")", "{", "$", "args", "[", "2", "]", "=", "$", "manager", "->", "countSourceRecords", "(", "$", "tag", ")", ";", "}", "return", "$", "args", ";", "}" ]
Generate the label. @param array $row @param string $label @param DataContainer $dc @param array $args @return array
[ "Generate", "the", "label", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/EventListener/DataContainer/TagListener.php#L201-L210
222,453
codefog/tags-bundle
src/EventListener/DataContainer/TagListener.php
TagListener.addAliasButton
public function addAliasButton(array $buttons, DataContainer $dc) { $request = $this->requestStack->getCurrentRequest(); // Generate the aliases if ('tl_select' === $request->request->get('FORM_SUBMIT') && $request->request->has('alias')) { $ids = $this->session->all()['CURRENT']['IDS']; /** * @var Controller * @var System $systemAdapter * @var TagModel $tagAdapter */ $controllerAdapter = $this->framework->getAdapter(Controller::class); $systemAdapter = $this->framework->getAdapter(System::class); $tagAdapter = $this->framework->getAdapter(TagModel::class); // Handle each model individually if (null !== ($tagModels = $tagAdapter->findMultipleByIds($ids))) { /** @var TagModel $tagModel */ foreach ($tagModels as $tagModel) { $dc->id = $tagModel->id; $dc->activeRecord = $tagModel; $alias = ''; // Generate new alias through save callbacks foreach ($GLOBALS['TL_DCA'][$dc->table]['fields']['alias']['save_callback'] as $callback) { if (\is_array($callback)) { $alias = $systemAdapter->importStatic($callback[0])->{$callback[1]}($alias, $dc); } elseif (\is_callable($callback)) { $alias = $callback($alias, $dc); } } // The alias has not changed if ($alias === $tagModel->alias) { continue; } // Initialize the version manager /** @var Versions $versions */ $versions = $this->framework->createInstance(Versions::class, [$dc->table, $tagModel->id]); $versions->initialize(); // Store the new alias $this->db->update($dc->table, ['alias' => $alias], ['id' => $tagModel->id]); // Create a new version $versions->create(); } } $controllerAdapter->redirect($systemAdapter->getReferer()); } // Add the button $buttons['alias'] = \sprintf('<button type="submit" name="alias" id="alias" class="tl_submit" accesskey="a">%s</button> ', $GLOBALS['TL_LANG']['MSC']['aliasSelected']); return $buttons; }
php
public function addAliasButton(array $buttons, DataContainer $dc) { $request = $this->requestStack->getCurrentRequest(); // Generate the aliases if ('tl_select' === $request->request->get('FORM_SUBMIT') && $request->request->has('alias')) { $ids = $this->session->all()['CURRENT']['IDS']; /** * @var Controller * @var System $systemAdapter * @var TagModel $tagAdapter */ $controllerAdapter = $this->framework->getAdapter(Controller::class); $systemAdapter = $this->framework->getAdapter(System::class); $tagAdapter = $this->framework->getAdapter(TagModel::class); // Handle each model individually if (null !== ($tagModels = $tagAdapter->findMultipleByIds($ids))) { /** @var TagModel $tagModel */ foreach ($tagModels as $tagModel) { $dc->id = $tagModel->id; $dc->activeRecord = $tagModel; $alias = ''; // Generate new alias through save callbacks foreach ($GLOBALS['TL_DCA'][$dc->table]['fields']['alias']['save_callback'] as $callback) { if (\is_array($callback)) { $alias = $systemAdapter->importStatic($callback[0])->{$callback[1]}($alias, $dc); } elseif (\is_callable($callback)) { $alias = $callback($alias, $dc); } } // The alias has not changed if ($alias === $tagModel->alias) { continue; } // Initialize the version manager /** @var Versions $versions */ $versions = $this->framework->createInstance(Versions::class, [$dc->table, $tagModel->id]); $versions->initialize(); // Store the new alias $this->db->update($dc->table, ['alias' => $alias], ['id' => $tagModel->id]); // Create a new version $versions->create(); } } $controllerAdapter->redirect($systemAdapter->getReferer()); } // Add the button $buttons['alias'] = \sprintf('<button type="submit" name="alias" id="alias" class="tl_submit" accesskey="a">%s</button> ', $GLOBALS['TL_LANG']['MSC']['aliasSelected']); return $buttons; }
[ "public", "function", "addAliasButton", "(", "array", "$", "buttons", ",", "DataContainer", "$", "dc", ")", "{", "$", "request", "=", "$", "this", "->", "requestStack", "->", "getCurrentRequest", "(", ")", ";", "// Generate the aliases", "if", "(", "'tl_select'", "===", "$", "request", "->", "request", "->", "get", "(", "'FORM_SUBMIT'", ")", "&&", "$", "request", "->", "request", "->", "has", "(", "'alias'", ")", ")", "{", "$", "ids", "=", "$", "this", "->", "session", "->", "all", "(", ")", "[", "'CURRENT'", "]", "[", "'IDS'", "]", ";", "/**\n * @var Controller\n * @var System $systemAdapter\n * @var TagModel $tagAdapter\n */", "$", "controllerAdapter", "=", "$", "this", "->", "framework", "->", "getAdapter", "(", "Controller", "::", "class", ")", ";", "$", "systemAdapter", "=", "$", "this", "->", "framework", "->", "getAdapter", "(", "System", "::", "class", ")", ";", "$", "tagAdapter", "=", "$", "this", "->", "framework", "->", "getAdapter", "(", "TagModel", "::", "class", ")", ";", "// Handle each model individually", "if", "(", "null", "!==", "(", "$", "tagModels", "=", "$", "tagAdapter", "->", "findMultipleByIds", "(", "$", "ids", ")", ")", ")", "{", "/** @var TagModel $tagModel */", "foreach", "(", "$", "tagModels", "as", "$", "tagModel", ")", "{", "$", "dc", "->", "id", "=", "$", "tagModel", "->", "id", ";", "$", "dc", "->", "activeRecord", "=", "$", "tagModel", ";", "$", "alias", "=", "''", ";", "// Generate new alias through save callbacks", "foreach", "(", "$", "GLOBALS", "[", "'TL_DCA'", "]", "[", "$", "dc", "->", "table", "]", "[", "'fields'", "]", "[", "'alias'", "]", "[", "'save_callback'", "]", "as", "$", "callback", ")", "{", "if", "(", "\\", "is_array", "(", "$", "callback", ")", ")", "{", "$", "alias", "=", "$", "systemAdapter", "->", "importStatic", "(", "$", "callback", "[", "0", "]", ")", "->", "{", "$", "callback", "[", "1", "]", "}", "(", "$", "alias", ",", "$", "dc", ")", ";", "}", "elseif", "(", "\\", "is_callable", "(", "$", "callback", ")", ")", "{", "$", "alias", "=", "$", "callback", "(", "$", "alias", ",", "$", "dc", ")", ";", "}", "}", "// The alias has not changed", "if", "(", "$", "alias", "===", "$", "tagModel", "->", "alias", ")", "{", "continue", ";", "}", "// Initialize the version manager", "/** @var Versions $versions */", "$", "versions", "=", "$", "this", "->", "framework", "->", "createInstance", "(", "Versions", "::", "class", ",", "[", "$", "dc", "->", "table", ",", "$", "tagModel", "->", "id", "]", ")", ";", "$", "versions", "->", "initialize", "(", ")", ";", "// Store the new alias", "$", "this", "->", "db", "->", "update", "(", "$", "dc", "->", "table", ",", "[", "'alias'", "=>", "$", "alias", "]", ",", "[", "'id'", "=>", "$", "tagModel", "->", "id", "]", ")", ";", "// Create a new version", "$", "versions", "->", "create", "(", ")", ";", "}", "}", "$", "controllerAdapter", "->", "redirect", "(", "$", "systemAdapter", "->", "getReferer", "(", ")", ")", ";", "}", "// Add the button", "$", "buttons", "[", "'alias'", "]", "=", "\\", "sprintf", "(", "'<button type=\"submit\" name=\"alias\" id=\"alias\" class=\"tl_submit\" accesskey=\"a\">%s</button> '", ",", "$", "GLOBALS", "[", "'TL_LANG'", "]", "[", "'MSC'", "]", "[", "'aliasSelected'", "]", ")", ";", "return", "$", "buttons", ";", "}" ]
Automatically generate the folder URL aliases. @param array $buttons @param DataContainer $dc @return array
[ "Automatically", "generate", "the", "folder", "URL", "aliases", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/EventListener/DataContainer/TagListener.php#L220-L280
222,454
php-soft/laravel-users
packages/Users/Models/RoutePermission.php
RoutePermission.setRoutePermissionsRoles
public static function setRoutePermissionsRoles($route, $permissions = [], $roles = []) { $routePermission = parent::firstOrNew(['route' => $route]); if (count($permissions)) { $routePermission->permissions = json_encode($permissions); } if (count($roles)) { $routePermission->roles = json_encode($roles); } $routePermission->save(); return $routePermission; }
php
public static function setRoutePermissionsRoles($route, $permissions = [], $roles = []) { $routePermission = parent::firstOrNew(['route' => $route]); if (count($permissions)) { $routePermission->permissions = json_encode($permissions); } if (count($roles)) { $routePermission->roles = json_encode($roles); } $routePermission->save(); return $routePermission; }
[ "public", "static", "function", "setRoutePermissionsRoles", "(", "$", "route", ",", "$", "permissions", "=", "[", "]", ",", "$", "roles", "=", "[", "]", ")", "{", "$", "routePermission", "=", "parent", "::", "firstOrNew", "(", "[", "'route'", "=>", "$", "route", "]", ")", ";", "if", "(", "count", "(", "$", "permissions", ")", ")", "{", "$", "routePermission", "->", "permissions", "=", "json_encode", "(", "$", "permissions", ")", ";", "}", "if", "(", "count", "(", "$", "roles", ")", ")", "{", "$", "routePermission", "->", "roles", "=", "json_encode", "(", "$", "roles", ")", ";", "}", "$", "routePermission", "->", "save", "(", ")", ";", "return", "$", "routePermission", ";", "}" ]
Set route permissions and roles @param string @param array
[ "Set", "route", "permissions", "and", "roles" ]
cd8d696dbf7337002188576d8a143cbc19d86b40
https://github.com/php-soft/laravel-users/blob/cd8d696dbf7337002188576d8a143cbc19d86b40/packages/Users/Models/RoutePermission.php#L52-L66
222,455
php-soft/laravel-users
packages/Users/Models/RoutePermission.php
RoutePermission.getRoutePermissionsRoles
public static function getRoutePermissionsRoles($route) { $routePermission = parent::where('route', $route)->first(); if (empty($routePermission)) { return null; } $routePermission->permissions = json_decode($routePermission->permissions); $routePermission->roles = json_decode($routePermission->roles); return $routePermission; }
php
public static function getRoutePermissionsRoles($route) { $routePermission = parent::where('route', $route)->first(); if (empty($routePermission)) { return null; } $routePermission->permissions = json_decode($routePermission->permissions); $routePermission->roles = json_decode($routePermission->roles); return $routePermission; }
[ "public", "static", "function", "getRoutePermissionsRoles", "(", "$", "route", ")", "{", "$", "routePermission", "=", "parent", "::", "where", "(", "'route'", ",", "$", "route", ")", "->", "first", "(", ")", ";", "if", "(", "empty", "(", "$", "routePermission", ")", ")", "{", "return", "null", ";", "}", "$", "routePermission", "->", "permissions", "=", "json_decode", "(", "$", "routePermission", "->", "permissions", ")", ";", "$", "routePermission", "->", "roles", "=", "json_decode", "(", "$", "routePermission", "->", "roles", ")", ";", "return", "$", "routePermission", ";", "}" ]
Get permissions and roles of an route @param string @return RoutePermission
[ "Get", "permissions", "and", "roles", "of", "an", "route" ]
cd8d696dbf7337002188576d8a143cbc19d86b40
https://github.com/php-soft/laravel-users/blob/cd8d696dbf7337002188576d8a143cbc19d86b40/packages/Users/Models/RoutePermission.php#L74-L83
222,456
php-soft/laravel-users
packages/Users/Models/RoutePermission.php
RoutePermission.browse
public static function browse($options = []) { $find = new RoutePermission(); $fillable = $find->fillable; if (!empty($options['filters'])) { $inFilters = array_intersect($fillable, array_keys($options['filters'])); if (!empty($inFilters)) { foreach ($inFilters as $key) { $find = ($options['filters'][$key] == null) ? $find : $find->where($key, 'LIKE', $options['filters'][$key]); } } } $total = $find->count(); if (!empty($options['order'])) { foreach ($options['order'] as $field => $direction) { if (in_array($field, $fillable)) { $find = $find->orderBy($field, $direction); } } } $find = $find->orderBy('id', 'DESC'); if (!empty($options['offset'])) { $find = $find->skip($options['offset']); } if (!empty($options['limit'])) { $find = $find->take($options['limit']); } return [ 'total' => $total, 'offset' => empty($options['offset']) ? 0 : $options['offset'], 'limit' => empty($options['limit']) ? 0 : $options['limit'], 'data' => $find->get(), ]; }
php
public static function browse($options = []) { $find = new RoutePermission(); $fillable = $find->fillable; if (!empty($options['filters'])) { $inFilters = array_intersect($fillable, array_keys($options['filters'])); if (!empty($inFilters)) { foreach ($inFilters as $key) { $find = ($options['filters'][$key] == null) ? $find : $find->where($key, 'LIKE', $options['filters'][$key]); } } } $total = $find->count(); if (!empty($options['order'])) { foreach ($options['order'] as $field => $direction) { if (in_array($field, $fillable)) { $find = $find->orderBy($field, $direction); } } } $find = $find->orderBy('id', 'DESC'); if (!empty($options['offset'])) { $find = $find->skip($options['offset']); } if (!empty($options['limit'])) { $find = $find->take($options['limit']); } return [ 'total' => $total, 'offset' => empty($options['offset']) ? 0 : $options['offset'], 'limit' => empty($options['limit']) ? 0 : $options['limit'], 'data' => $find->get(), ]; }
[ "public", "static", "function", "browse", "(", "$", "options", "=", "[", "]", ")", "{", "$", "find", "=", "new", "RoutePermission", "(", ")", ";", "$", "fillable", "=", "$", "find", "->", "fillable", ";", "if", "(", "!", "empty", "(", "$", "options", "[", "'filters'", "]", ")", ")", "{", "$", "inFilters", "=", "array_intersect", "(", "$", "fillable", ",", "array_keys", "(", "$", "options", "[", "'filters'", "]", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "inFilters", ")", ")", "{", "foreach", "(", "$", "inFilters", "as", "$", "key", ")", "{", "$", "find", "=", "(", "$", "options", "[", "'filters'", "]", "[", "$", "key", "]", "==", "null", ")", "?", "$", "find", ":", "$", "find", "->", "where", "(", "$", "key", ",", "'LIKE'", ",", "$", "options", "[", "'filters'", "]", "[", "$", "key", "]", ")", ";", "}", "}", "}", "$", "total", "=", "$", "find", "->", "count", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "options", "[", "'order'", "]", ")", ")", "{", "foreach", "(", "$", "options", "[", "'order'", "]", "as", "$", "field", "=>", "$", "direction", ")", "{", "if", "(", "in_array", "(", "$", "field", ",", "$", "fillable", ")", ")", "{", "$", "find", "=", "$", "find", "->", "orderBy", "(", "$", "field", ",", "$", "direction", ")", ";", "}", "}", "}", "$", "find", "=", "$", "find", "->", "orderBy", "(", "'id'", ",", "'DESC'", ")", ";", "if", "(", "!", "empty", "(", "$", "options", "[", "'offset'", "]", ")", ")", "{", "$", "find", "=", "$", "find", "->", "skip", "(", "$", "options", "[", "'offset'", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "options", "[", "'limit'", "]", ")", ")", "{", "$", "find", "=", "$", "find", "->", "take", "(", "$", "options", "[", "'limit'", "]", ")", ";", "}", "return", "[", "'total'", "=>", "$", "total", ",", "'offset'", "=>", "empty", "(", "$", "options", "[", "'offset'", "]", ")", "?", "0", ":", "$", "options", "[", "'offset'", "]", ",", "'limit'", "=>", "empty", "(", "$", "options", "[", "'limit'", "]", ")", "?", "0", ":", "$", "options", "[", "'limit'", "]", ",", "'data'", "=>", "$", "find", "->", "get", "(", ")", ",", "]", ";", "}" ]
List permissions and roles of all route @param array $options @return array
[ "List", "permissions", "and", "roles", "of", "all", "route" ]
cd8d696dbf7337002188576d8a143cbc19d86b40
https://github.com/php-soft/laravel-users/blob/cd8d696dbf7337002188576d8a143cbc19d86b40/packages/Users/Models/RoutePermission.php#L106-L147
222,457
codefog/tags-bundle
src/Manager/DefaultManager.php
DefaultManager.findByAlias
public function findByAlias(string $alias): ?Tag { /** @var TagModel $adapter */ $adapter = $this->framework->getAdapter(TagModel::class); $criteria = $this->getCriteria(); $criteria['alias'] = $alias; if (null === ($model = $adapter->findOneByCriteria($criteria))) { return null; } return ModelCollection::createTagFromModel($model); }
php
public function findByAlias(string $alias): ?Tag { /** @var TagModel $adapter */ $adapter = $this->framework->getAdapter(TagModel::class); $criteria = $this->getCriteria(); $criteria['alias'] = $alias; if (null === ($model = $adapter->findOneByCriteria($criteria))) { return null; } return ModelCollection::createTagFromModel($model); }
[ "public", "function", "findByAlias", "(", "string", "$", "alias", ")", ":", "?", "Tag", "{", "/** @var TagModel $adapter */", "$", "adapter", "=", "$", "this", "->", "framework", "->", "getAdapter", "(", "TagModel", "::", "class", ")", ";", "$", "criteria", "=", "$", "this", "->", "getCriteria", "(", ")", ";", "$", "criteria", "[", "'alias'", "]", "=", "$", "alias", ";", "if", "(", "null", "===", "(", "$", "model", "=", "$", "adapter", "->", "findOneByCriteria", "(", "$", "criteria", ")", ")", ")", "{", "return", "null", ";", "}", "return", "ModelCollection", "::", "createTagFromModel", "(", "$", "model", ")", ";", "}" ]
Find the tag by alias. @param string $alias @return Tag|null
[ "Find", "the", "tag", "by", "alias", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/Manager/DefaultManager.php#L112-L125
222,458
codefog/tags-bundle
src/Manager/DefaultManager.php
DefaultManager.findRelatedSourceRecords
public function findRelatedSourceRecords(int $sourceId, int $limit = null): array { /** @var Relations $relations */ $relations = $this->framework->getAdapter(Relations::class); if (false === ($relation = $relations->getRelation($this->sourceTable, $this->sourceField))) { throw new \RuntimeException(\sprintf('The field %s.%s is not related', $this->sourceTable, $this->sourceField)); } /** @var Model $relationsModel */ $relationsModel = $this->framework->getAdapter(Model::class); $tagIds = $relationsModel->getRelatedValues($this->sourceTable, $this->sourceField, $sourceId); $tagIds = \array_values(\array_unique($tagIds)); $tagIds = \array_map('intval', $tagIds); // Return if there are no tags if (0 === \count($tagIds)) { return []; } $query = \sprintf( 'SELECT %s, COUNT(*) AS relevance FROM %s WHERE %s IN (%s) AND %s != ? GROUP BY %s ORDER BY relevance DESC', $relation['reference_field'], $relation['table'], $relation['related_field'], \implode(',', $tagIds), $relation['reference_field'], $relation['reference_field'] ); // Set the limit if ($limit > 0) { $query .= \sprintf(' LIMIT %s', $limit); } $related = []; // Generate the related records foreach ($this->db->fetchAll($query, [$sourceId]) as $record) { $related[$record[$relation['reference_field']]] = [ 'total' => \count($tagIds), 'found' => $record['relevance'], 'prcnt' => ($record['relevance'] / \count($tagIds)) * 100, ]; } return $related; }
php
public function findRelatedSourceRecords(int $sourceId, int $limit = null): array { /** @var Relations $relations */ $relations = $this->framework->getAdapter(Relations::class); if (false === ($relation = $relations->getRelation($this->sourceTable, $this->sourceField))) { throw new \RuntimeException(\sprintf('The field %s.%s is not related', $this->sourceTable, $this->sourceField)); } /** @var Model $relationsModel */ $relationsModel = $this->framework->getAdapter(Model::class); $tagIds = $relationsModel->getRelatedValues($this->sourceTable, $this->sourceField, $sourceId); $tagIds = \array_values(\array_unique($tagIds)); $tagIds = \array_map('intval', $tagIds); // Return if there are no tags if (0 === \count($tagIds)) { return []; } $query = \sprintf( 'SELECT %s, COUNT(*) AS relevance FROM %s WHERE %s IN (%s) AND %s != ? GROUP BY %s ORDER BY relevance DESC', $relation['reference_field'], $relation['table'], $relation['related_field'], \implode(',', $tagIds), $relation['reference_field'], $relation['reference_field'] ); // Set the limit if ($limit > 0) { $query .= \sprintf(' LIMIT %s', $limit); } $related = []; // Generate the related records foreach ($this->db->fetchAll($query, [$sourceId]) as $record) { $related[$record[$relation['reference_field']]] = [ 'total' => \count($tagIds), 'found' => $record['relevance'], 'prcnt' => ($record['relevance'] / \count($tagIds)) * 100, ]; } return $related; }
[ "public", "function", "findRelatedSourceRecords", "(", "int", "$", "sourceId", ",", "int", "$", "limit", "=", "null", ")", ":", "array", "{", "/** @var Relations $relations */", "$", "relations", "=", "$", "this", "->", "framework", "->", "getAdapter", "(", "Relations", "::", "class", ")", ";", "if", "(", "false", "===", "(", "$", "relation", "=", "$", "relations", "->", "getRelation", "(", "$", "this", "->", "sourceTable", ",", "$", "this", "->", "sourceField", ")", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\\", "sprintf", "(", "'The field %s.%s is not related'", ",", "$", "this", "->", "sourceTable", ",", "$", "this", "->", "sourceField", ")", ")", ";", "}", "/** @var Model $relationsModel */", "$", "relationsModel", "=", "$", "this", "->", "framework", "->", "getAdapter", "(", "Model", "::", "class", ")", ";", "$", "tagIds", "=", "$", "relationsModel", "->", "getRelatedValues", "(", "$", "this", "->", "sourceTable", ",", "$", "this", "->", "sourceField", ",", "$", "sourceId", ")", ";", "$", "tagIds", "=", "\\", "array_values", "(", "\\", "array_unique", "(", "$", "tagIds", ")", ")", ";", "$", "tagIds", "=", "\\", "array_map", "(", "'intval'", ",", "$", "tagIds", ")", ";", "// Return if there are no tags", "if", "(", "0", "===", "\\", "count", "(", "$", "tagIds", ")", ")", "{", "return", "[", "]", ";", "}", "$", "query", "=", "\\", "sprintf", "(", "'SELECT %s, COUNT(*) AS relevance FROM %s WHERE %s IN (%s) AND %s != ? GROUP BY %s ORDER BY relevance DESC'", ",", "$", "relation", "[", "'reference_field'", "]", ",", "$", "relation", "[", "'table'", "]", ",", "$", "relation", "[", "'related_field'", "]", ",", "\\", "implode", "(", "','", ",", "$", "tagIds", ")", ",", "$", "relation", "[", "'reference_field'", "]", ",", "$", "relation", "[", "'reference_field'", "]", ")", ";", "// Set the limit", "if", "(", "$", "limit", ">", "0", ")", "{", "$", "query", ".=", "\\", "sprintf", "(", "' LIMIT %s'", ",", "$", "limit", ")", ";", "}", "$", "related", "=", "[", "]", ";", "// Generate the related records", "foreach", "(", "$", "this", "->", "db", "->", "fetchAll", "(", "$", "query", ",", "[", "$", "sourceId", "]", ")", "as", "$", "record", ")", "{", "$", "related", "[", "$", "record", "[", "$", "relation", "[", "'reference_field'", "]", "]", "]", "=", "[", "'total'", "=>", "\\", "count", "(", "$", "tagIds", ")", ",", "'found'", "=>", "$", "record", "[", "'relevance'", "]", ",", "'prcnt'", "=>", "(", "$", "record", "[", "'relevance'", "]", "/", "\\", "count", "(", "$", "tagIds", ")", ")", "*", "100", ",", "]", ";", "}", "return", "$", "related", ";", "}" ]
Find the related source records. @param int $sourceId @param int|null $limit @throws \RuntimeException @return array
[ "Find", "the", "related", "source", "records", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/Manager/DefaultManager.php#L137-L185
222,459
codefog/tags-bundle
src/Manager/DefaultManager.php
DefaultManager.getTopTagIds
public function getTopTagIds(array $sourceIds = [], int $limit = null, bool $withCount = false): array { /** @var Model $model */ $model = $this->framework->getAdapter(Model::class); $tagIds = $model->getRelatedValues($this->sourceTable, $this->sourceField, $sourceIds); $tagIds = \array_map('intval', $tagIds); if (0 === \count($tagIds)) { return []; } $helper = []; // Create the helper array with tag occurrences foreach ($tagIds as $tagId) { ++$helper[$tagId]; } // Sort the helper array descending \arsort($helper); // Strip the count data if (!$withCount) { $helper = \array_keys($helper); } return \array_slice($helper, 0, $limit, $withCount); }
php
public function getTopTagIds(array $sourceIds = [], int $limit = null, bool $withCount = false): array { /** @var Model $model */ $model = $this->framework->getAdapter(Model::class); $tagIds = $model->getRelatedValues($this->sourceTable, $this->sourceField, $sourceIds); $tagIds = \array_map('intval', $tagIds); if (0 === \count($tagIds)) { return []; } $helper = []; // Create the helper array with tag occurrences foreach ($tagIds as $tagId) { ++$helper[$tagId]; } // Sort the helper array descending \arsort($helper); // Strip the count data if (!$withCount) { $helper = \array_keys($helper); } return \array_slice($helper, 0, $limit, $withCount); }
[ "public", "function", "getTopTagIds", "(", "array", "$", "sourceIds", "=", "[", "]", ",", "int", "$", "limit", "=", "null", ",", "bool", "$", "withCount", "=", "false", ")", ":", "array", "{", "/** @var Model $model */", "$", "model", "=", "$", "this", "->", "framework", "->", "getAdapter", "(", "Model", "::", "class", ")", ";", "$", "tagIds", "=", "$", "model", "->", "getRelatedValues", "(", "$", "this", "->", "sourceTable", ",", "$", "this", "->", "sourceField", ",", "$", "sourceIds", ")", ";", "$", "tagIds", "=", "\\", "array_map", "(", "'intval'", ",", "$", "tagIds", ")", ";", "if", "(", "0", "===", "\\", "count", "(", "$", "tagIds", ")", ")", "{", "return", "[", "]", ";", "}", "$", "helper", "=", "[", "]", ";", "// Create the helper array with tag occurrences", "foreach", "(", "$", "tagIds", "as", "$", "tagId", ")", "{", "++", "$", "helper", "[", "$", "tagId", "]", ";", "}", "// Sort the helper array descending", "\\", "arsort", "(", "$", "helper", ")", ";", "// Strip the count data", "if", "(", "!", "$", "withCount", ")", "{", "$", "helper", "=", "\\", "array_keys", "(", "$", "helper", ")", ";", "}", "return", "\\", "array_slice", "(", "$", "helper", ",", "0", ",", "$", "limit", ",", "$", "withCount", ")", ";", "}" ]
Get the top tag IDs. @param array $sourceIds @param int|null $limit @param bool $withCount @return array
[ "Get", "the", "top", "tag", "IDs", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/Manager/DefaultManager.php#L196-L224
222,460
codefog/tags-bundle
src/Manager/DefaultManager.php
DefaultManager.createTag
protected function createTag(string $value): Tag { /** @var TagModel $model */ $model = $this->framework->createInstance(TagModel::class); $model->tstamp = \time(); $model->name = $value; $model->source = $this->alias; $model->save(); return ModelCollection::createTagFromModel($model); }
php
protected function createTag(string $value): Tag { /** @var TagModel $model */ $model = $this->framework->createInstance(TagModel::class); $model->tstamp = \time(); $model->name = $value; $model->source = $this->alias; $model->save(); return ModelCollection::createTagFromModel($model); }
[ "protected", "function", "createTag", "(", "string", "$", "value", ")", ":", "Tag", "{", "/** @var TagModel $model */", "$", "model", "=", "$", "this", "->", "framework", "->", "createInstance", "(", "TagModel", "::", "class", ")", ";", "$", "model", "->", "tstamp", "=", "\\", "time", "(", ")", ";", "$", "model", "->", "name", "=", "$", "value", ";", "$", "model", "->", "source", "=", "$", "this", "->", "alias", ";", "$", "model", "->", "save", "(", ")", ";", "return", "ModelCollection", "::", "createTagFromModel", "(", "$", "model", ")", ";", "}" ]
Create the tag. @param string $value @return Tag
[ "Create", "the", "tag", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/Manager/DefaultManager.php#L338-L348
222,461
codefog/tags-bundle
src/Manager/DefaultManager.php
DefaultManager.getCriteria
protected function getCriteria(array $criteria = []): array { $criteria['source'] = $this->alias; $criteria['sourceTable'] = $this->sourceTable; $criteria['sourceField'] = $this->sourceField; return $criteria; }
php
protected function getCriteria(array $criteria = []): array { $criteria['source'] = $this->alias; $criteria['sourceTable'] = $this->sourceTable; $criteria['sourceField'] = $this->sourceField; return $criteria; }
[ "protected", "function", "getCriteria", "(", "array", "$", "criteria", "=", "[", "]", ")", ":", "array", "{", "$", "criteria", "[", "'source'", "]", "=", "$", "this", "->", "alias", ";", "$", "criteria", "[", "'sourceTable'", "]", "=", "$", "this", "->", "sourceTable", ";", "$", "criteria", "[", "'sourceField'", "]", "=", "$", "this", "->", "sourceField", ";", "return", "$", "criteria", ";", "}" ]
Get the criteria with necessary data. @param array $criteria @return array
[ "Get", "the", "criteria", "with", "necessary", "data", "." ]
5fca40497b3a921c2cae28446753185adb240a5c
https://github.com/codefog/tags-bundle/blob/5fca40497b3a921c2cae28446753185adb240a5c/src/Manager/DefaultManager.php#L357-L364
222,462
ramsey/twig-codeblock
src/Highlighter/PygmentsHighlighter.php
PygmentsHighlighter.parseLexer
protected function parseLexer(array $options) { if (!empty($options['lang']) && strtolower($options['lang']) === 'plain') { return static::DEFAULT_LEXER; } if (!empty($options['lang'])) { return $options['lang']; } return static::DEFAULT_LEXER; }
php
protected function parseLexer(array $options) { if (!empty($options['lang']) && strtolower($options['lang']) === 'plain') { return static::DEFAULT_LEXER; } if (!empty($options['lang'])) { return $options['lang']; } return static::DEFAULT_LEXER; }
[ "protected", "function", "parseLexer", "(", "array", "$", "options", ")", "{", "if", "(", "!", "empty", "(", "$", "options", "[", "'lang'", "]", ")", "&&", "strtolower", "(", "$", "options", "[", "'lang'", "]", ")", "===", "'plain'", ")", "{", "return", "static", "::", "DEFAULT_LEXER", ";", "}", "if", "(", "!", "empty", "(", "$", "options", "[", "'lang'", "]", ")", ")", "{", "return", "$", "options", "[", "'lang'", "]", ";", "}", "return", "static", "::", "DEFAULT_LEXER", ";", "}" ]
Returns the programming language from the options @return string
[ "Returns", "the", "programming", "language", "from", "the", "options" ]
bf3a940af4c5d5a66b1e66e9464fccc29579b23f
https://github.com/ramsey/twig-codeblock/blob/bf3a940af4c5d5a66b1e66e9464fccc29579b23f/src/Highlighter/PygmentsHighlighter.php#L65-L76
222,463
ramsey/twig-codeblock
src/Highlighter/PygmentsHighlighter.php
PygmentsHighlighter.parsePygmentsOptions
protected function parsePygmentsOptions(array $options, $code) { $pygmentsOptions = ['encoding' => 'utf-8']; if (!empty($options['linenos']) && $options['linenos'] === true) { $pygmentsOptions['linenos'] = 'table'; } if (!empty($options['start'])) { $pygmentsOptions['linenostart'] = $options['start']; } if (!empty($options['mark'])) { $pygmentsOptions['hl_lines'] = $this->parseMarks($options['mark']); } if (!empty($options['lang']) && strtolower($options['lang']) === 'php' && stripos($code, '<?php') === false ) { $pygmentsOptions['startinline'] = 'True'; } return $pygmentsOptions; }
php
protected function parsePygmentsOptions(array $options, $code) { $pygmentsOptions = ['encoding' => 'utf-8']; if (!empty($options['linenos']) && $options['linenos'] === true) { $pygmentsOptions['linenos'] = 'table'; } if (!empty($options['start'])) { $pygmentsOptions['linenostart'] = $options['start']; } if (!empty($options['mark'])) { $pygmentsOptions['hl_lines'] = $this->parseMarks($options['mark']); } if (!empty($options['lang']) && strtolower($options['lang']) === 'php' && stripos($code, '<?php') === false ) { $pygmentsOptions['startinline'] = 'True'; } return $pygmentsOptions; }
[ "protected", "function", "parsePygmentsOptions", "(", "array", "$", "options", ",", "$", "code", ")", "{", "$", "pygmentsOptions", "=", "[", "'encoding'", "=>", "'utf-8'", "]", ";", "if", "(", "!", "empty", "(", "$", "options", "[", "'linenos'", "]", ")", "&&", "$", "options", "[", "'linenos'", "]", "===", "true", ")", "{", "$", "pygmentsOptions", "[", "'linenos'", "]", "=", "'table'", ";", "}", "if", "(", "!", "empty", "(", "$", "options", "[", "'start'", "]", ")", ")", "{", "$", "pygmentsOptions", "[", "'linenostart'", "]", "=", "$", "options", "[", "'start'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "options", "[", "'mark'", "]", ")", ")", "{", "$", "pygmentsOptions", "[", "'hl_lines'", "]", "=", "$", "this", "->", "parseMarks", "(", "$", "options", "[", "'mark'", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "options", "[", "'lang'", "]", ")", "&&", "strtolower", "(", "$", "options", "[", "'lang'", "]", ")", "===", "'php'", "&&", "stripos", "(", "$", "code", ",", "'<?php'", ")", "===", "false", ")", "{", "$", "pygmentsOptions", "[", "'startinline'", "]", "=", "'True'", ";", "}", "return", "$", "pygmentsOptions", ";", "}" ]
Returns an array of options formatted for use with pygmentize @param array $options Options passed to the highlighter @param string $code The code to highlight @return array
[ "Returns", "an", "array", "of", "options", "formatted", "for", "use", "with", "pygmentize" ]
bf3a940af4c5d5a66b1e66e9464fccc29579b23f
https://github.com/ramsey/twig-codeblock/blob/bf3a940af4c5d5a66b1e66e9464fccc29579b23f/src/Highlighter/PygmentsHighlighter.php#L85-L109
222,464
ramsey/twig-codeblock
src/Highlighter/PygmentsHighlighter.php
PygmentsHighlighter.parseMarks
protected function parseMarks($marks) { $markedLines = []; foreach (explode(',', $marks) as $nums) { if (strpos($nums, '-') !== false) { list($from, $to) = explode('-', $nums); $markedLines = array_merge($markedLines, range($from, $to)); } else { $markedLines[] = $nums; } } return implode(' ', $markedLines); }
php
protected function parseMarks($marks) { $markedLines = []; foreach (explode(',', $marks) as $nums) { if (strpos($nums, '-') !== false) { list($from, $to) = explode('-', $nums); $markedLines = array_merge($markedLines, range($from, $to)); } else { $markedLines[] = $nums; } } return implode(' ', $markedLines); }
[ "protected", "function", "parseMarks", "(", "$", "marks", ")", "{", "$", "markedLines", "=", "[", "]", ";", "foreach", "(", "explode", "(", "','", ",", "$", "marks", ")", "as", "$", "nums", ")", "{", "if", "(", "strpos", "(", "$", "nums", ",", "'-'", ")", "!==", "false", ")", "{", "list", "(", "$", "from", ",", "$", "to", ")", "=", "explode", "(", "'-'", ",", "$", "nums", ")", ";", "$", "markedLines", "=", "array_merge", "(", "$", "markedLines", ",", "range", "(", "$", "from", ",", "$", "to", ")", ")", ";", "}", "else", "{", "$", "markedLines", "[", "]", "=", "$", "nums", ";", "}", "}", "return", "implode", "(", "' '", ",", "$", "markedLines", ")", ";", "}" ]
Parses the marked lines in a way that pygmentize can use @param string $marks The marks received from the codeblock @return string
[ "Parses", "the", "marked", "lines", "in", "a", "way", "that", "pygmentize", "can", "use" ]
bf3a940af4c5d5a66b1e66e9464fccc29579b23f
https://github.com/ramsey/twig-codeblock/blob/bf3a940af4c5d5a66b1e66e9464fccc29579b23f/src/Highlighter/PygmentsHighlighter.php#L117-L131
222,465
contao-bootstrap/grid
src/Listener/Dca/FormListener.php
FormListener.generateColumns
public function generateColumns($value, $dataContainer) { if (!$dataContainer->activeRecord) { return null; } /** @var FormModel|Result $current */ $current = $dataContainer->activeRecord; if ($value && $dataContainer->activeRecord) { $stopElement = $this->getStopElement($current); $nextElements = $this->getNextElements($stopElement); $sorting = $stopElement->sorting; $sorting = $this->createSeparators($value, $current, $sorting); array_unshift($nextElements, $stopElement); $this->updateSortings($nextElements, $sorting); } return null; }
php
public function generateColumns($value, $dataContainer) { if (!$dataContainer->activeRecord) { return null; } /** @var FormModel|Result $current */ $current = $dataContainer->activeRecord; if ($value && $dataContainer->activeRecord) { $stopElement = $this->getStopElement($current); $nextElements = $this->getNextElements($stopElement); $sorting = $stopElement->sorting; $sorting = $this->createSeparators($value, $current, $sorting); array_unshift($nextElements, $stopElement); $this->updateSortings($nextElements, $sorting); } return null; }
[ "public", "function", "generateColumns", "(", "$", "value", ",", "$", "dataContainer", ")", "{", "if", "(", "!", "$", "dataContainer", "->", "activeRecord", ")", "{", "return", "null", ";", "}", "/** @var FormModel|Result $current */", "$", "current", "=", "$", "dataContainer", "->", "activeRecord", ";", "if", "(", "$", "value", "&&", "$", "dataContainer", "->", "activeRecord", ")", "{", "$", "stopElement", "=", "$", "this", "->", "getStopElement", "(", "$", "current", ")", ";", "$", "nextElements", "=", "$", "this", "->", "getNextElements", "(", "$", "stopElement", ")", ";", "$", "sorting", "=", "$", "stopElement", "->", "sorting", ";", "$", "sorting", "=", "$", "this", "->", "createSeparators", "(", "$", "value", ",", "$", "current", ",", "$", "sorting", ")", ";", "array_unshift", "(", "$", "nextElements", ",", "$", "stopElement", ")", ";", "$", "this", "->", "updateSortings", "(", "$", "nextElements", ",", "$", "sorting", ")", ";", "}", "return", "null", ";", "}" ]
Generate the columns. @param int $value Number of columns which should be generated. @param DataContainer $dataContainer Data container driver. @return null @SuppressWarnings(PHPMD.UnusedFormalParameters)
[ "Generate", "the", "columns", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Listener/Dca/FormListener.php#L39-L60
222,466
contao-bootstrap/grid
src/Definition/Grid.php
Grid.addClass
public function addClass(string $class): self { $classes = explode(' ', $class); foreach ($classes as $class) { if (!in_array($class, $this->rowClasses)) { $this->rowClasses[] = $class; } } return $this; }
php
public function addClass(string $class): self { $classes = explode(' ', $class); foreach ($classes as $class) { if (!in_array($class, $this->rowClasses)) { $this->rowClasses[] = $class; } } return $this; }
[ "public", "function", "addClass", "(", "string", "$", "class", ")", ":", "self", "{", "$", "classes", "=", "explode", "(", "' '", ",", "$", "class", ")", ";", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "if", "(", "!", "in_array", "(", "$", "class", ",", "$", "this", "->", "rowClasses", ")", ")", "{", "$", "this", "->", "rowClasses", "[", "]", "=", "$", "class", ";", "}", "}", "return", "$", "this", ";", "}" ]
Add a class to the row. @param string $class Row class. @return Grid
[ "Add", "a", "class", "to", "the", "row", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Definition/Grid.php#L114-L125
222,467
contao-bootstrap/grid
src/Definition/Grid.php
Grid.buildResets
public function buildResets(int $index): array { $resets = []; foreach ($this->columns as $size => $columns) { $column = $this->getColumnByIndex($columns, $index); if ($column) { $resets = $column->buildReset($resets, $size); } } return $resets; }
php
public function buildResets(int $index): array { $resets = []; foreach ($this->columns as $size => $columns) { $column = $this->getColumnByIndex($columns, $index); if ($column) { $resets = $column->buildReset($resets, $size); } } return $resets; }
[ "public", "function", "buildResets", "(", "int", "$", "index", ")", ":", "array", "{", "$", "resets", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "columns", "as", "$", "size", "=>", "$", "columns", ")", "{", "$", "column", "=", "$", "this", "->", "getColumnByIndex", "(", "$", "columns", ",", "$", "index", ")", ";", "if", "(", "$", "column", ")", "{", "$", "resets", "=", "$", "column", "->", "buildReset", "(", "$", "resets", ",", "$", "size", ")", ";", "}", "}", "return", "$", "resets", ";", "}" ]
Build reset classes. @param int $index Column index. @return array
[ "Build", "reset", "classes", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Definition/Grid.php#L192-L205
222,468
contao-bootstrap/grid
src/Definition/Grid.php
Grid.getColumnByIndex
private function getColumnByIndex(array $columns, int $index):? Column { $currentIndex = $index; if (!array_key_exists($currentIndex, $columns) && $currentIndex > 0) { $currentIndex = ($currentIndex % count($columns)); } if (array_key_exists($currentIndex, $columns)) { return $columns[$currentIndex]; } return null; }
php
private function getColumnByIndex(array $columns, int $index):? Column { $currentIndex = $index; if (!array_key_exists($currentIndex, $columns) && $currentIndex > 0) { $currentIndex = ($currentIndex % count($columns)); } if (array_key_exists($currentIndex, $columns)) { return $columns[$currentIndex]; } return null; }
[ "private", "function", "getColumnByIndex", "(", "array", "$", "columns", ",", "int", "$", "index", ")", ":", "?", "Column", "{", "$", "currentIndex", "=", "$", "index", ";", "if", "(", "!", "array_key_exists", "(", "$", "currentIndex", ",", "$", "columns", ")", "&&", "$", "currentIndex", ">", "0", ")", "{", "$", "currentIndex", "=", "(", "$", "currentIndex", "%", "count", "(", "$", "columns", ")", ")", ";", "}", "if", "(", "array_key_exists", "(", "$", "currentIndex", ",", "$", "columns", ")", ")", "{", "return", "$", "columns", "[", "$", "currentIndex", "]", ";", "}", "return", "null", ";", "}" ]
Get a column by index. @param Column[] $columns Column. @param int $index Column index. @return null|Column
[ "Get", "a", "column", "by", "index", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Definition/Grid.php#L215-L228
222,469
contao-bootstrap/grid
src/Listener/Dca/AbstractWrapperDcaListener.php
AbstractWrapperDcaListener.createSeparators
protected function createSeparators(int $value, $current, int $sorting): int { for ($count = 1; $count <= $value; $count++) { $sorting = ($sorting + 8); $this->createGridElement($current, 'bs_gridSeparator', $sorting); } return $sorting; }
php
protected function createSeparators(int $value, $current, int $sorting): int { for ($count = 1; $count <= $value; $count++) { $sorting = ($sorting + 8); $this->createGridElement($current, 'bs_gridSeparator', $sorting); } return $sorting; }
[ "protected", "function", "createSeparators", "(", "int", "$", "value", ",", "$", "current", ",", "int", "$", "sorting", ")", ":", "int", "{", "for", "(", "$", "count", "=", "1", ";", "$", "count", "<=", "$", "value", ";", "$", "count", "++", ")", "{", "$", "sorting", "=", "(", "$", "sorting", "+", "8", ")", ";", "$", "this", "->", "createGridElement", "(", "$", "current", ",", "'bs_gridSeparator'", ",", "$", "sorting", ")", ";", "}", "return", "$", "sorting", ";", "}" ]
Create separators. @param int $value Number of separators being created. @param Model $current Current model. @param int $sorting Current sorting value. @return int
[ "Create", "separators", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Listener/Dca/AbstractWrapperDcaListener.php#L74-L82
222,470
contao-bootstrap/grid
src/Listener/Dca/AbstractWrapperDcaListener.php
AbstractWrapperDcaListener.updateSortings
protected function updateSortings(array $elements, int $lastSorting): int { foreach ($elements as $element) { if ($lastSorting > $element->sorting) { $element->sorting = ($lastSorting + 8); $element->save(); } $lastSorting = (int) $element->sorting; } return $lastSorting; }
php
protected function updateSortings(array $elements, int $lastSorting): int { foreach ($elements as $element) { if ($lastSorting > $element->sorting) { $element->sorting = ($lastSorting + 8); $element->save(); } $lastSorting = (int) $element->sorting; } return $lastSorting; }
[ "protected", "function", "updateSortings", "(", "array", "$", "elements", ",", "int", "$", "lastSorting", ")", ":", "int", "{", "foreach", "(", "$", "elements", "as", "$", "element", ")", "{", "if", "(", "$", "lastSorting", ">", "$", "element", "->", "sorting", ")", "{", "$", "element", "->", "sorting", "=", "(", "$", "lastSorting", "+", "8", ")", ";", "$", "element", "->", "save", "(", ")", ";", "}", "$", "lastSorting", "=", "(", "int", ")", "$", "element", "->", "sorting", ";", "}", "return", "$", "lastSorting", ";", "}" ]
Update the sorting of given elements. @param Model[] $elements Model collection. @param int $lastSorting Last sorting value. @return int
[ "Update", "the", "sorting", "of", "given", "elements", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Listener/Dca/AbstractWrapperDcaListener.php#L92-L104
222,471
contao-bootstrap/grid
src/Listener/Dca/AbstractWrapperDcaListener.php
AbstractWrapperDcaListener.createStopElement
protected function createStopElement($current, int $sorting): Model { $sorting = ($sorting + 8); return $this->createGridElement($current, 'bs_gridStop', $sorting); }
php
protected function createStopElement($current, int $sorting): Model { $sorting = ($sorting + 8); return $this->createGridElement($current, 'bs_gridStop', $sorting); }
[ "protected", "function", "createStopElement", "(", "$", "current", ",", "int", "$", "sorting", ")", ":", "Model", "{", "$", "sorting", "=", "(", "$", "sorting", "+", "8", ")", ";", "return", "$", "this", "->", "createGridElement", "(", "$", "current", ",", "'bs_gridStop'", ",", "$", "sorting", ")", ";", "}" ]
Create the stop element. @param Model $current Model. @param int $sorting Last sorting value. @return Model
[ "Create", "the", "stop", "element", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Listener/Dca/AbstractWrapperDcaListener.php#L114-L119
222,472
shiftonelabs/laravel-cascade-deletes
src/CascadesDeletes.php
CascadesDeletes.bootCascadesDeletes
public static function bootCascadesDeletes() { // Setup the 'deleting' event listener. static::deleting(function ($model) { // Wrap all of the cascading deletes inside of a transaction to make this an // all or nothing operation. Any exceptions thrown inside the transaction // need to bubble up to make sure all transactions will be rolled back. $model->getConnectionResolver()->transaction(function () use ($model) { $relations = $model->getCascadeDeletesRelations(); if ($invalidRelations = $model->getInvalidCascadeDeletesRelations($relations)) { throw new LogicException(sprintf('[%s]: invalid relationship(s) for cascading deletes. Relationship method(s) [%s] must return an object of type Illuminate\Database\Eloquent\Relations\Relation.', static::class, implode(', ', $invalidRelations))); } $deleteMethod = $model->isCascadeDeletesForceDeleting() ? 'forceDelete' : 'delete'; foreach ($relations as $relationName => $relation) { $expected = 0; $deleted = 0; if ($relation instanceof BelongsToMany) { // Process the many-to-many relationships on the model. // These relationships should not delete the related // record, but should just detach from each other. $expected = $model->getCascadeDeletesRelationQuery($relationName)->count(); $deleted = $model->getCascadeDeletesRelationQuery($relationName)->detach(); } elseif ($relation instanceof HasOneOrMany) { // Process the one-to-one and one-to-many relationships // on the model. These relationships should actually // delete the related records from the database. $children = $model->getCascadeDeletesRelationQuery($relationName)->get(); // To protect against potential relationship defaults, // filter out any children that may not actually be // Model instances, or that don't actually exist. $children = $children->filter(function ($child) { return $child instanceof Model && $child->exists; })->all(); $expected = count($children); foreach ($children as $child) { // Delete the record using the proper method. $child->$deleteMethod(); // forceDelete doesn't return anything until Laravel 5.2. Check // exists property to determine if the delete was successful // since that is the last thing set before delete returns. $deleted += !$child->exists; } } else { // Not all relationship types make sense for cascading. As an // example, for a BelongsTo relationship, it does not make // sense to delete the parent when the child is deleted. throw new LogicException(sprintf('[%s]: error occurred deleting [%s]. Relation type [%s] not handled.', static::class, $relationName, get_class($relation))); } if ($deleted < $expected) { throw new LogicException(sprintf('[%s]: error occurred deleting [%s]. Only deleted [%d] out of [%d] records.', static::class, $relationName, $deleted, $expected)); } } }); }); }
php
public static function bootCascadesDeletes() { // Setup the 'deleting' event listener. static::deleting(function ($model) { // Wrap all of the cascading deletes inside of a transaction to make this an // all or nothing operation. Any exceptions thrown inside the transaction // need to bubble up to make sure all transactions will be rolled back. $model->getConnectionResolver()->transaction(function () use ($model) { $relations = $model->getCascadeDeletesRelations(); if ($invalidRelations = $model->getInvalidCascadeDeletesRelations($relations)) { throw new LogicException(sprintf('[%s]: invalid relationship(s) for cascading deletes. Relationship method(s) [%s] must return an object of type Illuminate\Database\Eloquent\Relations\Relation.', static::class, implode(', ', $invalidRelations))); } $deleteMethod = $model->isCascadeDeletesForceDeleting() ? 'forceDelete' : 'delete'; foreach ($relations as $relationName => $relation) { $expected = 0; $deleted = 0; if ($relation instanceof BelongsToMany) { // Process the many-to-many relationships on the model. // These relationships should not delete the related // record, but should just detach from each other. $expected = $model->getCascadeDeletesRelationQuery($relationName)->count(); $deleted = $model->getCascadeDeletesRelationQuery($relationName)->detach(); } elseif ($relation instanceof HasOneOrMany) { // Process the one-to-one and one-to-many relationships // on the model. These relationships should actually // delete the related records from the database. $children = $model->getCascadeDeletesRelationQuery($relationName)->get(); // To protect against potential relationship defaults, // filter out any children that may not actually be // Model instances, or that don't actually exist. $children = $children->filter(function ($child) { return $child instanceof Model && $child->exists; })->all(); $expected = count($children); foreach ($children as $child) { // Delete the record using the proper method. $child->$deleteMethod(); // forceDelete doesn't return anything until Laravel 5.2. Check // exists property to determine if the delete was successful // since that is the last thing set before delete returns. $deleted += !$child->exists; } } else { // Not all relationship types make sense for cascading. As an // example, for a BelongsTo relationship, it does not make // sense to delete the parent when the child is deleted. throw new LogicException(sprintf('[%s]: error occurred deleting [%s]. Relation type [%s] not handled.', static::class, $relationName, get_class($relation))); } if ($deleted < $expected) { throw new LogicException(sprintf('[%s]: error occurred deleting [%s]. Only deleted [%d] out of [%d] records.', static::class, $relationName, $deleted, $expected)); } } }); }); }
[ "public", "static", "function", "bootCascadesDeletes", "(", ")", "{", "// Setup the 'deleting' event listener.", "static", "::", "deleting", "(", "function", "(", "$", "model", ")", "{", "// Wrap all of the cascading deletes inside of a transaction to make this an", "// all or nothing operation. Any exceptions thrown inside the transaction", "// need to bubble up to make sure all transactions will be rolled back.", "$", "model", "->", "getConnectionResolver", "(", ")", "->", "transaction", "(", "function", "(", ")", "use", "(", "$", "model", ")", "{", "$", "relations", "=", "$", "model", "->", "getCascadeDeletesRelations", "(", ")", ";", "if", "(", "$", "invalidRelations", "=", "$", "model", "->", "getInvalidCascadeDeletesRelations", "(", "$", "relations", ")", ")", "{", "throw", "new", "LogicException", "(", "sprintf", "(", "'[%s]: invalid relationship(s) for cascading deletes. Relationship method(s) [%s] must return an object of type Illuminate\\Database\\Eloquent\\Relations\\Relation.'", ",", "static", "::", "class", ",", "implode", "(", "', '", ",", "$", "invalidRelations", ")", ")", ")", ";", "}", "$", "deleteMethod", "=", "$", "model", "->", "isCascadeDeletesForceDeleting", "(", ")", "?", "'forceDelete'", ":", "'delete'", ";", "foreach", "(", "$", "relations", "as", "$", "relationName", "=>", "$", "relation", ")", "{", "$", "expected", "=", "0", ";", "$", "deleted", "=", "0", ";", "if", "(", "$", "relation", "instanceof", "BelongsToMany", ")", "{", "// Process the many-to-many relationships on the model.", "// These relationships should not delete the related", "// record, but should just detach from each other.", "$", "expected", "=", "$", "model", "->", "getCascadeDeletesRelationQuery", "(", "$", "relationName", ")", "->", "count", "(", ")", ";", "$", "deleted", "=", "$", "model", "->", "getCascadeDeletesRelationQuery", "(", "$", "relationName", ")", "->", "detach", "(", ")", ";", "}", "elseif", "(", "$", "relation", "instanceof", "HasOneOrMany", ")", "{", "// Process the one-to-one and one-to-many relationships", "// on the model. These relationships should actually", "// delete the related records from the database.", "$", "children", "=", "$", "model", "->", "getCascadeDeletesRelationQuery", "(", "$", "relationName", ")", "->", "get", "(", ")", ";", "// To protect against potential relationship defaults,", "// filter out any children that may not actually be", "// Model instances, or that don't actually exist.", "$", "children", "=", "$", "children", "->", "filter", "(", "function", "(", "$", "child", ")", "{", "return", "$", "child", "instanceof", "Model", "&&", "$", "child", "->", "exists", ";", "}", ")", "->", "all", "(", ")", ";", "$", "expected", "=", "count", "(", "$", "children", ")", ";", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "// Delete the record using the proper method.", "$", "child", "->", "$", "deleteMethod", "(", ")", ";", "// forceDelete doesn't return anything until Laravel 5.2. Check", "// exists property to determine if the delete was successful", "// since that is the last thing set before delete returns.", "$", "deleted", "+=", "!", "$", "child", "->", "exists", ";", "}", "}", "else", "{", "// Not all relationship types make sense for cascading. As an", "// example, for a BelongsTo relationship, it does not make", "// sense to delete the parent when the child is deleted.", "throw", "new", "LogicException", "(", "sprintf", "(", "'[%s]: error occurred deleting [%s]. Relation type [%s] not handled.'", ",", "static", "::", "class", ",", "$", "relationName", ",", "get_class", "(", "$", "relation", ")", ")", ")", ";", "}", "if", "(", "$", "deleted", "<", "$", "expected", ")", "{", "throw", "new", "LogicException", "(", "sprintf", "(", "'[%s]: error occurred deleting [%s]. Only deleted [%d] out of [%d] records.'", ",", "static", "::", "class", ",", "$", "relationName", ",", "$", "deleted", ",", "$", "expected", ")", ")", ";", "}", "}", "}", ")", ";", "}", ")", ";", "}" ]
Use the boot function to setup model event listeners. @return void
[ "Use", "the", "boot", "function", "to", "setup", "model", "event", "listeners", "." ]
4302f0ecb7c0a166b9c4977cfbc10fe6ebedff0a
https://github.com/shiftonelabs/laravel-cascade-deletes/blob/4302f0ecb7c0a166b9c4977cfbc10fe6ebedff0a/src/CascadesDeletes.php#L19-L87
222,473
shiftonelabs/laravel-cascade-deletes
src/CascadesDeletes.php
CascadesDeletes.getCascadeDeletesRelations
public function getCascadeDeletesRelations() { $names = $this->getCascadeDeletesRelationNames(); return array_combine($names, array_map(function ($name) { $relation = method_exists($this, $name) ? $this->$name() : null; return $relation instanceof Relation ? $relation : null; }, $names)); }
php
public function getCascadeDeletesRelations() { $names = $this->getCascadeDeletesRelationNames(); return array_combine($names, array_map(function ($name) { $relation = method_exists($this, $name) ? $this->$name() : null; return $relation instanceof Relation ? $relation : null; }, $names)); }
[ "public", "function", "getCascadeDeletesRelations", "(", ")", "{", "$", "names", "=", "$", "this", "->", "getCascadeDeletesRelationNames", "(", ")", ";", "return", "array_combine", "(", "$", "names", ",", "array_map", "(", "function", "(", "$", "name", ")", "{", "$", "relation", "=", "method_exists", "(", "$", "this", ",", "$", "name", ")", "?", "$", "this", "->", "$", "name", "(", ")", ":", "null", ";", "return", "$", "relation", "instanceof", "Relation", "?", "$", "relation", ":", "null", ";", "}", ",", "$", "names", ")", ")", ";", "}" ]
Get an array of the cascading relation names mapped to their relation types. @return array
[ "Get", "an", "array", "of", "the", "cascading", "relation", "names", "mapped", "to", "their", "relation", "types", "." ]
4302f0ecb7c0a166b9c4977cfbc10fe6ebedff0a
https://github.com/shiftonelabs/laravel-cascade-deletes/blob/4302f0ecb7c0a166b9c4977cfbc10fe6ebedff0a/src/CascadesDeletes.php#L128-L137
222,474
shiftonelabs/laravel-cascade-deletes
src/CascadesDeletes.php
CascadesDeletes.getCascadeDeletesRelationQuery
public function getCascadeDeletesRelationQuery($relation) { $query = $this->$relation(); // If this is a force delete and the related model is using soft deletes, // we need to use the withTrashed() scope on the relationship query to // ensure all related records, plus soft deleted, are force deleted. if ($this->isCascadeDeletesForceDeleting()) { // Laravel 4.1 has the withTrashed method directly on the Eloquent // query builder, however Laravel 4.2+ uses a withTrashed macro // on the Eloquent query builder. if (!class_exists(SoftDeletingScope::class) || !is_null($query->getMacro('withTrashed'))) { $query = $query->withTrashed(); } } return $query; }
php
public function getCascadeDeletesRelationQuery($relation) { $query = $this->$relation(); // If this is a force delete and the related model is using soft deletes, // we need to use the withTrashed() scope on the relationship query to // ensure all related records, plus soft deleted, are force deleted. if ($this->isCascadeDeletesForceDeleting()) { // Laravel 4.1 has the withTrashed method directly on the Eloquent // query builder, however Laravel 4.2+ uses a withTrashed macro // on the Eloquent query builder. if (!class_exists(SoftDeletingScope::class) || !is_null($query->getMacro('withTrashed'))) { $query = $query->withTrashed(); } } return $query; }
[ "public", "function", "getCascadeDeletesRelationQuery", "(", "$", "relation", ")", "{", "$", "query", "=", "$", "this", "->", "$", "relation", "(", ")", ";", "// If this is a force delete and the related model is using soft deletes,", "// we need to use the withTrashed() scope on the relationship query to", "// ensure all related records, plus soft deleted, are force deleted.", "if", "(", "$", "this", "->", "isCascadeDeletesForceDeleting", "(", ")", ")", "{", "// Laravel 4.1 has the withTrashed method directly on the Eloquent", "// query builder, however Laravel 4.2+ uses a withTrashed macro", "// on the Eloquent query builder.", "if", "(", "!", "class_exists", "(", "SoftDeletingScope", "::", "class", ")", "||", "!", "is_null", "(", "$", "query", "->", "getMacro", "(", "'withTrashed'", ")", ")", ")", "{", "$", "query", "=", "$", "query", "->", "withTrashed", "(", ")", ";", "}", "}", "return", "$", "query", ";", "}" ]
Get the relationship query to use for the specified relation. @param string $relation @return \Illuminate\Database\Eloquent\Relations\Relation
[ "Get", "the", "relationship", "query", "to", "use", "for", "the", "specified", "relation", "." ]
4302f0ecb7c0a166b9c4977cfbc10fe6ebedff0a
https://github.com/shiftonelabs/laravel-cascade-deletes/blob/4302f0ecb7c0a166b9c4977cfbc10fe6ebedff0a/src/CascadesDeletes.php#L158-L175
222,475
shiftonelabs/laravel-cascade-deletes
src/CascadesDeletes.php
CascadesDeletes.isCascadeDeletesForceDeleting
public function isCascadeDeletesForceDeleting() { // Laravel 4.1 uses the softDelete property, and the only // indication that the delete should be forced is when // the softDelete property is set to false. if (property_exists($this, 'softDelete') && !class_exists(SoftDeletingScope::class)) { // @codeCoverageIgnoreStart return !$this->softDelete; // @codeCoverageIgnoreEnd } return property_exists($this, 'forceDeleting') && $this->forceDeleting; }
php
public function isCascadeDeletesForceDeleting() { // Laravel 4.1 uses the softDelete property, and the only // indication that the delete should be forced is when // the softDelete property is set to false. if (property_exists($this, 'softDelete') && !class_exists(SoftDeletingScope::class)) { // @codeCoverageIgnoreStart return !$this->softDelete; // @codeCoverageIgnoreEnd } return property_exists($this, 'forceDeleting') && $this->forceDeleting; }
[ "public", "function", "isCascadeDeletesForceDeleting", "(", ")", "{", "// Laravel 4.1 uses the softDelete property, and the only", "// indication that the delete should be forced is when", "// the softDelete property is set to false.", "if", "(", "property_exists", "(", "$", "this", ",", "'softDelete'", ")", "&&", "!", "class_exists", "(", "SoftDeletingScope", "::", "class", ")", ")", "{", "// @codeCoverageIgnoreStart", "return", "!", "$", "this", "->", "softDelete", ";", "// @codeCoverageIgnoreEnd", "}", "return", "property_exists", "(", "$", "this", ",", "'forceDeleting'", ")", "&&", "$", "this", "->", "forceDeleting", ";", "}" ]
Check if this cascading delete is a force delete. @return boolean
[ "Check", "if", "this", "cascading", "delete", "is", "a", "force", "delete", "." ]
4302f0ecb7c0a166b9c4977cfbc10fe6ebedff0a
https://github.com/shiftonelabs/laravel-cascade-deletes/blob/4302f0ecb7c0a166b9c4977cfbc10fe6ebedff0a/src/CascadesDeletes.php#L182-L194
222,476
contao-bootstrap/grid
src/Definition/Column.php
Column.build
public function build(array $classes, string $size = ''): array { $sizeSuffix = $size ? '-' . $size : $size; if ($this->width === 'auto') { $classes[] = 'col' . $sizeSuffix . '-auto'; } elseif ($this->width === null || $this->width > 0) { $widthSuffix = ($this->width > 0) ? '-' . $this->width : ''; $classes[] = 'col' . $sizeSuffix . $widthSuffix; } elseif ($size) { $classes[] = 'd-' . $size . '-none'; } else { $classes[] = 'd-none'; } $this->buildAlign($classes, $sizeSuffix); $this->buildJustify($classes, $sizeSuffix); $this->buildOrder($classes, $sizeSuffix); $this->buildOffset($classes, $sizeSuffix); if ($this->cssClasses) { $classes = array_merge($classes, $this->cssClasses); } return array_unique($classes); }
php
public function build(array $classes, string $size = ''): array { $sizeSuffix = $size ? '-' . $size : $size; if ($this->width === 'auto') { $classes[] = 'col' . $sizeSuffix . '-auto'; } elseif ($this->width === null || $this->width > 0) { $widthSuffix = ($this->width > 0) ? '-' . $this->width : ''; $classes[] = 'col' . $sizeSuffix . $widthSuffix; } elseif ($size) { $classes[] = 'd-' . $size . '-none'; } else { $classes[] = 'd-none'; } $this->buildAlign($classes, $sizeSuffix); $this->buildJustify($classes, $sizeSuffix); $this->buildOrder($classes, $sizeSuffix); $this->buildOffset($classes, $sizeSuffix); if ($this->cssClasses) { $classes = array_merge($classes, $this->cssClasses); } return array_unique($classes); }
[ "public", "function", "build", "(", "array", "$", "classes", ",", "string", "$", "size", "=", "''", ")", ":", "array", "{", "$", "sizeSuffix", "=", "$", "size", "?", "'-'", ".", "$", "size", ":", "$", "size", ";", "if", "(", "$", "this", "->", "width", "===", "'auto'", ")", "{", "$", "classes", "[", "]", "=", "'col'", ".", "$", "sizeSuffix", ".", "'-auto'", ";", "}", "elseif", "(", "$", "this", "->", "width", "===", "null", "||", "$", "this", "->", "width", ">", "0", ")", "{", "$", "widthSuffix", "=", "(", "$", "this", "->", "width", ">", "0", ")", "?", "'-'", ".", "$", "this", "->", "width", ":", "''", ";", "$", "classes", "[", "]", "=", "'col'", ".", "$", "sizeSuffix", ".", "$", "widthSuffix", ";", "}", "elseif", "(", "$", "size", ")", "{", "$", "classes", "[", "]", "=", "'d-'", ".", "$", "size", ".", "'-none'", ";", "}", "else", "{", "$", "classes", "[", "]", "=", "'d-none'", ";", "}", "$", "this", "->", "buildAlign", "(", "$", "classes", ",", "$", "sizeSuffix", ")", ";", "$", "this", "->", "buildJustify", "(", "$", "classes", ",", "$", "sizeSuffix", ")", ";", "$", "this", "->", "buildOrder", "(", "$", "classes", ",", "$", "sizeSuffix", ")", ";", "$", "this", "->", "buildOffset", "(", "$", "classes", ",", "$", "sizeSuffix", ")", ";", "if", "(", "$", "this", "->", "cssClasses", ")", "{", "$", "classes", "=", "array_merge", "(", "$", "classes", ",", "$", "this", "->", "cssClasses", ")", ";", "}", "return", "array_unique", "(", "$", "classes", ")", ";", "}" ]
Build the column definition. @param array $classes List of classes. @param string $size Column size. @return array
[ "Build", "the", "column", "definition", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Definition/Column.php#L197-L222
222,477
contao-bootstrap/grid
src/Definition/Column.php
Column.buildReset
public function buildReset(array $resets, string $size = ''): array { if ($this->reset === true) { $resets[] = sprintf('d-none d%s-block', $size ? '-' . $size : ''); } elseif ($this->reset !== false) { $resets[] = sprintf('d-none d%s-block d-%s-none', $size ? '-' . $size : '', $this->reset); } return $resets; }
php
public function buildReset(array $resets, string $size = ''): array { if ($this->reset === true) { $resets[] = sprintf('d-none d%s-block', $size ? '-' . $size : ''); } elseif ($this->reset !== false) { $resets[] = sprintf('d-none d%s-block d-%s-none', $size ? '-' . $size : '', $this->reset); } return $resets; }
[ "public", "function", "buildReset", "(", "array", "$", "resets", ",", "string", "$", "size", "=", "''", ")", ":", "array", "{", "if", "(", "$", "this", "->", "reset", "===", "true", ")", "{", "$", "resets", "[", "]", "=", "sprintf", "(", "'d-none d%s-block'", ",", "$", "size", "?", "'-'", ".", "$", "size", ":", "''", ")", ";", "}", "elseif", "(", "$", "this", "->", "reset", "!==", "false", ")", "{", "$", "resets", "[", "]", "=", "sprintf", "(", "'d-none d%s-block d-%s-none'", ",", "$", "size", "?", "'-'", ".", "$", "size", ":", "''", ",", "$", "this", "->", "reset", ")", ";", "}", "return", "$", "resets", ";", "}" ]
Build the reset for the column. @param array $resets Reset definitions. @param string $size Column size. @return array
[ "Build", "the", "reset", "for", "the", "column", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Definition/Column.php#L232-L241
222,478
contao-bootstrap/grid
src/Definition/Column.php
Column.buildAlign
private function buildAlign(array &$classes, string $sizeSuffix = ''): void { if ($this->align) { $classes[] = 'align-self'. $sizeSuffix . '-' . $this->align; } }
php
private function buildAlign(array &$classes, string $sizeSuffix = ''): void { if ($this->align) { $classes[] = 'align-self'. $sizeSuffix . '-' . $this->align; } }
[ "private", "function", "buildAlign", "(", "array", "&", "$", "classes", ",", "string", "$", "sizeSuffix", "=", "''", ")", ":", "void", "{", "if", "(", "$", "this", "->", "align", ")", "{", "$", "classes", "[", "]", "=", "'align-self'", ".", "$", "sizeSuffix", ".", "'-'", ".", "$", "this", "->", "align", ";", "}", "}" ]
Build the align setting. @param array $classes Column classes. @param string $sizeSuffix Bootstrap Size suffix like 'md' or 'lg'. @return void
[ "Build", "the", "align", "setting", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Definition/Column.php#L261-L266
222,479
contao-bootstrap/grid
src/Definition/Column.php
Column.buildJustify
private function buildJustify(array &$classes, string $sizeSuffix = ''): void { if ($this->justify) { $classes[] = 'justify-content' . $sizeSuffix . '-' . $this->justify; } }
php
private function buildJustify(array &$classes, string $sizeSuffix = ''): void { if ($this->justify) { $classes[] = 'justify-content' . $sizeSuffix . '-' . $this->justify; } }
[ "private", "function", "buildJustify", "(", "array", "&", "$", "classes", ",", "string", "$", "sizeSuffix", "=", "''", ")", ":", "void", "{", "if", "(", "$", "this", "->", "justify", ")", "{", "$", "classes", "[", "]", "=", "'justify-content'", ".", "$", "sizeSuffix", ".", "'-'", ".", "$", "this", "->", "justify", ";", "}", "}" ]
Build the justify setting. @param array $classes Column classes. @param string $sizeSuffix Bootstrap Size suffix like 'md' or 'lg'. @return void
[ "Build", "the", "justify", "setting", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Definition/Column.php#L276-L281
222,480
contao-bootstrap/grid
src/Definition/Column.php
Column.buildOrder
private function buildOrder(array &$classes, string $sizeSuffix): void { if ($this->order) { $classes[] = 'order' . $sizeSuffix . '-' . $this->order; } }
php
private function buildOrder(array &$classes, string $sizeSuffix): void { if ($this->order) { $classes[] = 'order' . $sizeSuffix . '-' . $this->order; } }
[ "private", "function", "buildOrder", "(", "array", "&", "$", "classes", ",", "string", "$", "sizeSuffix", ")", ":", "void", "{", "if", "(", "$", "this", "->", "order", ")", "{", "$", "classes", "[", "]", "=", "'order'", ".", "$", "sizeSuffix", ".", "'-'", ".", "$", "this", "->", "order", ";", "}", "}" ]
Build the order setting. @param array $classes Column classes. @param string $sizeSuffix Size suffix. @return void
[ "Build", "the", "order", "setting", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Definition/Column.php#L291-L296
222,481
contao-bootstrap/grid
src/Definition/Column.php
Column.buildOffset
private function buildOffset(array &$classes, string $sizeSuffix): void { if ($this->offset === null) { return; } if (is_int($this->offset)) { $classes[] = 'offset' . $sizeSuffix . '-' . $this->offset; } elseif (strlen($this->offset)) { $classes[] = $this->offset; } }
php
private function buildOffset(array &$classes, string $sizeSuffix): void { if ($this->offset === null) { return; } if (is_int($this->offset)) { $classes[] = 'offset' . $sizeSuffix . '-' . $this->offset; } elseif (strlen($this->offset)) { $classes[] = $this->offset; } }
[ "private", "function", "buildOffset", "(", "array", "&", "$", "classes", ",", "string", "$", "sizeSuffix", ")", ":", "void", "{", "if", "(", "$", "this", "->", "offset", "===", "null", ")", "{", "return", ";", "}", "if", "(", "is_int", "(", "$", "this", "->", "offset", ")", ")", "{", "$", "classes", "[", "]", "=", "'offset'", ".", "$", "sizeSuffix", ".", "'-'", ".", "$", "this", "->", "offset", ";", "}", "elseif", "(", "strlen", "(", "$", "this", "->", "offset", ")", ")", "{", "$", "classes", "[", "]", "=", "$", "this", "->", "offset", ";", "}", "}" ]
Build offset setting. @param array $classes Column classes. @param string $sizeSuffix Size suffix. @return void
[ "Build", "offset", "setting", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Definition/Column.php#L306-L317
222,482
contao-bootstrap/grid
src/Listener/ThemeImportListener.php
ThemeImportListener.onExtractThemeFiles
public function onExtractThemeFiles(\DOMDocument $xml, ZipReader $archive, $themeId): void { $tables = $xml->getElementsByTagName('table'); for ($index = 0; $index < $tables->length; $index++) { if ($tables->item($index)->getAttribute('name') !== 'tl_bs_grid') { continue; } $this->importGrid($tables->item($index), (int) $themeId); } }
php
public function onExtractThemeFiles(\DOMDocument $xml, ZipReader $archive, $themeId): void { $tables = $xml->getElementsByTagName('table'); for ($index = 0; $index < $tables->length; $index++) { if ($tables->item($index)->getAttribute('name') !== 'tl_bs_grid') { continue; } $this->importGrid($tables->item($index), (int) $themeId); } }
[ "public", "function", "onExtractThemeFiles", "(", "\\", "DOMDocument", "$", "xml", ",", "ZipReader", "$", "archive", ",", "$", "themeId", ")", ":", "void", "{", "$", "tables", "=", "$", "xml", "->", "getElementsByTagName", "(", "'table'", ")", ";", "for", "(", "$", "index", "=", "0", ";", "$", "index", "<", "$", "tables", "->", "length", ";", "$", "index", "++", ")", "{", "if", "(", "$", "tables", "->", "item", "(", "$", "index", ")", "->", "getAttribute", "(", "'name'", ")", "!==", "'tl_bs_grid'", ")", "{", "continue", ";", "}", "$", "this", "->", "importGrid", "(", "$", "tables", "->", "item", "(", "$", "index", ")", ",", "(", "int", ")", "$", "themeId", ")", ";", "}", "}" ]
Handle the extract theme files hook. @param \DOMDocument $xml Theme xml document. @param ZipReader $archive Zip archive. @param int|string $themeId Theme id. @return void @SuppressWarnings(PHPMD.UnusedFormalParameter)
[ "Handle", "the", "extract", "theme", "files", "hook", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Listener/ThemeImportListener.php#L37-L48
222,483
contao-bootstrap/grid
src/Listener/ThemeImportListener.php
ThemeImportListener.importGrid
private function importGrid(\DOMElement $item, int $themeId): void { $rows = $item->childNodes; for ($index = 0; $index < $rows->length; $index++) { $values = $this->getRowValues($rows->item($index), $themeId); $model = new GridModel(); $model->setRow($values); $model->save(); } }
php
private function importGrid(\DOMElement $item, int $themeId): void { $rows = $item->childNodes; for ($index = 0; $index < $rows->length; $index++) { $values = $this->getRowValues($rows->item($index), $themeId); $model = new GridModel(); $model->setRow($values); $model->save(); } }
[ "private", "function", "importGrid", "(", "\\", "DOMElement", "$", "item", ",", "int", "$", "themeId", ")", ":", "void", "{", "$", "rows", "=", "$", "item", "->", "childNodes", ";", "for", "(", "$", "index", "=", "0", ";", "$", "index", "<", "$", "rows", "->", "length", ";", "$", "index", "++", ")", "{", "$", "values", "=", "$", "this", "->", "getRowValues", "(", "$", "rows", "->", "item", "(", "$", "index", ")", ",", "$", "themeId", ")", ";", "$", "model", "=", "new", "GridModel", "(", ")", ";", "$", "model", "->", "setRow", "(", "$", "values", ")", ";", "$", "model", "->", "save", "(", ")", ";", "}", "}" ]
Import the grid definition. @param \DOMElement $item Table item. @param int $themeId Theme id. @return void
[ "Import", "the", "grid", "definition", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Listener/ThemeImportListener.php#L58-L69
222,484
contao-bootstrap/grid
src/Listener/ThemeImportListener.php
ThemeImportListener.getRowValues
private function getRowValues(\DOMElement $item, int $themeId): array { $fields = $item->childNodes; $values = []; for ($index = 0; $index < $fields->length; $index++) { $value = $fields->item($index)->nodeValue; $name = $fields->item($index)->getAttribute('name'); switch ($name) { case 'id': break; case 'pid': $values[$name] = $themeId; break; default: if ($value === 'NULL') { $value = null; } $values[$name] = $value; } } return $values; }
php
private function getRowValues(\DOMElement $item, int $themeId): array { $fields = $item->childNodes; $values = []; for ($index = 0; $index < $fields->length; $index++) { $value = $fields->item($index)->nodeValue; $name = $fields->item($index)->getAttribute('name'); switch ($name) { case 'id': break; case 'pid': $values[$name] = $themeId; break; default: if ($value === 'NULL') { $value = null; } $values[$name] = $value; } } return $values; }
[ "private", "function", "getRowValues", "(", "\\", "DOMElement", "$", "item", ",", "int", "$", "themeId", ")", ":", "array", "{", "$", "fields", "=", "$", "item", "->", "childNodes", ";", "$", "values", "=", "[", "]", ";", "for", "(", "$", "index", "=", "0", ";", "$", "index", "<", "$", "fields", "->", "length", ";", "$", "index", "++", ")", "{", "$", "value", "=", "$", "fields", "->", "item", "(", "$", "index", ")", "->", "nodeValue", ";", "$", "name", "=", "$", "fields", "->", "item", "(", "$", "index", ")", "->", "getAttribute", "(", "'name'", ")", ";", "switch", "(", "$", "name", ")", "{", "case", "'id'", ":", "break", ";", "case", "'pid'", ":", "$", "values", "[", "$", "name", "]", "=", "$", "themeId", ";", "break", ";", "default", ":", "if", "(", "$", "value", "===", "'NULL'", ")", "{", "$", "value", "=", "null", ";", "}", "$", "values", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "return", "$", "values", ";", "}" ]
Prepare row values. @param \DOMElement $item Row item element. @param int $themeId Theme id. @return array
[ "Prepare", "row", "values", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Listener/ThemeImportListener.php#L79-L107
222,485
contao-bootstrap/grid
src/Listener/BuildContextConfigListener.php
BuildContextConfigListener.buildThemeConfig
public function buildThemeConfig(BuildContextConfig $command): void { $context = $command->getContext(); if (!$context instanceof ThemeContext) { return; } $theme = ThemeModel::findByPk($context->getThemeId()); if ($theme && $theme->bs_grid_columns) { $config = $command->getConfig()->merge( [ 'grid' => [ 'columns' => (int) $theme->bs_grid_columns ] ] ); $command->setConfig($config); } }
php
public function buildThemeConfig(BuildContextConfig $command): void { $context = $command->getContext(); if (!$context instanceof ThemeContext) { return; } $theme = ThemeModel::findByPk($context->getThemeId()); if ($theme && $theme->bs_grid_columns) { $config = $command->getConfig()->merge( [ 'grid' => [ 'columns' => (int) $theme->bs_grid_columns ] ] ); $command->setConfig($config); } }
[ "public", "function", "buildThemeConfig", "(", "BuildContextConfig", "$", "command", ")", ":", "void", "{", "$", "context", "=", "$", "command", "->", "getContext", "(", ")", ";", "if", "(", "!", "$", "context", "instanceof", "ThemeContext", ")", "{", "return", ";", "}", "$", "theme", "=", "ThemeModel", "::", "findByPk", "(", "$", "context", "->", "getThemeId", "(", ")", ")", ";", "if", "(", "$", "theme", "&&", "$", "theme", "->", "bs_grid_columns", ")", "{", "$", "config", "=", "$", "command", "->", "getConfig", "(", ")", "->", "merge", "(", "[", "'grid'", "=>", "[", "'columns'", "=>", "(", "int", ")", "$", "theme", "->", "bs_grid_columns", "]", "]", ")", ";", "$", "command", "->", "setConfig", "(", "$", "config", ")", ";", "}", "}" ]
Build theme config. @param BuildContextConfig $command Command. @return void
[ "Build", "theme", "config", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Listener/BuildContextConfigListener.php#L36-L57
222,486
contao-bootstrap/grid
src/Component/ContentElement/GalleryElement.php
GalleryElement.prepareFiles
protected function prepareFiles(Collection $collection, array $auxDate = [], $deep = true): array { // Get all images foreach ($collection as $fileModel) { // Continue if the files has been processed or does not exist if (isset($this->images[$fileModel->path]) || !file_exists(TL_ROOT . '/' . $fileModel->path)) { continue; } if ($fileModel->type == 'file') { // Single files $file = new File($fileModel->path); if (!$file->isImage) { continue; } // Add the image $this->images[$fileModel->path] = [ 'id' => $fileModel->id, 'uuid' => $fileModel->uuid, 'name' => $file->basename, 'singleSRC' => $fileModel->path, 'title' => StringUtil::specialchars($file->basename), 'filesModel' => $fileModel->current(), ]; $auxDate[] = $file->mtime; } elseif ($deep) { // Folders $subfiles = FilesModel::findByPid($fileModel->uuid); if ($subfiles !== null) { $this->prepareFiles($subfiles, $auxDate, false); } } } return $auxDate; }
php
protected function prepareFiles(Collection $collection, array $auxDate = [], $deep = true): array { // Get all images foreach ($collection as $fileModel) { // Continue if the files has been processed or does not exist if (isset($this->images[$fileModel->path]) || !file_exists(TL_ROOT . '/' . $fileModel->path)) { continue; } if ($fileModel->type == 'file') { // Single files $file = new File($fileModel->path); if (!$file->isImage) { continue; } // Add the image $this->images[$fileModel->path] = [ 'id' => $fileModel->id, 'uuid' => $fileModel->uuid, 'name' => $file->basename, 'singleSRC' => $fileModel->path, 'title' => StringUtil::specialchars($file->basename), 'filesModel' => $fileModel->current(), ]; $auxDate[] = $file->mtime; } elseif ($deep) { // Folders $subfiles = FilesModel::findByPid($fileModel->uuid); if ($subfiles !== null) { $this->prepareFiles($subfiles, $auxDate, false); } } } return $auxDate; }
[ "protected", "function", "prepareFiles", "(", "Collection", "$", "collection", ",", "array", "$", "auxDate", "=", "[", "]", ",", "$", "deep", "=", "true", ")", ":", "array", "{", "// Get all images", "foreach", "(", "$", "collection", "as", "$", "fileModel", ")", "{", "// Continue if the files has been processed or does not exist", "if", "(", "isset", "(", "$", "this", "->", "images", "[", "$", "fileModel", "->", "path", "]", ")", "||", "!", "file_exists", "(", "TL_ROOT", ".", "'/'", ".", "$", "fileModel", "->", "path", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "fileModel", "->", "type", "==", "'file'", ")", "{", "// Single files", "$", "file", "=", "new", "File", "(", "$", "fileModel", "->", "path", ")", ";", "if", "(", "!", "$", "file", "->", "isImage", ")", "{", "continue", ";", "}", "// Add the image", "$", "this", "->", "images", "[", "$", "fileModel", "->", "path", "]", "=", "[", "'id'", "=>", "$", "fileModel", "->", "id", ",", "'uuid'", "=>", "$", "fileModel", "->", "uuid", ",", "'name'", "=>", "$", "file", "->", "basename", ",", "'singleSRC'", "=>", "$", "fileModel", "->", "path", ",", "'title'", "=>", "StringUtil", "::", "specialchars", "(", "$", "file", "->", "basename", ")", ",", "'filesModel'", "=>", "$", "fileModel", "->", "current", "(", ")", ",", "]", ";", "$", "auxDate", "[", "]", "=", "$", "file", "->", "mtime", ";", "}", "elseif", "(", "$", "deep", ")", "{", "// Folders", "$", "subfiles", "=", "FilesModel", "::", "findByPid", "(", "$", "fileModel", "->", "uuid", ")", ";", "if", "(", "$", "subfiles", "!==", "null", ")", "{", "$", "this", "->", "prepareFiles", "(", "$", "subfiles", ",", "$", "auxDate", ",", "false", ")", ";", "}", "}", "}", "return", "$", "auxDate", ";", "}" ]
Prepare all file data and return the aux dates. @param Collection $collection File model collection. @param array $auxDate Aux date array. @param bool $deep If true sub files are added as well. @return array @throws \Exception If file could not be opened.
[ "Prepare", "all", "file", "data", "and", "return", "the", "aux", "dates", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Component/ContentElement/GalleryElement.php#L184-L223
222,487
contao-bootstrap/grid
src/Component/ContentElement/GalleryElement.php
GalleryElement.applySorting
protected function applySorting(array $auxDate, array &$data): void { // Sort array switch ($this->get('sortBy')) { default: case 'name_asc': uksort($this->images, 'basename_natcasecmp'); break; case 'name_desc': uksort($this->images, 'basename_natcasercmp'); break; case 'date_asc': array_multisort($this->images, SORT_NUMERIC, $auxDate, SORT_ASC); break; case 'date_desc': array_multisort($this->images, SORT_NUMERIC, $auxDate, SORT_DESC); break; // Deprecated since Contao 4.0, to be removed in Contao 5.0 case 'meta': // @codingStandardsIgnoreStart @trigger_error( 'The "meta" key in ContentGallery::compile() has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED ); // @codingStandardsIgnoreEnd // no break here. Handle meta the same as custom. case 'custom': $this->applyCustomSorting(); break; case 'random': shuffle($this->images); $data['isRandomOrder'] = true; break; } $this->images = array_values($this->images); }
php
protected function applySorting(array $auxDate, array &$data): void { // Sort array switch ($this->get('sortBy')) { default: case 'name_asc': uksort($this->images, 'basename_natcasecmp'); break; case 'name_desc': uksort($this->images, 'basename_natcasercmp'); break; case 'date_asc': array_multisort($this->images, SORT_NUMERIC, $auxDate, SORT_ASC); break; case 'date_desc': array_multisort($this->images, SORT_NUMERIC, $auxDate, SORT_DESC); break; // Deprecated since Contao 4.0, to be removed in Contao 5.0 case 'meta': // @codingStandardsIgnoreStart @trigger_error( 'The "meta" key in ContentGallery::compile() has been deprecated and will no longer work in Contao 5.0.', E_USER_DEPRECATED ); // @codingStandardsIgnoreEnd // no break here. Handle meta the same as custom. case 'custom': $this->applyCustomSorting(); break; case 'random': shuffle($this->images); $data['isRandomOrder'] = true; break; } $this->images = array_values($this->images); }
[ "protected", "function", "applySorting", "(", "array", "$", "auxDate", ",", "array", "&", "$", "data", ")", ":", "void", "{", "// Sort array", "switch", "(", "$", "this", "->", "get", "(", "'sortBy'", ")", ")", "{", "default", ":", "case", "'name_asc'", ":", "uksort", "(", "$", "this", "->", "images", ",", "'basename_natcasecmp'", ")", ";", "break", ";", "case", "'name_desc'", ":", "uksort", "(", "$", "this", "->", "images", ",", "'basename_natcasercmp'", ")", ";", "break", ";", "case", "'date_asc'", ":", "array_multisort", "(", "$", "this", "->", "images", ",", "SORT_NUMERIC", ",", "$", "auxDate", ",", "SORT_ASC", ")", ";", "break", ";", "case", "'date_desc'", ":", "array_multisort", "(", "$", "this", "->", "images", ",", "SORT_NUMERIC", ",", "$", "auxDate", ",", "SORT_DESC", ")", ";", "break", ";", "// Deprecated since Contao 4.0, to be removed in Contao 5.0", "case", "'meta'", ":", "// @codingStandardsIgnoreStart", "@", "trigger_error", "(", "'The \"meta\" key in ContentGallery::compile() has been deprecated and will no longer work in Contao 5.0.'", ",", "E_USER_DEPRECATED", ")", ";", "// @codingStandardsIgnoreEnd", "// no break here. Handle meta the same as custom.", "case", "'custom'", ":", "$", "this", "->", "applyCustomSorting", "(", ")", ";", "break", ";", "case", "'random'", ":", "shuffle", "(", "$", "this", "->", "images", ")", ";", "$", "data", "[", "'isRandomOrder'", "]", "=", "true", ";", "break", ";", "}", "$", "this", "->", "images", "=", "array_values", "(", "$", "this", "->", "images", ")", ";", "}" ]
Apply the sorting. @param array $auxDate Aux dates. @param array $data Template data. @return void
[ "Apply", "the", "sorting", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Component/ContentElement/GalleryElement.php#L233-L275
222,488
contao-bootstrap/grid
src/Component/ContentElement/GalleryElement.php
GalleryElement.preparePagination
protected function preparePagination(&$offset, &$limit): ?string { $total = count($this->images); $perPage = $this->get('perPage'); // Paginate the result of not randomly sorted (see #8033) if ($perPage > 0 && $this->get('sortBy') != 'random') { // Get the current page $parameter = 'page_g' . $this->get('id'); $page = (Input::get($parameter) !== null) ? Input::get($parameter) : 1; // Do not index or cache the page if the page number is outside the range if ($page < 1 || $page > max(ceil($total / $perPage), 1)) { throw new PageNotFoundException('Page not found: ' . Environment::get('uri')); } // Set limit and offset $offset = (($page - 1) * $perPage); $limit = min(($perPage + $offset), $total); $pagination = new Pagination( $total, $perPage, Config::get('maxPaginationLinks'), $parameter ); return $pagination->generate("\n "); } return null; }
php
protected function preparePagination(&$offset, &$limit): ?string { $total = count($this->images); $perPage = $this->get('perPage'); // Paginate the result of not randomly sorted (see #8033) if ($perPage > 0 && $this->get('sortBy') != 'random') { // Get the current page $parameter = 'page_g' . $this->get('id'); $page = (Input::get($parameter) !== null) ? Input::get($parameter) : 1; // Do not index or cache the page if the page number is outside the range if ($page < 1 || $page > max(ceil($total / $perPage), 1)) { throw new PageNotFoundException('Page not found: ' . Environment::get('uri')); } // Set limit and offset $offset = (($page - 1) * $perPage); $limit = min(($perPage + $offset), $total); $pagination = new Pagination( $total, $perPage, Config::get('maxPaginationLinks'), $parameter ); return $pagination->generate("\n "); } return null; }
[ "protected", "function", "preparePagination", "(", "&", "$", "offset", ",", "&", "$", "limit", ")", ":", "?", "string", "{", "$", "total", "=", "count", "(", "$", "this", "->", "images", ")", ";", "$", "perPage", "=", "$", "this", "->", "get", "(", "'perPage'", ")", ";", "// Paginate the result of not randomly sorted (see #8033)", "if", "(", "$", "perPage", ">", "0", "&&", "$", "this", "->", "get", "(", "'sortBy'", ")", "!=", "'random'", ")", "{", "// Get the current page", "$", "parameter", "=", "'page_g'", ".", "$", "this", "->", "get", "(", "'id'", ")", ";", "$", "page", "=", "(", "Input", "::", "get", "(", "$", "parameter", ")", "!==", "null", ")", "?", "Input", "::", "get", "(", "$", "parameter", ")", ":", "1", ";", "// Do not index or cache the page if the page number is outside the range", "if", "(", "$", "page", "<", "1", "||", "$", "page", ">", "max", "(", "ceil", "(", "$", "total", "/", "$", "perPage", ")", ",", "1", ")", ")", "{", "throw", "new", "PageNotFoundException", "(", "'Page not found: '", ".", "Environment", "::", "get", "(", "'uri'", ")", ")", ";", "}", "// Set limit and offset", "$", "offset", "=", "(", "(", "$", "page", "-", "1", ")", "*", "$", "perPage", ")", ";", "$", "limit", "=", "min", "(", "(", "$", "perPage", "+", "$", "offset", ")", ",", "$", "total", ")", ";", "$", "pagination", "=", "new", "Pagination", "(", "$", "total", ",", "$", "perPage", ",", "Config", "::", "get", "(", "'maxPaginationLinks'", ")", ",", "$", "parameter", ")", ";", "return", "$", "pagination", "->", "generate", "(", "\"\\n \"", ")", ";", "}", "return", "null", ";", "}" ]
Prepare pagination. @param int $offset Offset number. @param int $limit Limit. @return string|null @throws PageNotFoundException When page parameter is out of bounds.
[ "Prepare", "pagination", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Component/ContentElement/GalleryElement.php#L287-L318
222,489
contao-bootstrap/grid
src/Component/ContentElement/GalleryElement.php
GalleryElement.compileImages
protected function compileImages($offset, $limit): array { $lightBoxId = 'lightbox[lb' . $this->get('id') . ']'; $body = []; $imageSizes = StringUtil::deserialize($this->get('bs_image_sizes'), true); for ($index = $offset; $index < $limit; $index++) { if (!isset($this->images[$index])) { break; } $cell = new \stdClass(); $cell->class = 'image_' . $index; // Loop through images sizes. $size = current($imageSizes); if (next($imageSizes) === false) { reset($imageSizes); } // Build legacy size format. if (is_array($size)) { $size = [$size['width'], $size['height'], $size['size']]; } // Add size and margin $this->images[$index]['size'] = $size; $this->images[$index]['fullsize'] = $this->get('fullsize'); Controller::addImageToTemplate( $cell, $this->images[$index], null, $lightBoxId, $this->images[$index]['filesModel'] ); $cell->picture['attributes'] = 'class="img-fluid figure-img img-thumbnail"'; $body[] = $cell; } return $body; }
php
protected function compileImages($offset, $limit): array { $lightBoxId = 'lightbox[lb' . $this->get('id') . ']'; $body = []; $imageSizes = StringUtil::deserialize($this->get('bs_image_sizes'), true); for ($index = $offset; $index < $limit; $index++) { if (!isset($this->images[$index])) { break; } $cell = new \stdClass(); $cell->class = 'image_' . $index; // Loop through images sizes. $size = current($imageSizes); if (next($imageSizes) === false) { reset($imageSizes); } // Build legacy size format. if (is_array($size)) { $size = [$size['width'], $size['height'], $size['size']]; } // Add size and margin $this->images[$index]['size'] = $size; $this->images[$index]['fullsize'] = $this->get('fullsize'); Controller::addImageToTemplate( $cell, $this->images[$index], null, $lightBoxId, $this->images[$index]['filesModel'] ); $cell->picture['attributes'] = 'class="img-fluid figure-img img-thumbnail"'; $body[] = $cell; } return $body; }
[ "protected", "function", "compileImages", "(", "$", "offset", ",", "$", "limit", ")", ":", "array", "{", "$", "lightBoxId", "=", "'lightbox[lb'", ".", "$", "this", "->", "get", "(", "'id'", ")", ".", "']'", ";", "$", "body", "=", "[", "]", ";", "$", "imageSizes", "=", "StringUtil", "::", "deserialize", "(", "$", "this", "->", "get", "(", "'bs_image_sizes'", ")", ",", "true", ")", ";", "for", "(", "$", "index", "=", "$", "offset", ";", "$", "index", "<", "$", "limit", ";", "$", "index", "++", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "images", "[", "$", "index", "]", ")", ")", "{", "break", ";", "}", "$", "cell", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "cell", "->", "class", "=", "'image_'", ".", "$", "index", ";", "// Loop through images sizes.", "$", "size", "=", "current", "(", "$", "imageSizes", ")", ";", "if", "(", "next", "(", "$", "imageSizes", ")", "===", "false", ")", "{", "reset", "(", "$", "imageSizes", ")", ";", "}", "// Build legacy size format.", "if", "(", "is_array", "(", "$", "size", ")", ")", "{", "$", "size", "=", "[", "$", "size", "[", "'width'", "]", ",", "$", "size", "[", "'height'", "]", ",", "$", "size", "[", "'size'", "]", "]", ";", "}", "// Add size and margin", "$", "this", "->", "images", "[", "$", "index", "]", "[", "'size'", "]", "=", "$", "size", ";", "$", "this", "->", "images", "[", "$", "index", "]", "[", "'fullsize'", "]", "=", "$", "this", "->", "get", "(", "'fullsize'", ")", ";", "Controller", "::", "addImageToTemplate", "(", "$", "cell", ",", "$", "this", "->", "images", "[", "$", "index", "]", ",", "null", ",", "$", "lightBoxId", ",", "$", "this", "->", "images", "[", "$", "index", "]", "[", "'filesModel'", "]", ")", ";", "$", "cell", "->", "picture", "[", "'attributes'", "]", "=", "'class=\"img-fluid figure-img img-thumbnail\"'", ";", "$", "body", "[", "]", "=", "$", "cell", ";", "}", "return", "$", "body", ";", "}" ]
Compile all images. @param int $offset Offset. @param int $limit Limit. @return array
[ "Compile", "all", "images", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Component/ContentElement/GalleryElement.php#L328-L372
222,490
contao-bootstrap/grid
src/Component/ContentElement/GalleryElement.php
GalleryElement.getGalleryTemplateName
protected function getGalleryTemplateName(): string { $templateName = 'bs_gallery_default'; // Use a custom template if (TL_MODE == 'FE' && $this->get('galleryTpl') != '') { return (string) $this->get('galleryTpl'); } return $templateName; }
php
protected function getGalleryTemplateName(): string { $templateName = 'bs_gallery_default'; // Use a custom template if (TL_MODE == 'FE' && $this->get('galleryTpl') != '') { return (string) $this->get('galleryTpl'); } return $templateName; }
[ "protected", "function", "getGalleryTemplateName", "(", ")", ":", "string", "{", "$", "templateName", "=", "'bs_gallery_default'", ";", "// Use a custom template", "if", "(", "TL_MODE", "==", "'FE'", "&&", "$", "this", "->", "get", "(", "'galleryTpl'", ")", "!=", "''", ")", "{", "return", "(", "string", ")", "$", "this", "->", "get", "(", "'galleryTpl'", ")", ";", "}", "return", "$", "templateName", ";", "}" ]
Get the gallery template name. @return string
[ "Get", "the", "gallery", "template", "name", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Component/ContentElement/GalleryElement.php#L379-L389
222,491
contao-bootstrap/grid
src/Component/ContentElement/GalleryElement.php
GalleryElement.applyCustomSorting
protected function applyCustomSorting(): void { if ($this->get('orderSRC') != '') { $tmp = StringUtil::deserialize($this->get('orderSRC')); if (!empty($tmp) && is_array($tmp)) { // Remove all values $order = array_map( function () { }, array_flip($tmp) ); // Move the matching elements to their position in $arrOrder foreach ($this->images as $k => $v) { if (array_key_exists($v['uuid'], $order)) { $order[$v['uuid']] = $v; unset($this->images[$k]); } } // Append the left-over images at the end if (!empty($this->images)) { $order = array_merge($order, array_values($this->images)); } // Remove empty (unreplaced) entries $this->images = array_values(array_filter($order)); unset($order); } } }
php
protected function applyCustomSorting(): void { if ($this->get('orderSRC') != '') { $tmp = StringUtil::deserialize($this->get('orderSRC')); if (!empty($tmp) && is_array($tmp)) { // Remove all values $order = array_map( function () { }, array_flip($tmp) ); // Move the matching elements to their position in $arrOrder foreach ($this->images as $k => $v) { if (array_key_exists($v['uuid'], $order)) { $order[$v['uuid']] = $v; unset($this->images[$k]); } } // Append the left-over images at the end if (!empty($this->images)) { $order = array_merge($order, array_values($this->images)); } // Remove empty (unreplaced) entries $this->images = array_values(array_filter($order)); unset($order); } } }
[ "protected", "function", "applyCustomSorting", "(", ")", ":", "void", "{", "if", "(", "$", "this", "->", "get", "(", "'orderSRC'", ")", "!=", "''", ")", "{", "$", "tmp", "=", "StringUtil", "::", "deserialize", "(", "$", "this", "->", "get", "(", "'orderSRC'", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "tmp", ")", "&&", "is_array", "(", "$", "tmp", ")", ")", "{", "// Remove all values", "$", "order", "=", "array_map", "(", "function", "(", ")", "{", "}", ",", "array_flip", "(", "$", "tmp", ")", ")", ";", "// Move the matching elements to their position in $arrOrder", "foreach", "(", "$", "this", "->", "images", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "array_key_exists", "(", "$", "v", "[", "'uuid'", "]", ",", "$", "order", ")", ")", "{", "$", "order", "[", "$", "v", "[", "'uuid'", "]", "]", "=", "$", "v", ";", "unset", "(", "$", "this", "->", "images", "[", "$", "k", "]", ")", ";", "}", "}", "// Append the left-over images at the end", "if", "(", "!", "empty", "(", "$", "this", "->", "images", ")", ")", "{", "$", "order", "=", "array_merge", "(", "$", "order", ",", "array_values", "(", "$", "this", "->", "images", ")", ")", ";", "}", "// Remove empty (unreplaced) entries", "$", "this", "->", "images", "=", "array_values", "(", "array_filter", "(", "$", "order", ")", ")", ";", "unset", "(", "$", "order", ")", ";", "}", "}", "}" ]
Apply custom sorting. @return void
[ "Apply", "custom", "sorting", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Component/ContentElement/GalleryElement.php#L396-L427
222,492
contao-bootstrap/grid
src/GridProvider.php
GridProvider.getGrid
public function getGrid(int $gridId): Grid { if (!isset($this->grids[$gridId])) { $this->grids[$gridId] = $this->builder->build($gridId); } return $this->grids[$gridId]; }
php
public function getGrid(int $gridId): Grid { if (!isset($this->grids[$gridId])) { $this->grids[$gridId] = $this->builder->build($gridId); } return $this->grids[$gridId]; }
[ "public", "function", "getGrid", "(", "int", "$", "gridId", ")", ":", "Grid", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "grids", "[", "$", "gridId", "]", ")", ")", "{", "$", "this", "->", "grids", "[", "$", "gridId", "]", "=", "$", "this", "->", "builder", "->", "build", "(", "$", "gridId", ")", ";", "}", "return", "$", "this", "->", "grids", "[", "$", "gridId", "]", ";", "}" ]
Get a grid. @param int $gridId Grid id. @return Grid @throws \RuntimeException When grid could not be build.
[ "Get", "a", "grid", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/GridProvider.php#L67-L74
222,493
contao-bootstrap/grid
src/Component/Module/GridModule.php
GridModule.generateModules
protected function generateModules(array $config, array $modules, ?GridIterator $iterator = null): array { $buffer = []; foreach ($config as $entry) { if ($entry['inactive'] || !$entry['module']) { continue; } if (is_numeric($entry['module'])) { if (!empty($modules[$entry['module']])) { $buffer[] = $modules[$entry['module']]; } continue; } if ($iterator) { $iterator->next(); foreach ($iterator->resets() as $reset) { $buffer[] = '<div class="clearfix w-100 ' . $reset . '"></div>'; } $buffer[] = sprintf( "\n" . '</div>' . "\n" . '<div class="%s">', $iterator->current() ); } } return $buffer; }
php
protected function generateModules(array $config, array $modules, ?GridIterator $iterator = null): array { $buffer = []; foreach ($config as $entry) { if ($entry['inactive'] || !$entry['module']) { continue; } if (is_numeric($entry['module'])) { if (!empty($modules[$entry['module']])) { $buffer[] = $modules[$entry['module']]; } continue; } if ($iterator) { $iterator->next(); foreach ($iterator->resets() as $reset) { $buffer[] = '<div class="clearfix w-100 ' . $reset . '"></div>'; } $buffer[] = sprintf( "\n" . '</div>' . "\n" . '<div class="%s">', $iterator->current() ); } } return $buffer; }
[ "protected", "function", "generateModules", "(", "array", "$", "config", ",", "array", "$", "modules", ",", "?", "GridIterator", "$", "iterator", "=", "null", ")", ":", "array", "{", "$", "buffer", "=", "[", "]", ";", "foreach", "(", "$", "config", "as", "$", "entry", ")", "{", "if", "(", "$", "entry", "[", "'inactive'", "]", "||", "!", "$", "entry", "[", "'module'", "]", ")", "{", "continue", ";", "}", "if", "(", "is_numeric", "(", "$", "entry", "[", "'module'", "]", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "modules", "[", "$", "entry", "[", "'module'", "]", "]", ")", ")", "{", "$", "buffer", "[", "]", "=", "$", "modules", "[", "$", "entry", "[", "'module'", "]", "]", ";", "}", "continue", ";", "}", "if", "(", "$", "iterator", ")", "{", "$", "iterator", "->", "next", "(", ")", ";", "foreach", "(", "$", "iterator", "->", "resets", "(", ")", "as", "$", "reset", ")", "{", "$", "buffer", "[", "]", "=", "'<div class=\"clearfix w-100 '", ".", "$", "reset", ".", "'\"></div>'", ";", "}", "$", "buffer", "[", "]", "=", "sprintf", "(", "\"\\n\"", ".", "'</div>'", ".", "\"\\n\"", ".", "'<div class=\"%s\">'", ",", "$", "iterator", "->", "current", "(", ")", ")", ";", "}", "}", "return", "$", "buffer", ";", "}" ]
Generate all modules. @param array $config Module config. @param array $modules Generated modules. @param GridIterator|null $iterator Grid iterator. @return array
[ "Generate", "all", "modules", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Component/Module/GridModule.php#L133-L165
222,494
contao-bootstrap/grid
src/Component/Module/GridModule.php
GridModule.getModuleIds
protected function getModuleIds(array $config): array { $moduleIds = array_filter( array_map( function ($item) { return $item['module']; }, array_filter( $config, function ($item) { return $item['inactive'] == ''; } ) ), 'is_numeric' ); return $moduleIds; }
php
protected function getModuleIds(array $config): array { $moduleIds = array_filter( array_map( function ($item) { return $item['module']; }, array_filter( $config, function ($item) { return $item['inactive'] == ''; } ) ), 'is_numeric' ); return $moduleIds; }
[ "protected", "function", "getModuleIds", "(", "array", "$", "config", ")", ":", "array", "{", "$", "moduleIds", "=", "array_filter", "(", "array_map", "(", "function", "(", "$", "item", ")", "{", "return", "$", "item", "[", "'module'", "]", ";", "}", ",", "array_filter", "(", "$", "config", ",", "function", "(", "$", "item", ")", "{", "return", "$", "item", "[", "'inactive'", "]", "==", "''", ";", "}", ")", ")", ",", "'is_numeric'", ")", ";", "return", "$", "moduleIds", ";", "}" ]
Get the module ids. @param array $config Config. @return array
[ "Get", "the", "module", "ids", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Component/Module/GridModule.php#L174-L192
222,495
contao-bootstrap/grid
src/Component/Module/GridModule.php
GridModule.preCompileModules
protected function preCompileModules(array $moduleIds): array { $collection = ModuleModel::findMultipleByIds($moduleIds); $modules = []; if ($collection) { foreach ($collection as $model) { $modules[$model->id] = Controller::getFrontendModule($model, $this->getColumn()); } } return $modules; }
php
protected function preCompileModules(array $moduleIds): array { $collection = ModuleModel::findMultipleByIds($moduleIds); $modules = []; if ($collection) { foreach ($collection as $model) { $modules[$model->id] = Controller::getFrontendModule($model, $this->getColumn()); } } return $modules; }
[ "protected", "function", "preCompileModules", "(", "array", "$", "moduleIds", ")", ":", "array", "{", "$", "collection", "=", "ModuleModel", "::", "findMultipleByIds", "(", "$", "moduleIds", ")", ";", "$", "modules", "=", "[", "]", ";", "if", "(", "$", "collection", ")", "{", "foreach", "(", "$", "collection", "as", "$", "model", ")", "{", "$", "modules", "[", "$", "model", "->", "id", "]", "=", "Controller", "::", "getFrontendModule", "(", "$", "model", ",", "$", "this", "->", "getColumn", "(", ")", ")", ";", "}", "}", "return", "$", "modules", ";", "}" ]
Precompile the modules. @param array $moduleIds List of module ids. @return array
[ "Precompile", "the", "modules", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Component/Module/GridModule.php#L201-L213
222,496
contao-bootstrap/grid
src/Migration/MigrateAutoGridWidths.php
MigrateAutoGridWidths.migrateRow
private function migrateRow(array $row): void { $data = ['tstamp' => time()]; foreach (self::SIZES as $size) { $size .= 'Size'; $data[$size] = $this->migrateSize($row[$size]); } $this->connection->update('tl_bs_grid', $data, ['id' => $row['id']]); }
php
private function migrateRow(array $row): void { $data = ['tstamp' => time()]; foreach (self::SIZES as $size) { $size .= 'Size'; $data[$size] = $this->migrateSize($row[$size]); } $this->connection->update('tl_bs_grid', $data, ['id' => $row['id']]); }
[ "private", "function", "migrateRow", "(", "array", "$", "row", ")", ":", "void", "{", "$", "data", "=", "[", "'tstamp'", "=>", "time", "(", ")", "]", ";", "foreach", "(", "self", "::", "SIZES", "as", "$", "size", ")", "{", "$", "size", ".=", "'Size'", ";", "$", "data", "[", "$", "size", "]", "=", "$", "this", "->", "migrateSize", "(", "$", "row", "[", "$", "size", "]", ")", ";", "}", "$", "this", "->", "connection", "->", "update", "(", "'tl_bs_grid'", ",", "$", "data", ",", "[", "'id'", "=>", "$", "row", "[", "'id'", "]", "]", ")", ";", "}" ]
Migrate a grid definition row. @param array $row The grid definition row. @return void
[ "Migrate", "a", "grid", "definition", "row", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Migration/MigrateAutoGridWidths.php#L70-L80
222,497
contao-bootstrap/grid
src/Migration/MigrateAutoGridWidths.php
MigrateAutoGridWidths.migrateSize
private function migrateSize(?string $size): ?string { if ($size === null) { return null; } $columns = array_map( function (array $column) { if ($column['width'] === 'auto') { $column['width'] = 'equal'; } return $column; }, StringUtil::deserialize($size, true) ); return serialize($columns); }
php
private function migrateSize(?string $size): ?string { if ($size === null) { return null; } $columns = array_map( function (array $column) { if ($column['width'] === 'auto') { $column['width'] = 'equal'; } return $column; }, StringUtil::deserialize($size, true) ); return serialize($columns); }
[ "private", "function", "migrateSize", "(", "?", "string", "$", "size", ")", ":", "?", "string", "{", "if", "(", "$", "size", "===", "null", ")", "{", "return", "null", ";", "}", "$", "columns", "=", "array_map", "(", "function", "(", "array", "$", "column", ")", "{", "if", "(", "$", "column", "[", "'width'", "]", "===", "'auto'", ")", "{", "$", "column", "[", "'width'", "]", "=", "'equal'", ";", "}", "return", "$", "column", ";", "}", ",", "StringUtil", "::", "deserialize", "(", "$", "size", ",", "true", ")", ")", ";", "return", "serialize", "(", "$", "columns", ")", ";", "}" ]
Migrate a grid size. @param string|null $size The grid size definition. @return string|null
[ "Migrate", "a", "grid", "size", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Migration/MigrateAutoGridWidths.php#L89-L108
222,498
contao-bootstrap/grid
src/GridBuilder.php
GridBuilder.loadModel
protected function loadModel(int $gridId): void { $model = GridModel::findByPk($gridId); if (!$model) { throw new RuntimeException(sprintf('Grid ID "%s" not found', $gridId)); } $this->model = $model; }
php
protected function loadModel(int $gridId): void { $model = GridModel::findByPk($gridId); if (!$model) { throw new RuntimeException(sprintf('Grid ID "%s" not found', $gridId)); } $this->model = $model; }
[ "protected", "function", "loadModel", "(", "int", "$", "gridId", ")", ":", "void", "{", "$", "model", "=", "GridModel", "::", "findByPk", "(", "$", "gridId", ")", ";", "if", "(", "!", "$", "model", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Grid ID \"%s\" not found'", ",", "$", "gridId", ")", ")", ";", "}", "$", "this", "->", "model", "=", "$", "model", ";", "}" ]
Load grid model from the database. @param int $gridId THe grid id. @return void @throws RuntimeException When Grid does not exist.
[ "Load", "grid", "model", "from", "the", "database", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/GridBuilder.php#L72-L80
222,499
contao-bootstrap/grid
src/GridBuilder.php
GridBuilder.createGrid
private function createGrid(): void { $this->grid = new Grid(); $sizes = StringUtil::deserialize($this->model->sizes, true); $this->buildRow(); foreach ($sizes as $size) { $field = $size . 'Size'; $definition = StringUtil::deserialize($this->model->{$field}, true); if ($size === 'xs') { $size = ''; } $this->buildSize($size, $definition, $sizes); } }
php
private function createGrid(): void { $this->grid = new Grid(); $sizes = StringUtil::deserialize($this->model->sizes, true); $this->buildRow(); foreach ($sizes as $size) { $field = $size . 'Size'; $definition = StringUtil::deserialize($this->model->{$field}, true); if ($size === 'xs') { $size = ''; } $this->buildSize($size, $definition, $sizes); } }
[ "private", "function", "createGrid", "(", ")", ":", "void", "{", "$", "this", "->", "grid", "=", "new", "Grid", "(", ")", ";", "$", "sizes", "=", "StringUtil", "::", "deserialize", "(", "$", "this", "->", "model", "->", "sizes", ",", "true", ")", ";", "$", "this", "->", "buildRow", "(", ")", ";", "foreach", "(", "$", "sizes", "as", "$", "size", ")", "{", "$", "field", "=", "$", "size", ".", "'Size'", ";", "$", "definition", "=", "StringUtil", "::", "deserialize", "(", "$", "this", "->", "model", "->", "{", "$", "field", "}", ",", "true", ")", ";", "if", "(", "$", "size", "===", "'xs'", ")", "{", "$", "size", "=", "''", ";", "}", "$", "this", "->", "buildSize", "(", "$", "size", ",", "$", "definition", ",", "$", "sizes", ")", ";", "}", "}" ]
Create the grid from the model. @return void
[ "Create", "the", "grid", "from", "the", "model", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/GridBuilder.php#L87-L104