repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
pulsarvp/vps-tools
src/html/Field.php
Field.render
public function render ($content = null) { // Custom error output. $errors = $this->model->getErrors($this->attribute); if (count($errors) == 0) $this->parts[ '{error}' ] = ''; else { $class = isset($this->errorOptions[ 'class' ]) ? ' class="' . $this->errorOptions[ 'class' ] . '"' : ''; $this->parts[ '{error}' ] = '<div' . $class . '><ul class="list-unstyled">'; foreach ($errors as $e) { $this->parts[ '{error}' ] .= '<li>' . $e . '</li>'; } $this->parts[ '{error}' ] .= '</ul></div>'; } return parent::render($content); }
php
public function render ($content = null) { // Custom error output. $errors = $this->model->getErrors($this->attribute); if (count($errors) == 0) $this->parts[ '{error}' ] = ''; else { $class = isset($this->errorOptions[ 'class' ]) ? ' class="' . $this->errorOptions[ 'class' ] . '"' : ''; $this->parts[ '{error}' ] = '<div' . $class . '><ul class="list-unstyled">'; foreach ($errors as $e) { $this->parts[ '{error}' ] .= '<li>' . $e . '</li>'; } $this->parts[ '{error}' ] .= '</ul></div>'; } return parent::render($content); }
[ "public", "function", "render", "(", "$", "content", "=", "null", ")", "{", "// Custom error output.", "$", "errors", "=", "$", "this", "->", "model", "->", "getErrors", "(", "$", "this", "->", "attribute", ")", ";", "if", "(", "count", "(", "$", "erro...
This function overrides error output. All errors are displayed. @inheritdoc
[ "This", "function", "overrides", "error", "output", ".", "All", "errors", "are", "displayed", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/html/Field.php#L111-L130
train
pulsarvp/vps-tools
src/html/Field.php
Field.submit
public function submit ($text, $options = []) { $this->label(false); $this->parts[ '{input}' ] = Html::submitButton($text, [ 'class' => 'btn btn-lg btn-primary', 'name' => 's-' . $this->attribute ]); return $this; }
php
public function submit ($text, $options = []) { $this->label(false); $this->parts[ '{input}' ] = Html::submitButton($text, [ 'class' => 'btn btn-lg btn-primary', 'name' => 's-' . $this->attribute ]); return $this; }
[ "public", "function", "submit", "(", "$", "text", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "label", "(", "false", ")", ";", "$", "this", "->", "parts", "[", "'{input}'", "]", "=", "Html", "::", "submitButton", "(", "$", "t...
Renders submit button. @param string $text @param array $options @return $this
[ "Renders", "submit", "button", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/html/Field.php#L240-L246
train
pulsarvp/vps-tools
src/html/Field.php
Field.renderLabelParts
protected function renderLabelParts ($label = null, $options = []) { parent::renderLabelParts($label, $options); if (!empty($this->parts[ '{labelTitle}' ])) $this->parts[ '{labelTitle}' ] = Yii::tr($this->parts[ '{labelTitle}' ]); }
php
protected function renderLabelParts ($label = null, $options = []) { parent::renderLabelParts($label, $options); if (!empty($this->parts[ '{labelTitle}' ])) $this->parts[ '{labelTitle}' ] = Yii::tr($this->parts[ '{labelTitle}' ]); }
[ "protected", "function", "renderLabelParts", "(", "$", "label", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "parent", "::", "renderLabelParts", "(", "$", "label", ",", "$", "options", ")", ";", "if", "(", "!", "empty", "(", "$", "this"...
Added translation for label title. @inheritdoc
[ "Added", "translation", "for", "label", "title", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/html/Field.php#L289-L294
train
cedx/yii2-mustache
lib/helpers/Url.php
Url.getBase
function getBase(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { return UrlHelper::base($helper->render($value) ?: false); }; }
php
function getBase(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { return UrlHelper::base($helper->render($value) ?: false); }; }
[ "function", "getBase", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "return", "UrlHelper", "::", "base", "(", "$", "helper", "->", "render", "(", "$", "value", ...
Returns a function returning the base URL of the current request. @return \Closure A function returning the base URL of the current request.
[ "Returns", "a", "function", "returning", "the", "base", "URL", "of", "the", "current", "request", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Url.php#L23-L27
train
cedx/yii2-mustache
lib/helpers/Url.php
Url.getCurrent
function getCurrent(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'params', ['scheme' => false]); return UrlHelper::current($args['params'], $args['scheme']); }; }
php
function getCurrent(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'params', ['scheme' => false]); return UrlHelper::current($args['params'], $args['scheme']); }; }
[ "function", "getCurrent", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "$", "args", "=", "$", "this", "->", "parseArguments", "(", "$", "helper", "->", "render"...
Returns a function creating a URL by using the current route and the GET parameters. @return \Closure A function creating a URL by using the current route and the GET parameters.
[ "Returns", "a", "function", "creating", "a", "URL", "by", "using", "the", "current", "route", "and", "the", "GET", "parameters", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Url.php#L41-L46
train
cedx/yii2-mustache
lib/helpers/Url.php
Url.getHome
function getHome(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { return UrlHelper::home($helper->render($value) ?: false); }; }
php
function getHome(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { return UrlHelper::home($helper->render($value) ?: false); }; }
[ "function", "getHome", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "return", "UrlHelper", "::", "home", "(", "$", "helper", "->", "render", "(", "$", "value", ...
Returns a function returning the home URL. @return \Closure A function returning the home URL.
[ "Returns", "a", "function", "returning", "the", "home", "URL", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Url.php#L52-L56
train
cedx/yii2-mustache
lib/helpers/Url.php
Url.getPrevious
function getPrevious(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { return UrlHelper::previous($helper->render($value) ?: null); }; }
php
function getPrevious(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { return UrlHelper::previous($helper->render($value) ?: null); }; }
[ "function", "getPrevious", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "return", "UrlHelper", "::", "previous", "(", "$", "helper", "->", "render", "(", "$", "...
Returns a function returning the URL previously remembered. @return \Closure A function returning the URL previously remembered.
[ "Returns", "a", "function", "returning", "the", "URL", "previously", "remembered", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Url.php#L62-L66
train
cedx/yii2-mustache
lib/helpers/Url.php
Url.getTo
function getTo(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'url', ['scheme' => false]); return UrlHelper::to($args['url'], $args['scheme']); }; }
php
function getTo(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'url', ['scheme' => false]); return UrlHelper::to($args['url'], $args['scheme']); }; }
[ "function", "getTo", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "$", "args", "=", "$", "this", "->", "parseArguments", "(", "$", "helper", "->", "render", "...
Returns a function creating a URL based on the given parameters. @return \Closure A function creating a URL based on the given parameters.
[ "Returns", "a", "function", "creating", "a", "URL", "based", "on", "the", "given", "parameters", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Url.php#L72-L77
train
cedx/yii2-mustache
lib/helpers/Url.php
Url.getToRoute
function getToRoute(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'route', ['scheme' => false]); return UrlHelper::toRoute($args['route'], $args['scheme']); }; }
php
function getToRoute(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'route', ['scheme' => false]); return UrlHelper::toRoute($args['route'], $args['scheme']); }; }
[ "function", "getToRoute", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "$", "args", "=", "$", "this", "->", "parseArguments", "(", "$", "helper", "->", "render"...
Returns a function creating a URL for the given route. @return \Closure A function creating a URL for the given route.
[ "Returns", "a", "function", "creating", "a", "URL", "for", "the", "given", "route", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Url.php#L83-L88
train
cedx/yii2-mustache
lib/helpers/Html.php
Html.getBeginBody
function getBeginBody(): string { /** @var \yii\web\View|null $view */ $view = \Yii::$app->view; if (!$view || !$view->hasMethod('beginBody')) return ''; return $this->captureOutput([$view, 'beginBody']); }
php
function getBeginBody(): string { /** @var \yii\web\View|null $view */ $view = \Yii::$app->view; if (!$view || !$view->hasMethod('beginBody')) return ''; return $this->captureOutput([$view, 'beginBody']); }
[ "function", "getBeginBody", "(", ")", ":", "string", "{", "/** @var \\yii\\web\\View|null $view */", "$", "view", "=", "\\", "Yii", "::", "$", "app", "->", "view", ";", "if", "(", "!", "$", "view", "||", "!", "$", "view", "->", "hasMethod", "(", "'beginB...
Returns the tag marking the beginning of an HTML body section. @return string The tag marking the beginning of an HTML body section.
[ "Returns", "the", "tag", "marking", "the", "beginning", "of", "an", "HTML", "body", "section", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Html.php#L24-L29
train
cedx/yii2-mustache
lib/helpers/Html.php
Html.getEndBody
function getEndBody(): string { /** @var \yii\web\View|null $view */ $view = \Yii::$app->view; if (!$view || !$view->hasMethod('endBody')) return ''; return $this->captureOutput([$view, 'endBody']); }
php
function getEndBody(): string { /** @var \yii\web\View|null $view */ $view = \Yii::$app->view; if (!$view || !$view->hasMethod('endBody')) return ''; return $this->captureOutput([$view, 'endBody']); }
[ "function", "getEndBody", "(", ")", ":", "string", "{", "/** @var \\yii\\web\\View|null $view */", "$", "view", "=", "\\", "Yii", "::", "$", "app", "->", "view", ";", "if", "(", "!", "$", "view", "||", "!", "$", "view", "->", "hasMethod", "(", "'endBody'...
Returns the tag marking the ending of an HTML body section. @return string The tag marking the ending of an HTML body section.
[ "Returns", "the", "tag", "marking", "the", "ending", "of", "an", "HTML", "body", "section", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Html.php#L35-L40
train
cedx/yii2-mustache
lib/helpers/Html.php
Html.getHead
function getHead(): string { /** @var \yii\web\View|null $view */ $view = \Yii::$app->view; if (!$view || !$view->hasMethod('head')) return ''; return $this->captureOutput([$view, 'head']); }
php
function getHead(): string { /** @var \yii\web\View|null $view */ $view = \Yii::$app->view; if (!$view || !$view->hasMethod('head')) return ''; return $this->captureOutput([$view, 'head']); }
[ "function", "getHead", "(", ")", ":", "string", "{", "/** @var \\yii\\web\\View|null $view */", "$", "view", "=", "\\", "Yii", "::", "$", "app", "->", "view", ";", "if", "(", "!", "$", "view", "||", "!", "$", "view", "->", "hasMethod", "(", "'head'", "...
Returns the tag marking the position of an HTML head section. @return string The tag marking the position of an HTML head section.
[ "Returns", "the", "tag", "marking", "the", "position", "of", "an", "HTML", "head", "section", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Html.php#L46-L51
train
cedx/yii2-mustache
lib/helpers/Html.php
Html.getMarkdown
function getMarkdown(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'markdown', ['flavor' => Markdown::$defaultFlavor]); return Markdown::process($args['markdown'], $args['flavor']); }; }
php
function getMarkdown(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'markdown', ['flavor' => Markdown::$defaultFlavor]); return Markdown::process($args['markdown'], $args['flavor']); }; }
[ "function", "getMarkdown", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "$", "args", "=", "$", "this", "->", "parseArguments", "(", "$", "helper", "->", "render...
Returns a function converting Markdown into HTML. @return \Closure A function converting Markdown into HTML.
[ "Returns", "a", "function", "converting", "Markdown", "into", "HTML", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Html.php#L57-L62
train
cedx/yii2-mustache
lib/helpers/Html.php
Html.getMarkdownParagraph
function getMarkdownParagraph(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'markdown', ['flavor' => Markdown::$defaultFlavor]); return Markdown::processParagraph($args['markdown'], $args['flavor']); }; }
php
function getMarkdownParagraph(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'markdown', ['flavor' => Markdown::$defaultFlavor]); return Markdown::processParagraph($args['markdown'], $args['flavor']); }; }
[ "function", "getMarkdownParagraph", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "$", "args", "=", "$", "this", "->", "parseArguments", "(", "$", "helper", "->", ...
Returns a function converting Markdown into HTML but only parsing inline elements. @return \Closure A function converting Markdown into HTML but only parsing inline elements.
[ "Returns", "a", "function", "converting", "Markdown", "into", "HTML", "but", "only", "parsing", "inline", "elements", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Html.php#L68-L73
train
cedx/yii2-mustache
lib/helpers/Html.php
Html.getSpaceless
function getSpaceless(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { return $this->captureOutput(function() use ($helper, $value) { Spaceless::begin(); echo $helper->render($value); Spaceless::end(); }); }; }
php
function getSpaceless(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { return $this->captureOutput(function() use ($helper, $value) { Spaceless::begin(); echo $helper->render($value); Spaceless::end(); }); }; }
[ "function", "getSpaceless", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "return", "$", "this", "->", "captureOutput", "(", "function", "(", ")", "use", "(", "$...
Returns a function removing whitespace characters between HTML tags. @return \Closure A function removing whitespaces between HTML tags.
[ "Returns", "a", "function", "removing", "whitespace", "characters", "between", "HTML", "tags", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Html.php#L79-L87
train
cedx/yii2-mustache
lib/helpers/Html.php
Html.getViewTitle
function getViewTitle(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $view = \Yii::$app->view; if ($view && $view->canSetProperty('title')) $view->title = trim($helper->render($value)); }; }
php
function getViewTitle(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $view = \Yii::$app->view; if ($view && $view->canSetProperty('title')) $view->title = trim($helper->render($value)); }; }
[ "function", "getViewTitle", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "$", "view", "=", "\\", "Yii", "::", "$", "app", "->", "view", ";", "if", "(", "$",...
Returns a function setting the view title. @return \Closure A function setting the view title.
[ "Returns", "a", "function", "setting", "the", "view", "title", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Html.php#L93-L98
train
bearcms/bearframework-addon
classes/BearCMS/Internal/Data2/Addons.php
Addons.get
public function get(string $id) { $app = App::get(); $data = $app->data->getValue('bearcms/addons/addon/' . md5($id) . '.json'); if ($data !== null) { return $this->makeAddonFromRawData($data); } return null; }
php
public function get(string $id) { $app = App::get(); $data = $app->data->getValue('bearcms/addons/addon/' . md5($id) . '.json'); if ($data !== null) { return $this->makeAddonFromRawData($data); } return null; }
[ "public", "function", "get", "(", "string", "$", "id", ")", "{", "$", "app", "=", "App", "::", "get", "(", ")", ";", "$", "data", "=", "$", "app", "->", "data", "->", "getValue", "(", "'bearcms/addons/addon/'", ".", "md5", "(", "$", "id", ")", "....
Retrieves information about the addon specified @param string $id The addon ID @return \IvoPetkov\DataObject|null The addon data or null if addon not found @throws \InvalidArgumentException
[ "Retrieves", "information", "about", "the", "addon", "specified" ]
7ef131b81aac26070a2b937dd67f530a6caa02f0
https://github.com/bearcms/bearframework-addon/blob/7ef131b81aac26070a2b937dd67f530a6caa02f0/classes/BearCMS/Internal/Data2/Addons.php#L34-L42
train
bearcms/bearframework-addon
classes/BearCMS/Internal/Data2/Addons.php
Addons.getList
public function getList() { $app = App::get(); $list = $app->data->getList() ->filterBy('key', 'bearcms/addons/addon/', 'startWith'); $result = []; foreach ($list as $item) { $result[] = $this->makeAddonFromRawData($item->value); } return new \IvoPetkov\DataList($result); }
php
public function getList() { $app = App::get(); $list = $app->data->getList() ->filterBy('key', 'bearcms/addons/addon/', 'startWith'); $result = []; foreach ($list as $item) { $result[] = $this->makeAddonFromRawData($item->value); } return new \IvoPetkov\DataList($result); }
[ "public", "function", "getList", "(", ")", "{", "$", "app", "=", "App", "::", "get", "(", ")", ";", "$", "list", "=", "$", "app", "->", "data", "->", "getList", "(", ")", "->", "filterBy", "(", "'key'", ",", "'bearcms/addons/addon/'", ",", "'startWit...
Retrieves a list of all addons @return \IvoPetkov\DataList List containing all addons data
[ "Retrieves", "a", "list", "of", "all", "addons" ]
7ef131b81aac26070a2b937dd67f530a6caa02f0
https://github.com/bearcms/bearframework-addon/blob/7ef131b81aac26070a2b937dd67f530a6caa02f0/classes/BearCMS/Internal/Data2/Addons.php#L49-L59
train
wikimedia/slimapp
src/AbstractApp.php
AbstractApp.run
public function run() { session_name( '_s' ); session_cache_limiter( false ); ini_set( 'session.cookie_httponly', true ); session_start(); register_shutdown_function( 'session_write_close' ); $this->slim->run(); }
php
public function run() { session_name( '_s' ); session_cache_limiter( false ); ini_set( 'session.cookie_httponly', true ); session_start(); register_shutdown_function( 'session_write_close' ); $this->slim->run(); }
[ "public", "function", "run", "(", ")", "{", "session_name", "(", "'_s'", ")", ";", "session_cache_limiter", "(", "false", ")", ";", "ini_set", "(", "'session.cookie_httponly'", ",", "true", ")", ";", "session_start", "(", ")", ";", "register_shutdown_function", ...
Main entry point for all requests.
[ "Main", "entry", "point", "for", "all", "requests", "." ]
9fd0deba96f635c96d28d59d1f761283f62842d4
https://github.com/wikimedia/slimapp/blob/9fd0deba96f635c96d28d59d1f761283f62842d4/src/AbstractApp.php#L165-L172
train
wikimedia/slimapp
src/AbstractApp.php
AbstractApp.redirect
public static function redirect( \Slim\Slim $slim, $name, $to, $routeName = null ) { $routeName = $routeName ?: $name; $slim->get( $name, function () use ( $slim, $name, $to ) { $slim->flashKeep(); $slim->redirect( $slim->urlFor( $to ) ); } )->name( $routeName ); }
php
public static function redirect( \Slim\Slim $slim, $name, $to, $routeName = null ) { $routeName = $routeName ?: $name; $slim->get( $name, function () use ( $slim, $name, $to ) { $slim->flashKeep(); $slim->redirect( $slim->urlFor( $to ) ); } )->name( $routeName ); }
[ "public", "static", "function", "redirect", "(", "\\", "Slim", "\\", "Slim", "$", "slim", ",", "$", "name", ",", "$", "to", ",", "$", "routeName", "=", "null", ")", "{", "$", "routeName", "=", "$", "routeName", "?", ":", "$", "name", ";", "$", "s...
Add a redirect route to the app. @param \Slim\Slim $slim App @param string $name Page name @param string $to Redirect target route name @param string $routeName Name for the route
[ "Add", "a", "redirect", "route", "to", "the", "app", "." ]
9fd0deba96f635c96d28d59d1f761283f62842d4
https://github.com/wikimedia/slimapp/blob/9fd0deba96f635c96d28d59d1f761283f62842d4/src/AbstractApp.php#L181-L190
train
wikimedia/slimapp
src/AbstractApp.php
AbstractApp.template
public static function template( \Slim\Slim $slim, $name, $routeName = null ) { $routeName = $routeName ?: $name; $slim->get( $name, function () use ( $slim, $name ) { $slim->render( "{$name}.html" ); } )->name( $routeName ); }
php
public static function template( \Slim\Slim $slim, $name, $routeName = null ) { $routeName = $routeName ?: $name; $slim->get( $name, function () use ( $slim, $name ) { $slim->render( "{$name}.html" ); } )->name( $routeName ); }
[ "public", "static", "function", "template", "(", "\\", "Slim", "\\", "Slim", "$", "slim", ",", "$", "name", ",", "$", "routeName", "=", "null", ")", "{", "$", "routeName", "=", "$", "routeName", "?", ":", "$", "name", ";", "$", "slim", "->", "get",...
Add a static template route to the app. @param \Slim\Slim $slim App @param string $name Page name @param string $routeName Name for the route
[ "Add", "a", "static", "template", "route", "to", "the", "app", "." ]
9fd0deba96f635c96d28d59d1f761283f62842d4
https://github.com/wikimedia/slimapp/blob/9fd0deba96f635c96d28d59d1f761283f62842d4/src/AbstractApp.php#L198-L206
train
Jalle19/php-yui-compressor
lib/YUI/Compressor.php
Compressor.setType
public function setType($type) { if ($type === self::TYPE_CSS || $type === self::TYPE_JS) $this->_options['type'] = $type; else throw new Exception('Invalid type: '.$type); }
php
public function setType($type) { if ($type === self::TYPE_CSS || $type === self::TYPE_JS) $this->_options['type'] = $type; else throw new Exception('Invalid type: '.$type); }
[ "public", "function", "setType", "(", "$", "type", ")", "{", "if", "(", "$", "type", "===", "self", "::", "TYPE_CSS", "||", "$", "type", "===", "self", "::", "TYPE_JS", ")", "$", "this", "->", "_options", "[", "'type'", "]", "=", "$", "type", ";", ...
Sets the compressor type. Valid values are TYPE_JS and TYPE_CSS. This method can be used to change the compressor type after the class has been instantiated. @param string $type the type @throws Exception if the type is invalid
[ "Sets", "the", "compressor", "type", ".", "Valid", "values", "are", "TYPE_JS", "and", "TYPE_CSS", ".", "This", "method", "can", "be", "used", "to", "change", "the", "compressor", "type", "after", "the", "class", "has", "been", "instantiated", "." ]
eb88c4f7fd8d7c8bd15a1970611d67cca11f71a0
https://github.com/Jalle19/php-yui-compressor/blob/eb88c4f7fd8d7c8bd15a1970611d67cca11f71a0/lib/YUI/Compressor.php#L85-L91
train
Jalle19/php-yui-compressor
lib/YUI/Compressor.php
Compressor.compress
public function compress($data) { // Construct the command $cmd = $this->_options['javaPath'].' -jar '.escapeshellarg($this->_jarPath); $cmd .= ' --charset '.$this->_options['charset']; $cmd .= ' --type '.$this->_options['type']; if ($this->_options['line-break'] !== false) $cmd .= ' --line-break '.(int) $this->_options['line-break']; if ($this->_options['verbose']) $cmd .= " -v"; // Javascript-specific options if ($this->_options['type'] === self::TYPE_JS) foreach (self::$_javaScriptOptions as $option) if ($this->_options[$option]) $cmd .= ' --'.$option; // Run the command $pipes = array(); $descriptors = array( 0=>array('pipe', 'r'), 1=>array('pipe', 'w'), 2=>array('pipe', 'w'), ); $process = proc_open($cmd, $descriptors, $pipes); if (is_resource($process)) { // Write the data we want to compress to STDIN fwrite($pipes[0], $data); fclose($pipes[0]); // Get the compressed data and eventual error from STDOUT and STDERR $compressedData = stream_get_contents($pipes[1]); $error = stream_get_contents($pipes[2]); fclose($pipes[1]); fclose($pipes[2]); $return = proc_close($process); // Throw an exception if compression fails if ($return === 0) return $compressedData; else throw new Exception('Failed to compress data: '.$error, $return); } throw new Exception('Failed to open a process'); }
php
public function compress($data) { // Construct the command $cmd = $this->_options['javaPath'].' -jar '.escapeshellarg($this->_jarPath); $cmd .= ' --charset '.$this->_options['charset']; $cmd .= ' --type '.$this->_options['type']; if ($this->_options['line-break'] !== false) $cmd .= ' --line-break '.(int) $this->_options['line-break']; if ($this->_options['verbose']) $cmd .= " -v"; // Javascript-specific options if ($this->_options['type'] === self::TYPE_JS) foreach (self::$_javaScriptOptions as $option) if ($this->_options[$option]) $cmd .= ' --'.$option; // Run the command $pipes = array(); $descriptors = array( 0=>array('pipe', 'r'), 1=>array('pipe', 'w'), 2=>array('pipe', 'w'), ); $process = proc_open($cmd, $descriptors, $pipes); if (is_resource($process)) { // Write the data we want to compress to STDIN fwrite($pipes[0], $data); fclose($pipes[0]); // Get the compressed data and eventual error from STDOUT and STDERR $compressedData = stream_get_contents($pipes[1]); $error = stream_get_contents($pipes[2]); fclose($pipes[1]); fclose($pipes[2]); $return = proc_close($process); // Throw an exception if compression fails if ($return === 0) return $compressedData; else throw new Exception('Failed to compress data: '.$error, $return); } throw new Exception('Failed to open a process'); }
[ "public", "function", "compress", "(", "$", "data", ")", "{", "// Construct the command", "$", "cmd", "=", "$", "this", "->", "_options", "[", "'javaPath'", "]", ".", "' -jar '", ".", "escapeshellarg", "(", "$", "this", "->", "_jarPath", ")", ";", "$", "...
Compresses the specified data and returns it @param string $data the data @return string the compressed data @throws Exception if the compression fails
[ "Compresses", "the", "specified", "data", "and", "returns", "it" ]
eb88c4f7fd8d7c8bd15a1970611d67cca11f71a0
https://github.com/Jalle19/php-yui-compressor/blob/eb88c4f7fd8d7c8bd15a1970611d67cca11f71a0/lib/YUI/Compressor.php#L99-L150
train
shimabox/SMBArrayto
src/SMB/Arrayto/Traits/Ltsv/Creatable.php
Creatable.createOutputContents
protected function createOutputContents() { $formattedItems = $this->formatterInstance()->format($this->rows); $ret = array(); foreach ($formattedItems as $label => $value) { $ret[] = $label . ':' . $value; } return join("\t", $ret) . $this->EOL; }
php
protected function createOutputContents() { $formattedItems = $this->formatterInstance()->format($this->rows); $ret = array(); foreach ($formattedItems as $label => $value) { $ret[] = $label . ':' . $value; } return join("\t", $ret) . $this->EOL; }
[ "protected", "function", "createOutputContents", "(", ")", "{", "$", "formattedItems", "=", "$", "this", "->", "formatterInstance", "(", ")", "->", "format", "(", "$", "this", "->", "rows", ")", ";", "$", "ret", "=", "array", "(", ")", ";", "foreach", ...
Create an output content for Ltsv @return string
[ "Create", "an", "output", "content", "for", "Ltsv" ]
7ecacc0c15994c02224bbd3efe055d3bce243971
https://github.com/shimabox/SMBArrayto/blob/7ecacc0c15994c02224bbd3efe055d3bce243971/src/SMB/Arrayto/Traits/Ltsv/Creatable.php#L33-L43
train
pulsarvp/vps-tools
src/helpers/Html.php
Html.buttonFa
public static function buttonFa ($text, $fa, $options = []) { $class = 'fa fa-' . $fa; if (!empty(trim($text))) $class .= ' margin'; $icon = self::tag('i', '', [ 'class' => $class ]); if (!isset($options[ 'title' ])) $options[ 'title' ] = $text; if (isset($options[ 'raw' ]) and $options[ 'raw' ] == true) { unset($options[ 'raw' ]); return parent::button($icon . $text, $options); } else { unset($options[ 'raw' ]); return parent::button($icon . Yii::t('app', $text), $options); } }
php
public static function buttonFa ($text, $fa, $options = []) { $class = 'fa fa-' . $fa; if (!empty(trim($text))) $class .= ' margin'; $icon = self::tag('i', '', [ 'class' => $class ]); if (!isset($options[ 'title' ])) $options[ 'title' ] = $text; if (isset($options[ 'raw' ]) and $options[ 'raw' ] == true) { unset($options[ 'raw' ]); return parent::button($icon . $text, $options); } else { unset($options[ 'raw' ]); return parent::button($icon . Yii::t('app', $text), $options); } }
[ "public", "static", "function", "buttonFa", "(", "$", "text", ",", "$", "fa", ",", "$", "options", "=", "[", "]", ")", "{", "$", "class", "=", "'fa fa-'", ".", "$", "fa", ";", "if", "(", "!", "empty", "(", "trim", "(", "$", "text", ")", ")", ...
Creates button with FontAwesome icon. ```php Html::buttonFa('Save', 'save', [ 'raw' => true ]); // <button type="button"><i class="fa fa-save margin"></i>Save</button> ``` @param string $text Button text. @param string $fa Icon name. @param array $options Additional options. @return string
[ "Creates", "button", "with", "FontAwesome", "icon", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/helpers/Html.php#L99-L120
train
wikimedia/slimapp
src/Controller.php
Controller.flashGet
protected function flashGet( $key ) { if ( isset( $this->slim->environment['slim.flash'] ) ) { return $this->slim->environment['slim.flash'][$key]; } else { return null; } }
php
protected function flashGet( $key ) { if ( isset( $this->slim->environment['slim.flash'] ) ) { return $this->slim->environment['slim.flash'][$key]; } else { return null; } }
[ "protected", "function", "flashGet", "(", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "slim", "->", "environment", "[", "'slim.flash'", "]", ")", ")", "{", "return", "$", "this", "->", "slim", "->", "environment", "[", "'slim.flas...
Get a flash message. @param string $key Message key @return mixed|null
[ "Get", "a", "flash", "message", "." ]
9fd0deba96f635c96d28d59d1f761283f62842d4
https://github.com/wikimedia/slimapp/blob/9fd0deba96f635c96d28d59d1f761283f62842d4/src/Controller.php#L163-L169
train
wikimedia/slimapp
src/Controller.php
Controller.pagination
protected function pagination( $total, $current, $pageSize, $around = 4 ) { $pageCount = ceil( $total / $pageSize ); $first = max( 0, $current - $around ); $last = min( max( 0, $pageCount - 1 ), $current + 4 ); return [ $pageCount, $first, $last ]; }
php
protected function pagination( $total, $current, $pageSize, $around = 4 ) { $pageCount = ceil( $total / $pageSize ); $first = max( 0, $current - $around ); $last = min( max( 0, $pageCount - 1 ), $current + 4 ); return [ $pageCount, $first, $last ]; }
[ "protected", "function", "pagination", "(", "$", "total", ",", "$", "current", ",", "$", "pageSize", ",", "$", "around", "=", "4", ")", "{", "$", "pageCount", "=", "ceil", "(", "$", "total", "/", "$", "pageSize", ")", ";", "$", "first", "=", "max",...
Compute pagination data. @param int $total Total records @param int $current Current page number (0-indexed) @param int $pageSize Number of items per page @param int $around Numer of pages to show on each side of current @return array Page count, first page index, last page index
[ "Compute", "pagination", "data", "." ]
9fd0deba96f635c96d28d59d1f761283f62842d4
https://github.com/wikimedia/slimapp/blob/9fd0deba96f635c96d28d59d1f761283f62842d4/src/Controller.php#L191-L196
train
pulsarvp/vps-tools
src/controllers/DbController.php
DbController.actionRecreateViews
public function actionRecreateViews () { $db = Yii::$app->db; $views = $this->getViews(); foreach ($views as $view) { $info = $db->createCommand("SHOW CREATE VIEW `$view`")->queryAll(); $sql = $info[ 0 ][ 'Create View' ]; preg_match("/.*VIEW `$view` as (.*)/i", $sql, $match); if (isset($match[ 1 ])) { $db->createCommand("CREATE OR REPLACE VIEW `$view` AS " . $match[ 1 ])->execute(); Console::printColor("View `$view` was recreated.", "green"); } else { Console::printColor("Cannot find create string for view `$view`.", "red"); } } }
php
public function actionRecreateViews () { $db = Yii::$app->db; $views = $this->getViews(); foreach ($views as $view) { $info = $db->createCommand("SHOW CREATE VIEW `$view`")->queryAll(); $sql = $info[ 0 ][ 'Create View' ]; preg_match("/.*VIEW `$view` as (.*)/i", $sql, $match); if (isset($match[ 1 ])) { $db->createCommand("CREATE OR REPLACE VIEW `$view` AS " . $match[ 1 ])->execute(); Console::printColor("View `$view` was recreated.", "green"); } else { Console::printColor("Cannot find create string for view `$view`.", "red"); } } }
[ "public", "function", "actionRecreateViews", "(", ")", "{", "$", "db", "=", "Yii", "::", "$", "app", "->", "db", ";", "$", "views", "=", "$", "this", "->", "getViews", "(", ")", ";", "foreach", "(", "$", "views", "as", "$", "view", ")", "{", "$",...
List all views. This method is needed in order to match the database collection if it was changed.
[ "List", "all", "views", ".", "This", "method", "is", "needed", "in", "order", "to", "match", "the", "database", "collection", "if", "it", "was", "changed", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/controllers/DbController.php#L17-L37
train
cedx/yii2-mustache
lib/ViewRenderer.php
ViewRenderer.setHelpers
function setHelpers(array $value): self { if ($this->engine) $this->engine->setHelpers($value); else $this->helpers = $value; return $this; }
php
function setHelpers(array $value): self { if ($this->engine) $this->engine->setHelpers($value); else $this->helpers = $value; return $this; }
[ "function", "setHelpers", "(", "array", "$", "value", ")", ":", "self", "{", "if", "(", "$", "this", "->", "engine", ")", "$", "this", "->", "engine", "->", "setHelpers", "(", "$", "value", ")", ";", "else", "$", "this", "->", "helpers", "=", "$", ...
Sets the values to prepend to the context stack, so they will be available in any view loaded by this instance. @param array $value The list of the values to prepend to the context stack. @return $this This instance.
[ "Sets", "the", "values", "to", "prepend", "to", "the", "context", "stack", "so", "they", "will", "be", "available", "in", "any", "view", "loaded", "by", "this", "instance", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/ViewRenderer.php#L107-L111
train
pulsarvp/vps-tools
src/components/ImageManager.php
ImageManager.saveImage
public function saveImage ($path, $file, $resize = false) { $filename = UuidHelper::generate() . '.' . $file->extension; $name = $filename[ 0 ] . DIRECTORY_SEPARATOR . $filename[ 1 ] . DIRECTORY_SEPARATOR . $filename; $filepath = $path . DIRECTORY_SEPARATOR . $name; if ($resize) { $data = []; foreach ($this->_formats() as $format) { $method = '_save' . ucfirst($format); $this->$method($path, $name, $file->tempName); $data[ $format ] = $path . DIRECTORY_SEPARATOR . $name; } if (file_exists($filepath)) return $data; else return false; } else { $this->_saveOriginal($path, $name, $file->tempName); if (file_exists($filepath)) return [ self::F_ORIGINAL => $path . DIRECTORY_SEPARATOR . $name ]; else return false; } }
php
public function saveImage ($path, $file, $resize = false) { $filename = UuidHelper::generate() . '.' . $file->extension; $name = $filename[ 0 ] . DIRECTORY_SEPARATOR . $filename[ 1 ] . DIRECTORY_SEPARATOR . $filename; $filepath = $path . DIRECTORY_SEPARATOR . $name; if ($resize) { $data = []; foreach ($this->_formats() as $format) { $method = '_save' . ucfirst($format); $this->$method($path, $name, $file->tempName); $data[ $format ] = $path . DIRECTORY_SEPARATOR . $name; } if (file_exists($filepath)) return $data; else return false; } else { $this->_saveOriginal($path, $name, $file->tempName); if (file_exists($filepath)) return [ self::F_ORIGINAL => $path . DIRECTORY_SEPARATOR . $name ]; else return false; } }
[ "public", "function", "saveImage", "(", "$", "path", ",", "$", "file", ",", "$", "resize", "=", "false", ")", "{", "$", "filename", "=", "UuidHelper", "::", "generate", "(", ")", ".", "'.'", ".", "$", "file", "->", "extension", ";", "$", "name", "=...
Save all formats image. @param string $path The path to the file. @param UploadedFile $file The path to the source file. ```php return Yii::$app->image->saveImage('var/www/site/data/img/author', $image); ``` @return bool|string
[ "Save", "all", "formats", "image", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/components/ImageManager.php#L44-L72
train
pulsarvp/vps-tools
src/components/ImageManager.php
ImageManager._resize
private function _resize (ImageInterface $image, BoxInterface $newSize) { $size = $image->getSize(); $ratio = min($newSize->getHeight() / $size->getHeight(), $newSize->getWidth() / $size->getWidth()); if ($ratio < 1) $image->resize($size->scale($ratio)); }
php
private function _resize (ImageInterface $image, BoxInterface $newSize) { $size = $image->getSize(); $ratio = min($newSize->getHeight() / $size->getHeight(), $newSize->getWidth() / $size->getWidth()); if ($ratio < 1) $image->resize($size->scale($ratio)); }
[ "private", "function", "_resize", "(", "ImageInterface", "$", "image", ",", "BoxInterface", "$", "newSize", ")", "{", "$", "size", "=", "$", "image", "->", "getSize", "(", ")", ";", "$", "ratio", "=", "min", "(", "$", "newSize", "->", "getHeight", "(",...
Resize the image proportionally with max sizes constraints @param ImageInterface $image @param BoxInterface $newSize
[ "Resize", "the", "image", "proportionally", "with", "max", "sizes", "constraints" ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/components/ImageManager.php#L92-L98
train
pulsarvp/vps-tools
src/components/ImageManager.php
ImageManager._save
private function _save ($path, $file, $format) { $image = ( new Imagine() )->open($file); $class = $this->config; $params = $class::get($format); $newSize = $this->_size($format); if ($class::$fit == ImageSizeFit::WIDTH) $this->resizeToWidth($image, $newSize->getWidth()); elseif ($class::$fit == ImageSizeFit::HEIGHT) $this->resizeToHeight($image, $newSize->getHeight()); else $this->_resize($image, $newSize); FileHelper::createDirectory(dirname($path)); $image->save($path, [ 'jpeg_quality' => $params[ 'quality' ] ]); }
php
private function _save ($path, $file, $format) { $image = ( new Imagine() )->open($file); $class = $this->config; $params = $class::get($format); $newSize = $this->_size($format); if ($class::$fit == ImageSizeFit::WIDTH) $this->resizeToWidth($image, $newSize->getWidth()); elseif ($class::$fit == ImageSizeFit::HEIGHT) $this->resizeToHeight($image, $newSize->getHeight()); else $this->_resize($image, $newSize); FileHelper::createDirectory(dirname($path)); $image->save($path, [ 'jpeg_quality' => $params[ 'quality' ] ]); }
[ "private", "function", "_save", "(", "$", "path", ",", "$", "file", ",", "$", "format", ")", "{", "$", "image", "=", "(", "new", "Imagine", "(", ")", ")", "->", "open", "(", "$", "file", ")", ";", "$", "class", "=", "$", "this", "->", "config",...
Saves image to the format using sizes from settings. @param string $path @param string $dest @param string $type @param string $format
[ "Saves", "image", "to", "the", "format", "using", "sizes", "from", "settings", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/components/ImageManager.php#L108-L122
train
pulsarvp/vps-tools
src/components/ImageManager.php
ImageManager._saveHd
private function _saveHd ($path, $name, $file) { $this->_save($path . DIRECTORY_SEPARATOR . self::F_HD . DIRECTORY_SEPARATOR . $name, $file, self::F_HD); }
php
private function _saveHd ($path, $name, $file) { $this->_save($path . DIRECTORY_SEPARATOR . self::F_HD . DIRECTORY_SEPARATOR . $name, $file, self::F_HD); }
[ "private", "function", "_saveHd", "(", "$", "path", ",", "$", "name", ",", "$", "file", ")", "{", "$", "this", "->", "_save", "(", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "self", "::", "F_HD", ".", "DIRECTORY_SEPARATOR", ".", "$", "name", ",", ...
Saves a image to the HD format. @param string $path @param string $dest @param string $type
[ "Saves", "a", "image", "to", "the", "HD", "format", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/components/ImageManager.php#L163-L166
train
pulsarvp/vps-tools
src/components/ImageManager.php
ImageManager._saveOriginal
private function _saveOriginal ($path, $name, $file) { $filepath = $path . DIRECTORY_SEPARATOR . $name; if (Yii::$app->settings->get('image_original_save', true)) { FileHelper::createDirectory(dirname($filepath)); copy($file, $filepath); } }
php
private function _saveOriginal ($path, $name, $file) { $filepath = $path . DIRECTORY_SEPARATOR . $name; if (Yii::$app->settings->get('image_original_save', true)) { FileHelper::createDirectory(dirname($filepath)); copy($file, $filepath); } }
[ "private", "function", "_saveOriginal", "(", "$", "path", ",", "$", "name", ",", "$", "file", ")", "{", "$", "filepath", "=", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "$", "name", ";", "if", "(", "Yii", "::", "$", "app", "->", "settings", "->", ...
Saves a image to the original format. @param string $path @param string $dest @param string $type
[ "Saves", "a", "image", "to", "the", "original", "format", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/components/ImageManager.php#L175-L183
train
pulsarvp/vps-tools
src/components/ImageManager.php
ImageManager._saveSd
private function _saveSd ($path, $name, $file) { $this->_save($path . DIRECTORY_SEPARATOR . self::F_SD . DIRECTORY_SEPARATOR . $name, $file, self::F_SD); }
php
private function _saveSd ($path, $name, $file) { $this->_save($path . DIRECTORY_SEPARATOR . self::F_SD . DIRECTORY_SEPARATOR . $name, $file, self::F_SD); }
[ "private", "function", "_saveSd", "(", "$", "path", ",", "$", "name", ",", "$", "file", ")", "{", "$", "this", "->", "_save", "(", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "self", "::", "F_SD", ".", "DIRECTORY_SEPARATOR", ".", "$", "name", ",", ...
Saves a image to the SD format. @param string $path @param string $dest @param string $type
[ "Saves", "a", "image", "to", "the", "SD", "format", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/components/ImageManager.php#L192-L195
train
pulsarvp/vps-tools
src/modules/user/models/User.php
User.getRoleName
public function getRoleName () { $auth = Yii::$app->getAuthManager(); $roles = $auth->getRolesByUser($this->id); $role = current($roles); return $role ? $role->name : null; }
php
public function getRoleName () { $auth = Yii::$app->getAuthManager(); $roles = $auth->getRolesByUser($this->id); $role = current($roles); return $role ? $role->name : null; }
[ "public", "function", "getRoleName", "(", ")", "{", "$", "auth", "=", "Yii", "::", "$", "app", "->", "getAuthManager", "(", ")", ";", "$", "roles", "=", "$", "auth", "->", "getRolesByUser", "(", "$", "this", "->", "id", ")", ";", "$", "role", "=", ...
Gets user role. @return string|null
[ "Gets", "user", "role", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/modules/user/models/User.php#L57-L64
train
pulsarvp/vps-tools
src/modules/user/models/User.php
User.getRolesNames
public function getRolesNames () { $auth = Yii::$app->getAuthManager(); $rolesByUser = $auth->getRolesByUser($this->id); $roles = ArrayHelper::objectsAttribute($rolesByUser, 'name'); return $roles; }
php
public function getRolesNames () { $auth = Yii::$app->getAuthManager(); $rolesByUser = $auth->getRolesByUser($this->id); $roles = ArrayHelper::objectsAttribute($rolesByUser, 'name'); return $roles; }
[ "public", "function", "getRolesNames", "(", ")", "{", "$", "auth", "=", "Yii", "::", "$", "app", "->", "getAuthManager", "(", ")", ";", "$", "rolesByUser", "=", "$", "auth", "->", "getRolesByUser", "(", "$", "this", "->", "id", ")", ";", "$", "roles"...
Gets user all roles. @return array
[ "Gets", "user", "all", "roles", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/modules/user/models/User.php#L71-L78
train
pulsarvp/vps-tools
src/modules/user/models/User.php
User.register
public function register ($name, $email, $profile, $active) { $this->active = $active; $this->name = $name; $this->email = $email; $this->profile = $profile; $this->loginDT = TimeHelper::now(); return $this->save(); }
php
public function register ($name, $email, $profile, $active) { $this->active = $active; $this->name = $name; $this->email = $email; $this->profile = $profile; $this->loginDT = TimeHelper::now(); return $this->save(); }
[ "public", "function", "register", "(", "$", "name", ",", "$", "email", ",", "$", "profile", ",", "$", "active", ")", "{", "$", "this", "->", "active", "=", "$", "active", ";", "$", "this", "->", "name", "=", "$", "name", ";", "$", "this", "->", ...
Saves user with given parameters. @param string $name @param string $email @param string $profile @return bool Whether user save was successful.
[ "Saves", "user", "with", "given", "parameters", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/modules/user/models/User.php#L154-L163
train
bearcms/bearframework-addon
classes/BearCMS.php
BearCMS.disabledCheck
public function disabledCheck(): ?\BearFramework\App\Response { $currentUserExists = Config::hasServer() && (Config::hasFeature('USERS') || Config::hasFeature('USERS_LOGIN_*')) ? $this->currentUser->exists() : false; $settings = $this->app->bearCMS->data->settings->get(); $isDisabled = !$currentUserExists && $settings->disabled; if ($isDisabled) { return new App\Response\TemporaryUnavailable(htmlspecialchars($settings->disabledText)); } return null; }
php
public function disabledCheck(): ?\BearFramework\App\Response { $currentUserExists = Config::hasServer() && (Config::hasFeature('USERS') || Config::hasFeature('USERS_LOGIN_*')) ? $this->currentUser->exists() : false; $settings = $this->app->bearCMS->data->settings->get(); $isDisabled = !$currentUserExists && $settings->disabled; if ($isDisabled) { return new App\Response\TemporaryUnavailable(htmlspecialchars($settings->disabledText)); } return null; }
[ "public", "function", "disabledCheck", "(", ")", ":", "?", "\\", "BearFramework", "\\", "App", "\\", "Response", "{", "$", "currentUserExists", "=", "Config", "::", "hasServer", "(", ")", "&&", "(", "Config", "::", "hasFeature", "(", "'USERS'", ")", "||", ...
A middleware to be used in routes that returns a temporary unavailable response if an administrator has disabled the app. @return \BearFramework\App\Response|null
[ "A", "middleware", "to", "be", "used", "in", "routes", "that", "returns", "a", "temporary", "unavailable", "response", "if", "an", "administrator", "has", "disabled", "the", "app", "." ]
7ef131b81aac26070a2b937dd67f530a6caa02f0
https://github.com/bearcms/bearframework-addon/blob/7ef131b81aac26070a2b937dd67f530a6caa02f0/classes/BearCMS.php#L1629-L1638
train
czim/laravel-listify
src/Listify.php
Listify.setListifyConfig
public function setListifyConfig($key, $value) { switch ($key) { case 'add_new_at': if ( ! method_exists($this, "addToList{$value}")) { throw new \UnexpectedValueException("No method exists for applying the add_new_at value '{$value}'."); } break; case 'scope': $normalizedScope = $this->normalizeListifyScope($value); if (null !== $normalizedScope && ! is_string($normalizedScope)) { throw new \InvalidArgumentException("Given list scope does not resolve to a usable where clause"); } break; // default omitted on purpose } $this->listifyConfig[ $key ] = $value; if ($key === 'scope') { $this->rememberCurrentlyUsedScope(); } return $this; }
php
public function setListifyConfig($key, $value) { switch ($key) { case 'add_new_at': if ( ! method_exists($this, "addToList{$value}")) { throw new \UnexpectedValueException("No method exists for applying the add_new_at value '{$value}'."); } break; case 'scope': $normalizedScope = $this->normalizeListifyScope($value); if (null !== $normalizedScope && ! is_string($normalizedScope)) { throw new \InvalidArgumentException("Given list scope does not resolve to a usable where clause"); } break; // default omitted on purpose } $this->listifyConfig[ $key ] = $value; if ($key === 'scope') { $this->rememberCurrentlyUsedScope(); } return $this; }
[ "public", "function", "setListifyConfig", "(", "$", "key", ",", "$", "value", ")", "{", "switch", "(", "$", "key", ")", "{", "case", "'add_new_at'", ":", "if", "(", "!", "method_exists", "(", "$", "this", ",", "\"addToList{$value}\"", ")", ")", "{", "t...
Sets a listify config value. @param string @param mixed @return $this
[ "Sets", "a", "listify", "config", "value", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L117-L146
train
czim/laravel-listify
src/Listify.php
Listify.getListifyConfigValue
protected function getListifyConfigValue($key) { return array_key_exists($key, $this->listifyConfig) ? $this->listifyConfig[ $key ] : null; }
php
protected function getListifyConfigValue($key) { return array_key_exists($key, $this->listifyConfig) ? $this->listifyConfig[ $key ] : null; }
[ "protected", "function", "getListifyConfigValue", "(", "$", "key", ")", "{", "return", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "listifyConfig", ")", "?", "$", "this", "->", "listifyConfig", "[", "$", "key", "]", ":", "null", ";", "}"...
Returns a config value by key, or null if it does not exist. @param string $key @return null|mixed
[ "Returns", "a", "config", "value", "by", "key", "or", "null", "if", "it", "does", "not", "exist", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L194-L197
train
czim/laravel-listify
src/Listify.php
Listify.scopeListifyScope
public function scopeListifyScope(Builder $query) { if (method_exists($this, 'cleanListifyScopedQuery')) { $this->cleanListifyScopedQuery($query); } return $query->whereRaw($this->listifyScopeCondition()); }
php
public function scopeListifyScope(Builder $query) { if (method_exists($this, 'cleanListifyScopedQuery')) { $this->cleanListifyScopedQuery($query); } return $query->whereRaw($this->listifyScopeCondition()); }
[ "public", "function", "scopeListifyScope", "(", "Builder", "$", "query", ")", "{", "if", "(", "method_exists", "(", "$", "this", ",", "'cleanListifyScopedQuery'", ")", ")", "{", "$", "this", "->", "cleanListifyScopedQuery", "(", "$", "query", ")", ";", "}", ...
Applies the listify scope to a query builder instance. Eloquent scope method. @param Builder|QueryBuilder $query @return Builder|QueryBuilder
[ "Applies", "the", "listify", "scope", "to", "a", "query", "builder", "instance", ".", "Eloquent", "scope", "method", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L211-L218
train
czim/laravel-listify
src/Listify.php
Listify.scopeInList
public function scopeInList(Builder $query) { return $query->listifyScope()->whereNotNull($this->getTable() . "." . $this->positionColumn()); }
php
public function scopeInList(Builder $query) { return $query->listifyScope()->whereNotNull($this->getTable() . "." . $this->positionColumn()); }
[ "public", "function", "scopeInList", "(", "Builder", "$", "query", ")", "{", "return", "$", "query", "->", "listifyScope", "(", ")", "->", "whereNotNull", "(", "$", "this", "->", "getTable", "(", ")", ".", "\".\"", ".", "$", "this", "->", "positionColumn...
Applies conditions to a query in order to retrieve only the records that are in a list. Eloquent scope method. @param Builder|QueryBuilder|Listify $query @return Builder|QueryBuilder|Listify
[ "Applies", "conditions", "to", "a", "query", "in", "order", "to", "retrieve", "only", "the", "records", "that", "are", "in", "a", "list", ".", "Eloquent", "scope", "method", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L227-L230
train
czim/laravel-listify
src/Listify.php
Listify.addToListBottom
protected function addToListBottom() { if ($this->isInList()) return; $newPosition = $this->getBottomPositionValue(); if (null === $newPosition) { $newPosition = $this->listifyTop(); } else { $newPosition += 1; } $this->setListifyPosition($newPosition); }
php
protected function addToListBottom() { if ($this->isInList()) return; $newPosition = $this->getBottomPositionValue(); if (null === $newPosition) { $newPosition = $this->listifyTop(); } else { $newPosition += 1; } $this->setListifyPosition($newPosition); }
[ "protected", "function", "addToListBottom", "(", ")", "{", "if", "(", "$", "this", "->", "isInList", "(", ")", ")", "return", ";", "$", "newPosition", "=", "$", "this", "->", "getBottomPositionValue", "(", ")", ";", "if", "(", "null", "===", "$", "newP...
Adds record to the bottom of the list. Note that this does not save the model.
[ "Adds", "record", "to", "the", "bottom", "of", "the", "list", ".", "Note", "that", "this", "does", "not", "save", "the", "model", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L299-L312
train
czim/laravel-listify
src/Listify.php
Listify.insertAt
public function insertAt($position = null) { if (null === $position) { $position = $this->listifyTop(); } $this->insertAtPositionAndReorder($position); return $this; }
php
public function insertAt($position = null) { if (null === $position) { $position = $this->listifyTop(); } $this->insertAtPositionAndReorder($position); return $this; }
[ "public", "function", "insertAt", "(", "$", "position", "=", "null", ")", "{", "if", "(", "null", "===", "$", "position", ")", "{", "$", "position", "=", "$", "this", "->", "listifyTop", "(", ")", ";", "}", "$", "this", "->", "insertAtPositionAndReorde...
Inserts record at the given position. This re-arranges the affected surrounding records. @param integer $position default is listifyTop() @return $this
[ "Inserts", "record", "at", "the", "given", "position", ".", "This", "re", "-", "arranges", "the", "affected", "surrounding", "records", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L321-L330
train
czim/laravel-listify
src/Listify.php
Listify.moveToBottom
public function moveToBottom() { if ($this->isNotInList()) return $this; $this->getConnection()->transaction(function() { $this->decrementPositionsOfItemsBelow(); $bottomPosition = $this->getBottomPositionValue($this); $newPosition = (null === $bottomPosition) ? $this->listifyTop() : $bottomPosition + 1; $this->setListPosition($newPosition); }); return $this; }
php
public function moveToBottom() { if ($this->isNotInList()) return $this; $this->getConnection()->transaction(function() { $this->decrementPositionsOfItemsBelow(); $bottomPosition = $this->getBottomPositionValue($this); $newPosition = (null === $bottomPosition) ? $this->listifyTop() : $bottomPosition + 1; $this->setListPosition($newPosition); }); return $this; }
[ "public", "function", "moveToBottom", "(", ")", "{", "if", "(", "$", "this", "->", "isNotInList", "(", ")", ")", "return", "$", "this", ";", "$", "this", "->", "getConnection", "(", ")", "->", "transaction", "(", "function", "(", ")", "{", "$", "this...
Moves the record to the bottom of the list. This re-arranges the affected surrounding records. @return $this
[ "Moves", "the", "record", "to", "the", "bottom", "of", "the", "list", ".", "This", "re", "-", "arranges", "the", "affected", "surrounding", "records", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L386-L401
train
czim/laravel-listify
src/Listify.php
Listify.moveToTop
public function moveToTop() { if ($this->isNotInList()) return $this; $this->getConnection()->transaction(function() { $this->incrementPositionsOfItemsAbove(); $this->setListPosition($this->listifyTop()); }); return $this; }
php
public function moveToTop() { if ($this->isNotInList()) return $this; $this->getConnection()->transaction(function() { $this->incrementPositionsOfItemsAbove(); $this->setListPosition($this->listifyTop()); }); return $this; }
[ "public", "function", "moveToTop", "(", ")", "{", "if", "(", "$", "this", "->", "isNotInList", "(", ")", ")", "return", "$", "this", ";", "$", "this", "->", "getConnection", "(", ")", "->", "transaction", "(", "function", "(", ")", "{", "$", "this", ...
Moves the record to the top of the list. This re-arranges the affected surrounding records. @return $this
[ "Moves", "the", "record", "to", "the", "top", "of", "the", "list", ".", "This", "re", "-", "arranges", "the", "affected", "surrounding", "records", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L409-L421
train
czim/laravel-listify
src/Listify.php
Listify.removeFromList
public function removeFromList() { if ( ! $this->isInList()) return $this; $this->decrementPositionsOfItemsBelow(); $this->setListPosition(null); return $this; }
php
public function removeFromList() { if ( ! $this->isInList()) return $this; $this->decrementPositionsOfItemsBelow(); $this->setListPosition(null); return $this; }
[ "public", "function", "removeFromList", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isInList", "(", ")", ")", "return", "$", "this", ";", "$", "this", "->", "decrementPositionsOfItemsBelow", "(", ")", ";", "$", "this", "->", "setListPosition", "("...
Removes the record from the list. This re-arranges the affected surrounding records. @return $this
[ "Removes", "the", "record", "from", "the", "list", ".", "This", "re", "-", "arranges", "the", "affected", "surrounding", "records", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L429-L437
train
czim/laravel-listify
src/Listify.php
Listify.decrementPosition
public function decrementPosition($count = 1) { if ($this->isNotInList()) return $this; $newPosition = $this->getListifyPosition() - $count; if ($newPosition < $this->listifyTop()) { $newPosition = $this->listifyTop(); } $this->setListifyPosition($newPosition); return $this; }
php
public function decrementPosition($count = 1) { if ($this->isNotInList()) return $this; $newPosition = $this->getListifyPosition() - $count; if ($newPosition < $this->listifyTop()) { $newPosition = $this->listifyTop(); } $this->setListifyPosition($newPosition); return $this; }
[ "public", "function", "decrementPosition", "(", "$", "count", "=", "1", ")", "{", "if", "(", "$", "this", "->", "isNotInList", "(", ")", ")", "return", "$", "this", ";", "$", "newPosition", "=", "$", "this", "->", "getListifyPosition", "(", ")", "-", ...
Decrease the position of the record without affecting other record positions. @param integer $count default 1 @return $this
[ "Decrease", "the", "position", "of", "the", "record", "without", "affecting", "other", "record", "positions", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L461-L474
train
czim/laravel-listify
src/Listify.php
Listify.higherItems
public function higherItems($limit = null) { if ($this->isNotInList()) return null; $query = $this->listifyScopedQuery() ->where($this->positionColumn(), '<', $this->getListifyPosition()) ->orderBy($this->getTable() . '.' . $this->positionColumn(), 'DESC'); if (null !== $limit) { $query->take($limit); } return $query->get(); }
php
public function higherItems($limit = null) { if ($this->isNotInList()) return null; $query = $this->listifyScopedQuery() ->where($this->positionColumn(), '<', $this->getListifyPosition()) ->orderBy($this->getTable() . '.' . $this->positionColumn(), 'DESC'); if (null !== $limit) { $query->take($limit); } return $query->get(); }
[ "public", "function", "higherItems", "(", "$", "limit", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isNotInList", "(", ")", ")", "return", "null", ";", "$", "query", "=", "$", "this", "->", "listifyScopedQuery", "(", ")", "->", "where", "("...
Returns a number of previous records on the list, above the current record. @param null|integer $limit the maximum number of records to retrieve @return \Illuminate\Database\Eloquent\Collection|static[]
[ "Returns", "a", "number", "of", "previous", "records", "on", "the", "list", "above", "the", "current", "record", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L523-L536
train
czim/laravel-listify
src/Listify.php
Listify.lowerItem
public function lowerItem() { if ($this->isNotInList()) return null; return $this->listifyScopedQuery() ->where($this->positionColumn(), '>', $this->getListifyPosition()) ->orderBy($this->getTable() . '.' . $this->positionColumn()) ->first(); }
php
public function lowerItem() { if ($this->isNotInList()) return null; return $this->listifyScopedQuery() ->where($this->positionColumn(), '>', $this->getListifyPosition()) ->orderBy($this->getTable() . '.' . $this->positionColumn()) ->first(); }
[ "public", "function", "lowerItem", "(", ")", "{", "if", "(", "$", "this", "->", "isNotInList", "(", ")", ")", "return", "null", ";", "return", "$", "this", "->", "listifyScopedQuery", "(", ")", "->", "where", "(", "$", "this", "->", "positionColumn", "...
Returns the next record on the list, the one below the current record. @return null|static
[ "Returns", "the", "next", "record", "on", "the", "list", "the", "one", "below", "the", "current", "record", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L544-L552
train
czim/laravel-listify
src/Listify.php
Listify.hasListifyScopeChanged
protected function hasListifyScopeChanged() { $scope = $this->normalizeListifyScope($this->getScopeName(), true); if ($scope instanceof BelongsTo) { // for BelongsTo scopes, use a cleaner way to check for differences $foreignKey = $scope->getForeignKeyName(); return (Arr::get($this->getOriginal(), $foreignKey) != $this->getAttribute($foreignKey)); } if (null === $this->stringScopeValue && ! $this->stringScopeNullExplicitlySet) { // if the known previous scope is null, make sure this isn't the result of a // variable scope that returned null - if that is the case, the scope has changed if (null !== $scope && $this->hasVariableListifyScope()) { $this->swapChangedAttributes(); $previousScope = $this->normalizeListifyScope($this->getScopeName()); $this->swapChangedAttributes(); if (null === $previousScope) return true; } $this->stringScopeValue = $scope; $this->stringScopeNullExplicitlySet = (null === $scope); return false; } return ($scope != $this->stringScopeValue); }
php
protected function hasListifyScopeChanged() { $scope = $this->normalizeListifyScope($this->getScopeName(), true); if ($scope instanceof BelongsTo) { // for BelongsTo scopes, use a cleaner way to check for differences $foreignKey = $scope->getForeignKeyName(); return (Arr::get($this->getOriginal(), $foreignKey) != $this->getAttribute($foreignKey)); } if (null === $this->stringScopeValue && ! $this->stringScopeNullExplicitlySet) { // if the known previous scope is null, make sure this isn't the result of a // variable scope that returned null - if that is the case, the scope has changed if (null !== $scope && $this->hasVariableListifyScope()) { $this->swapChangedAttributes(); $previousScope = $this->normalizeListifyScope($this->getScopeName()); $this->swapChangedAttributes(); if (null === $previousScope) return true; } $this->stringScopeValue = $scope; $this->stringScopeNullExplicitlySet = (null === $scope); return false; } return ($scope != $this->stringScopeValue); }
[ "protected", "function", "hasListifyScopeChanged", "(", ")", "{", "$", "scope", "=", "$", "this", "->", "normalizeListifyScope", "(", "$", "this", "->", "getScopeName", "(", ")", ",", "true", ")", ";", "if", "(", "$", "scope", "instanceof", "BelongsTo", ")...
Returns whether the scope has changed since it was last applied. Note that this also updates the last known scope, resetting the changed state back to false @return boolean
[ "Returns", "whether", "the", "scope", "has", "changed", "since", "it", "was", "last", "applied", ".", "Note", "that", "this", "also", "updates", "the", "last", "known", "scope", "resetting", "the", "changed", "state", "back", "to", "false" ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L648-L677
train
czim/laravel-listify
src/Listify.php
Listify.normalizeListifyScope
protected function normalizeListifyScope($scope, $doNotResolveBelongsTo = false) { if ($scope instanceof BelongsTo) { if ($doNotResolveBelongsTo) return $scope; return $this->getConditionStringFromBelongsTo($scope); } if ($scope instanceof QueryBuilder) { return $this->getConditionStringFromQueryBuilder($scope); } if (is_callable($scope)) { return $this->normalizeListifyScope( $scope($this) ); } // scope can only be a string in this case return $scope; }
php
protected function normalizeListifyScope($scope, $doNotResolveBelongsTo = false) { if ($scope instanceof BelongsTo) { if ($doNotResolveBelongsTo) return $scope; return $this->getConditionStringFromBelongsTo($scope); } if ($scope instanceof QueryBuilder) { return $this->getConditionStringFromQueryBuilder($scope); } if (is_callable($scope)) { return $this->normalizeListifyScope( $scope($this) ); } // scope can only be a string in this case return $scope; }
[ "protected", "function", "normalizeListifyScope", "(", "$", "scope", ",", "$", "doNotResolveBelongsTo", "=", "false", ")", "{", "if", "(", "$", "scope", "instanceof", "BelongsTo", ")", "{", "if", "(", "$", "doNotResolveBelongsTo", ")", "return", "$", "scope", ...
Normalizes the currently applicable list scope to a string or BelongsTo relation instance. @param mixed $scope @param boolean $doNotResolveBelongsTo if true, does not stringify a BelongsTo instance @return string|BelongsTo
[ "Normalizes", "the", "currently", "applicable", "list", "scope", "to", "a", "string", "or", "BelongsTo", "relation", "instance", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L712-L730
train
czim/laravel-listify
src/Listify.php
Listify.listifyScopeCondition
protected function listifyScopeCondition() { $this->stringScopeValue = $this->normalizeListifyScope($this->getScopeName()); $this->stringScopeNullExplicitlySet = (null === $this->stringScopeValue); return $this->stringScopeValue; }
php
protected function listifyScopeCondition() { $this->stringScopeValue = $this->normalizeListifyScope($this->getScopeName()); $this->stringScopeNullExplicitlySet = (null === $this->stringScopeValue); return $this->stringScopeValue; }
[ "protected", "function", "listifyScopeCondition", "(", ")", "{", "$", "this", "->", "stringScopeValue", "=", "$", "this", "->", "normalizeListifyScope", "(", "$", "this", "->", "getScopeName", "(", ")", ")", ";", "$", "this", "->", "stringScopeNullExplicitlySet"...
Returns string version of current listify scope. @return string
[ "Returns", "string", "version", "of", "current", "listify", "scope", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L737-L744
train
czim/laravel-listify
src/Listify.php
Listify.listifyScopedQuery
protected function listifyScopedQuery() { $model = new static; $model->setListifyConfig('scope', $this->listifyScopeCondition()); // if set, call a method that may be used to remove global scopes // and other automatically active listify-scope breaking clauses if (method_exists($this, 'cleanListifyScopedQuery')) { $model = $this->cleanListifyScopedQuery($model); } return $model->whereRaw($this->listifyScopeCondition()); }
php
protected function listifyScopedQuery() { $model = new static; $model->setListifyConfig('scope', $this->listifyScopeCondition()); // if set, call a method that may be used to remove global scopes // and other automatically active listify-scope breaking clauses if (method_exists($this, 'cleanListifyScopedQuery')) { $model = $this->cleanListifyScopedQuery($model); } return $model->whereRaw($this->listifyScopeCondition()); }
[ "protected", "function", "listifyScopedQuery", "(", ")", "{", "$", "model", "=", "new", "static", ";", "$", "model", "->", "setListifyConfig", "(", "'scope'", ",", "$", "this", "->", "listifyScopeCondition", "(", ")", ")", ";", "// if set, call a method that may...
Returns a fresh query builder after re-applying the listify scope condition. @return Builder
[ "Returns", "a", "fresh", "query", "builder", "after", "re", "-", "applying", "the", "listify", "scope", "condition", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L752-L765
train
czim/laravel-listify
src/Listify.php
Listify.handleListifyScopeChange
protected function handleListifyScopeChange() { if ( ! $this->hasListifyScopeChanged()) return; $this->rememberCurrentlyUsedScope(); // swap the attributes so the record is scoped in its old scope $this->swapChangedAttributes(); if ( ! $this->excludeFromList() && $this->lowerItem()) { $this->decrementPositionsOfItemsBelow(); } // swap the attributes back, so the item can be positioned in its new scope $this->swapChangedAttributes(); // unset its position, so it will get the correct new position in its new scope $this->setListifyPosition(null); $this->performConfiguredAddMethod($this); }
php
protected function handleListifyScopeChange() { if ( ! $this->hasListifyScopeChanged()) return; $this->rememberCurrentlyUsedScope(); // swap the attributes so the record is scoped in its old scope $this->swapChangedAttributes(); if ( ! $this->excludeFromList() && $this->lowerItem()) { $this->decrementPositionsOfItemsBelow(); } // swap the attributes back, so the item can be positioned in its new scope $this->swapChangedAttributes(); // unset its position, so it will get the correct new position in its new scope $this->setListifyPosition(null); $this->performConfiguredAddMethod($this); }
[ "protected", "function", "handleListifyScopeChange", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasListifyScopeChanged", "(", ")", ")", "return", ";", "$", "this", "->", "rememberCurrentlyUsedScope", "(", ")", ";", "// swap the attributes so the record is sc...
Checks and handles when the model's list scope has changed. Makes sure that the old list positions are adjusted and the model is correctly placed in the new list.
[ "Checks", "and", "handles", "when", "the", "model", "s", "list", "scope", "has", "changed", ".", "Makes", "sure", "that", "the", "old", "list", "positions", "are", "adjusted", "and", "the", "model", "is", "correctly", "placed", "in", "the", "new", "list", ...
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L772-L792
train
czim/laravel-listify
src/Listify.php
Listify.reorderPositionsOnItemsBetween
protected function reorderPositionsOnItemsBetween($positionBefore, $positionAfter, $ignoreId = null) { if ($positionBefore == $positionAfter) { return; } $query = $this->listifyScopedQuery(); if ($ignoreId) { $query->where($this->getPrimaryKey(), '!=', $ignoreId); } if ($positionBefore < $positionAfter) { // increment the in-between positions $query ->where($this->positionColumn(), '>', $positionBefore) ->where($this->positionColumn(), '<=', $positionAfter) ->decrement($this->positionColumn()); } else { // decrement the in-between positions $query ->where($this->positionColumn(), '>=', $positionAfter) ->where($this->positionColumn(), '<', $positionBefore) ->increment($this->positionColumn()); } }
php
protected function reorderPositionsOnItemsBetween($positionBefore, $positionAfter, $ignoreId = null) { if ($positionBefore == $positionAfter) { return; } $query = $this->listifyScopedQuery(); if ($ignoreId) { $query->where($this->getPrimaryKey(), '!=', $ignoreId); } if ($positionBefore < $positionAfter) { // increment the in-between positions $query ->where($this->positionColumn(), '>', $positionBefore) ->where($this->positionColumn(), '<=', $positionAfter) ->decrement($this->positionColumn()); } else { // decrement the in-between positions $query ->where($this->positionColumn(), '>=', $positionAfter) ->where($this->positionColumn(), '<', $positionBefore) ->increment($this->positionColumn()); } }
[ "protected", "function", "reorderPositionsOnItemsBetween", "(", "$", "positionBefore", ",", "$", "positionAfter", ",", "$", "ignoreId", "=", "null", ")", "{", "if", "(", "$", "positionBefore", "==", "$", "positionAfter", ")", "{", "return", ";", "}", "$", "q...
Reorders the positions of all items between two affected positions. @param integer $positionBefore @param integer $positionAfter @param null|integer $ignoreId
[ "Reorders", "the", "positions", "of", "all", "items", "between", "two", "affected", "positions", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L828-L856
train
czim/laravel-listify
src/Listify.php
Listify.decrementPositionsOfItemsBelow
protected function decrementPositionsOfItemsBelow($position = null) { if ($this->isNotInList()) return; if (null === $position) { $position = $this->getListifyPosition(); } $this->listifyScopedQuery() ->where($this->positionColumn(), '>', $position) ->decrement($this->positionColumn()); }
php
protected function decrementPositionsOfItemsBelow($position = null) { if ($this->isNotInList()) return; if (null === $position) { $position = $this->getListifyPosition(); } $this->listifyScopedQuery() ->where($this->positionColumn(), '>', $position) ->decrement($this->positionColumn()); }
[ "protected", "function", "decrementPositionsOfItemsBelow", "(", "$", "position", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isNotInList", "(", ")", ")", "return", ";", "if", "(", "null", "===", "$", "position", ")", "{", "$", "position", "=", ...
Increments the position values of records with a higher position value than the given. Note that 'below' means a higher position value. @param null|integer $position if null, uses this record's current position
[ "Increments", "the", "position", "values", "of", "records", "with", "a", "higher", "position", "value", "than", "the", "given", ".", "Note", "that", "below", "means", "a", "higher", "position", "value", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L864-L875
train
czim/laravel-listify
src/Listify.php
Listify.incrementPositionsOfItemsAbove
protected function incrementPositionsOfItemsAbove($position = null) { if ($this->isNotInList()) return; if (null === $position) { $position = $this->getListifyPosition(); } $this->listifyScopedQuery() ->where($this->positionColumn(), '<', $position) ->increment($this->positionColumn()); }
php
protected function incrementPositionsOfItemsAbove($position = null) { if ($this->isNotInList()) return; if (null === $position) { $position = $this->getListifyPosition(); } $this->listifyScopedQuery() ->where($this->positionColumn(), '<', $position) ->increment($this->positionColumn()); }
[ "protected", "function", "incrementPositionsOfItemsAbove", "(", "$", "position", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isNotInList", "(", ")", ")", "return", ";", "if", "(", "null", "===", "$", "position", ")", "{", "$", "position", "=", ...
Increments the position values of records with a lower position value than the given. Note that 'above' means a lower position value. @param null|integer $position if null, uses this record's current position
[ "Increments", "the", "position", "values", "of", "records", "with", "a", "lower", "position", "value", "than", "the", "given", ".", "Note", "that", "above", "means", "a", "lower", "position", "value", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L883-L894
train
czim/laravel-listify
src/Listify.php
Listify.incrementPositionsOfItemsBelow
protected function incrementPositionsOfItemsBelow($position) { $this->listifyScopedQuery() ->where($this->positionColumn(), '>=', $position) ->increment($this->positionColumn()); }
php
protected function incrementPositionsOfItemsBelow($position) { $this->listifyScopedQuery() ->where($this->positionColumn(), '>=', $position) ->increment($this->positionColumn()); }
[ "protected", "function", "incrementPositionsOfItemsBelow", "(", "$", "position", ")", "{", "$", "this", "->", "listifyScopedQuery", "(", ")", "->", "where", "(", "$", "this", "->", "positionColumn", "(", ")", ",", "'>='", ",", "$", "position", ")", "->", "...
Increments the position values of records with a lower position value than the given. Note that 'below' means a smaller position value. @param integer $position if null, uses this record's current position
[ "Increments", "the", "position", "values", "of", "records", "with", "a", "lower", "position", "value", "than", "the", "given", ".", "Note", "that", "below", "means", "a", "smaller", "position", "value", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L902-L907
train
czim/laravel-listify
src/Listify.php
Listify.updateListifyPositions
protected function updateListifyPositions() { $newPosition = $this->getListifyPosition(); // check for duplicate positions and resolve them if required if (null === $newPosition) return; $count = $this->listifyScopedQuery() ->where($this->positionColumn(), $newPosition) ->count(); if ($count < 2) return; $oldPosition = Arr::get($this->getOriginal(), $this->positionColumn(), false); if (false === $oldPosition) return; // reorder positions while excluding the current model $this->reorderPositionsOnItemsBetween($oldPosition, $newPosition, $this->id); }
php
protected function updateListifyPositions() { $newPosition = $this->getListifyPosition(); // check for duplicate positions and resolve them if required if (null === $newPosition) return; $count = $this->listifyScopedQuery() ->where($this->positionColumn(), $newPosition) ->count(); if ($count < 2) return; $oldPosition = Arr::get($this->getOriginal(), $this->positionColumn(), false); if (false === $oldPosition) return; // reorder positions while excluding the current model $this->reorderPositionsOnItemsBetween($oldPosition, $newPosition, $this->id); }
[ "protected", "function", "updateListifyPositions", "(", ")", "{", "$", "newPosition", "=", "$", "this", "->", "getListifyPosition", "(", ")", ";", "// check for duplicate positions and resolve them if required", "if", "(", "null", "===", "$", "newPosition", ")", "retu...
Updates all record positions based on changed position of the record in the current list.
[ "Updates", "all", "record", "positions", "based", "on", "changed", "position", "of", "the", "record", "in", "the", "current", "list", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L920-L939
train
czim/laravel-listify
src/Listify.php
Listify.getBottomPositionValue
protected function getBottomPositionValue($exclude = null) { $item = $this->getBottomItem($exclude); if ( ! $item) return null; return $item->getListifyPosition(); }
php
protected function getBottomPositionValue($exclude = null) { $item = $this->getBottomItem($exclude); if ( ! $item) return null; return $item->getListifyPosition(); }
[ "protected", "function", "getBottomPositionValue", "(", "$", "exclude", "=", "null", ")", "{", "$", "item", "=", "$", "this", "->", "getBottomItem", "(", "$", "exclude", ")", ";", "if", "(", "!", "$", "item", ")", "return", "null", ";", "return", "$", ...
Returns the value of the bottom position. @param null|Model|Listify $exclude a model whose value to exclude in determining the position @return integer|null
[ "Returns", "the", "value", "of", "the", "bottom", "position", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L948-L955
train
czim/laravel-listify
src/Listify.php
Listify.getBottomItem
protected function getBottomItem(Model $exclude = null) { $query = $this->listifyScopedQuery() ->whereNotNull($this->getTable() . '.' . $this->positionColumn()) ->orderBy($this->getTable() . "." . $this->positionColumn(), "DESC") ->take(1); if ($exclude) { $query->where($this->getPrimaryKey(), '!=', $exclude->id); } return $query->first(); }
php
protected function getBottomItem(Model $exclude = null) { $query = $this->listifyScopedQuery() ->whereNotNull($this->getTable() . '.' . $this->positionColumn()) ->orderBy($this->getTable() . "." . $this->positionColumn(), "DESC") ->take(1); if ($exclude) { $query->where($this->getPrimaryKey(), '!=', $exclude->id); } return $query->first(); }
[ "protected", "function", "getBottomItem", "(", "Model", "$", "exclude", "=", "null", ")", "{", "$", "query", "=", "$", "this", "->", "listifyScopedQuery", "(", ")", "->", "whereNotNull", "(", "$", "this", "->", "getTable", "(", ")", ".", "'.'", ".", "$...
Returns the bottom item. @param null|Model|Listify $exclude a model to exclude as a match @return null|Model|Listify
[ "Returns", "the", "bottom", "item", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L963-L975
train
czim/laravel-listify
src/Listify.php
Listify.getConditionStringFromQueryBuilder
protected function getConditionStringFromQueryBuilder(QueryBuilder $query) { $initialQueryChunks = explode('where ', $query->toSql()); if (count($initialQueryChunks) == 1) { throw new InvalidArgumentException( 'The query builder instance must have a where clause to build a condition string from' ); } $queryChunks = explode('?', $initialQueryChunks[1]); $chunkCount = count($queryChunks); $bindings = $query->getBindings(); $whereString = ''; for ($i = 0; $i < $chunkCount; $i++) { $whereString .= $queryChunks[ $i ]; if (isset($bindings[ $i ])) { if (gettype($bindings[ $i ]) === 'string') { $whereString .= '"' . $bindings[ $i ] . '"'; } } } return $whereString; }
php
protected function getConditionStringFromQueryBuilder(QueryBuilder $query) { $initialQueryChunks = explode('where ', $query->toSql()); if (count($initialQueryChunks) == 1) { throw new InvalidArgumentException( 'The query builder instance must have a where clause to build a condition string from' ); } $queryChunks = explode('?', $initialQueryChunks[1]); $chunkCount = count($queryChunks); $bindings = $query->getBindings(); $whereString = ''; for ($i = 0; $i < $chunkCount; $i++) { $whereString .= $queryChunks[ $i ]; if (isset($bindings[ $i ])) { if (gettype($bindings[ $i ]) === 'string') { $whereString .= '"' . $bindings[ $i ] . '"'; } } } return $whereString; }
[ "protected", "function", "getConditionStringFromQueryBuilder", "(", "QueryBuilder", "$", "query", ")", "{", "$", "initialQueryChunks", "=", "explode", "(", "'where '", ",", "$", "query", "->", "toSql", "(", ")", ")", ";", "if", "(", "count", "(", "$", "initi...
Extracts a raw WHERE clause string from a QueryBuilder instance. Note that this is practically identical to the original Listify. @param QueryBuilder $query A Query Builder instance @return string
[ "Extracts", "a", "raw", "WHERE", "clause", "string", "from", "a", "QueryBuilder", "instance", ".", "Note", "that", "this", "is", "practically", "identical", "to", "the", "original", "Listify", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L990-L1018
train
czim/laravel-listify
src/Listify.php
Listify.getConditionStringFromBelongsTo
protected function getConditionStringFromBelongsTo(BelongsTo $relation) { $id = $this->getAttribute( $relation->getForeignKeyName() ); // an empty foreign key will, as a null-scope, remove the item from any list if (null === $id) return null; return '`' . $relation->getForeignKeyName() . '` = ' . (int) $id; }
php
protected function getConditionStringFromBelongsTo(BelongsTo $relation) { $id = $this->getAttribute( $relation->getForeignKeyName() ); // an empty foreign key will, as a null-scope, remove the item from any list if (null === $id) return null; return '`' . $relation->getForeignKeyName() . '` = ' . (int) $id; }
[ "protected", "function", "getConditionStringFromBelongsTo", "(", "BelongsTo", "$", "relation", ")", "{", "$", "id", "=", "$", "this", "->", "getAttribute", "(", "$", "relation", "->", "getForeignKeyName", "(", ")", ")", ";", "// an empty foreign key will, as a null-...
Makes a raw where condition string from a BelongsTo relation instance. @param BelongsTo $relation @return string
[ "Makes", "a", "raw", "where", "condition", "string", "from", "a", "BelongsTo", "relation", "instance", "." ]
c7c12faacf43de1c024a7b39cb44183d2711a838
https://github.com/czim/laravel-listify/blob/c7c12faacf43de1c024a7b39cb44183d2711a838/src/Listify.php#L1026-L1034
train
EmchBerger/cube-custom-fields-bundle
src/Form/DataTransformer/EntityCustomFieldTransformer.php
EntityCustomFieldTransformer.transform
public function transform($collection) { if ($collection && !is_array($collection) && !($collection instanceof \ArrayAccess)) { // in case of single entity, we have to make sure it's managed if (!$this->er->getManager()->contains($collection)) { $collection = $this->er->getManager()->merge($collection); } } return $collection; }
php
public function transform($collection) { if ($collection && !is_array($collection) && !($collection instanceof \ArrayAccess)) { // in case of single entity, we have to make sure it's managed if (!$this->er->getManager()->contains($collection)) { $collection = $this->er->getManager()->merge($collection); } } return $collection; }
[ "public", "function", "transform", "(", "$", "collection", ")", "{", "if", "(", "$", "collection", "&&", "!", "is_array", "(", "$", "collection", ")", "&&", "!", "(", "$", "collection", "instanceof", "\\", "ArrayAccess", ")", ")", "{", "// in case of singl...
No real transformation required in forward direction @return mixed An array of entities @throws TransformationFailedException
[ "No", "real", "transformation", "required", "in", "forward", "direction" ]
7c87f9e8e0f7a5f50536d0d801c04a0ba6de3414
https://github.com/EmchBerger/cube-custom-fields-bundle/blob/7c87f9e8e0f7a5f50536d0d801c04a0ba6de3414/src/Form/DataTransformer/EntityCustomFieldTransformer.php#L32-L41
train
bearcms/bearframework-addon
classes/BearCMS/Themes.php
Themes.register
public function register(string $id, callable $callback): self { Internal\Themes::$registrations[$id] = $callback; if (Config::$initialized) { // Initialize to add asset dirs $currentThemeID = Internal\CurrentTheme::getID(); if ($currentThemeID === $id) { Internal\Themes::initialize($currentThemeID); } } return $this; }
php
public function register(string $id, callable $callback): self { Internal\Themes::$registrations[$id] = $callback; if (Config::$initialized) { // Initialize to add asset dirs $currentThemeID = Internal\CurrentTheme::getID(); if ($currentThemeID === $id) { Internal\Themes::initialize($currentThemeID); } } return $this; }
[ "public", "function", "register", "(", "string", "$", "id", ",", "callable", "$", "callback", ")", ":", "self", "{", "Internal", "\\", "Themes", "::", "$", "registrations", "[", "$", "id", "]", "=", "$", "callback", ";", "if", "(", "Config", "::", "$...
Register a new theme. @param string $id The theme ID. @param callable $callback A function to define theme parameters. @return self Returns a reference to itself.
[ "Register", "a", "new", "theme", "." ]
7ef131b81aac26070a2b937dd67f530a6caa02f0
https://github.com/bearcms/bearframework-addon/blob/7ef131b81aac26070a2b937dd67f530a6caa02f0/classes/BearCMS/Themes.php#L29-L41
train
pulsarvp/vps-tools
src/modules/notification/components/NotificationManager.php
NotificationManager.init
public function init () { if (session_status() == PHP_SESSION_NONE) session_start(); if (isset($_SESSION[ 'notification' ])) { $notification = $_SESSION[ 'notification' ]; foreach ($notification as $type => $data) foreach ($data as $message) $this->_data[] = new Notification($message, $type, true); $_SESSION[ 'notification' ] = []; } parent::init(); }
php
public function init () { if (session_status() == PHP_SESSION_NONE) session_start(); if (isset($_SESSION[ 'notification' ])) { $notification = $_SESSION[ 'notification' ]; foreach ($notification as $type => $data) foreach ($data as $message) $this->_data[] = new Notification($message, $type, true); $_SESSION[ 'notification' ] = []; } parent::init(); }
[ "public", "function", "init", "(", ")", "{", "if", "(", "session_status", "(", ")", "==", "PHP_SESSION_NONE", ")", "session_start", "(", ")", ";", "if", "(", "isset", "(", "$", "_SESSION", "[", "'notification'", "]", ")", ")", "{", "$", "notification", ...
Initialization method for checking if there are some notification stored in session. If so the list of notifications is populated and the list of notifications stored in session is cleared. @return void
[ "Initialization", "method", "for", "checking", "if", "there", "are", "some", "notification", "stored", "in", "session", ".", "If", "so", "the", "list", "of", "notifications", "is", "populated", "and", "the", "list", "of", "notifications", "stored", "in", "sess...
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/modules/notification/components/NotificationManager.php#L70-L84
train
pulsarvp/vps-tools
src/modules/notification/components/NotificationManager.php
NotificationManager.error
public function error ($message, $isRaw = false, $canHide = true) { $this->add($message, Notification::ERROR, $isRaw, $canHide); }
php
public function error ($message, $isRaw = false, $canHide = true) { $this->add($message, Notification::ERROR, $isRaw, $canHide); }
[ "public", "function", "error", "(", "$", "message", ",", "$", "isRaw", "=", "false", ",", "$", "canHide", "=", "true", ")", "{", "$", "this", "->", "add", "(", "$", "message", ",", "Notification", "::", "ERROR", ",", "$", "isRaw", ",", "$", "canHid...
Adds notification of type 'error' to list. @param string $message Message. @param boolean $isRaw Whether given message is raw text or should be translated. @param boolean $canHide viewed button close. @return void
[ "Adds", "notification", "of", "type", "error", "to", "list", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/modules/notification/components/NotificationManager.php#L134-L137
train
pulsarvp/vps-tools
src/modules/notification/components/NotificationManager.php
NotificationManager.errorToSession
public function errorToSession ($message, $isRaw = false, $canHide = true) { $this->toSession($message, Notification::ERROR, $isRaw, $canHide); }
php
public function errorToSession ($message, $isRaw = false, $canHide = true) { $this->toSession($message, Notification::ERROR, $isRaw, $canHide); }
[ "public", "function", "errorToSession", "(", "$", "message", ",", "$", "isRaw", "=", "false", ",", "$", "canHide", "=", "true", ")", "{", "$", "this", "->", "toSession", "(", "$", "message", ",", "Notification", "::", "ERROR", ",", "$", "isRaw", ",", ...
Saves notification of type 'error' type to session. @param string $message Message. @param boolean $isRaw Whether given message is raw text or should be translated. @param boolean $canHide viewed button close. @return void
[ "Saves", "notification", "of", "type", "error", "type", "to", "session", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/modules/notification/components/NotificationManager.php#L147-L150
train
pulsarvp/vps-tools
src/modules/notification/components/NotificationManager.php
NotificationManager.message
public function message ($message, $isRaw = false, $canHide = true) { $this->add($message, Notification::MESSAGE, $isRaw, $canHide); }
php
public function message ($message, $isRaw = false, $canHide = true) { $this->add($message, Notification::MESSAGE, $isRaw, $canHide); }
[ "public", "function", "message", "(", "$", "message", ",", "$", "isRaw", "=", "false", ",", "$", "canHide", "=", "true", ")", "{", "$", "this", "->", "add", "(", "$", "message", ",", "Notification", "::", "MESSAGE", ",", "$", "isRaw", ",", "$", "ca...
Adds notification of type 'message' to list. @param string $message Message. @param boolean $isRaw Whether given message is raw text or should be translated. @param boolean $canHide viewed button close. @return void
[ "Adds", "notification", "of", "type", "message", "to", "list", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/modules/notification/components/NotificationManager.php#L160-L163
train
pulsarvp/vps-tools
src/modules/notification/components/NotificationManager.php
NotificationManager.messageToSession
public function messageToSession ($message, $isRaw = false, $canHide = true) { $this->toSession($message, Notification::MESSAGE, $isRaw, $canHide); }
php
public function messageToSession ($message, $isRaw = false, $canHide = true) { $this->toSession($message, Notification::MESSAGE, $isRaw, $canHide); }
[ "public", "function", "messageToSession", "(", "$", "message", ",", "$", "isRaw", "=", "false", ",", "$", "canHide", "=", "true", ")", "{", "$", "this", "->", "toSession", "(", "$", "message", ",", "Notification", "::", "MESSAGE", ",", "$", "isRaw", ",...
Saves notification of type 'message' type to session. @param string $message Message. @param boolean $isRaw Whether given message is raw text or should be translated. @param boolean $canHide viewed button close. @return void
[ "Saves", "notification", "of", "type", "message", "type", "to", "session", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/modules/notification/components/NotificationManager.php#L173-L176
train
pulsarvp/vps-tools
src/modules/notification/components/NotificationManager.php
NotificationManager.warning
public function warning ($message, $isRaw = false, $canHide = true) { $this->add($message, Notification::WARNING, $isRaw, $canHide); }
php
public function warning ($message, $isRaw = false, $canHide = true) { $this->add($message, Notification::WARNING, $isRaw, $canHide); }
[ "public", "function", "warning", "(", "$", "message", ",", "$", "isRaw", "=", "false", ",", "$", "canHide", "=", "true", ")", "{", "$", "this", "->", "add", "(", "$", "message", ",", "Notification", "::", "WARNING", ",", "$", "isRaw", ",", "$", "ca...
Adds notification of type 'warning' to list. @param string $message Message. @param boolean $isRaw Whether given message is raw text or should be translated. @param boolean $canHide viewed button close. @return void
[ "Adds", "notification", "of", "type", "warning", "to", "list", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/modules/notification/components/NotificationManager.php#L186-L189
train
pulsarvp/vps-tools
src/modules/notification/components/NotificationManager.php
NotificationManager.warningToSession
public function warningToSession ($message, $isRaw = false, $canHide = true) { $this->toSession($message, Notification::WARNING, $isRaw, $canHide); }
php
public function warningToSession ($message, $isRaw = false, $canHide = true) { $this->toSession($message, Notification::WARNING, $isRaw, $canHide); }
[ "public", "function", "warningToSession", "(", "$", "message", ",", "$", "isRaw", "=", "false", ",", "$", "canHide", "=", "true", ")", "{", "$", "this", "->", "toSession", "(", "$", "message", ",", "Notification", "::", "WARNING", ",", "$", "isRaw", ",...
Saves notification of type 'warning' type to session. @param string $message Message. @param boolean $isRaw Whether given message is raw text or should be translated. @param boolean $canHide viewed button close. @return void
[ "Saves", "notification", "of", "type", "warning", "type", "to", "session", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/modules/notification/components/NotificationManager.php#L199-L202
train
pulsarvp/vps-tools
src/modules/notification/components/NotificationManager.php
NotificationManager.add
private function add ($message, $type = Notification::ERROR, $isRaw = false, $canHide = true) { $this->_data[] = new Notification ($message, $type, $isRaw, $canHide); }
php
private function add ($message, $type = Notification::ERROR, $isRaw = false, $canHide = true) { $this->_data[] = new Notification ($message, $type, $isRaw, $canHide); }
[ "private", "function", "add", "(", "$", "message", ",", "$", "type", "=", "Notification", "::", "ERROR", ",", "$", "isRaw", "=", "false", ",", "$", "canHide", "=", "true", ")", "{", "$", "this", "->", "_data", "[", "]", "=", "new", "Notification", ...
Adds notification to list. @param string $message Message. @param integer $type Message type. @param boolean $isRaw Whether given message is raw text or should be translated. @param boolean $canHide viewed button close. @return void
[ "Adds", "notification", "to", "list", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/modules/notification/components/NotificationManager.php#L213-L216
train
pulsarvp/vps-tools
src/modules/notification/components/NotificationManager.php
NotificationManager.getNotifications
private function getNotifications ($type) { $data = []; /** @var Notification $notification */ foreach ($this->_data as $notification) { if ($notification->type == $type) $data[] = $notification; } return $data; }
php
private function getNotifications ($type) { $data = []; /** @var Notification $notification */ foreach ($this->_data as $notification) { if ($notification->type == $type) $data[] = $notification; } return $data; }
[ "private", "function", "getNotifications", "(", "$", "type", ")", "{", "$", "data", "=", "[", "]", ";", "/** @var Notification $notification */", "foreach", "(", "$", "this", "->", "_data", "as", "$", "notification", ")", "{", "if", "(", "$", "notification",...
Finds all notifications of given type. @param int $type @return array
[ "Finds", "all", "notifications", "of", "given", "type", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/modules/notification/components/NotificationManager.php#L224-L235
train
pulsarvp/vps-tools
src/modules/notification/components/NotificationManager.php
NotificationManager.toSession
private function toSession ($message, $type = Notification::ERROR, $isRaw = false, $canHide = true) { $ntf = new Notification($message, $type, $isRaw, $canHide); $notification = isset($_SESSION[ 'notification' ]) ? $_SESSION[ 'notification' ] : []; $notification[ $type ][] = $ntf->message; $_SESSION[ 'notification' ] = $notification; }
php
private function toSession ($message, $type = Notification::ERROR, $isRaw = false, $canHide = true) { $ntf = new Notification($message, $type, $isRaw, $canHide); $notification = isset($_SESSION[ 'notification' ]) ? $_SESSION[ 'notification' ] : []; $notification[ $type ][] = $ntf->message; $_SESSION[ 'notification' ] = $notification; }
[ "private", "function", "toSession", "(", "$", "message", ",", "$", "type", "=", "Notification", "::", "ERROR", ",", "$", "isRaw", "=", "false", ",", "$", "canHide", "=", "true", ")", "{", "$", "ntf", "=", "new", "Notification", "(", "$", "message", "...
Saves notification to session. @param string $message Message. @param integer $type Message type. @param boolean $isRaw Whether given message is raw text or should be translated. @param boolean $canHide viewed button close. @return void
[ "Saves", "notification", "to", "session", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/modules/notification/components/NotificationManager.php#L246-L254
train
radig/auditable
Lib/QueryLogSource.php
QueryLogSource.getModelQueries
public function getModelQueries(Model $Model, $action = 'create', $associateds = false) { $queries = $this->getCleanLog($Model); $valids = array(); $table = $Model->tablePrefix . $Model->table; foreach ($queries as $query) { // Guarda apenas queries do modelo atual que representam a ação executada if (strpos($query, $table) !== false && strpos($query, $this->mapActionSql[$action]) !== false) { $valids[] = $query; } } return $valids; }
php
public function getModelQueries(Model $Model, $action = 'create', $associateds = false) { $queries = $this->getCleanLog($Model); $valids = array(); $table = $Model->tablePrefix . $Model->table; foreach ($queries as $query) { // Guarda apenas queries do modelo atual que representam a ação executada if (strpos($query, $table) !== false && strpos($query, $this->mapActionSql[$action]) !== false) { $valids[] = $query; } } return $valids; }
[ "public", "function", "getModelQueries", "(", "Model", "$", "Model", ",", "$", "action", "=", "'create'", ",", "$", "associateds", "=", "false", ")", "{", "$", "queries", "=", "$", "this", "->", "getCleanLog", "(", "$", "Model", ")", ";", "$", "valids"...
Recupera todas as queries que foram registradas pelo datasource para um determinado modelo. @param Model $Model Instancia do modelo que terá as queries retornadas. @param string $action 'create' | 'modify' | 'delete' @param bool $associateds Habilita ou não o retorno de queries geradas por modelos relacionados. Não implementado ainda. @return array
[ "Recupera", "todas", "as", "queries", "que", "foram", "registradas", "pelo", "datasource", "para", "um", "determinado", "modelo", "." ]
af8b5031522ebd6d69daa0e694a65c1cb2935b48
https://github.com/radig/auditable/blob/af8b5031522ebd6d69daa0e694a65c1cb2935b48/Lib/QueryLogSource.php#L90-L104
train
gdbots/ncr-php
src/PbjxHelperTrait.php
PbjxHelperTrait.bindFromNode
protected function bindFromNode(Message $message, Node $node, Pbjx $pbjx): void { $node->freeze(); $pbjxEvent = new BindFromNodeEvent($message, $node); $pbjx->trigger($message, 'bind_from_node', $pbjxEvent, false); }
php
protected function bindFromNode(Message $message, Node $node, Pbjx $pbjx): void { $node->freeze(); $pbjxEvent = new BindFromNodeEvent($message, $node); $pbjx->trigger($message, 'bind_from_node', $pbjxEvent, false); }
[ "protected", "function", "bindFromNode", "(", "Message", "$", "message", ",", "Node", "$", "node", ",", "Pbjx", "$", "pbjx", ")", ":", "void", "{", "$", "node", "->", "freeze", "(", ")", ";", "$", "pbjxEvent", "=", "new", "BindFromNodeEvent", "(", "$",...
The handler generally has the current node which provides an opportunity to bind data to the event, response, etc. @param Message $message @param Node $node @param Pbjx $pbjx
[ "The", "handler", "generally", "has", "the", "current", "node", "which", "provides", "an", "opportunity", "to", "bind", "data", "to", "the", "event", "response", "etc", "." ]
b31c1315144f9a5bc6c48463dd77b6c643fdf250
https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/PbjxHelperTrait.php#L61-L66
train
gdbots/ncr-php
src/PbjxHelperTrait.php
PbjxHelperTrait.createGetNodeRequest
protected function createGetNodeRequest(Message $message, NodeRef $nodeRef, Pbjx $pbjx): GetNodeRequest { $curie = $message::schema()->getCurie(); /** @var GetNodeRequest $class */ $class = MessageResolver::resolveCurie(SchemaCurie::fromString( "{$curie->getVendor()}:{$curie->getPackage()}:request:get-{$nodeRef->getLabel()}-request" )); return $class::create(); }
php
protected function createGetNodeRequest(Message $message, NodeRef $nodeRef, Pbjx $pbjx): GetNodeRequest { $curie = $message::schema()->getCurie(); /** @var GetNodeRequest $class */ $class = MessageResolver::resolveCurie(SchemaCurie::fromString( "{$curie->getVendor()}:{$curie->getPackage()}:request:get-{$nodeRef->getLabel()}-request" )); return $class::create(); }
[ "protected", "function", "createGetNodeRequest", "(", "Message", "$", "message", ",", "NodeRef", "$", "nodeRef", ",", "Pbjx", "$", "pbjx", ")", ":", "GetNodeRequest", "{", "$", "curie", "=", "$", "message", "::", "schema", "(", ")", "->", "getCurie", "(", ...
A conventional factory to create a get node request from an existing message and node ref. Various pbjx lifecycle events need to fetch the node for the operation currently executing. For example, when attempting to update a node we fetch the current node in order to make some validations possible. Override this method if the convention doesn't match or needs to have a special case handled. You can also override when you need to populate data on the get node request before it's processed (multi-tenant apps sometimes need this). @param Message $message @param NodeRef $nodeRef @param Pbjx $pbjx @return GetNodeRequest
[ "A", "conventional", "factory", "to", "create", "a", "get", "node", "request", "from", "an", "existing", "message", "and", "node", "ref", ".", "Various", "pbjx", "lifecycle", "events", "need", "to", "fetch", "the", "node", "for", "the", "operation", "current...
b31c1315144f9a5bc6c48463dd77b6c643fdf250
https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/PbjxHelperTrait.php#L84-L94
train
gdbots/ncr-php
src/PbjxHelperTrait.php
PbjxHelperTrait.createResponseFromRequest
protected function createResponseFromRequest(Request $request, Pbjx $pbjx): Response { $curie = str_replace('-request', '-response', $request::schema()->getCurie()->toString()); /** @var Response $class */ $class = MessageResolver::resolveCurie(SchemaCurie::fromString($curie)); return $class::create(); }
php
protected function createResponseFromRequest(Request $request, Pbjx $pbjx): Response { $curie = str_replace('-request', '-response', $request::schema()->getCurie()->toString()); /** @var Response $class */ $class = MessageResolver::resolveCurie(SchemaCurie::fromString($curie)); return $class::create(); }
[ "protected", "function", "createResponseFromRequest", "(", "Request", "$", "request", ",", "Pbjx", "$", "pbjx", ")", ":", "Response", "{", "$", "curie", "=", "str_replace", "(", "'-request'", ",", "'-response'", ",", "$", "request", "::", "schema", "(", ")",...
Conventionally the response messages are named the same as the request but with a "-response" suffix. Override when needed. @param Request $request @param Pbjx $pbjx @return Response
[ "Conventionally", "the", "response", "messages", "are", "named", "the", "same", "as", "the", "request", "but", "with", "a", "-", "response", "suffix", ".", "Override", "when", "needed", "." ]
b31c1315144f9a5bc6c48463dd77b6c643fdf250
https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/PbjxHelperTrait.php#L105-L111
train
gdbots/ncr-php
src/Validator/NodeIdempotencyValidator.php
NodeIdempotencyValidator.onCreateNodeAfterHandle
public function onCreateNodeAfterHandle(PbjxEvent $pbjxEvent): void { $command = $pbjxEvent->getMessage(); if (!$command->has('node')) { return; } /** @var Node $node */ $node = $command->get('node'); if ($this->shouldIgnoreNode($node)) { return; } /** @var CacheItemInterface[] $cacheItems */ $cacheItems = $this->cache->getItems($this->getIdempotencyKeys($node)); foreach ($cacheItems as $cacheItem) { $cacheItem->set(true)->expiresAfter($this->getCacheTtl($node)); $this->cache->saveDeferred($cacheItem); } }
php
public function onCreateNodeAfterHandle(PbjxEvent $pbjxEvent): void { $command = $pbjxEvent->getMessage(); if (!$command->has('node')) { return; } /** @var Node $node */ $node = $command->get('node'); if ($this->shouldIgnoreNode($node)) { return; } /** @var CacheItemInterface[] $cacheItems */ $cacheItems = $this->cache->getItems($this->getIdempotencyKeys($node)); foreach ($cacheItems as $cacheItem) { $cacheItem->set(true)->expiresAfter($this->getCacheTtl($node)); $this->cache->saveDeferred($cacheItem); } }
[ "public", "function", "onCreateNodeAfterHandle", "(", "PbjxEvent", "$", "pbjxEvent", ")", ":", "void", "{", "$", "command", "=", "$", "pbjxEvent", "->", "getMessage", "(", ")", ";", "if", "(", "!", "$", "command", "->", "has", "(", "'node'", ")", ")", ...
Populates cache keys so idempotency check can reject duplicates after nodes are successfully created. @param PbjxEvent $pbjxEvent
[ "Populates", "cache", "keys", "so", "idempotency", "check", "can", "reject", "duplicates", "after", "nodes", "are", "successfully", "created", "." ]
b31c1315144f9a5bc6c48463dd77b6c643fdf250
https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/Validator/NodeIdempotencyValidator.php#L89-L109
train
gdbots/ncr-php
src/Validator/NodeIdempotencyValidator.php
NodeIdempotencyValidator.getIdempotencyKeys
public function getIdempotencyKeys(Node $node): array { $qname = $node::schema()->getQName(); $keys = []; if ($node->has('title')) { $keys[$this->getCacheKey($qname, SlugUtils::create($node->get('title')))] = true; } if ($node->has('slug')) { $keys[$this->getCacheKey($qname, $node->get('slug'))] = true; } if ($node instanceof User && $node->has('email')) { $keys[$this->getCacheKey($qname, $node->get('email'))] = true; } return array_keys($keys); }
php
public function getIdempotencyKeys(Node $node): array { $qname = $node::schema()->getQName(); $keys = []; if ($node->has('title')) { $keys[$this->getCacheKey($qname, SlugUtils::create($node->get('title')))] = true; } if ($node->has('slug')) { $keys[$this->getCacheKey($qname, $node->get('slug'))] = true; } if ($node instanceof User && $node->has('email')) { $keys[$this->getCacheKey($qname, $node->get('email'))] = true; } return array_keys($keys); }
[ "public", "function", "getIdempotencyKeys", "(", "Node", "$", "node", ")", ":", "array", "{", "$", "qname", "=", "$", "node", "::", "schema", "(", ")", "->", "getQName", "(", ")", ";", "$", "keys", "=", "[", "]", ";", "if", "(", "$", "node", "->"...
Derives the keys to use for the idempotency check from the node itself. @param Node $node @return array
[ "Derives", "the", "keys", "to", "use", "for", "the", "idempotency", "check", "from", "the", "node", "itself", "." ]
b31c1315144f9a5bc6c48463dd77b6c643fdf250
https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/Validator/NodeIdempotencyValidator.php#L118-L136
train
starweb/starlit-db
src/BasicDbEntityService.php
BasicDbEntityService.load
public function load(AbstractDbEntity $dbEntity) { // Check that the primary key is set if (!$dbEntity->getPrimaryDbValue()) { throw new \InvalidArgumentException( 'Database entity can not be loaded because primary value is not set' ); } // Fetch ad from db $row = $this->db->fetchRow( ' SELECT * FROM `' . $dbEntity->getDbTableName() . '` WHERE ' . $this->getPrimaryKeyWhereSql($dbEntity) . ' ', $this->getPrimaryKeyWhereParameters($dbEntity) ); if (!$row) { throw new Exception\EntityNotFoundException("Db entity[{$dbEntity->getPrimaryDbValue()}] does not exist"); } $dbEntity->setDbDataFromRow($row); }
php
public function load(AbstractDbEntity $dbEntity) { // Check that the primary key is set if (!$dbEntity->getPrimaryDbValue()) { throw new \InvalidArgumentException( 'Database entity can not be loaded because primary value is not set' ); } // Fetch ad from db $row = $this->db->fetchRow( ' SELECT * FROM `' . $dbEntity->getDbTableName() . '` WHERE ' . $this->getPrimaryKeyWhereSql($dbEntity) . ' ', $this->getPrimaryKeyWhereParameters($dbEntity) ); if (!$row) { throw new Exception\EntityNotFoundException("Db entity[{$dbEntity->getPrimaryDbValue()}] does not exist"); } $dbEntity->setDbDataFromRow($row); }
[ "public", "function", "load", "(", "AbstractDbEntity", "$", "dbEntity", ")", "{", "// Check that the primary key is set", "if", "(", "!", "$", "dbEntity", "->", "getPrimaryDbValue", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Datab...
Load object's values from database table. @param AbstractDbEntity $dbEntity @throws Exception\EntityNotFoundException
[ "Load", "object", "s", "values", "from", "database", "table", "." ]
521efeb4a6ffebf616b02a436575bdc1bf304e88
https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/BasicDbEntityService.php#L44-L68
train
starweb/starlit-db
src/BasicDbEntityService.php
BasicDbEntityService.save
public function save(AbstractDbEntity $dbEntity) { if ($dbEntity->shouldBeDeletedFromDbOnSave()) { // Only delete if previously saved to db if ($dbEntity->getPrimaryDbValue()) { $this->delete($dbEntity); } return false; } if ($dbEntity->shouldInsertOnDbSave()) { // Note that database data always contains all properties, // with defaults for non set properties $dataToSave = $dbEntity->getDbData(); } else { if ($dbEntity->hasModifiedDbProperties()) { $dataToSave = $dbEntity->getModifiedDbData(); } else { // Return if no value has been modified and it's not an insert // (we always want to insert if no id exist, since some child objects might // depend on the this primary id being available) return false; } } // Check data $sqlData = []; foreach ($dataToSave as $propertyName => $value) { if (!empty($value) && is_scalar($value) && $dbEntity->getDbPropertyMaxLength($propertyName) && mb_strlen($value) > $dbEntity->getDbPropertyMaxLength($propertyName) ) { throw new \RuntimeException( "Database field \"{$propertyName}\" exceeds field max length (value: \"{$value}\")" ); } elseif (empty($value) && $dbEntity->getDbPropertyNonEmpty($propertyName)) { throw new \RuntimeException("Database field \"{$propertyName}\" is empty and required"); } elseif (((is_scalar($value) && ((string) $value) === '') || (!is_scalar($value) && empty($value))) && $dbEntity->getDbPropertyRequired($propertyName) ) { throw new \RuntimeException("Database field \"{$propertyName}\" is required to be set"); } // Set data keys db field format $fieldName = $dbEntity->getDbFieldName($propertyName); $sqlData[$fieldName] = $value; } // Insert new database row if ($dbEntity->shouldInsertOnDbSave()) { $this->db->insert( $dbEntity->getDbTableName(), $sqlData ); // Update entity with auto increment value if (!is_array($dbEntity->getPrimaryDbPropertyKey()) && !empty($lastInsertId = $this->db->getLastInsertId()) ) { $dbEntity->setPrimaryDbValue($lastInsertId); } else { // For entities with for example string primary keys, we update primary value // with value/values from db data, indicating that the entity is now // in database/loaded. $dbEntity->updatePrimaryDbValueFromDbData(); } // Update existing database row } else { $this->db->update( $dbEntity->getDbTableName(), $sqlData, $this->getPrimaryKeyWhereSql($dbEntity), $this->getPrimaryKeyWhereParameters($dbEntity) ); } $dbEntity->clearModifiedDbProperties(); $dbEntity->setForceDbInsertOnSave(false); return true; }
php
public function save(AbstractDbEntity $dbEntity) { if ($dbEntity->shouldBeDeletedFromDbOnSave()) { // Only delete if previously saved to db if ($dbEntity->getPrimaryDbValue()) { $this->delete($dbEntity); } return false; } if ($dbEntity->shouldInsertOnDbSave()) { // Note that database data always contains all properties, // with defaults for non set properties $dataToSave = $dbEntity->getDbData(); } else { if ($dbEntity->hasModifiedDbProperties()) { $dataToSave = $dbEntity->getModifiedDbData(); } else { // Return if no value has been modified and it's not an insert // (we always want to insert if no id exist, since some child objects might // depend on the this primary id being available) return false; } } // Check data $sqlData = []; foreach ($dataToSave as $propertyName => $value) { if (!empty($value) && is_scalar($value) && $dbEntity->getDbPropertyMaxLength($propertyName) && mb_strlen($value) > $dbEntity->getDbPropertyMaxLength($propertyName) ) { throw new \RuntimeException( "Database field \"{$propertyName}\" exceeds field max length (value: \"{$value}\")" ); } elseif (empty($value) && $dbEntity->getDbPropertyNonEmpty($propertyName)) { throw new \RuntimeException("Database field \"{$propertyName}\" is empty and required"); } elseif (((is_scalar($value) && ((string) $value) === '') || (!is_scalar($value) && empty($value))) && $dbEntity->getDbPropertyRequired($propertyName) ) { throw new \RuntimeException("Database field \"{$propertyName}\" is required to be set"); } // Set data keys db field format $fieldName = $dbEntity->getDbFieldName($propertyName); $sqlData[$fieldName] = $value; } // Insert new database row if ($dbEntity->shouldInsertOnDbSave()) { $this->db->insert( $dbEntity->getDbTableName(), $sqlData ); // Update entity with auto increment value if (!is_array($dbEntity->getPrimaryDbPropertyKey()) && !empty($lastInsertId = $this->db->getLastInsertId()) ) { $dbEntity->setPrimaryDbValue($lastInsertId); } else { // For entities with for example string primary keys, we update primary value // with value/values from db data, indicating that the entity is now // in database/loaded. $dbEntity->updatePrimaryDbValueFromDbData(); } // Update existing database row } else { $this->db->update( $dbEntity->getDbTableName(), $sqlData, $this->getPrimaryKeyWhereSql($dbEntity), $this->getPrimaryKeyWhereParameters($dbEntity) ); } $dbEntity->clearModifiedDbProperties(); $dbEntity->setForceDbInsertOnSave(false); return true; }
[ "public", "function", "save", "(", "AbstractDbEntity", "$", "dbEntity", ")", "{", "if", "(", "$", "dbEntity", "->", "shouldBeDeletedFromDbOnSave", "(", ")", ")", "{", "// Only delete if previously saved to db", "if", "(", "$", "dbEntity", "->", "getPrimaryDbValue", ...
Save entity to database table. @param AbstractDbEntity $dbEntity @return bool
[ "Save", "entity", "to", "database", "table", "." ]
521efeb4a6ffebf616b02a436575bdc1bf304e88
https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/BasicDbEntityService.php#L76-L158
train
starweb/starlit-db
src/BasicDbEntityService.php
BasicDbEntityService.delete
public function delete(AbstractDbEntity $dbEntity) { if (!$dbEntity->getPrimaryDbValue()) { throw new \InvalidArgumentException('Primary database value not set'); } $this->db->exec( 'DELETE FROM `' . $dbEntity->getDbTableName() . '` WHERE ' . $this->getPrimaryKeyWhereSql($dbEntity), $this->getPrimaryKeyWhereParameters($dbEntity) ); $dbEntity->setDeleted(); }
php
public function delete(AbstractDbEntity $dbEntity) { if (!$dbEntity->getPrimaryDbValue()) { throw new \InvalidArgumentException('Primary database value not set'); } $this->db->exec( 'DELETE FROM `' . $dbEntity->getDbTableName() . '` WHERE ' . $this->getPrimaryKeyWhereSql($dbEntity), $this->getPrimaryKeyWhereParameters($dbEntity) ); $dbEntity->setDeleted(); }
[ "public", "function", "delete", "(", "AbstractDbEntity", "$", "dbEntity", ")", "{", "if", "(", "!", "$", "dbEntity", "->", "getPrimaryDbValue", "(", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Primary database value not set'", ")", ";...
Delete entity's corresponding database row. @param AbstractDbEntity $dbEntity
[ "Delete", "entity", "s", "corresponding", "database", "row", "." ]
521efeb4a6ffebf616b02a436575bdc1bf304e88
https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/BasicDbEntityService.php#L165-L177
train
gdbots/ncr-php
src/Repository/DynamoDb/BatchGetItemRequest.php
BatchGetItemRequest.addItemKey
public function addItemKey(string $table, array $key): self { $this->queue[] = ['table' => $table, 'key' => $key]; return $this; }
php
public function addItemKey(string $table, array $key): self { $this->queue[] = ['table' => $table, 'key' => $key]; return $this; }
[ "public", "function", "addItemKey", "(", "string", "$", "table", ",", "array", "$", "key", ")", ":", "self", "{", "$", "this", "->", "queue", "[", "]", "=", "[", "'table'", "=>", "$", "table", ",", "'key'", "=>", "$", "key", "]", ";", "return", "...
Adds an item key to get in this batch request. @param string $table @param array $key @return self
[ "Adds", "an", "item", "key", "to", "get", "in", "this", "batch", "request", "." ]
b31c1315144f9a5bc6c48463dd77b6c643fdf250
https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/Repository/DynamoDb/BatchGetItemRequest.php#L116-L120
train
gdbots/ncr-php
src/Repository/DynamoDb/BatchGetItemRequest.php
BatchGetItemRequest.getItems
public function getItems(): array { $allItems = []; while ($this->queue) { $commands = $this->prepareCommands(); $pool = new CommandPool($this->client, $commands, [ 'concurrency' => $this->poolSize, 'fulfilled' => function (ResultInterface $result) use (&$allItems) { if ($result->hasKey('UnprocessedKeys')) { $this->retryUnprocessed($result['UnprocessedKeys']); } foreach ((array)$result->get('Responses') as $tableName => $items) { $allItems = array_merge($allItems, $items); } }, 'rejected' => function ($reason) { if ($reason instanceof AwsException) { if ('ProvisionedThroughputExceededException' === $reason->getAwsErrorCode()) { $this->retryUnprocessed($reason->getCommand()['RequestItems']); return; } if (is_callable($this->errorFunc)) { $func = $this->errorFunc; $func($reason); } } }, ]); $pool->promise()->wait(); } return $allItems; }
php
public function getItems(): array { $allItems = []; while ($this->queue) { $commands = $this->prepareCommands(); $pool = new CommandPool($this->client, $commands, [ 'concurrency' => $this->poolSize, 'fulfilled' => function (ResultInterface $result) use (&$allItems) { if ($result->hasKey('UnprocessedKeys')) { $this->retryUnprocessed($result['UnprocessedKeys']); } foreach ((array)$result->get('Responses') as $tableName => $items) { $allItems = array_merge($allItems, $items); } }, 'rejected' => function ($reason) { if ($reason instanceof AwsException) { if ('ProvisionedThroughputExceededException' === $reason->getAwsErrorCode()) { $this->retryUnprocessed($reason->getCommand()['RequestItems']); return; } if (is_callable($this->errorFunc)) { $func = $this->errorFunc; $func($reason); } } }, ]); $pool->promise()->wait(); } return $allItems; }
[ "public", "function", "getItems", "(", ")", ":", "array", "{", "$", "allItems", "=", "[", "]", ";", "while", "(", "$", "this", "->", "queue", ")", "{", "$", "commands", "=", "$", "this", "->", "prepareCommands", "(", ")", ";", "$", "pool", "=", "...
Processes the batch by combining all the queued requests into BatchGetItem commands and executing them. UnprocessedKeys are automatically re-queued. @return array
[ "Processes", "the", "batch", "by", "combining", "all", "the", "queued", "requests", "into", "BatchGetItem", "commands", "and", "executing", "them", ".", "UnprocessedKeys", "are", "automatically", "re", "-", "queued", "." ]
b31c1315144f9a5bc6c48463dd77b6c643fdf250
https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/Repository/DynamoDb/BatchGetItemRequest.php#L129-L165
train
gdbots/ncr-php
src/Repository/DynamoDb/BatchGetItemRequest.php
BatchGetItemRequest.prepareCommands
private function prepareCommands(): array { $batches = array_chunk($this->queue, $this->batchSize); $this->queue = []; $commands = []; foreach ($batches as $batch) { $requests = []; foreach ($batch as $item) { if (!isset($requests[$item['table']])) { $requests[$item['table']] = ['Keys' => [], 'ConsistentRead' => $this->consistentRead]; } $requests[$item['table']]['Keys'][] = $item['key']; } $commands[] = $this->client->getCommand('BatchGetItem', ['RequestItems' => $requests]); } return $commands; }
php
private function prepareCommands(): array { $batches = array_chunk($this->queue, $this->batchSize); $this->queue = []; $commands = []; foreach ($batches as $batch) { $requests = []; foreach ($batch as $item) { if (!isset($requests[$item['table']])) { $requests[$item['table']] = ['Keys' => [], 'ConsistentRead' => $this->consistentRead]; } $requests[$item['table']]['Keys'][] = $item['key']; } $commands[] = $this->client->getCommand('BatchGetItem', ['RequestItems' => $requests]); } return $commands; }
[ "private", "function", "prepareCommands", "(", ")", ":", "array", "{", "$", "batches", "=", "array_chunk", "(", "$", "this", "->", "queue", ",", "$", "this", "->", "batchSize", ")", ";", "$", "this", "->", "queue", "=", "[", "]", ";", "$", "commands"...
Creates BatchGetItem commands from the items in the queue. @return CommandInterface[]
[ "Creates", "BatchGetItem", "commands", "from", "the", "items", "in", "the", "queue", "." ]
b31c1315144f9a5bc6c48463dd77b6c643fdf250
https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/Repository/DynamoDb/BatchGetItemRequest.php#L172-L190
train
starweb/starlit-db
src/AbstractDbEntity.php
AbstractDbEntity.checkStaticProperties
private static function checkStaticProperties() { static $checkedClasses = []; if (!in_array(static::class, $checkedClasses)) { if (empty(static::$dbTableName) || empty(static::$dbProperties) || empty(static::$primaryDbPropertyKey) || (is_scalar(static::$primaryDbPropertyKey) && !isset(static::$dbProperties[static::$primaryDbPropertyKey]['type'])) || (is_array(static::$primaryDbPropertyKey) && !Arr::allIn(static::$primaryDbPropertyKey, array_keys(static::$dbProperties))) ) { throw new \LogicException("All db entity's static properties not set"); } $checkedClasses[] = static::class; } }
php
private static function checkStaticProperties() { static $checkedClasses = []; if (!in_array(static::class, $checkedClasses)) { if (empty(static::$dbTableName) || empty(static::$dbProperties) || empty(static::$primaryDbPropertyKey) || (is_scalar(static::$primaryDbPropertyKey) && !isset(static::$dbProperties[static::$primaryDbPropertyKey]['type'])) || (is_array(static::$primaryDbPropertyKey) && !Arr::allIn(static::$primaryDbPropertyKey, array_keys(static::$dbProperties))) ) { throw new \LogicException("All db entity's static properties not set"); } $checkedClasses[] = static::class; } }
[ "private", "static", "function", "checkStaticProperties", "(", ")", "{", "static", "$", "checkedClasses", "=", "[", "]", ";", "if", "(", "!", "in_array", "(", "static", "::", "class", ",", "$", "checkedClasses", ")", ")", "{", "if", "(", "empty", "(", ...
Make sure that class has all necessary static properties set.
[ "Make", "sure", "that", "class", "has", "all", "necessary", "static", "properties", "set", "." ]
521efeb4a6ffebf616b02a436575bdc1bf304e88
https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/AbstractDbEntity.php#L142-L158
train
starweb/starlit-db
src/AbstractDbEntity.php
AbstractDbEntity.getDefaultDbData
public function getDefaultDbData() { $class = get_called_class(); if (!isset(self::$cachedDefaultDbData[$class])) { self::$cachedDefaultDbData[$class] = []; foreach (array_keys(static::$dbProperties) as $propertyName) { self::$cachedDefaultDbData[$class][$propertyName] = $this->getDefaultDbPropertyValue($propertyName); } } return self::$cachedDefaultDbData[$class]; }
php
public function getDefaultDbData() { $class = get_called_class(); if (!isset(self::$cachedDefaultDbData[$class])) { self::$cachedDefaultDbData[$class] = []; foreach (array_keys(static::$dbProperties) as $propertyName) { self::$cachedDefaultDbData[$class][$propertyName] = $this->getDefaultDbPropertyValue($propertyName); } } return self::$cachedDefaultDbData[$class]; }
[ "public", "function", "getDefaultDbData", "(", ")", "{", "$", "class", "=", "get_called_class", "(", ")", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "cachedDefaultDbData", "[", "$", "class", "]", ")", ")", "{", "self", "::", "$", "cachedDefa...
Get all default database values. @return array
[ "Get", "all", "default", "database", "values", "." ]
521efeb4a6ffebf616b02a436575bdc1bf304e88
https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/AbstractDbEntity.php#L179-L190
train
starweb/starlit-db
src/AbstractDbEntity.php
AbstractDbEntity.updatePrimaryDbValueFromDbData
public function updatePrimaryDbValueFromDbData() { $dbDataPrimaryValue = $this->getDbDataPrimaryValue(); if ($dbDataPrimaryValue !== $this->getDbDataPrimaryDefaultValue()) { $this->setPrimaryDbValue($dbDataPrimaryValue); } }
php
public function updatePrimaryDbValueFromDbData() { $dbDataPrimaryValue = $this->getDbDataPrimaryValue(); if ($dbDataPrimaryValue !== $this->getDbDataPrimaryDefaultValue()) { $this->setPrimaryDbValue($dbDataPrimaryValue); } }
[ "public", "function", "updatePrimaryDbValueFromDbData", "(", ")", "{", "$", "dbDataPrimaryValue", "=", "$", "this", "->", "getDbDataPrimaryValue", "(", ")", ";", "if", "(", "$", "dbDataPrimaryValue", "!==", "$", "this", "->", "getDbDataPrimaryDefaultValue", "(", "...
Update primary database value with data from set database data.
[ "Update", "primary", "database", "value", "with", "data", "from", "set", "database", "data", "." ]
521efeb4a6ffebf616b02a436575bdc1bf304e88
https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/AbstractDbEntity.php#L254-L261
train
starweb/starlit-db
src/AbstractDbEntity.php
AbstractDbEntity.setDbValue
protected function setDbValue($property, $value, $setAsModified = true, $force = false) { $value = $this->getValueWithPropertyType($property, $value); if ($this->dbData[$property] !== $value || $force) { $this->dbData[$property] = $value; if ($setAsModified && !$this->isDbPropertyModified($property)) { $this->modifiedDbProperties[] = $property; } } }
php
protected function setDbValue($property, $value, $setAsModified = true, $force = false) { $value = $this->getValueWithPropertyType($property, $value); if ($this->dbData[$property] !== $value || $force) { $this->dbData[$property] = $value; if ($setAsModified && !$this->isDbPropertyModified($property)) { $this->modifiedDbProperties[] = $property; } } }
[ "protected", "function", "setDbValue", "(", "$", "property", ",", "$", "value", ",", "$", "setAsModified", "=", "true", ",", "$", "force", "=", "false", ")", "{", "$", "value", "=", "$", "this", "->", "getValueWithPropertyType", "(", "$", "property", ","...
Set a row field value. @param string $property @param mixed $value @param bool $setAsModified @param bool $force
[ "Set", "a", "row", "field", "value", "." ]
521efeb4a6ffebf616b02a436575bdc1bf304e88
https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/AbstractDbEntity.php#L329-L340
train
starweb/starlit-db
src/AbstractDbEntity.php
AbstractDbEntity.setDbData
public function setDbData(array $data) { foreach (array_keys(static::$dbProperties) as $propertyName) { if (array_key_exists($propertyName, $data)) { $this->setDbValue($propertyName, $data[$propertyName], true); } } }
php
public function setDbData(array $data) { foreach (array_keys(static::$dbProperties) as $propertyName) { if (array_key_exists($propertyName, $data)) { $this->setDbValue($propertyName, $data[$propertyName], true); } } }
[ "public", "function", "setDbData", "(", "array", "$", "data", ")", "{", "foreach", "(", "array_keys", "(", "static", "::", "$", "dbProperties", ")", "as", "$", "propertyName", ")", "{", "if", "(", "array_key_exists", "(", "$", "propertyName", ",", "$", "...
Set database fields' data. @param array $data
[ "Set", "database", "fields", "data", "." ]
521efeb4a6ffebf616b02a436575bdc1bf304e88
https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/AbstractDbEntity.php#L548-L555
train
starweb/starlit-db
src/AbstractDbEntity.php
AbstractDbEntity.setDbDataFromRow
public function setDbDataFromRow(array $rowData) { // If there are less row data than properties, use rows as starting point (optimization) if (count($rowData) < count(static::$dbProperties)) { foreach ($rowData as $dbFieldName => $value) { $propertyName = static::getDbPropertyName($dbFieldName); if (isset(static::$dbProperties[$propertyName])) { $this->setDbValue($propertyName, $value, false); } } // If there are more row data than properties, use properties as starting point } else { foreach (array_keys(static::$dbProperties) as $propertyName) { $fieldName = static::getDbFieldName($propertyName); if (array_key_exists($fieldName, $rowData)) { $this->setDbValue($propertyName, $rowData[$fieldName], false); } } } $this->updatePrimaryDbValueFromDbData(); }
php
public function setDbDataFromRow(array $rowData) { // If there are less row data than properties, use rows as starting point (optimization) if (count($rowData) < count(static::$dbProperties)) { foreach ($rowData as $dbFieldName => $value) { $propertyName = static::getDbPropertyName($dbFieldName); if (isset(static::$dbProperties[$propertyName])) { $this->setDbValue($propertyName, $value, false); } } // If there are more row data than properties, use properties as starting point } else { foreach (array_keys(static::$dbProperties) as $propertyName) { $fieldName = static::getDbFieldName($propertyName); if (array_key_exists($fieldName, $rowData)) { $this->setDbValue($propertyName, $rowData[$fieldName], false); } } } $this->updatePrimaryDbValueFromDbData(); }
[ "public", "function", "setDbDataFromRow", "(", "array", "$", "rowData", ")", "{", "// If there are less row data than properties, use rows as starting point (optimization)", "if", "(", "count", "(", "$", "rowData", ")", "<", "count", "(", "static", "::", "$", "dbPropert...
Set db data from raw database row data with field names in database format. @param array $rowData
[ "Set", "db", "data", "from", "raw", "database", "row", "data", "with", "field", "names", "in", "database", "format", "." ]
521efeb4a6ffebf616b02a436575bdc1bf304e88
https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/AbstractDbEntity.php#L562-L583
train
starweb/starlit-db
src/AbstractDbEntity.php
AbstractDbEntity.getDbPropertyNames
public static function getDbPropertyNames(array $exclude = []) { $dbPropertyNames = array_keys(static::$dbProperties); return $exclude ? array_diff($dbPropertyNames, $exclude) : $dbPropertyNames; }
php
public static function getDbPropertyNames(array $exclude = []) { $dbPropertyNames = array_keys(static::$dbProperties); return $exclude ? array_diff($dbPropertyNames, $exclude) : $dbPropertyNames; }
[ "public", "static", "function", "getDbPropertyNames", "(", "array", "$", "exclude", "=", "[", "]", ")", "{", "$", "dbPropertyNames", "=", "array_keys", "(", "static", "::", "$", "dbProperties", ")", ";", "return", "$", "exclude", "?", "array_diff", "(", "$...
Return array with db property names. @param array $exclude @return array
[ "Return", "array", "with", "db", "property", "names", "." ]
521efeb4a6ffebf616b02a436575bdc1bf304e88
https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/AbstractDbEntity.php#L767-L772
train
starweb/starlit-db
src/AbstractDbEntity.php
AbstractDbEntity.getDbFieldNames
public static function getDbFieldNames(array $exclude = []) { $fieldNames = []; foreach (array_keys(static::$dbProperties) as $propertyName) { $fieldNames[] = static::getDbFieldName($propertyName); } return $exclude ? array_diff($fieldNames, $exclude) : $fieldNames; }
php
public static function getDbFieldNames(array $exclude = []) { $fieldNames = []; foreach (array_keys(static::$dbProperties) as $propertyName) { $fieldNames[] = static::getDbFieldName($propertyName); } return $exclude ? array_diff($fieldNames, $exclude) : $fieldNames; }
[ "public", "static", "function", "getDbFieldNames", "(", "array", "$", "exclude", "=", "[", "]", ")", "{", "$", "fieldNames", "=", "[", "]", ";", "foreach", "(", "array_keys", "(", "static", "::", "$", "dbProperties", ")", "as", "$", "propertyName", ")", ...
Return array with raw db field names. @param array $exclude @return array
[ "Return", "array", "with", "raw", "db", "field", "names", "." ]
521efeb4a6ffebf616b02a436575bdc1bf304e88
https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/AbstractDbEntity.php#L780-L788
train
starweb/starlit-db
src/AbstractDbEntity.php
AbstractDbEntity.filterStripDbRowData
public static function filterStripDbRowData(array $rowData, $dbTableAlias, $skipStrip = false) { $columnPrefix = $dbTableAlias . '_'; $filteredAndStrippedRowData = []; foreach ($rowData as $key => $val) { if (strpos($key, $columnPrefix) === 0) { $strippedKey = $skipStrip ? $key : Str::stripLeft($key, $columnPrefix); $filteredAndStrippedRowData[$strippedKey] = $val; } } return $filteredAndStrippedRowData; }
php
public static function filterStripDbRowData(array $rowData, $dbTableAlias, $skipStrip = false) { $columnPrefix = $dbTableAlias . '_'; $filteredAndStrippedRowData = []; foreach ($rowData as $key => $val) { if (strpos($key, $columnPrefix) === 0) { $strippedKey = $skipStrip ? $key : Str::stripLeft($key, $columnPrefix); $filteredAndStrippedRowData[$strippedKey] = $val; } } return $filteredAndStrippedRowData; }
[ "public", "static", "function", "filterStripDbRowData", "(", "array", "$", "rowData", ",", "$", "dbTableAlias", ",", "$", "skipStrip", "=", "false", ")", "{", "$", "columnPrefix", "=", "$", "dbTableAlias", ".", "'_'", ";", "$", "filteredAndStrippedRowData", "=...
Filters a full db item array by it's table alias and the strips the table alias. @param array $rowData @param string $dbTableAlias @param bool $skipStrip For cases when you want to filter only (no stripping) @return array
[ "Filters", "a", "full", "db", "item", "array", "by", "it", "s", "table", "alias", "and", "the", "strips", "the", "table", "alias", "." ]
521efeb4a6ffebf616b02a436575bdc1bf304e88
https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/AbstractDbEntity.php#L830-L843
train
starweb/starlit-db
src/AbstractDbEntity.php
AbstractDbEntity.unserialize
public function unserialize($serializedObject) { $objectVars = unserialize($serializedObject); foreach ($objectVars as $key => $value) { $this->{$key} = $value; } }
php
public function unserialize($serializedObject) { $objectVars = unserialize($serializedObject); foreach ($objectVars as $key => $value) { $this->{$key} = $value; } }
[ "public", "function", "unserialize", "(", "$", "serializedObject", ")", "{", "$", "objectVars", "=", "unserialize", "(", "$", "serializedObject", ")", ";", "foreach", "(", "$", "objectVars", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "-...
Method to handle the unserialization of this object. Implementation of Serializable interface. If descendant private properties should be unserialized, they need to be visible to this parent (i.e. not private). @param string $serializedObject
[ "Method", "to", "handle", "the", "unserialization", "of", "this", "object", "." ]
521efeb4a6ffebf616b02a436575bdc1bf304e88
https://github.com/starweb/starlit-db/blob/521efeb4a6ffebf616b02a436575bdc1bf304e88/src/AbstractDbEntity.php#L874-L881
train
gdbots/ncr-php
src/AbstractNodeCommandHandler.php
AbstractNodeCommandHandler.createEventFromCommand
protected function createEventFromCommand(Command $command, string $suffix): Event { /** @var NodeRef $nodeRef */ $nodeRef = $command->get('node_ref') ?: NodeRef::fromNode($command->get('node')); $curie = $command::schema()->getCurie(); $eventCurie = "{$curie->getVendor()}:{$curie->getPackage()}:event:{$nodeRef->getLabel()}-{$suffix}"; /** @var Event $class */ $class = MessageResolver::resolveCurie(SchemaCurie::fromString($eventCurie)); return $class::create(); }
php
protected function createEventFromCommand(Command $command, string $suffix): Event { /** @var NodeRef $nodeRef */ $nodeRef = $command->get('node_ref') ?: NodeRef::fromNode($command->get('node')); $curie = $command::schema()->getCurie(); $eventCurie = "{$curie->getVendor()}:{$curie->getPackage()}:event:{$nodeRef->getLabel()}-{$suffix}"; /** @var Event $class */ $class = MessageResolver::resolveCurie(SchemaCurie::fromString($eventCurie)); return $class::create(); }
[ "protected", "function", "createEventFromCommand", "(", "Command", "$", "command", ",", "string", "$", "suffix", ")", ":", "Event", "{", "/** @var NodeRef $nodeRef */", "$", "nodeRef", "=", "$", "command", "->", "get", "(", "'node_ref'", ")", "?", ":", "NodeRe...
90% of the time this works 100% of the time. When events for common node operations match the convention of "blah-suffix" you can use this method to save some typing. It's always optional. @param Command $command @param string $suffix @return Event
[ "90%", "of", "the", "time", "this", "works", "100%", "of", "the", "time", ".", "When", "events", "for", "common", "node", "operations", "match", "the", "convention", "of", "blah", "-", "suffix", "you", "can", "use", "this", "method", "to", "save", "some"...
b31c1315144f9a5bc6c48463dd77b6c643fdf250
https://github.com/gdbots/ncr-php/blob/b31c1315144f9a5bc6c48463dd77b6c643fdf250/src/AbstractNodeCommandHandler.php#L58-L68
train