id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
228,400
|
tightenco/laravel-elm
|
src/Elm.php
|
Elm.make
|
public function make($app_name, $flags = [])
{
ob_start(); ?>
<div id="<?= $app_name ?>"></div>
<script>
window.addEventListener('load', function () {
<?php if (!empty($flags)) : ?>
Elm.<?= $app_name ?>.embed(
document.getElementById('<?= $app_name ?>'),
<?= json_encode($flags) ?>
);
<?php else : ?>
Elm.<?= $app_name ?>.embed(
document.getElementById('<?= $app_name ?>')
);
<?php endif; ?>
});
</script>
<?php return ob_get_clean();
}
|
php
|
public function make($app_name, $flags = [])
{
ob_start(); ?>
<div id="<?= $app_name ?>"></div>
<script>
window.addEventListener('load', function () {
<?php if (!empty($flags)) : ?>
Elm.<?= $app_name ?>.embed(
document.getElementById('<?= $app_name ?>'),
<?= json_encode($flags) ?>
);
<?php else : ?>
Elm.<?= $app_name ?>.embed(
document.getElementById('<?= $app_name ?>')
);
<?php endif; ?>
});
</script>
<?php return ob_get_clean();
}
|
[
"public",
"function",
"make",
"(",
"$",
"app_name",
",",
"$",
"flags",
"=",
"[",
"]",
")",
"{",
"ob_start",
"(",
")",
";",
"?>\n\n <div id=\"<?=",
"$",
"app_name",
"?>\"></div>\n\n <script>\n window.addEventListener('load', function () {\n <?php",
"if",
"(",
"!",
"empty",
"(",
"$",
"flags",
")",
")",
":",
"?>\n Elm.<?=",
"$",
"app_name",
"?>.embed(\n document.getElementById('<?=",
"$",
"app_name",
"?>'),\n <?=",
"json_encode",
"(",
"$",
"flags",
")",
"?>\n );\n <?php",
"else",
":",
"?>\n Elm.<?=",
"$",
"app_name",
"?>.embed(\n document.getElementById('<?=",
"$",
"app_name",
"?>')\n );\n <?php",
"endif",
";",
"?>\n });\n </script>\n\n <?php",
"return",
"ob_get_clean",
"(",
")",
";",
"}"
] |
Bind the given array of variables to the elm program,
render the script include,
and return the html.
|
[
"Bind",
"the",
"given",
"array",
"of",
"variables",
"to",
"the",
"elm",
"program",
"render",
"the",
"script",
"include",
"and",
"return",
"the",
"html",
"."
] |
b1b1a8c0ab799178ef0f7e4e5e8d38e2c94eb671
|
https://github.com/tightenco/laravel-elm/blob/b1b1a8c0ab799178ef0f7e4e5e8d38e2c94eb671/src/Elm.php#L16-L38
|
228,401
|
antaresproject/core
|
src/components/console/src/Schedule.php
|
Schedule.rejectCommand
|
public function rejectCommand($command)
{
$binary = ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));
if (defined('HHVM_VERSION')) {
$binary .= ' --php';
}
if (defined('ARTISAN_BINARY')) {
$artisan = ProcessUtils::escapeArgument(ARTISAN_BINARY);
} else {
$artisan = 'artisan';
}
return trim(str_replace([$binary, $artisan], '', $command));
}
|
php
|
public function rejectCommand($command)
{
$binary = ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false));
if (defined('HHVM_VERSION')) {
$binary .= ' --php';
}
if (defined('ARTISAN_BINARY')) {
$artisan = ProcessUtils::escapeArgument(ARTISAN_BINARY);
} else {
$artisan = 'artisan';
}
return trim(str_replace([$binary, $artisan], '', $command));
}
|
[
"public",
"function",
"rejectCommand",
"(",
"$",
"command",
")",
"{",
"$",
"binary",
"=",
"ProcessUtils",
"::",
"escapeArgument",
"(",
"(",
"new",
"PhpExecutableFinder",
")",
"->",
"find",
"(",
"false",
")",
")",
";",
"if",
"(",
"defined",
"(",
"'HHVM_VERSION'",
")",
")",
"{",
"$",
"binary",
".=",
"' --php'",
";",
"}",
"if",
"(",
"defined",
"(",
"'ARTISAN_BINARY'",
")",
")",
"{",
"$",
"artisan",
"=",
"ProcessUtils",
"::",
"escapeArgument",
"(",
"ARTISAN_BINARY",
")",
";",
"}",
"else",
"{",
"$",
"artisan",
"=",
"'artisan'",
";",
"}",
"return",
"trim",
"(",
"str_replace",
"(",
"[",
"$",
"binary",
",",
"$",
"artisan",
"]",
",",
"''",
",",
"$",
"command",
")",
")",
";",
"}"
] |
reject Artisan command
@param string $command
@return \Illuminate\Console\Scheduling\Event
|
[
"reject",
"Artisan",
"command"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/console/src/Schedule.php#L37-L50
|
228,402
|
antaresproject/core
|
src/components/extension/src/Config/SettingsFormBuilder.php
|
SettingsFormBuilder.build
|
public function build(ExtensionModel $model, SettingsFormContract $settingsForm, SettingsContract $settings)
{
return $this->formFactory->make(function(FormGrid $form) use($model, $settingsForm, $settings) {
$url = route(area() . '.modules.viewer.configuration.update', ['id' => $model->getId()]);
$form->simple($url, [], $model);
$form->name($model->getFullName() . ' Configuration');
$form->hidden('id');
$form->layout('antares/foundation::components.form');
$form->fieldset('Configuration', function(Fieldset $fieldset) use($settingsForm, $settings) {
$settingsForm->build($fieldset, $settings);
$fieldset->control('button', 'button')
->attributes(['type' => 'submit', 'class' => 'btn btn-primary'])
->value(trans('antares/foundation::label.save_changes'));
});
$form
->rules($settings->getValidationRules())
->phrases($settings->getValidationPhrases());
});
}
|
php
|
public function build(ExtensionModel $model, SettingsFormContract $settingsForm, SettingsContract $settings)
{
return $this->formFactory->make(function(FormGrid $form) use($model, $settingsForm, $settings) {
$url = route(area() . '.modules.viewer.configuration.update', ['id' => $model->getId()]);
$form->simple($url, [], $model);
$form->name($model->getFullName() . ' Configuration');
$form->hidden('id');
$form->layout('antares/foundation::components.form');
$form->fieldset('Configuration', function(Fieldset $fieldset) use($settingsForm, $settings) {
$settingsForm->build($fieldset, $settings);
$fieldset->control('button', 'button')
->attributes(['type' => 'submit', 'class' => 'btn btn-primary'])
->value(trans('antares/foundation::label.save_changes'));
});
$form
->rules($settings->getValidationRules())
->phrases($settings->getValidationPhrases());
});
}
|
[
"public",
"function",
"build",
"(",
"ExtensionModel",
"$",
"model",
",",
"SettingsFormContract",
"$",
"settingsForm",
",",
"SettingsContract",
"$",
"settings",
")",
"{",
"return",
"$",
"this",
"->",
"formFactory",
"->",
"make",
"(",
"function",
"(",
"FormGrid",
"$",
"form",
")",
"use",
"(",
"$",
"model",
",",
"$",
"settingsForm",
",",
"$",
"settings",
")",
"{",
"$",
"url",
"=",
"route",
"(",
"area",
"(",
")",
".",
"'.modules.viewer.configuration.update'",
",",
"[",
"'id'",
"=>",
"$",
"model",
"->",
"getId",
"(",
")",
"]",
")",
";",
"$",
"form",
"->",
"simple",
"(",
"$",
"url",
",",
"[",
"]",
",",
"$",
"model",
")",
";",
"$",
"form",
"->",
"name",
"(",
"$",
"model",
"->",
"getFullName",
"(",
")",
".",
"' Configuration'",
")",
";",
"$",
"form",
"->",
"hidden",
"(",
"'id'",
")",
";",
"$",
"form",
"->",
"layout",
"(",
"'antares/foundation::components.form'",
")",
";",
"$",
"form",
"->",
"fieldset",
"(",
"'Configuration'",
",",
"function",
"(",
"Fieldset",
"$",
"fieldset",
")",
"use",
"(",
"$",
"settingsForm",
",",
"$",
"settings",
")",
"{",
"$",
"settingsForm",
"->",
"build",
"(",
"$",
"fieldset",
",",
"$",
"settings",
")",
";",
"$",
"fieldset",
"->",
"control",
"(",
"'button'",
",",
"'button'",
")",
"->",
"attributes",
"(",
"[",
"'type'",
"=>",
"'submit'",
",",
"'class'",
"=>",
"'btn btn-primary'",
"]",
")",
"->",
"value",
"(",
"trans",
"(",
"'antares/foundation::label.save_changes'",
")",
")",
";",
"}",
")",
";",
"$",
"form",
"->",
"rules",
"(",
"$",
"settings",
"->",
"getValidationRules",
"(",
")",
")",
"->",
"phrases",
"(",
"$",
"settings",
"->",
"getValidationPhrases",
"(",
")",
")",
";",
"}",
")",
";",
"}"
] |
Builds the form for the given extension model and its settings.
@param ExtensionModel $model
@param SettingsFormContract $settingsForm
@param SettingsContract $settings
@return \Antares\Contracts\Html\Builder
|
[
"Builds",
"the",
"form",
"for",
"the",
"given",
"extension",
"model",
"and",
"its",
"settings",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Config/SettingsFormBuilder.php#L39-L61
|
228,403
|
antaresproject/core
|
src/ui/components/datatables/src/Html/Builder.php
|
Builder.beforeTable
|
protected function beforeTable()
{
$hasMassActions = $this->hasMassActions();
$filters = $this->filterAdapter->getFilters();
$hasColumnFilter = $this->hasColumnFilter();
$params = [];
if (!$hasMassActions and ! $this->searchable and empty($this->selects) and ! $filters and ! $hasColumnFilter) {
return '';
}
if (!empty($this->selects)) {
array_set($params, 'selects', implode('', $this->selects));
}
array_set($params, 'searchable', $this->searchable);
if ($this->searchable) {
$value = (($value = $this->getGlobalSearchValue()) !== false) ? $value : '';
array_set($params, 'search', $value);
}
$result = event(strtolower(class_basename($this->datatable)) . '.datatables.top.center', [&$return]);
if (isset($result[0])) {
array_set($params, 'datatables_top_center', $result[0]);
}
if (!is_null($this->rightCtrls)) {
array_set($params, 'rightCtrls', $this->rightCtrls);
}
if (empty($filters) and ! is_null($this->datatable)) {
$list = $this->datatable->getFilters();
foreach ($list as $filter) {
$this->filterAdapter->add($filter);
}
$filters = $this->filterAdapter->getFilters();
}
if ($hasColumnFilter) {
array_set($params, 'columnFilter', $this->getColumnFilterAdapter());
}
if ($filters) {
array_set($params, 'filters', $filters);
}
if ($hasMassActions) {
array_set($params, 'massActions', $this->massActions);
}
return view('datatables-helpers::before', $params)->render();
}
|
php
|
protected function beforeTable()
{
$hasMassActions = $this->hasMassActions();
$filters = $this->filterAdapter->getFilters();
$hasColumnFilter = $this->hasColumnFilter();
$params = [];
if (!$hasMassActions and ! $this->searchable and empty($this->selects) and ! $filters and ! $hasColumnFilter) {
return '';
}
if (!empty($this->selects)) {
array_set($params, 'selects', implode('', $this->selects));
}
array_set($params, 'searchable', $this->searchable);
if ($this->searchable) {
$value = (($value = $this->getGlobalSearchValue()) !== false) ? $value : '';
array_set($params, 'search', $value);
}
$result = event(strtolower(class_basename($this->datatable)) . '.datatables.top.center', [&$return]);
if (isset($result[0])) {
array_set($params, 'datatables_top_center', $result[0]);
}
if (!is_null($this->rightCtrls)) {
array_set($params, 'rightCtrls', $this->rightCtrls);
}
if (empty($filters) and ! is_null($this->datatable)) {
$list = $this->datatable->getFilters();
foreach ($list as $filter) {
$this->filterAdapter->add($filter);
}
$filters = $this->filterAdapter->getFilters();
}
if ($hasColumnFilter) {
array_set($params, 'columnFilter', $this->getColumnFilterAdapter());
}
if ($filters) {
array_set($params, 'filters', $filters);
}
if ($hasMassActions) {
array_set($params, 'massActions', $this->massActions);
}
return view('datatables-helpers::before', $params)->render();
}
|
[
"protected",
"function",
"beforeTable",
"(",
")",
"{",
"$",
"hasMassActions",
"=",
"$",
"this",
"->",
"hasMassActions",
"(",
")",
";",
"$",
"filters",
"=",
"$",
"this",
"->",
"filterAdapter",
"->",
"getFilters",
"(",
")",
";",
"$",
"hasColumnFilter",
"=",
"$",
"this",
"->",
"hasColumnFilter",
"(",
")",
";",
"$",
"params",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"$",
"hasMassActions",
"and",
"!",
"$",
"this",
"->",
"searchable",
"and",
"empty",
"(",
"$",
"this",
"->",
"selects",
")",
"and",
"!",
"$",
"filters",
"and",
"!",
"$",
"hasColumnFilter",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"selects",
")",
")",
"{",
"array_set",
"(",
"$",
"params",
",",
"'selects'",
",",
"implode",
"(",
"''",
",",
"$",
"this",
"->",
"selects",
")",
")",
";",
"}",
"array_set",
"(",
"$",
"params",
",",
"'searchable'",
",",
"$",
"this",
"->",
"searchable",
")",
";",
"if",
"(",
"$",
"this",
"->",
"searchable",
")",
"{",
"$",
"value",
"=",
"(",
"(",
"$",
"value",
"=",
"$",
"this",
"->",
"getGlobalSearchValue",
"(",
")",
")",
"!==",
"false",
")",
"?",
"$",
"value",
":",
"''",
";",
"array_set",
"(",
"$",
"params",
",",
"'search'",
",",
"$",
"value",
")",
";",
"}",
"$",
"result",
"=",
"event",
"(",
"strtolower",
"(",
"class_basename",
"(",
"$",
"this",
"->",
"datatable",
")",
")",
".",
"'.datatables.top.center'",
",",
"[",
"&",
"$",
"return",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"0",
"]",
")",
")",
"{",
"array_set",
"(",
"$",
"params",
",",
"'datatables_top_center'",
",",
"$",
"result",
"[",
"0",
"]",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"rightCtrls",
")",
")",
"{",
"array_set",
"(",
"$",
"params",
",",
"'rightCtrls'",
",",
"$",
"this",
"->",
"rightCtrls",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"filters",
")",
"and",
"!",
"is_null",
"(",
"$",
"this",
"->",
"datatable",
")",
")",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"datatable",
"->",
"getFilters",
"(",
")",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"filter",
")",
"{",
"$",
"this",
"->",
"filterAdapter",
"->",
"add",
"(",
"$",
"filter",
")",
";",
"}",
"$",
"filters",
"=",
"$",
"this",
"->",
"filterAdapter",
"->",
"getFilters",
"(",
")",
";",
"}",
"if",
"(",
"$",
"hasColumnFilter",
")",
"{",
"array_set",
"(",
"$",
"params",
",",
"'columnFilter'",
",",
"$",
"this",
"->",
"getColumnFilterAdapter",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"filters",
")",
"{",
"array_set",
"(",
"$",
"params",
",",
"'filters'",
",",
"$",
"filters",
")",
";",
"}",
"if",
"(",
"$",
"hasMassActions",
")",
"{",
"array_set",
"(",
"$",
"params",
",",
"'massActions'",
",",
"$",
"this",
"->",
"massActions",
")",
";",
"}",
"return",
"view",
"(",
"'datatables-helpers::before'",
",",
"$",
"params",
")",
"->",
"render",
"(",
")",
";",
"}"
] |
triggers before table
@return string
|
[
"triggers",
"before",
"table"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Html/Builder.php#L495-L543
|
228,404
|
antaresproject/core
|
src/ui/components/datatables/src/Html/Builder.php
|
Builder.addRightCtrls
|
public function addRightCtrls($rightCtrls = null)
{
if (!is_string($rightCtrls)) {
return $this;
}
$this->rightCtrls = $rightCtrls;
return $this;
}
|
php
|
public function addRightCtrls($rightCtrls = null)
{
if (!is_string($rightCtrls)) {
return $this;
}
$this->rightCtrls = $rightCtrls;
return $this;
}
|
[
"public",
"function",
"addRightCtrls",
"(",
"$",
"rightCtrls",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"rightCtrls",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"rightCtrls",
"=",
"$",
"rightCtrls",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds right ctrls container
@param String $rightCtrls
@return $this
|
[
"Adds",
"right",
"ctrls",
"container"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Html/Builder.php#L551-L558
|
228,405
|
antaresproject/core
|
src/ui/components/datatables/src/Html/Builder.php
|
Builder.getColumnFilterAdapter
|
protected function getColumnFilterAdapter()
{
if (is_null($this->columnFilterAdapter)) {
$this->columnFilterAdapter = app(ColumnFilterAdapter::class, [$this->collection, get_class($this->datatable)]);
}
return $this->columnFilterAdapter;
}
|
php
|
protected function getColumnFilterAdapter()
{
if (is_null($this->columnFilterAdapter)) {
$this->columnFilterAdapter = app(ColumnFilterAdapter::class, [$this->collection, get_class($this->datatable)]);
}
return $this->columnFilterAdapter;
}
|
[
"protected",
"function",
"getColumnFilterAdapter",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"columnFilterAdapter",
")",
")",
"{",
"$",
"this",
"->",
"columnFilterAdapter",
"=",
"app",
"(",
"ColumnFilterAdapter",
"::",
"class",
",",
"[",
"$",
"this",
"->",
"collection",
",",
"get_class",
"(",
"$",
"this",
"->",
"datatable",
")",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"columnFilterAdapter",
";",
"}"
] |
Gets colum filter adapter instance
@return ColumnFilterAdapter
|
[
"Gets",
"colum",
"filter",
"adapter",
"instance"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Html/Builder.php#L586-L592
|
228,406
|
antaresproject/core
|
src/ui/components/datatables/src/Html/Builder.php
|
Builder.setDeferedData
|
public function setDeferedData()
{
if (request()->has('search')) {
return $this;
}
$totalItemsCount = $this->datatable->count();
$this->deferredData = $this->datatable->ajax()->getData()->data; // dubluje zapytania sql
$filters = $this->datatable->getFilters();
$query = $this->datatable->query();
foreach ($filters as $filter) {
$this->addFilter($filter, $query);
}
$this->attributes = array_merge($this->attributes, [
"deferLoading" => $totalItemsCount,
'iDisplayLength' => $this->datatable->getPerPage()
]);
return $this;
}
|
php
|
public function setDeferedData()
{
if (request()->has('search')) {
return $this;
}
$totalItemsCount = $this->datatable->count();
$this->deferredData = $this->datatable->ajax()->getData()->data; // dubluje zapytania sql
$filters = $this->datatable->getFilters();
$query = $this->datatable->query();
foreach ($filters as $filter) {
$this->addFilter($filter, $query);
}
$this->attributes = array_merge($this->attributes, [
"deferLoading" => $totalItemsCount,
'iDisplayLength' => $this->datatable->getPerPage()
]);
return $this;
}
|
[
"public",
"function",
"setDeferedData",
"(",
")",
"{",
"if",
"(",
"request",
"(",
")",
"->",
"has",
"(",
"'search'",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"totalItemsCount",
"=",
"$",
"this",
"->",
"datatable",
"->",
"count",
"(",
")",
";",
"$",
"this",
"->",
"deferredData",
"=",
"$",
"this",
"->",
"datatable",
"->",
"ajax",
"(",
")",
"->",
"getData",
"(",
")",
"->",
"data",
";",
"// dubluje zapytania sql",
"$",
"filters",
"=",
"$",
"this",
"->",
"datatable",
"->",
"getFilters",
"(",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"datatable",
"->",
"query",
"(",
")",
";",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"filter",
")",
"{",
"$",
"this",
"->",
"addFilter",
"(",
"$",
"filter",
",",
"$",
"query",
")",
";",
"}",
"$",
"this",
"->",
"attributes",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"attributes",
",",
"[",
"\"deferLoading\"",
"=>",
"$",
"totalItemsCount",
",",
"'iDisplayLength'",
"=>",
"$",
"this",
"->",
"datatable",
"->",
"getPerPage",
"(",
")",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
defered data setter
@return $this
|
[
"defered",
"data",
"setter"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Html/Builder.php#L641-L661
|
228,407
|
antaresproject/core
|
src/ui/components/datatables/src/Html/Builder.php
|
Builder.containerAttributes
|
public function containerAttributes(array $attributes = []): Builder
{
foreach ($this->containerAttributes as $name => $value) {
if (is_null($param = array_get($attributes, $name))) {
continue;
}
array_set($this->containerAttributes, $name, $value . ' ' . $param);
}
return $this;
}
|
php
|
public function containerAttributes(array $attributes = []): Builder
{
foreach ($this->containerAttributes as $name => $value) {
if (is_null($param = array_get($attributes, $name))) {
continue;
}
array_set($this->containerAttributes, $name, $value . ' ' . $param);
}
return $this;
}
|
[
"public",
"function",
"containerAttributes",
"(",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"Builder",
"{",
"foreach",
"(",
"$",
"this",
"->",
"containerAttributes",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"param",
"=",
"array_get",
"(",
"$",
"attributes",
",",
"$",
"name",
")",
")",
")",
"{",
"continue",
";",
"}",
"array_set",
"(",
"$",
"this",
"->",
"containerAttributes",
",",
"$",
"name",
",",
"$",
"value",
".",
"' '",
".",
"$",
"param",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Container attributes setter
@param array $attributes
@return $this
|
[
"Container",
"attributes",
"setter"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Html/Builder.php#L779-L788
|
228,408
|
antaresproject/core
|
src/ui/components/datatables/src/Html/Builder.php
|
Builder.tableAttributes
|
public function tableAttributes(array $attributes = array()): Builder
{
array_set($attributes, 'id', array_get($attributes, 'id') . str_random(3));
$this->tableAttributes = array_merge($this->tableAttributes, $attributes);
return $this;
}
|
php
|
public function tableAttributes(array $attributes = array()): Builder
{
array_set($attributes, 'id', array_get($attributes, 'id') . str_random(3));
$this->tableAttributes = array_merge($this->tableAttributes, $attributes);
return $this;
}
|
[
"public",
"function",
"tableAttributes",
"(",
"array",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
":",
"Builder",
"{",
"array_set",
"(",
"$",
"attributes",
",",
"'id'",
",",
"array_get",
"(",
"$",
"attributes",
",",
"'id'",
")",
".",
"str_random",
"(",
"3",
")",
")",
";",
"$",
"this",
"->",
"tableAttributes",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"tableAttributes",
",",
"$",
"attributes",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Table attributes setter
@param array $attributes
@return $this
|
[
"Table",
"attributes",
"setter"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Html/Builder.php#L796-L801
|
228,409
|
antaresproject/core
|
src/ui/components/datatables/src/Html/Builder.php
|
Builder.addColumn
|
public function addColumn(array $attributes)
{
$query = $this->getQuery();
$orders = $query instanceof \Illuminate\Database\Eloquent\Builder ? $query->getQuery()->orders : null;
if (!isset($this->attributes['order']) and ! is_null($query) and ! is_null($orders)) {
foreach ($orders as $order) {
if ($order['column'] != $attributes['name']) {
continue;
}
$this->attributes['order'] = [
$this->collection->count(), $order['direction']
];
}
}
$path = uri();
$this->dispatcher->fire('datatables:' . $path . ':column.' . $attributes['name'], [&$attributes]);
$this->dispatcher->fire(new \Antares\Events\Datatables\Column($path, $attributes['name'], $attributes));
$this->collection->push(new Column($attributes));
$this->dispatcher->fire('datatables:' . $path . ':after.' . $attributes['name'], $this);
$this->dispatcher->fire(new AfterColumn($path, $attributes['name'], $this));
return $this;
}
|
php
|
public function addColumn(array $attributes)
{
$query = $this->getQuery();
$orders = $query instanceof \Illuminate\Database\Eloquent\Builder ? $query->getQuery()->orders : null;
if (!isset($this->attributes['order']) and ! is_null($query) and ! is_null($orders)) {
foreach ($orders as $order) {
if ($order['column'] != $attributes['name']) {
continue;
}
$this->attributes['order'] = [
$this->collection->count(), $order['direction']
];
}
}
$path = uri();
$this->dispatcher->fire('datatables:' . $path . ':column.' . $attributes['name'], [&$attributes]);
$this->dispatcher->fire(new \Antares\Events\Datatables\Column($path, $attributes['name'], $attributes));
$this->collection->push(new Column($attributes));
$this->dispatcher->fire('datatables:' . $path . ':after.' . $attributes['name'], $this);
$this->dispatcher->fire(new AfterColumn($path, $attributes['name'], $this));
return $this;
}
|
[
"public",
"function",
"addColumn",
"(",
"array",
"$",
"attributes",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getQuery",
"(",
")",
";",
"$",
"orders",
"=",
"$",
"query",
"instanceof",
"\\",
"Illuminate",
"\\",
"Database",
"\\",
"Eloquent",
"\\",
"Builder",
"?",
"$",
"query",
"->",
"getQuery",
"(",
")",
"->",
"orders",
":",
"null",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'order'",
"]",
")",
"and",
"!",
"is_null",
"(",
"$",
"query",
")",
"and",
"!",
"is_null",
"(",
"$",
"orders",
")",
")",
"{",
"foreach",
"(",
"$",
"orders",
"as",
"$",
"order",
")",
"{",
"if",
"(",
"$",
"order",
"[",
"'column'",
"]",
"!=",
"$",
"attributes",
"[",
"'name'",
"]",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"attributes",
"[",
"'order'",
"]",
"=",
"[",
"$",
"this",
"->",
"collection",
"->",
"count",
"(",
")",
",",
"$",
"order",
"[",
"'direction'",
"]",
"]",
";",
"}",
"}",
"$",
"path",
"=",
"uri",
"(",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"fire",
"(",
"'datatables:'",
".",
"$",
"path",
".",
"':column.'",
".",
"$",
"attributes",
"[",
"'name'",
"]",
",",
"[",
"&",
"$",
"attributes",
"]",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"fire",
"(",
"new",
"\\",
"Antares",
"\\",
"Events",
"\\",
"Datatables",
"\\",
"Column",
"(",
"$",
"path",
",",
"$",
"attributes",
"[",
"'name'",
"]",
",",
"$",
"attributes",
")",
")",
";",
"$",
"this",
"->",
"collection",
"->",
"push",
"(",
"new",
"Column",
"(",
"$",
"attributes",
")",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"fire",
"(",
"'datatables:'",
".",
"$",
"path",
".",
"':after.'",
".",
"$",
"attributes",
"[",
"'name'",
"]",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"dispatcher",
"->",
"fire",
"(",
"new",
"AfterColumn",
"(",
"$",
"path",
",",
"$",
"attributes",
"[",
"'name'",
"]",
",",
"$",
"this",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a column in collection using attributes.
@param array $attributes
@return $this
|
[
"Add",
"a",
"column",
"in",
"collection",
"using",
"attributes",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Html/Builder.php#L809-L830
|
228,410
|
antaresproject/core
|
src/ui/components/datatables/src/Html/Builder.php
|
Builder.addMassAction
|
public function addMassAction($name, Expression $massAction)
{
$model = $this->getQuery()->getModel();
$this->massActions = array_merge($this->massActions, (array)
//event('datatables:' . uri() . ':before.massactions.action.' . $name, [$this->massActions, $model], true)
event(new BeforeMassActionsAction(uri(), $name, $model, $this->massActions), [], true)
);
if (empty($this->massActions)) {
$this->massActions = [];
}
array_push($this->massActions, $massAction);
$this->massActions = array_merge($this->massActions, (array)
//event('datatables:' . uri() . ':after.massactions.action.' . $name, [$this->massActions, $model], true);
event(new AfterMassActionsAction(uri(), $name, $model, $this->massActions), [], true)
);
$this->massActions = array_unique($this->massActions);
return $this;
}
|
php
|
public function addMassAction($name, Expression $massAction)
{
$model = $this->getQuery()->getModel();
$this->massActions = array_merge($this->massActions, (array)
//event('datatables:' . uri() . ':before.massactions.action.' . $name, [$this->massActions, $model], true)
event(new BeforeMassActionsAction(uri(), $name, $model, $this->massActions), [], true)
);
if (empty($this->massActions)) {
$this->massActions = [];
}
array_push($this->massActions, $massAction);
$this->massActions = array_merge($this->massActions, (array)
//event('datatables:' . uri() . ':after.massactions.action.' . $name, [$this->massActions, $model], true);
event(new AfterMassActionsAction(uri(), $name, $model, $this->massActions), [], true)
);
$this->massActions = array_unique($this->massActions);
return $this;
}
|
[
"public",
"function",
"addMassAction",
"(",
"$",
"name",
",",
"Expression",
"$",
"massAction",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"getQuery",
"(",
")",
"->",
"getModel",
"(",
")",
";",
"$",
"this",
"->",
"massActions",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"massActions",
",",
"(",
"array",
")",
"//event('datatables:' . uri() . ':before.massactions.action.' . $name, [$this->massActions, $model], true)",
"event",
"(",
"new",
"BeforeMassActionsAction",
"(",
"uri",
"(",
")",
",",
"$",
"name",
",",
"$",
"model",
",",
"$",
"this",
"->",
"massActions",
")",
",",
"[",
"]",
",",
"true",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"massActions",
")",
")",
"{",
"$",
"this",
"->",
"massActions",
"=",
"[",
"]",
";",
"}",
"array_push",
"(",
"$",
"this",
"->",
"massActions",
",",
"$",
"massAction",
")",
";",
"$",
"this",
"->",
"massActions",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"massActions",
",",
"(",
"array",
")",
"//event('datatables:' . uri() . ':after.massactions.action.' . $name, [$this->massActions, $model], true);",
"event",
"(",
"new",
"AfterMassActionsAction",
"(",
"uri",
"(",
")",
",",
"$",
"name",
",",
"$",
"model",
",",
"$",
"this",
"->",
"massActions",
")",
",",
"[",
"]",
",",
"true",
")",
")",
";",
"$",
"this",
"->",
"massActions",
"=",
"array_unique",
"(",
"$",
"this",
"->",
"massActions",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
appends mass actions to mass actions container
@param Expression $massAction
@return \Antares\Datatables\Html\Builder
|
[
"appends",
"mass",
"actions",
"to",
"mass",
"actions",
"container"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Html/Builder.php#L872-L889
|
228,411
|
antaresproject/core
|
src/ui/components/datatables/src/Html/Builder.php
|
Builder.setDataTable
|
public function setDataTable($datatable)
{
$this->setQuery($datatable->query());
$this->datatable = $datatable;
return $this;
}
|
php
|
public function setDataTable($datatable)
{
$this->setQuery($datatable->query());
$this->datatable = $datatable;
return $this;
}
|
[
"public",
"function",
"setDataTable",
"(",
"$",
"datatable",
")",
"{",
"$",
"this",
"->",
"setQuery",
"(",
"$",
"datatable",
"->",
"query",
"(",
")",
")",
";",
"$",
"this",
"->",
"datatable",
"=",
"$",
"datatable",
";",
"return",
"$",
"this",
";",
"}"
] |
Defered data setter
@param type $datatable
@return \Antares\Datatables\Html\Builder
|
[
"Defered",
"data",
"setter"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Html/Builder.php#L938-L943
|
228,412
|
antaresproject/core
|
src/ui/components/datatables/src/Html/Builder.php
|
Builder.addGroupSelect
|
public function addGroupSelect($options, $columnIndex = 0, $defaultSelected = null, array $attributes = [])
{
$orderAdapter = app(OrderAdapter::class)->setClassname(get_class($this->datatable));
if (($order = $orderAdapter->getSelected()) !== false) {
$this->parameters([
'order' => [[$order['column'], $order['dir']]],
]);
}
$groupsFilter = app(GroupsFilterAdapter::class)->setClassname(get_class($this->datatable))->setIndex($columnIndex);
$data = ($options instanceof Collection) ? $options->toArray() : $options;
if ($defaultSelected) {
$this->selectedGroups[$columnIndex] = $defaultSelected;
}
$id = array_get($this->tableAttributes, 'id') . '-filter-group';
if (is_null($value = $groupsFilter->getSelected($columnIndex))) {
$value = $defaultSelected;
}
$decorated = $this->html->decorate($attributes, [
'data-selectar--mdl-big' => "true",
'class' => 'mb24 select2-left select--category select2--prefix',
'id' => $id,
'data-select2--class' => 'card-ctrls--select2'
]);
$html = Form::select('category', $data, $value, $decorated);
$groupsFilter->scripts(array_get($decorated, 'id'), $columnIndex);
array_push($this->selects, $html);
return $this;
}
|
php
|
public function addGroupSelect($options, $columnIndex = 0, $defaultSelected = null, array $attributes = [])
{
$orderAdapter = app(OrderAdapter::class)->setClassname(get_class($this->datatable));
if (($order = $orderAdapter->getSelected()) !== false) {
$this->parameters([
'order' => [[$order['column'], $order['dir']]],
]);
}
$groupsFilter = app(GroupsFilterAdapter::class)->setClassname(get_class($this->datatable))->setIndex($columnIndex);
$data = ($options instanceof Collection) ? $options->toArray() : $options;
if ($defaultSelected) {
$this->selectedGroups[$columnIndex] = $defaultSelected;
}
$id = array_get($this->tableAttributes, 'id') . '-filter-group';
if (is_null($value = $groupsFilter->getSelected($columnIndex))) {
$value = $defaultSelected;
}
$decorated = $this->html->decorate($attributes, [
'data-selectar--mdl-big' => "true",
'class' => 'mb24 select2-left select--category select2--prefix',
'id' => $id,
'data-select2--class' => 'card-ctrls--select2'
]);
$html = Form::select('category', $data, $value, $decorated);
$groupsFilter->scripts(array_get($decorated, 'id'), $columnIndex);
array_push($this->selects, $html);
return $this;
}
|
[
"public",
"function",
"addGroupSelect",
"(",
"$",
"options",
",",
"$",
"columnIndex",
"=",
"0",
",",
"$",
"defaultSelected",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"orderAdapter",
"=",
"app",
"(",
"OrderAdapter",
"::",
"class",
")",
"->",
"setClassname",
"(",
"get_class",
"(",
"$",
"this",
"->",
"datatable",
")",
")",
";",
"if",
"(",
"(",
"$",
"order",
"=",
"$",
"orderAdapter",
"->",
"getSelected",
"(",
")",
")",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"parameters",
"(",
"[",
"'order'",
"=>",
"[",
"[",
"$",
"order",
"[",
"'column'",
"]",
",",
"$",
"order",
"[",
"'dir'",
"]",
"]",
"]",
",",
"]",
")",
";",
"}",
"$",
"groupsFilter",
"=",
"app",
"(",
"GroupsFilterAdapter",
"::",
"class",
")",
"->",
"setClassname",
"(",
"get_class",
"(",
"$",
"this",
"->",
"datatable",
")",
")",
"->",
"setIndex",
"(",
"$",
"columnIndex",
")",
";",
"$",
"data",
"=",
"(",
"$",
"options",
"instanceof",
"Collection",
")",
"?",
"$",
"options",
"->",
"toArray",
"(",
")",
":",
"$",
"options",
";",
"if",
"(",
"$",
"defaultSelected",
")",
"{",
"$",
"this",
"->",
"selectedGroups",
"[",
"$",
"columnIndex",
"]",
"=",
"$",
"defaultSelected",
";",
"}",
"$",
"id",
"=",
"array_get",
"(",
"$",
"this",
"->",
"tableAttributes",
",",
"'id'",
")",
".",
"'-filter-group'",
";",
"if",
"(",
"is_null",
"(",
"$",
"value",
"=",
"$",
"groupsFilter",
"->",
"getSelected",
"(",
"$",
"columnIndex",
")",
")",
")",
"{",
"$",
"value",
"=",
"$",
"defaultSelected",
";",
"}",
"$",
"decorated",
"=",
"$",
"this",
"->",
"html",
"->",
"decorate",
"(",
"$",
"attributes",
",",
"[",
"'data-selectar--mdl-big'",
"=>",
"\"true\"",
",",
"'class'",
"=>",
"'mb24 select2-left select--category select2--prefix'",
",",
"'id'",
"=>",
"$",
"id",
",",
"'data-select2--class'",
"=>",
"'card-ctrls--select2'",
"]",
")",
";",
"$",
"html",
"=",
"Form",
"::",
"select",
"(",
"'category'",
",",
"$",
"data",
",",
"$",
"value",
",",
"$",
"decorated",
")",
";",
"$",
"groupsFilter",
"->",
"scripts",
"(",
"array_get",
"(",
"$",
"decorated",
",",
"'id'",
")",
",",
"$",
"columnIndex",
")",
";",
"array_push",
"(",
"$",
"this",
"->",
"selects",
",",
"$",
"html",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add additional table selects
@param String $html
@return \Antares\Datatables\Html\Builder
|
[
"Add",
"additional",
"table",
"selects"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Html/Builder.php#L951-L981
|
228,413
|
antaresproject/core
|
src/ui/components/datatables/src/Html/Builder.php
|
Builder.parameters
|
public function parameters(array $attributes = [])
{
if (!is_null($defaultOrder = array_get($attributes, 'order'))) {
$orderAdapter = app(OrderAdapter::class)->setClassname(get_class($this->datatable));
if (($order = $orderAdapter->getSelected()) !== false) {
// $attributes = array_merge($attributes, [
// 'order' => [[$order['column'], $order['dir']]],
// ]);
}
}
return parent::parameters($attributes);
}
|
php
|
public function parameters(array $attributes = [])
{
if (!is_null($defaultOrder = array_get($attributes, 'order'))) {
$orderAdapter = app(OrderAdapter::class)->setClassname(get_class($this->datatable));
if (($order = $orderAdapter->getSelected()) !== false) {
// $attributes = array_merge($attributes, [
// 'order' => [[$order['column'], $order['dir']]],
// ]);
}
}
return parent::parameters($attributes);
}
|
[
"public",
"function",
"parameters",
"(",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"defaultOrder",
"=",
"array_get",
"(",
"$",
"attributes",
",",
"'order'",
")",
")",
")",
"{",
"$",
"orderAdapter",
"=",
"app",
"(",
"OrderAdapter",
"::",
"class",
")",
"->",
"setClassname",
"(",
"get_class",
"(",
"$",
"this",
"->",
"datatable",
")",
")",
";",
"if",
"(",
"(",
"$",
"order",
"=",
"$",
"orderAdapter",
"->",
"getSelected",
"(",
")",
")",
"!==",
"false",
")",
"{",
"// $attributes = array_merge($attributes, [",
"// 'order' => [[$order['column'], $order['dir']]],",
"// ]);",
"}",
"}",
"return",
"parent",
"::",
"parameters",
"(",
"$",
"attributes",
")",
";",
"}"
] |
Configure DataTable's parameters.
@param array $attributes
@return $this
|
[
"Configure",
"DataTable",
"s",
"parameters",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Html/Builder.php#L989-L1004
|
228,414
|
antaresproject/core
|
src/foundation/src/Http/Resolver/ModuleNamespaceResolver.php
|
ModuleNamespaceResolver.resolve
|
public function resolve($matches = [])
{
if (!isset($this->route['controller'])) {
return false;
}
list($controller,) = explode('@', $this->route['controller']);
$fileName = (new ReflectionClass($controller))->getFileName();
$rootPath = substr($fileName, 0, strrpos($fileName, 'src'));
$composerFilePath = $rootPath . 'composer.json';
if($rootPath === '' || ! file_exists($composerFilePath)) {
return false;
}
$this->package = $this->extensionFactory->getComposerPackage($composerFilePath);
$this->name = $this->package->getName();
return $this->name;
}
|
php
|
public function resolve($matches = [])
{
if (!isset($this->route['controller'])) {
return false;
}
list($controller,) = explode('@', $this->route['controller']);
$fileName = (new ReflectionClass($controller))->getFileName();
$rootPath = substr($fileName, 0, strrpos($fileName, 'src'));
$composerFilePath = $rootPath . 'composer.json';
if($rootPath === '' || ! file_exists($composerFilePath)) {
return false;
}
$this->package = $this->extensionFactory->getComposerPackage($composerFilePath);
$this->name = $this->package->getName();
return $this->name;
}
|
[
"public",
"function",
"resolve",
"(",
"$",
"matches",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"route",
"[",
"'controller'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"list",
"(",
"$",
"controller",
",",
")",
"=",
"explode",
"(",
"'@'",
",",
"$",
"this",
"->",
"route",
"[",
"'controller'",
"]",
")",
";",
"$",
"fileName",
"=",
"(",
"new",
"ReflectionClass",
"(",
"$",
"controller",
")",
")",
"->",
"getFileName",
"(",
")",
";",
"$",
"rootPath",
"=",
"substr",
"(",
"$",
"fileName",
",",
"0",
",",
"strrpos",
"(",
"$",
"fileName",
",",
"'src'",
")",
")",
";",
"$",
"composerFilePath",
"=",
"$",
"rootPath",
".",
"'composer.json'",
";",
"if",
"(",
"$",
"rootPath",
"===",
"''",
"||",
"!",
"file_exists",
"(",
"$",
"composerFilePath",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"package",
"=",
"$",
"this",
"->",
"extensionFactory",
"->",
"getComposerPackage",
"(",
"$",
"composerFilePath",
")",
";",
"$",
"this",
"->",
"name",
"=",
"$",
"this",
"->",
"package",
"->",
"getName",
"(",
")",
";",
"return",
"$",
"this",
"->",
"name",
";",
"}"
] |
module namespace resolver
@param array $matches
@return String
@throws RuntimeException
|
[
"module",
"namespace",
"resolver"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Resolver/ModuleNamespaceResolver.php#L107-L127
|
228,415
|
antaresproject/core
|
src/foundation/src/Http/Resolver/ModuleNamespaceResolver.php
|
ModuleNamespaceResolver.getClear
|
public function getClear()
{
$return = str_replace(self::$namespacePrefix . '/', '', $this->name);
$exists = array_where(self::$core, function($key) use($return) {
return $return == $key;
});
if (!empty($exists)) {
return self::$registeredForCore;
}
if ($return == 'app') {
return 'content';
}
$name = ($return == 'app') ? self::frontendContentComponent : $return;
return str_replace('antaresproject/', '', $name);
}
|
php
|
public function getClear()
{
$return = str_replace(self::$namespacePrefix . '/', '', $this->name);
$exists = array_where(self::$core, function($key) use($return) {
return $return == $key;
});
if (!empty($exists)) {
return self::$registeredForCore;
}
if ($return == 'app') {
return 'content';
}
$name = ($return == 'app') ? self::frontendContentComponent : $return;
return str_replace('antaresproject/', '', $name);
}
|
[
"public",
"function",
"getClear",
"(",
")",
"{",
"$",
"return",
"=",
"str_replace",
"(",
"self",
"::",
"$",
"namespacePrefix",
".",
"'/'",
",",
"''",
",",
"$",
"this",
"->",
"name",
")",
";",
"$",
"exists",
"=",
"array_where",
"(",
"self",
"::",
"$",
"core",
",",
"function",
"(",
"$",
"key",
")",
"use",
"(",
"$",
"return",
")",
"{",
"return",
"$",
"return",
"==",
"$",
"key",
";",
"}",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"exists",
")",
")",
"{",
"return",
"self",
"::",
"$",
"registeredForCore",
";",
"}",
"if",
"(",
"$",
"return",
"==",
"'app'",
")",
"{",
"return",
"'content'",
";",
"}",
"$",
"name",
"=",
"(",
"$",
"return",
"==",
"'app'",
")",
"?",
"self",
"::",
"frontendContentComponent",
":",
"$",
"return",
";",
"return",
"str_replace",
"(",
"'antaresproject/'",
",",
"''",
",",
"$",
"name",
")",
";",
"}"
] |
cleared namespace of module
@return String
|
[
"cleared",
"namespace",
"of",
"module"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Resolver/ModuleNamespaceResolver.php#L134-L150
|
228,416
|
antaresproject/core
|
src/foundation/src/Http/Resolver/ModuleNamespaceResolver.php
|
ModuleNamespaceResolver.getController
|
public function getController($matches = [])
{
if (!isset($this->route['controller'])) {
return false;
}
$controller = $this->route['controller'];
preg_match("/.+?(?=Controllers)(.*)@/", $controller, $matches);
if (!isset($matches[1])) {
return false;
}
return str_ireplace(['Controllers', 'Controller', '\\'], "", $matches[1]);
}
|
php
|
public function getController($matches = [])
{
if (!isset($this->route['controller'])) {
return false;
}
$controller = $this->route['controller'];
preg_match("/.+?(?=Controllers)(.*)@/", $controller, $matches);
if (!isset($matches[1])) {
return false;
}
return str_ireplace(['Controllers', 'Controller', '\\'], "", $matches[1]);
}
|
[
"public",
"function",
"getController",
"(",
"$",
"matches",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"route",
"[",
"'controller'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"controller",
"=",
"$",
"this",
"->",
"route",
"[",
"'controller'",
"]",
";",
"preg_match",
"(",
"\"/.+?(?=Controllers)(.*)@/\"",
",",
"$",
"controller",
",",
"$",
"matches",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"str_ireplace",
"(",
"[",
"'Controllers'",
",",
"'Controller'",
",",
"'\\\\'",
"]",
",",
"\"\"",
",",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"}"
] |
resolver controller name from route
@param array $matches
@return boolean|String
|
[
"resolver",
"controller",
"name",
"from",
"route"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Resolver/ModuleNamespaceResolver.php#L177-L189
|
228,417
|
lawoole/framework
|
src/Homer/Calling/Invokers/ConcreteInvoker.php
|
ConcreteInvoker.getConcrete
|
public function getConcrete()
{
if ($this->instance) {
return $this->instance;
}
if (is_object($this->concrete) || $this->concrete instanceof Closure) {
$instance = $this->concrete;
} else {
$instance = $this->context->getContainer()->make($this->concrete);
}
if (! $this->isDynamic()) {
$this->checkConcreteInstance($instance);
}
return $this->instance = $instance;
}
|
php
|
public function getConcrete()
{
if ($this->instance) {
return $this->instance;
}
if (is_object($this->concrete) || $this->concrete instanceof Closure) {
$instance = $this->concrete;
} else {
$instance = $this->context->getContainer()->make($this->concrete);
}
if (! $this->isDynamic()) {
$this->checkConcreteInstance($instance);
}
return $this->instance = $instance;
}
|
[
"public",
"function",
"getConcrete",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"instance",
")",
"{",
"return",
"$",
"this",
"->",
"instance",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"this",
"->",
"concrete",
")",
"||",
"$",
"this",
"->",
"concrete",
"instanceof",
"Closure",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"concrete",
";",
"}",
"else",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"context",
"->",
"getContainer",
"(",
")",
"->",
"make",
"(",
"$",
"this",
"->",
"concrete",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isDynamic",
"(",
")",
")",
"{",
"$",
"this",
"->",
"checkConcreteInstance",
"(",
"$",
"instance",
")",
";",
"}",
"return",
"$",
"this",
"->",
"instance",
"=",
"$",
"instance",
";",
"}"
] |
Get the concrete instance.
@return object|\Closure
|
[
"Get",
"the",
"concrete",
"instance",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Calling/Invokers/ConcreteInvoker.php#L92-L109
|
228,418
|
pxgamer/torrent-parser-php
|
src/Traits/Parser.php
|
Parser.xml2array
|
private static function xml2array(\SimpleXMLElement $xml)
{
$arr = [];
if ($xml) {
foreach ($xml->children() as $r) {
$t = [];
if (!is_null($r) && count($r->children()) == 0) {
$arr[$r->getName()] = strval($r);
} else {
$arr[$r->getName()][] = self::xml2array($r);
}
}
}
return $arr;
}
|
php
|
private static function xml2array(\SimpleXMLElement $xml)
{
$arr = [];
if ($xml) {
foreach ($xml->children() as $r) {
$t = [];
if (!is_null($r) && count($r->children()) == 0) {
$arr[$r->getName()] = strval($r);
} else {
$arr[$r->getName()][] = self::xml2array($r);
}
}
}
return $arr;
}
|
[
"private",
"static",
"function",
"xml2array",
"(",
"\\",
"SimpleXMLElement",
"$",
"xml",
")",
"{",
"$",
"arr",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"xml",
")",
"{",
"foreach",
"(",
"$",
"xml",
"->",
"children",
"(",
")",
"as",
"$",
"r",
")",
"{",
"$",
"t",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"r",
")",
"&&",
"count",
"(",
"$",
"r",
"->",
"children",
"(",
")",
")",
"==",
"0",
")",
"{",
"$",
"arr",
"[",
"$",
"r",
"->",
"getName",
"(",
")",
"]",
"=",
"strval",
"(",
"$",
"r",
")",
";",
"}",
"else",
"{",
"$",
"arr",
"[",
"$",
"r",
"->",
"getName",
"(",
")",
"]",
"[",
"]",
"=",
"self",
"::",
"xml2array",
"(",
"$",
"r",
")",
";",
"}",
"}",
"}",
"return",
"$",
"arr",
";",
"}"
] |
Convert a SimpleXMLElement to an array
@param \SimpleXMLElement $xml
@return array
|
[
"Convert",
"a",
"SimpleXMLElement",
"to",
"an",
"array"
] |
7ad4d44b4701d54630ba775525bd2bd36ee448bb
|
https://github.com/pxgamer/torrent-parser-php/blob/7ad4d44b4701d54630ba775525bd2bd36ee448bb/src/Traits/Parser.php#L16-L32
|
228,419
|
antaresproject/core
|
src/ui/components/datatables/src/Request.php
|
Request.searchableColumnIndex
|
public function searchableColumnIndex()
{
$searchable = [];
for ($i = 0, $c = count($this->get('columns')); $i < $c; $i++) {
if ($this->isColumnSearchable($i, false)) {
$searchable[] = $i;
}
}
return $searchable;
}
|
php
|
public function searchableColumnIndex()
{
$searchable = [];
for ($i = 0, $c = count($this->get('columns')); $i < $c; $i++) {
if ($this->isColumnSearchable($i, false)) {
$searchable[] = $i;
}
}
return $searchable;
}
|
[
"public",
"function",
"searchableColumnIndex",
"(",
")",
"{",
"$",
"searchable",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"c",
"=",
"count",
"(",
"$",
"this",
"->",
"get",
"(",
"'columns'",
")",
")",
";",
"$",
"i",
"<",
"$",
"c",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isColumnSearchable",
"(",
"$",
"i",
",",
"false",
")",
")",
"{",
"$",
"searchable",
"[",
"]",
"=",
"$",
"i",
";",
"}",
"}",
"return",
"$",
"searchable",
";",
"}"
] |
Get searchable column indexes
@return array
|
[
"Get",
"searchable",
"column",
"indexes"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Request.php#L40-L50
|
228,420
|
antaresproject/core
|
src/ui/components/datatables/src/Request.php
|
Request.isSearchable
|
public function isSearchable()
{
if (request()->has('inline_search')) {
$this->replace([
'start' => 0,
'length' => 25,
'search' => request()->get('inline_search')
]);
}
$search = (array) $this->get('search');
return isset($search['value']) ? $search['value'] != '' : false;
}
|
php
|
public function isSearchable()
{
if (request()->has('inline_search')) {
$this->replace([
'start' => 0,
'length' => 25,
'search' => request()->get('inline_search')
]);
}
$search = (array) $this->get('search');
return isset($search['value']) ? $search['value'] != '' : false;
}
|
[
"public",
"function",
"isSearchable",
"(",
")",
"{",
"if",
"(",
"request",
"(",
")",
"->",
"has",
"(",
"'inline_search'",
")",
")",
"{",
"$",
"this",
"->",
"replace",
"(",
"[",
"'start'",
"=>",
"0",
",",
"'length'",
"=>",
"25",
",",
"'search'",
"=>",
"request",
"(",
")",
"->",
"get",
"(",
"'inline_search'",
")",
"]",
")",
";",
"}",
"$",
"search",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"get",
"(",
"'search'",
")",
";",
"return",
"isset",
"(",
"$",
"search",
"[",
"'value'",
"]",
")",
"?",
"$",
"search",
"[",
"'value'",
"]",
"!=",
"''",
":",
"false",
";",
"}"
] |
Check if Datatables is searchable.
@return bool
|
[
"Check",
"if",
"Datatables",
"is",
"searchable",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Request.php#L85-L96
|
228,421
|
gggeek/ggwebservices
|
lib/xmlrpc/xmlrpc.inc.php
|
xmlrpc_client.setCredentials
|
function setCredentials($u, $p, $t=1)
{
$this->username=$u;
$this->password=$p;
$this->authtype=$t;
}
|
php
|
function setCredentials($u, $p, $t=1)
{
$this->username=$u;
$this->password=$p;
$this->authtype=$t;
}
|
[
"function",
"setCredentials",
"(",
"$",
"u",
",",
"$",
"p",
",",
"$",
"t",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"username",
"=",
"$",
"u",
";",
"$",
"this",
"->",
"password",
"=",
"$",
"p",
";",
"$",
"this",
"->",
"authtype",
"=",
"$",
"t",
";",
"}"
] |
Add some http BASIC AUTH credentials, used by the client to authenticate
@param string $u username
@param string $p password
@param integer $t auth type. See curl_setopt man page for supported auth types. Defaults to CURLAUTH_BASIC (basic auth)
@access public
|
[
"Add",
"some",
"http",
"BASIC",
"AUTH",
"credentials",
"used",
"by",
"the",
"client",
"to",
"authenticate"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/lib/xmlrpc/xmlrpc.inc.php#L966-L971
|
228,422
|
gggeek/ggwebservices
|
lib/xmlrpc/xmlrpc.inc.php
|
xmlrpc_client.&
|
function& send($msg, $timeout=0, $method='')
{
// if user deos not specify http protocol, use native method of this client
// (i.e. method set during call to constructor)
if($method == '')
{
$method = $this->method;
}
if(is_array($msg))
{
// $msg is an array of xmlrpcmsg's
$r = $this->multicall($msg, $timeout, $method);
return $r;
}
elseif(is_string($msg))
{
$n = new xmlrpcmsg('');
$n->payload = $msg;
$msg = $n;
}
// where msg is an xmlrpcmsg
$msg->debug=$this->debug;
if($method == 'https')
{
$r =& $this->sendPayloadHTTPS(
$msg,
$this->server,
$this->port,
$timeout,
$this->username,
$this->password,
$this->authtype,
$this->cert,
$this->certpass,
$this->cacert,
$this->cacertdir,
$this->proxy,
$this->proxyport,
$this->proxy_user,
$this->proxy_pass,
$this->proxy_authtype,
$this->keepalive,
$this->key,
$this->keypass
);
}
elseif($method == 'http11')
{
$r =& $this->sendPayloadCURL(
$msg,
$this->server,
$this->port,
$timeout,
$this->username,
$this->password,
$this->authtype,
null,
null,
null,
null,
$this->proxy,
$this->proxyport,
$this->proxy_user,
$this->proxy_pass,
$this->proxy_authtype,
'http',
$this->keepalive
);
}
else
{
$r =& $this->sendPayloadHTTP10(
$msg,
$this->server,
$this->port,
$timeout,
$this->username,
$this->password,
$this->authtype,
$this->proxy,
$this->proxyport,
$this->proxy_user,
$this->proxy_pass,
$this->proxy_authtype
);
}
return $r;
}
|
php
|
function& send($msg, $timeout=0, $method='')
{
// if user deos not specify http protocol, use native method of this client
// (i.e. method set during call to constructor)
if($method == '')
{
$method = $this->method;
}
if(is_array($msg))
{
// $msg is an array of xmlrpcmsg's
$r = $this->multicall($msg, $timeout, $method);
return $r;
}
elseif(is_string($msg))
{
$n = new xmlrpcmsg('');
$n->payload = $msg;
$msg = $n;
}
// where msg is an xmlrpcmsg
$msg->debug=$this->debug;
if($method == 'https')
{
$r =& $this->sendPayloadHTTPS(
$msg,
$this->server,
$this->port,
$timeout,
$this->username,
$this->password,
$this->authtype,
$this->cert,
$this->certpass,
$this->cacert,
$this->cacertdir,
$this->proxy,
$this->proxyport,
$this->proxy_user,
$this->proxy_pass,
$this->proxy_authtype,
$this->keepalive,
$this->key,
$this->keypass
);
}
elseif($method == 'http11')
{
$r =& $this->sendPayloadCURL(
$msg,
$this->server,
$this->port,
$timeout,
$this->username,
$this->password,
$this->authtype,
null,
null,
null,
null,
$this->proxy,
$this->proxyport,
$this->proxy_user,
$this->proxy_pass,
$this->proxy_authtype,
'http',
$this->keepalive
);
}
else
{
$r =& $this->sendPayloadHTTP10(
$msg,
$this->server,
$this->port,
$timeout,
$this->username,
$this->password,
$this->authtype,
$this->proxy,
$this->proxyport,
$this->proxy_user,
$this->proxy_pass,
$this->proxy_authtype
);
}
return $r;
}
|
[
"function",
"&",
"send",
"(",
"$",
"msg",
",",
"$",
"timeout",
"=",
"0",
",",
"$",
"method",
"=",
"''",
")",
"{",
"// if user deos not specify http protocol, use native method of this client\r",
"// (i.e. method set during call to constructor)\r",
"if",
"(",
"$",
"method",
"==",
"''",
")",
"{",
"$",
"method",
"=",
"$",
"this",
"->",
"method",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"msg",
")",
")",
"{",
"// $msg is an array of xmlrpcmsg's\r",
"$",
"r",
"=",
"$",
"this",
"->",
"multicall",
"(",
"$",
"msg",
",",
"$",
"timeout",
",",
"$",
"method",
")",
";",
"return",
"$",
"r",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"msg",
")",
")",
"{",
"$",
"n",
"=",
"new",
"xmlrpcmsg",
"(",
"''",
")",
";",
"$",
"n",
"->",
"payload",
"=",
"$",
"msg",
";",
"$",
"msg",
"=",
"$",
"n",
";",
"}",
"// where msg is an xmlrpcmsg\r",
"$",
"msg",
"->",
"debug",
"=",
"$",
"this",
"->",
"debug",
";",
"if",
"(",
"$",
"method",
"==",
"'https'",
")",
"{",
"$",
"r",
"=",
"&",
"$",
"this",
"->",
"sendPayloadHTTPS",
"(",
"$",
"msg",
",",
"$",
"this",
"->",
"server",
",",
"$",
"this",
"->",
"port",
",",
"$",
"timeout",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"this",
"->",
"authtype",
",",
"$",
"this",
"->",
"cert",
",",
"$",
"this",
"->",
"certpass",
",",
"$",
"this",
"->",
"cacert",
",",
"$",
"this",
"->",
"cacertdir",
",",
"$",
"this",
"->",
"proxy",
",",
"$",
"this",
"->",
"proxyport",
",",
"$",
"this",
"->",
"proxy_user",
",",
"$",
"this",
"->",
"proxy_pass",
",",
"$",
"this",
"->",
"proxy_authtype",
",",
"$",
"this",
"->",
"keepalive",
",",
"$",
"this",
"->",
"key",
",",
"$",
"this",
"->",
"keypass",
")",
";",
"}",
"elseif",
"(",
"$",
"method",
"==",
"'http11'",
")",
"{",
"$",
"r",
"=",
"&",
"$",
"this",
"->",
"sendPayloadCURL",
"(",
"$",
"msg",
",",
"$",
"this",
"->",
"server",
",",
"$",
"this",
"->",
"port",
",",
"$",
"timeout",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"this",
"->",
"authtype",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"$",
"this",
"->",
"proxy",
",",
"$",
"this",
"->",
"proxyport",
",",
"$",
"this",
"->",
"proxy_user",
",",
"$",
"this",
"->",
"proxy_pass",
",",
"$",
"this",
"->",
"proxy_authtype",
",",
"'http'",
",",
"$",
"this",
"->",
"keepalive",
")",
";",
"}",
"else",
"{",
"$",
"r",
"=",
"&",
"$",
"this",
"->",
"sendPayloadHTTP10",
"(",
"$",
"msg",
",",
"$",
"this",
"->",
"server",
",",
"$",
"this",
"->",
"port",
",",
"$",
"timeout",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"this",
"->",
"authtype",
",",
"$",
"this",
"->",
"proxy",
",",
"$",
"this",
"->",
"proxyport",
",",
"$",
"this",
"->",
"proxy_user",
",",
"$",
"this",
"->",
"proxy_pass",
",",
"$",
"this",
"->",
"proxy_authtype",
")",
";",
"}",
"return",
"$",
"r",
";",
"}"
] |
Send an xmlrpc request
@param mixed $msg The message object, or an array of messages for using multicall, or the complete xml representation of a request
@param integer $timeout Connection timeout, in seconds, If unspecified, a platform specific timeout will apply
@param string $method if left unspecified, the http protocol chosen during creation of the object will be used
@return xmlrpcresp
@access public
|
[
"Send",
"an",
"xmlrpc",
"request"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/lib/xmlrpc/xmlrpc.inc.php#L1151-L1242
|
228,423
|
gggeek/ggwebservices
|
lib/xmlrpc/xmlrpc.inc.php
|
xmlrpcresp.serialize
|
function serialize($charset_encoding='')
{
if ($charset_encoding != '')
$this->content_type = 'text/xml; charset=' . $charset_encoding;
else
$this->content_type = 'text/xml';
if ($GLOBALS['xmlrpc_null_apache_encoding'])
{
$result = "<methodResponse xmlns:ex=\"".$GLOBALS['xmlrpc_null_apache_encoding_ns']."\">\n";
}
else
{
$result = "<methodResponse>\n";
}
if($this->errno)
{
// G. Giunta 2005/2/13: let non-ASCII response messages be tolerated by clients
// by xml-encoding non ascii chars
$result .= "<fault>\n" .
"<value>\n<struct><member><name>faultCode</name>\n<value><int>" . $this->errno .
"</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>" .
xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "</string></value>\n</member>\n" .
"</struct>\n</value>\n</fault>";
}
else
{
if(!is_object($this->val) || !is_a($this->val, 'xmlrpcval'))
{
if (is_string($this->val) && $this->valtyp == 'xml')
{
$result .= "<params>\n<param>\n" .
$this->val .
"</param>\n</params>";
}
else
{
/// @todo try to build something serializable?
die('cannot serialize xmlrpcresp objects whose content is native php values');
}
}
else
{
$result .= "<params>\n<param>\n" .
$this->val->serialize($charset_encoding) .
"</param>\n</params>";
}
}
$result .= "\n</methodResponse>";
$this->payload = $result;
return $result;
}
|
php
|
function serialize($charset_encoding='')
{
if ($charset_encoding != '')
$this->content_type = 'text/xml; charset=' . $charset_encoding;
else
$this->content_type = 'text/xml';
if ($GLOBALS['xmlrpc_null_apache_encoding'])
{
$result = "<methodResponse xmlns:ex=\"".$GLOBALS['xmlrpc_null_apache_encoding_ns']."\">\n";
}
else
{
$result = "<methodResponse>\n";
}
if($this->errno)
{
// G. Giunta 2005/2/13: let non-ASCII response messages be tolerated by clients
// by xml-encoding non ascii chars
$result .= "<fault>\n" .
"<value>\n<struct><member><name>faultCode</name>\n<value><int>" . $this->errno .
"</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>" .
xmlrpc_encode_entitites($this->errstr, $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "</string></value>\n</member>\n" .
"</struct>\n</value>\n</fault>";
}
else
{
if(!is_object($this->val) || !is_a($this->val, 'xmlrpcval'))
{
if (is_string($this->val) && $this->valtyp == 'xml')
{
$result .= "<params>\n<param>\n" .
$this->val .
"</param>\n</params>";
}
else
{
/// @todo try to build something serializable?
die('cannot serialize xmlrpcresp objects whose content is native php values');
}
}
else
{
$result .= "<params>\n<param>\n" .
$this->val->serialize($charset_encoding) .
"</param>\n</params>";
}
}
$result .= "\n</methodResponse>";
$this->payload = $result;
return $result;
}
|
[
"function",
"serialize",
"(",
"$",
"charset_encoding",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"charset_encoding",
"!=",
"''",
")",
"$",
"this",
"->",
"content_type",
"=",
"'text/xml; charset='",
".",
"$",
"charset_encoding",
";",
"else",
"$",
"this",
"->",
"content_type",
"=",
"'text/xml'",
";",
"if",
"(",
"$",
"GLOBALS",
"[",
"'xmlrpc_null_apache_encoding'",
"]",
")",
"{",
"$",
"result",
"=",
"\"<methodResponse xmlns:ex=\\\"\"",
".",
"$",
"GLOBALS",
"[",
"'xmlrpc_null_apache_encoding_ns'",
"]",
".",
"\"\\\">\\n\"",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"\"<methodResponse>\\n\"",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"errno",
")",
"{",
"// G. Giunta 2005/2/13: let non-ASCII response messages be tolerated by clients\r",
"// by xml-encoding non ascii chars\r",
"$",
"result",
".=",
"\"<fault>\\n\"",
".",
"\"<value>\\n<struct><member><name>faultCode</name>\\n<value><int>\"",
".",
"$",
"this",
"->",
"errno",
".",
"\"</int></value>\\n</member>\\n<member>\\n<name>faultString</name>\\n<value><string>\"",
".",
"xmlrpc_encode_entitites",
"(",
"$",
"this",
"->",
"errstr",
",",
"$",
"GLOBALS",
"[",
"'xmlrpc_internalencoding'",
"]",
",",
"$",
"charset_encoding",
")",
".",
"\"</string></value>\\n</member>\\n\"",
".",
"\"</struct>\\n</value>\\n</fault>\"",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"this",
"->",
"val",
")",
"||",
"!",
"is_a",
"(",
"$",
"this",
"->",
"val",
",",
"'xmlrpcval'",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"this",
"->",
"val",
")",
"&&",
"$",
"this",
"->",
"valtyp",
"==",
"'xml'",
")",
"{",
"$",
"result",
".=",
"\"<params>\\n<param>\\n\"",
".",
"$",
"this",
"->",
"val",
".",
"\"</param>\\n</params>\"",
";",
"}",
"else",
"{",
"/// @todo try to build something serializable?\r",
"die",
"(",
"'cannot serialize xmlrpcresp objects whose content is native php values'",
")",
";",
"}",
"}",
"else",
"{",
"$",
"result",
".=",
"\"<params>\\n<param>\\n\"",
".",
"$",
"this",
"->",
"val",
"->",
"serialize",
"(",
"$",
"charset_encoding",
")",
".",
"\"</param>\\n</params>\"",
";",
"}",
"}",
"$",
"result",
".=",
"\"\\n</methodResponse>\"",
";",
"$",
"this",
"->",
"payload",
"=",
"$",
"result",
";",
"return",
"$",
"result",
";",
"}"
] |
Returns xml representation of the response. XML prologue not included
@param string $charset_encoding the charset to be used for serialization. if null, US-ASCII is assumed
@return string the xml representation of the response
@access public
|
[
"Returns",
"xml",
"representation",
"of",
"the",
"response",
".",
"XML",
"prologue",
"not",
"included"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/lib/xmlrpc/xmlrpc.inc.php#L2076-L2126
|
228,424
|
gggeek/ggwebservices
|
lib/xmlrpc/xmlrpc.inc.php
|
xmlrpcmsg.addParam
|
function addParam($par)
{
// add check: do not add to self params which are not xmlrpcvals
if(is_object($par) && is_a($par, 'xmlrpcval'))
{
$this->params[]=$par;
return true;
}
else
{
return false;
}
}
|
php
|
function addParam($par)
{
// add check: do not add to self params which are not xmlrpcvals
if(is_object($par) && is_a($par, 'xmlrpcval'))
{
$this->params[]=$par;
return true;
}
else
{
return false;
}
}
|
[
"function",
"addParam",
"(",
"$",
"par",
")",
"{",
"// add check: do not add to self params which are not xmlrpcvals\r",
"if",
"(",
"is_object",
"(",
"$",
"par",
")",
"&&",
"is_a",
"(",
"$",
"par",
",",
"'xmlrpcval'",
")",
")",
"{",
"$",
"this",
"->",
"params",
"[",
"]",
"=",
"$",
"par",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Add a parameter to the list of parameters to be used upon method invocation
@param xmlrpcval $par
@return boolean false on failure
@access public
|
[
"Add",
"a",
"parameter",
"to",
"the",
"list",
"of",
"parameters",
"to",
"be",
"used",
"upon",
"method",
"invocation"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/lib/xmlrpc/xmlrpc.inc.php#L2239-L2251
|
228,425
|
gggeek/ggwebservices
|
lib/xmlrpc/xmlrpc.inc.php
|
xmlrpcval.serialize
|
function serialize($charset_encoding='')
{
// add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals...
//if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval')))
//{
reset($this->me);
list($typ, $val) = each($this->me);
return '<value>' . $this->serializedata($typ, $val, $charset_encoding) . "</value>\n";
//}
}
|
php
|
function serialize($charset_encoding='')
{
// add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals...
//if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval')))
//{
reset($this->me);
list($typ, $val) = each($this->me);
return '<value>' . $this->serializedata($typ, $val, $charset_encoding) . "</value>\n";
//}
}
|
[
"function",
"serialize",
"(",
"$",
"charset_encoding",
"=",
"''",
")",
"{",
"// add check? slower, but helps to avoid recursion in serializing broken xmlrpcvals...\r",
"//if (is_object($o) && (get_class($o) == 'xmlrpcval' || is_subclass_of($o, 'xmlrpcval')))\r",
"//{\r",
"reset",
"(",
"$",
"this",
"->",
"me",
")",
";",
"list",
"(",
"$",
"typ",
",",
"$",
"val",
")",
"=",
"each",
"(",
"$",
"this",
"->",
"me",
")",
";",
"return",
"'<value>'",
".",
"$",
"this",
"->",
"serializedata",
"(",
"$",
"typ",
",",
"$",
"val",
",",
"$",
"charset_encoding",
")",
".",
"\"</value>\\n\"",
";",
"//}\r",
"}"
] |
Returns xml representation of the value. XML prologue not included
@param string $charset_encoding the charset to be used for serialization. if null, US-ASCII is assumed
@return string
@access public
|
[
"Returns",
"xml",
"representation",
"of",
"the",
"value",
".",
"XML",
"prologue",
"not",
"included"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/lib/xmlrpc/xmlrpc.inc.php#L3082-L3091
|
228,426
|
gggeek/ggwebservices
|
lib/xmlrpc/xmlrpc.inc.php
|
xmlrpcval.getval
|
function getval()
{
// UNSTABLE
reset($this->me);
list($a,$b)=each($this->me);
// contributed by I Sofer, 2001-03-24
// add support for nested arrays to scalarval
// i've created a new method here, so as to
// preserve back compatibility
if(is_array($b))
{
@reset($b);
while(list($id,$cont) = @each($b))
{
$b[$id] = $cont->scalarval();
}
}
// add support for structures directly encoding php objects
if(is_object($b))
{
$t = get_object_vars($b);
@reset($t);
while(list($id,$cont) = @each($t))
{
$t[$id] = $cont->scalarval();
}
@reset($t);
while(list($id,$cont) = @each($t))
{
@$b->$id = $cont;
}
}
// end contrib
return $b;
}
|
php
|
function getval()
{
// UNSTABLE
reset($this->me);
list($a,$b)=each($this->me);
// contributed by I Sofer, 2001-03-24
// add support for nested arrays to scalarval
// i've created a new method here, so as to
// preserve back compatibility
if(is_array($b))
{
@reset($b);
while(list($id,$cont) = @each($b))
{
$b[$id] = $cont->scalarval();
}
}
// add support for structures directly encoding php objects
if(is_object($b))
{
$t = get_object_vars($b);
@reset($t);
while(list($id,$cont) = @each($t))
{
$t[$id] = $cont->scalarval();
}
@reset($t);
while(list($id,$cont) = @each($t))
{
@$b->$id = $cont;
}
}
// end contrib
return $b;
}
|
[
"function",
"getval",
"(",
")",
"{",
"// UNSTABLE\r",
"reset",
"(",
"$",
"this",
"->",
"me",
")",
";",
"list",
"(",
"$",
"a",
",",
"$",
"b",
")",
"=",
"each",
"(",
"$",
"this",
"->",
"me",
")",
";",
"// contributed by I Sofer, 2001-03-24\r",
"// add support for nested arrays to scalarval\r",
"// i've created a new method here, so as to\r",
"// preserve back compatibility\r",
"if",
"(",
"is_array",
"(",
"$",
"b",
")",
")",
"{",
"@",
"reset",
"(",
"$",
"b",
")",
";",
"while",
"(",
"list",
"(",
"$",
"id",
",",
"$",
"cont",
")",
"=",
"@",
"each",
"(",
"$",
"b",
")",
")",
"{",
"$",
"b",
"[",
"$",
"id",
"]",
"=",
"$",
"cont",
"->",
"scalarval",
"(",
")",
";",
"}",
"}",
"// add support for structures directly encoding php objects\r",
"if",
"(",
"is_object",
"(",
"$",
"b",
")",
")",
"{",
"$",
"t",
"=",
"get_object_vars",
"(",
"$",
"b",
")",
";",
"@",
"reset",
"(",
"$",
"t",
")",
";",
"while",
"(",
"list",
"(",
"$",
"id",
",",
"$",
"cont",
")",
"=",
"@",
"each",
"(",
"$",
"t",
")",
")",
"{",
"$",
"t",
"[",
"$",
"id",
"]",
"=",
"$",
"cont",
"->",
"scalarval",
"(",
")",
";",
"}",
"@",
"reset",
"(",
"$",
"t",
")",
";",
"while",
"(",
"list",
"(",
"$",
"id",
",",
"$",
"cont",
")",
"=",
"@",
"each",
"(",
"$",
"t",
")",
")",
"{",
"@",
"$",
"b",
"->",
"$",
"id",
"=",
"$",
"cont",
";",
"}",
"}",
"// end contrib\r",
"return",
"$",
"b",
";",
"}"
] |
for a long long time. Shall we remove it for 2.0?
|
[
"for",
"a",
"long",
"long",
"time",
".",
"Shall",
"we",
"remove",
"it",
"for",
"2",
".",
"0?"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/lib/xmlrpc/xmlrpc.inc.php#L3151-L3187
|
228,427
|
gggeek/ggwebservices
|
lib/xmlrpc/xmlrpc.inc.php
|
xmlrpcval.scalarval
|
function scalarval()
{
reset($this->me);
list(,$b)=each($this->me);
return $b;
}
|
php
|
function scalarval()
{
reset($this->me);
list(,$b)=each($this->me);
return $b;
}
|
[
"function",
"scalarval",
"(",
")",
"{",
"reset",
"(",
"$",
"this",
"->",
"me",
")",
";",
"list",
"(",
",",
"$",
"b",
")",
"=",
"each",
"(",
"$",
"this",
"->",
"me",
")",
";",
"return",
"$",
"b",
";",
"}"
] |
Returns the value of a scalar xmlrpcval
@return mixed
@access public
|
[
"Returns",
"the",
"value",
"of",
"a",
"scalar",
"xmlrpcval"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/lib/xmlrpc/xmlrpc.inc.php#L3194-L3199
|
228,428
|
gggeek/ggwebservices
|
lib/xmlrpc/xmlrpc.inc.php
|
xmlrpcval.scalartyp
|
function scalartyp()
{
reset($this->me);
list($a,)=each($this->me);
if($a==$GLOBALS['xmlrpcI4'])
{
$a=$GLOBALS['xmlrpcInt'];
}
return $a;
}
|
php
|
function scalartyp()
{
reset($this->me);
list($a,)=each($this->me);
if($a==$GLOBALS['xmlrpcI4'])
{
$a=$GLOBALS['xmlrpcInt'];
}
return $a;
}
|
[
"function",
"scalartyp",
"(",
")",
"{",
"reset",
"(",
"$",
"this",
"->",
"me",
")",
";",
"list",
"(",
"$",
"a",
",",
")",
"=",
"each",
"(",
"$",
"this",
"->",
"me",
")",
";",
"if",
"(",
"$",
"a",
"==",
"$",
"GLOBALS",
"[",
"'xmlrpcI4'",
"]",
")",
"{",
"$",
"a",
"=",
"$",
"GLOBALS",
"[",
"'xmlrpcInt'",
"]",
";",
"}",
"return",
"$",
"a",
";",
"}"
] |
Returns the type of the xmlrpcval.
For integers, 'int' is always returned in place of 'i4'
@return string
@access public
|
[
"Returns",
"the",
"type",
"of",
"the",
"xmlrpcval",
".",
"For",
"integers",
"int",
"is",
"always",
"returned",
"in",
"place",
"of",
"i4"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/lib/xmlrpc/xmlrpc.inc.php#L3207-L3216
|
228,429
|
coincheckjp/coincheck-php
|
lib/Coincheck/Leverage.php
|
Leverage.positions
|
public function positions($params = array())
{
$arr = $params;
$rawResponse = $this->client->request('get', 'api/exchange/leverage/positions', $arr);
return $rawResponse;
}
|
php
|
public function positions($params = array())
{
$arr = $params;
$rawResponse = $this->client->request('get', 'api/exchange/leverage/positions', $arr);
return $rawResponse;
}
|
[
"public",
"function",
"positions",
"(",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"arr",
"=",
"$",
"params",
";",
"$",
"rawResponse",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'get'",
",",
"'api/exchange/leverage/positions'",
",",
"$",
"arr",
")",
";",
"return",
"$",
"rawResponse",
";",
"}"
] |
Get a leverage positions list.
@param mixed
@return Json Array
|
[
"Get",
"a",
"leverage",
"positions",
"list",
"."
] |
5991003cb0ae827697888aeebd0aea0267fad7fa
|
https://github.com/coincheckjp/coincheck-php/blob/5991003cb0ae827697888aeebd0aea0267fad7fa/lib/Coincheck/Leverage.php#L21-L26
|
228,430
|
antaresproject/core
|
src/ui/components/templates/src/Repository/Repository.php
|
Repository.save
|
public function save($name, $attributes = [])
{
if (auth()->guest()) {
return;
}
$params = [
'uid' => auth()->user()->id,
'brand_id' => brand_id(),
'resource' => uri(),
'name' => snake_case($name),
'data' => $attributes,
];
$this->cache->forget($this->cacheKey($params));
$wid = $this->getComponentId($name);
$params['wid'] = $wid;
$componentParams = ComponentParams::firstOrNew($params);
$componentParams->save();
return $componentParams;
}
|
php
|
public function save($name, $attributes = [])
{
if (auth()->guest()) {
return;
}
$params = [
'uid' => auth()->user()->id,
'brand_id' => brand_id(),
'resource' => uri(),
'name' => snake_case($name),
'data' => $attributes,
];
$this->cache->forget($this->cacheKey($params));
$wid = $this->getComponentId($name);
$params['wid'] = $wid;
$componentParams = ComponentParams::firstOrNew($params);
$componentParams->save();
return $componentParams;
}
|
[
"public",
"function",
"save",
"(",
"$",
"name",
",",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"auth",
"(",
")",
"->",
"guest",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"params",
"=",
"[",
"'uid'",
"=>",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"id",
",",
"'brand_id'",
"=>",
"brand_id",
"(",
")",
",",
"'resource'",
"=>",
"uri",
"(",
")",
",",
"'name'",
"=>",
"snake_case",
"(",
"$",
"name",
")",
",",
"'data'",
"=>",
"$",
"attributes",
",",
"]",
";",
"$",
"this",
"->",
"cache",
"->",
"forget",
"(",
"$",
"this",
"->",
"cacheKey",
"(",
"$",
"params",
")",
")",
";",
"$",
"wid",
"=",
"$",
"this",
"->",
"getComponentId",
"(",
"$",
"name",
")",
";",
"$",
"params",
"[",
"'wid'",
"]",
"=",
"$",
"wid",
";",
"$",
"componentParams",
"=",
"ComponentParams",
"::",
"firstOrNew",
"(",
"$",
"params",
")",
";",
"$",
"componentParams",
"->",
"save",
"(",
")",
";",
"return",
"$",
"componentParams",
";",
"}"
] |
Saves ui component
@param String $name
@param array $attributes
@return WidgetParams
|
[
"Saves",
"ui",
"component"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Repository/Repository.php#L72-L90
|
228,431
|
antaresproject/core
|
src/ui/components/templates/src/Repository/Repository.php
|
Repository.getComponentId
|
protected function getComponentId($name)
{
$where = [
'name' => $name,
'type_id' => app(ComponentTypes::class)->newInstance()->getDefault()->id
];
$exists = $this->makeModel()->where($where)->first();
if (!is_null($exists)) {
return $exists->id;
}
$component = $this->makeModel()->getModel()->newInstance($where);
$component->save();
return $component->id;
}
|
php
|
protected function getComponentId($name)
{
$where = [
'name' => $name,
'type_id' => app(ComponentTypes::class)->newInstance()->getDefault()->id
];
$exists = $this->makeModel()->where($where)->first();
if (!is_null($exists)) {
return $exists->id;
}
$component = $this->makeModel()->getModel()->newInstance($where);
$component->save();
return $component->id;
}
|
[
"protected",
"function",
"getComponentId",
"(",
"$",
"name",
")",
"{",
"$",
"where",
"=",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'type_id'",
"=>",
"app",
"(",
"ComponentTypes",
"::",
"class",
")",
"->",
"newInstance",
"(",
")",
"->",
"getDefault",
"(",
")",
"->",
"id",
"]",
";",
"$",
"exists",
"=",
"$",
"this",
"->",
"makeModel",
"(",
")",
"->",
"where",
"(",
"$",
"where",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"exists",
")",
")",
"{",
"return",
"$",
"exists",
"->",
"id",
";",
"}",
"$",
"component",
"=",
"$",
"this",
"->",
"makeModel",
"(",
")",
"->",
"getModel",
"(",
")",
"->",
"newInstance",
"(",
"$",
"where",
")",
";",
"$",
"component",
"->",
"save",
"(",
")",
";",
"return",
"$",
"component",
"->",
"id",
";",
"}"
] |
Gets existing ui component id or add new
@param String $name
@return mixed
|
[
"Gets",
"existing",
"ui",
"component",
"id",
"or",
"add",
"new"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Repository/Repository.php#L98-L111
|
228,432
|
antaresproject/core
|
src/ui/components/templates/src/Repository/Repository.php
|
Repository.findAllByResourceAndNames
|
public function findAllByResourceAndNames($resource, array $params)
{
$where = $this->getWhere(['resource' => $resource]);
$model = $this->makeModel()->getModel()->widgetParams()->getModel()->newQuery();
return $model->where($where)->whereIn('name', $params)->get()->toArray();
}
|
php
|
public function findAllByResourceAndNames($resource, array $params)
{
$where = $this->getWhere(['resource' => $resource]);
$model = $this->makeModel()->getModel()->widgetParams()->getModel()->newQuery();
return $model->where($where)->whereIn('name', $params)->get()->toArray();
}
|
[
"public",
"function",
"findAllByResourceAndNames",
"(",
"$",
"resource",
",",
"array",
"$",
"params",
")",
"{",
"$",
"where",
"=",
"$",
"this",
"->",
"getWhere",
"(",
"[",
"'resource'",
"=>",
"$",
"resource",
"]",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"makeModel",
"(",
")",
"->",
"getModel",
"(",
")",
"->",
"widgetParams",
"(",
")",
"->",
"getModel",
"(",
")",
"->",
"newQuery",
"(",
")",
";",
"return",
"$",
"model",
"->",
"where",
"(",
"$",
"where",
")",
"->",
"whereIn",
"(",
"'name'",
",",
"$",
"params",
")",
"->",
"get",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"}"
] |
Finds all ui components by resource and additional params
@param String $resource
@param array $params
@return array
|
[
"Finds",
"all",
"ui",
"components",
"by",
"resource",
"and",
"additional",
"params"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Repository/Repository.php#L144-L149
|
228,433
|
antaresproject/core
|
src/ui/components/templates/src/Repository/Repository.php
|
Repository.findByParams
|
protected function findByParams($where)
{
$model = $this->makeModel()->getModel()->widgetParams()->getModel()->newQuery();
return $model->where($where)->get()->toArray();
}
|
php
|
protected function findByParams($where)
{
$model = $this->makeModel()->getModel()->widgetParams()->getModel()->newQuery();
return $model->where($where)->get()->toArray();
}
|
[
"protected",
"function",
"findByParams",
"(",
"$",
"where",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"makeModel",
"(",
")",
"->",
"getModel",
"(",
")",
"->",
"widgetParams",
"(",
")",
"->",
"getModel",
"(",
")",
"->",
"newQuery",
"(",
")",
";",
"return",
"$",
"model",
"->",
"where",
"(",
"$",
"where",
")",
"->",
"get",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"}"
] |
Find items by params
@param array $where
@return array
|
[
"Find",
"items",
"by",
"params"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Repository/Repository.php#L157-L161
|
228,434
|
antaresproject/core
|
src/ui/components/templates/src/Repository/Repository.php
|
Repository.saveEntity
|
public function saveEntity(Model $model)
{
$cacheKey = $this->cacheKey($model->toArray());
$this->cache->forget($cacheKey);
return $model->save();
}
|
php
|
public function saveEntity(Model $model)
{
$cacheKey = $this->cacheKey($model->toArray());
$this->cache->forget($cacheKey);
return $model->save();
}
|
[
"public",
"function",
"saveEntity",
"(",
"Model",
"$",
"model",
")",
"{",
"$",
"cacheKey",
"=",
"$",
"this",
"->",
"cacheKey",
"(",
"$",
"model",
"->",
"toArray",
"(",
")",
")",
";",
"$",
"this",
"->",
"cache",
"->",
"forget",
"(",
"$",
"cacheKey",
")",
";",
"return",
"$",
"model",
"->",
"save",
"(",
")",
";",
"}"
] |
Saves single entity
@param Model $model
@return boolean
|
[
"Saves",
"single",
"entity"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Repository/Repository.php#L213-L218
|
228,435
|
antaresproject/core
|
src/ui/components/templates/src/Repository/Repository.php
|
Repository.cacheKey
|
protected function cacheKey(array $params = [])
{
$prefix = config('antares/ui-components::cache');
$required = ['resource', 'uid', 'brand_id', 'name'];
if (count(array_only($params, $required)) != count($required)) {
return $prefix;
}
$ordered = [];
foreach ($required as $key) {
$ordered[$key] = array_get($params, $key);
}
return implode('.', array_merge([config('antares/ui-components::cache')], $ordered));
}
|
php
|
protected function cacheKey(array $params = [])
{
$prefix = config('antares/ui-components::cache');
$required = ['resource', 'uid', 'brand_id', 'name'];
if (count(array_only($params, $required)) != count($required)) {
return $prefix;
}
$ordered = [];
foreach ($required as $key) {
$ordered[$key] = array_get($params, $key);
}
return implode('.', array_merge([config('antares/ui-components::cache')], $ordered));
}
|
[
"protected",
"function",
"cacheKey",
"(",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"prefix",
"=",
"config",
"(",
"'antares/ui-components::cache'",
")",
";",
"$",
"required",
"=",
"[",
"'resource'",
",",
"'uid'",
",",
"'brand_id'",
",",
"'name'",
"]",
";",
"if",
"(",
"count",
"(",
"array_only",
"(",
"$",
"params",
",",
"$",
"required",
")",
")",
"!=",
"count",
"(",
"$",
"required",
")",
")",
"{",
"return",
"$",
"prefix",
";",
"}",
"$",
"ordered",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"required",
"as",
"$",
"key",
")",
"{",
"$",
"ordered",
"[",
"$",
"key",
"]",
"=",
"array_get",
"(",
"$",
"params",
",",
"$",
"key",
")",
";",
"}",
"return",
"implode",
"(",
"'.'",
",",
"array_merge",
"(",
"[",
"config",
"(",
"'antares/ui-components::cache'",
")",
"]",
",",
"$",
"ordered",
")",
")",
";",
"}"
] |
Creates cache key
@param array $params
@return type
|
[
"Creates",
"cache",
"key"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Repository/Repository.php#L226-L238
|
228,436
|
antaresproject/core
|
src/ui/components/templates/src/Repository/Repository.php
|
Repository.load
|
public function load()
{
if (auth()->guest()) {
return new Collection();
}
return ComponentParams::withoutGlobalScopes()
->select(['tbl_widgets_params.id', 'tbl_widgets_params.wid', 'tbl_widgets_params.resource', 'tbl_widgets_params.name', 'tbl_widgets_params.data'])
->where('brand_id', brand_id())
->where('uid', auth()->user()->id)
->get();
}
|
php
|
public function load()
{
if (auth()->guest()) {
return new Collection();
}
return ComponentParams::withoutGlobalScopes()
->select(['tbl_widgets_params.id', 'tbl_widgets_params.wid', 'tbl_widgets_params.resource', 'tbl_widgets_params.name', 'tbl_widgets_params.data'])
->where('brand_id', brand_id())
->where('uid', auth()->user()->id)
->get();
}
|
[
"public",
"function",
"load",
"(",
")",
"{",
"if",
"(",
"auth",
"(",
")",
"->",
"guest",
"(",
")",
")",
"{",
"return",
"new",
"Collection",
"(",
")",
";",
"}",
"return",
"ComponentParams",
"::",
"withoutGlobalScopes",
"(",
")",
"->",
"select",
"(",
"[",
"'tbl_widgets_params.id'",
",",
"'tbl_widgets_params.wid'",
",",
"'tbl_widgets_params.resource'",
",",
"'tbl_widgets_params.name'",
",",
"'tbl_widgets_params.data'",
"]",
")",
"->",
"where",
"(",
"'brand_id'",
",",
"brand_id",
"(",
")",
")",
"->",
"where",
"(",
"'uid'",
",",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"id",
")",
"->",
"get",
"(",
")",
";",
"}"
] |
Loads all ui components
@return \Illuminate\Support\Collection
|
[
"Loads",
"all",
"ui",
"components"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Repository/Repository.php#L245-L255
|
228,437
|
antaresproject/core
|
src/components/support/src/Providers/Traits/PackageProviderTrait.php
|
PackageProviderTrait.addViewComponent
|
public function addViewComponent($package, $namespace, $path)
{
$files = $this->app->make('files');
$view = $this->app->make('view');
foreach ($this->getAppViewPaths($package) as $appView) {
if ($files->isDirectory($appView)) {
$view->addNamespace($namespace, $appView);
}
}
$view->addNamespace($namespace, $path);
}
|
php
|
public function addViewComponent($package, $namespace, $path)
{
$files = $this->app->make('files');
$view = $this->app->make('view');
foreach ($this->getAppViewPaths($package) as $appView) {
if ($files->isDirectory($appView)) {
$view->addNamespace($namespace, $appView);
}
}
$view->addNamespace($namespace, $path);
}
|
[
"public",
"function",
"addViewComponent",
"(",
"$",
"package",
",",
"$",
"namespace",
",",
"$",
"path",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'files'",
")",
";",
"$",
"view",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'view'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getAppViewPaths",
"(",
"$",
"package",
")",
"as",
"$",
"appView",
")",
"{",
"if",
"(",
"$",
"files",
"->",
"isDirectory",
"(",
"$",
"appView",
")",
")",
"{",
"$",
"view",
"->",
"addNamespace",
"(",
"$",
"namespace",
",",
"$",
"appView",
")",
";",
"}",
"}",
"$",
"view",
"->",
"addNamespace",
"(",
"$",
"namespace",
",",
"$",
"path",
")",
";",
"}"
] |
Register the package's view component namespaces.
@param string $package
@param string $namespace
@param string $path
@return void
|
[
"Register",
"the",
"package",
"s",
"view",
"component",
"namespaces",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Providers/Traits/PackageProviderTrait.php#L70-L81
|
228,438
|
lawoole/framework
|
src/WebSocket/WebSocketServerSocketHandler.php
|
WebSocketServerSocketHandler.onMessage
|
public function onMessage($server, $serverSocket, $frame)
{
$id = $frame->fd;
if (isset($this->connections[$id])) {
$this->fireMessageEvent(
$this->connections[$id]['handler'],
$this->connections[$id]['connection'],
$frame
);
}
}
|
php
|
public function onMessage($server, $serverSocket, $frame)
{
$id = $frame->fd;
if (isset($this->connections[$id])) {
$this->fireMessageEvent(
$this->connections[$id]['handler'],
$this->connections[$id]['connection'],
$frame
);
}
}
|
[
"public",
"function",
"onMessage",
"(",
"$",
"server",
",",
"$",
"serverSocket",
",",
"$",
"frame",
")",
"{",
"$",
"id",
"=",
"$",
"frame",
"->",
"fd",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"connections",
"[",
"$",
"id",
"]",
")",
")",
"{",
"$",
"this",
"->",
"fireMessageEvent",
"(",
"$",
"this",
"->",
"connections",
"[",
"$",
"id",
"]",
"[",
"'handler'",
"]",
",",
"$",
"this",
"->",
"connections",
"[",
"$",
"id",
"]",
"[",
"'connection'",
"]",
",",
"$",
"frame",
")",
";",
"}",
"}"
] |
Called when the server receive a WebSocket message frame.
@param \Lawoole\Server\Server $server
@param \Lawoole\Server\ServerSockets\ServerSocket $serverSocket
@param \Swoole\WebSocket\Frame $frame
|
[
"Called",
"when",
"the",
"server",
"receive",
"a",
"WebSocket",
"message",
"frame",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/WebSocket/WebSocketServerSocketHandler.php#L58-L69
|
228,439
|
lawoole/framework
|
src/WebSocket/WebSocketServerSocketHandler.php
|
WebSocketServerSocketHandler.onClose
|
public function onClose($server, $serverSocket, $id)
{
if (isset($this->connections[$id])) {
$this->fireCloseEvent(
$this->connections[$id]['handler'],
$this->connections[$id]['connection']
);
unset($this->connections[$id]);
}
}
|
php
|
public function onClose($server, $serverSocket, $id)
{
if (isset($this->connections[$id])) {
$this->fireCloseEvent(
$this->connections[$id]['handler'],
$this->connections[$id]['connection']
);
unset($this->connections[$id]);
}
}
|
[
"public",
"function",
"onClose",
"(",
"$",
"server",
",",
"$",
"serverSocket",
",",
"$",
"id",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"connections",
"[",
"$",
"id",
"]",
")",
")",
"{",
"$",
"this",
"->",
"fireCloseEvent",
"(",
"$",
"this",
"->",
"connections",
"[",
"$",
"id",
"]",
"[",
"'handler'",
"]",
",",
"$",
"this",
"->",
"connections",
"[",
"$",
"id",
"]",
"[",
"'connection'",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"connections",
"[",
"$",
"id",
"]",
")",
";",
"}",
"}"
] |
Called when a connection has been closed.
@param \Lawoole\Server\Server $server
@param \Lawoole\Server\ServerSockets\ServerSocket $serverSocket
@param int $id
|
[
"Called",
"when",
"a",
"connection",
"has",
"been",
"closed",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/WebSocket/WebSocketServerSocketHandler.php#L78-L88
|
228,440
|
lawoole/framework
|
src/WebSocket/WebSocketServerSocketHandler.php
|
WebSocketServerSocketHandler.acceptConnection
|
protected function acceptConnection($server, $request, $httpRequest, $handler)
{
$id = $request->fd;
$connection = $this->createWebSocketConnection($server, $id);
$this->fireOpenEvent($handler, $connection, $httpRequest);
$this->connections[$id] = compact('connection', 'handler');
}
|
php
|
protected function acceptConnection($server, $request, $httpRequest, $handler)
{
$id = $request->fd;
$connection = $this->createWebSocketConnection($server, $id);
$this->fireOpenEvent($handler, $connection, $httpRequest);
$this->connections[$id] = compact('connection', 'handler');
}
|
[
"protected",
"function",
"acceptConnection",
"(",
"$",
"server",
",",
"$",
"request",
",",
"$",
"httpRequest",
",",
"$",
"handler",
")",
"{",
"$",
"id",
"=",
"$",
"request",
"->",
"fd",
";",
"$",
"connection",
"=",
"$",
"this",
"->",
"createWebSocketConnection",
"(",
"$",
"server",
",",
"$",
"id",
")",
";",
"$",
"this",
"->",
"fireOpenEvent",
"(",
"$",
"handler",
",",
"$",
"connection",
",",
"$",
"httpRequest",
")",
";",
"$",
"this",
"->",
"connections",
"[",
"$",
"id",
"]",
"=",
"compact",
"(",
"'connection'",
",",
"'handler'",
")",
";",
"}"
] |
Accept the web socket connection.
@param \Lawoole\Server\Server $server
@param \Swoole\Http\Request $request
@param \Illuminate\Http\Request $httpRequest
@param \Lawoole\Contracts\WebSocket\WebSocketHandler $handler
|
[
"Accept",
"the",
"web",
"socket",
"connection",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/WebSocket/WebSocketServerSocketHandler.php#L112-L121
|
228,441
|
lawoole/framework
|
src/WebSocket/WebSocketServerSocketHandler.php
|
WebSocketServerSocketHandler.fireMessageEvent
|
protected function fireMessageEvent($handler, $connection, $frame)
{
$isBinary = $frame->opcode == WEBSOCKET_OPCODE_BINARY;
$this->fireWebSocketHandler($handler, 'onMessage', $connection, $isBinary, $frame->data);
}
|
php
|
protected function fireMessageEvent($handler, $connection, $frame)
{
$isBinary = $frame->opcode == WEBSOCKET_OPCODE_BINARY;
$this->fireWebSocketHandler($handler, 'onMessage', $connection, $isBinary, $frame->data);
}
|
[
"protected",
"function",
"fireMessageEvent",
"(",
"$",
"handler",
",",
"$",
"connection",
",",
"$",
"frame",
")",
"{",
"$",
"isBinary",
"=",
"$",
"frame",
"->",
"opcode",
"==",
"WEBSOCKET_OPCODE_BINARY",
";",
"$",
"this",
"->",
"fireWebSocketHandler",
"(",
"$",
"handler",
",",
"'onMessage'",
",",
"$",
"connection",
",",
"$",
"isBinary",
",",
"$",
"frame",
"->",
"data",
")",
";",
"}"
] |
Fire the message received event.
@param \Lawoole\Contracts\WebSocket\WebSocketHandler $handler
@param \Lawoole\Contracts\WebSocket\Connection $connection
@param \Swoole\WebSocket\Frame $frame
|
[
"Fire",
"the",
"message",
"received",
"event",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/WebSocket/WebSocketServerSocketHandler.php#L155-L160
|
228,442
|
lawoole/framework
|
src/WebSocket/WebSocketServerSocketHandler.php
|
WebSocketServerSocketHandler.fireWebSocketHandler
|
protected function fireWebSocketHandler($handler, $method, ...$arguments)
{
if ($handler == null) {
return;
}
try {
call_user_func([$handler, $method], ...$arguments);
} catch (Exception $e) {
$this->reportException($e);
} catch (Throwable $e) {
$this->reportException(new FatalThrowableError($e));
}
}
|
php
|
protected function fireWebSocketHandler($handler, $method, ...$arguments)
{
if ($handler == null) {
return;
}
try {
call_user_func([$handler, $method], ...$arguments);
} catch (Exception $e) {
$this->reportException($e);
} catch (Throwable $e) {
$this->reportException(new FatalThrowableError($e));
}
}
|
[
"protected",
"function",
"fireWebSocketHandler",
"(",
"$",
"handler",
",",
"$",
"method",
",",
"...",
"$",
"arguments",
")",
"{",
"if",
"(",
"$",
"handler",
"==",
"null",
")",
"{",
"return",
";",
"}",
"try",
"{",
"call_user_func",
"(",
"[",
"$",
"handler",
",",
"$",
"method",
"]",
",",
"...",
"$",
"arguments",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"reportException",
"(",
"$",
"e",
")",
";",
"}",
"catch",
"(",
"Throwable",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"reportException",
"(",
"new",
"FatalThrowableError",
"(",
"$",
"e",
")",
")",
";",
"}",
"}"
] |
Send the event to the handler.
@param \Lawoole\Contracts\WebSocket\WebSocketHandler $handler
@param string $method
@param array $arguments
|
[
"Send",
"the",
"event",
"to",
"the",
"handler",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/WebSocket/WebSocketServerSocketHandler.php#L180-L193
|
228,443
|
antaresproject/core
|
src/components/html/src/Form/BootstrapThreePresenter.php
|
BootstrapThreePresenter.file
|
public function file(FieldContract $field)
{
$attributes = $this->html->decorate($field->get('attributes'), ['class' => 'form-control']);
return $this->form->file($field->get('name'), $attributes);
}
|
php
|
public function file(FieldContract $field)
{
$attributes = $this->html->decorate($field->get('attributes'), ['class' => 'form-control']);
return $this->form->file($field->get('name'), $attributes);
}
|
[
"public",
"function",
"file",
"(",
"FieldContract",
"$",
"field",
")",
"{",
"$",
"attributes",
"=",
"$",
"this",
"->",
"html",
"->",
"decorate",
"(",
"$",
"field",
"->",
"get",
"(",
"'attributes'",
")",
",",
"[",
"'class'",
"=>",
"'form-control'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"form",
"->",
"file",
"(",
"$",
"field",
"->",
"get",
"(",
"'name'",
")",
",",
"$",
"attributes",
")",
";",
"}"
] |
File template.
@param \Antares\Contracts\Html\Form\Field $field
@return string
|
[
"File",
"template",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/BootstrapThreePresenter.php#L118-L122
|
228,444
|
antaresproject/core
|
src/components/html/src/Form/BootstrapThreePresenter.php
|
BootstrapThreePresenter.input
|
public function input(FieldContract $field)
{
$attributes = $field->get('attributes');
if (isset($attributes['field'])) {
unset($attributes['field']);
}
$decoratedAttributes = $this->html->decorate($attributes);
return $this->form->input($field->get('type'), $field->get('name'), $field->get('value'), $decoratedAttributes);
}
|
php
|
public function input(FieldContract $field)
{
$attributes = $field->get('attributes');
if (isset($attributes['field'])) {
unset($attributes['field']);
}
$decoratedAttributes = $this->html->decorate($attributes);
return $this->form->input($field->get('type'), $field->get('name'), $field->get('value'), $decoratedAttributes);
}
|
[
"public",
"function",
"input",
"(",
"FieldContract",
"$",
"field",
")",
"{",
"$",
"attributes",
"=",
"$",
"field",
"->",
"get",
"(",
"'attributes'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"'field'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"attributes",
"[",
"'field'",
"]",
")",
";",
"}",
"$",
"decoratedAttributes",
"=",
"$",
"this",
"->",
"html",
"->",
"decorate",
"(",
"$",
"attributes",
")",
";",
"return",
"$",
"this",
"->",
"form",
"->",
"input",
"(",
"$",
"field",
"->",
"get",
"(",
"'type'",
")",
",",
"$",
"field",
"->",
"get",
"(",
"'name'",
")",
",",
"$",
"field",
"->",
"get",
"(",
"'value'",
")",
",",
"$",
"decoratedAttributes",
")",
";",
"}"
] |
Input template.
@param \Antares\Contracts\Html\Form\Field $field
@return string
|
[
"Input",
"template",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/BootstrapThreePresenter.php#L131-L143
|
228,445
|
antaresproject/core
|
src/foundation/src/Http/Presenters/DropzoneTrait.php
|
DropzoneTrait.getValidationRules
|
protected function getValidationRules($inputName, $validator)
{
$validator->onUpload();
$rules = $validator->getValidationRules();
$attributes = [];
foreach ($rules[$inputName] as $rule) {
if (strpos($rule, ':') !== FALSE) {
list($rulename, $value) = explode(':', $rule);
switch ($rulename) {
case 'mimes':
$separator = ',';
$value = implode($separator, array_map(function($item) {
return '.' . $item;
}, explode($separator, $value)));
$attributes['acceptedFiles'] = $value;
break;
case 'max':
$attributes['maxFilesize'] = $value / 1024;
break;
case 'min':
$attributes['minFilesize'] = $value / 1024;
break;
}
}
}
return $attributes;
}
|
php
|
protected function getValidationRules($inputName, $validator)
{
$validator->onUpload();
$rules = $validator->getValidationRules();
$attributes = [];
foreach ($rules[$inputName] as $rule) {
if (strpos($rule, ':') !== FALSE) {
list($rulename, $value) = explode(':', $rule);
switch ($rulename) {
case 'mimes':
$separator = ',';
$value = implode($separator, array_map(function($item) {
return '.' . $item;
}, explode($separator, $value)));
$attributes['acceptedFiles'] = $value;
break;
case 'max':
$attributes['maxFilesize'] = $value / 1024;
break;
case 'min':
$attributes['minFilesize'] = $value / 1024;
break;
}
}
}
return $attributes;
}
|
[
"protected",
"function",
"getValidationRules",
"(",
"$",
"inputName",
",",
"$",
"validator",
")",
"{",
"$",
"validator",
"->",
"onUpload",
"(",
")",
";",
"$",
"rules",
"=",
"$",
"validator",
"->",
"getValidationRules",
"(",
")",
";",
"$",
"attributes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"rules",
"[",
"$",
"inputName",
"]",
"as",
"$",
"rule",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"rule",
",",
"':'",
")",
"!==",
"FALSE",
")",
"{",
"list",
"(",
"$",
"rulename",
",",
"$",
"value",
")",
"=",
"explode",
"(",
"':'",
",",
"$",
"rule",
")",
";",
"switch",
"(",
"$",
"rulename",
")",
"{",
"case",
"'mimes'",
":",
"$",
"separator",
"=",
"','",
";",
"$",
"value",
"=",
"implode",
"(",
"$",
"separator",
",",
"array_map",
"(",
"function",
"(",
"$",
"item",
")",
"{",
"return",
"'.'",
".",
"$",
"item",
";",
"}",
",",
"explode",
"(",
"$",
"separator",
",",
"$",
"value",
")",
")",
")",
";",
"$",
"attributes",
"[",
"'acceptedFiles'",
"]",
"=",
"$",
"value",
";",
"break",
";",
"case",
"'max'",
":",
"$",
"attributes",
"[",
"'maxFilesize'",
"]",
"=",
"$",
"value",
"/",
"1024",
";",
"break",
";",
"case",
"'min'",
":",
"$",
"attributes",
"[",
"'minFilesize'",
"]",
"=",
"$",
"value",
"/",
"1024",
";",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"attributes",
";",
"}"
] |
getting dropzone validation rules from validator
@param \Illuminate\Support\Facades\Validator $validator
@return array
|
[
"getting",
"dropzone",
"validation",
"rules",
"from",
"validator"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Presenters/DropzoneTrait.php#L35-L61
|
228,446
|
expressodev/laravel-codeigniter-db
|
src/CodeIgniterConnection.php
|
CodeIgniterConnection.getDefaultQueryGrammar
|
protected function getDefaultQueryGrammar()
{
$driver = $this->ci->db->dbdriver;
switch ($driver) {
case 'mysql':
case 'mysqli':
if (class_exists('\Illuminate\Database\Query\Grammars\MySqlGrammar')) {
return $this->withTablePrefix(new \Illuminate\Database\Query\Grammars\MySqlGrammar);
}
return $this->withTablePrefix(new \Illuminate\Database\Schema\Grammars\MySqlGrammar);
}
throw new \InvalidArgumentException("Unknown CI database driver '$driver'");
}
|
php
|
protected function getDefaultQueryGrammar()
{
$driver = $this->ci->db->dbdriver;
switch ($driver) {
case 'mysql':
case 'mysqli':
if (class_exists('\Illuminate\Database\Query\Grammars\MySqlGrammar')) {
return $this->withTablePrefix(new \Illuminate\Database\Query\Grammars\MySqlGrammar);
}
return $this->withTablePrefix(new \Illuminate\Database\Schema\Grammars\MySqlGrammar);
}
throw new \InvalidArgumentException("Unknown CI database driver '$driver'");
}
|
[
"protected",
"function",
"getDefaultQueryGrammar",
"(",
")",
"{",
"$",
"driver",
"=",
"$",
"this",
"->",
"ci",
"->",
"db",
"->",
"dbdriver",
";",
"switch",
"(",
"$",
"driver",
")",
"{",
"case",
"'mysql'",
":",
"case",
"'mysqli'",
":",
"if",
"(",
"class_exists",
"(",
"'\\Illuminate\\Database\\Query\\Grammars\\MySqlGrammar'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"withTablePrefix",
"(",
"new",
"\\",
"Illuminate",
"\\",
"Database",
"\\",
"Query",
"\\",
"Grammars",
"\\",
"MySqlGrammar",
")",
";",
"}",
"return",
"$",
"this",
"->",
"withTablePrefix",
"(",
"new",
"\\",
"Illuminate",
"\\",
"Database",
"\\",
"Schema",
"\\",
"Grammars",
"\\",
"MySqlGrammar",
")",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Unknown CI database driver '$driver'\"",
")",
";",
"}"
] |
Get the default query grammar instance.
@return \Illuminate\Database\Grammar
|
[
"Get",
"the",
"default",
"query",
"grammar",
"instance",
"."
] |
c97a2fa1e93431df7abbd452128377af84cc9627
|
https://github.com/expressodev/laravel-codeigniter-db/blob/c97a2fa1e93431df7abbd452128377af84cc9627/src/CodeIgniterConnection.php#L31-L45
|
228,447
|
expressodev/laravel-codeigniter-db
|
src/CodeIgniterConnection.php
|
CodeIgniterConnection.getDefaultSchemaGrammar
|
protected function getDefaultSchemaGrammar()
{
$driver = $this->ci->db->dbdriver;
switch ($driver) {
case 'mysql':
case 'mysqli':
return $this->withTablePrefix(new \Illuminate\Database\Schema\Grammars\MySqlGrammar);
}
throw new \InvalidArgumentException("Unsupported CodeIgniter database driver '$driver'");
}
|
php
|
protected function getDefaultSchemaGrammar()
{
$driver = $this->ci->db->dbdriver;
switch ($driver) {
case 'mysql':
case 'mysqli':
return $this->withTablePrefix(new \Illuminate\Database\Schema\Grammars\MySqlGrammar);
}
throw new \InvalidArgumentException("Unsupported CodeIgniter database driver '$driver'");
}
|
[
"protected",
"function",
"getDefaultSchemaGrammar",
"(",
")",
"{",
"$",
"driver",
"=",
"$",
"this",
"->",
"ci",
"->",
"db",
"->",
"dbdriver",
";",
"switch",
"(",
"$",
"driver",
")",
"{",
"case",
"'mysql'",
":",
"case",
"'mysqli'",
":",
"return",
"$",
"this",
"->",
"withTablePrefix",
"(",
"new",
"\\",
"Illuminate",
"\\",
"Database",
"\\",
"Schema",
"\\",
"Grammars",
"\\",
"MySqlGrammar",
")",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Unsupported CodeIgniter database driver '$driver'\"",
")",
";",
"}"
] |
Get the default schema grammar instance.
@return \Illuminate\Database\Grammar
|
[
"Get",
"the",
"default",
"schema",
"grammar",
"instance",
"."
] |
c97a2fa1e93431df7abbd452128377af84cc9627
|
https://github.com/expressodev/laravel-codeigniter-db/blob/c97a2fa1e93431df7abbd452128377af84cc9627/src/CodeIgniterConnection.php#L52-L62
|
228,448
|
expressodev/laravel-codeigniter-db
|
src/CodeIgniterConnection.php
|
CodeIgniterConnection.fetchResult
|
public function fetchResult($result)
{
$fetchMode = $this->fetchMode;
switch ($fetchMode) {
case PDO::FETCH_ASSOC:
return $result->result_array();
case PDO::FETCH_OBJ:
return $result->result();
}
throw new \BadMethodCallException("Unsupported fetch mode '$fetchMode'.");
}
|
php
|
public function fetchResult($result)
{
$fetchMode = $this->fetchMode;
switch ($fetchMode) {
case PDO::FETCH_ASSOC:
return $result->result_array();
case PDO::FETCH_OBJ:
return $result->result();
}
throw new \BadMethodCallException("Unsupported fetch mode '$fetchMode'.");
}
|
[
"public",
"function",
"fetchResult",
"(",
"$",
"result",
")",
"{",
"$",
"fetchMode",
"=",
"$",
"this",
"->",
"fetchMode",
";",
"switch",
"(",
"$",
"fetchMode",
")",
"{",
"case",
"PDO",
"::",
"FETCH_ASSOC",
":",
"return",
"$",
"result",
"->",
"result_array",
"(",
")",
";",
"case",
"PDO",
"::",
"FETCH_OBJ",
":",
"return",
"$",
"result",
"->",
"result",
"(",
")",
";",
"}",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"\"Unsupported fetch mode '$fetchMode'.\"",
")",
";",
"}"
] |
Fetch a CodeIgniter result set as an array or object, emulating current PDO fetch mode
@param object $result
@return mixed
|
[
"Fetch",
"a",
"CodeIgniter",
"result",
"set",
"as",
"an",
"array",
"or",
"object",
"emulating",
"current",
"PDO",
"fetch",
"mode"
] |
c97a2fa1e93431df7abbd452128377af84cc9627
|
https://github.com/expressodev/laravel-codeigniter-db/blob/c97a2fa1e93431df7abbd452128377af84cc9627/src/CodeIgniterConnection.php#L123-L134
|
228,449
|
antaresproject/core
|
src/utils/helpers/ResponseHelper.php
|
ResponseHelper.make
|
public static function make(string $type, string $message, string $url = null) : ResponseHelper {
return new static($type, $message, $url);
}
|
php
|
public static function make(string $type, string $message, string $url = null) : ResponseHelper {
return new static($type, $message, $url);
}
|
[
"public",
"static",
"function",
"make",
"(",
"string",
"$",
"type",
",",
"string",
"$",
"message",
",",
"string",
"$",
"url",
"=",
"null",
")",
":",
"ResponseHelper",
"{",
"return",
"new",
"static",
"(",
"$",
"type",
",",
"$",
"message",
",",
"$",
"url",
")",
";",
"}"
] |
Creates a response.
@param string $type
@param string $message
@param string $url (optional)
@return ResponseHelper
|
[
"Creates",
"a",
"response",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/helpers/ResponseHelper.php#L53-L55
|
228,450
|
antaresproject/core
|
src/utils/helpers/ResponseHelper.php
|
ResponseHelper.notify
|
public function notify() : ResponseHelper {
$this->notified = true;
app('antares.messages')->add($this->type, $this->message);
return $this;
}
|
php
|
public function notify() : ResponseHelper {
$this->notified = true;
app('antares.messages')->add($this->type, $this->message);
return $this;
}
|
[
"public",
"function",
"notify",
"(",
")",
":",
"ResponseHelper",
"{",
"$",
"this",
"->",
"notified",
"=",
"true",
";",
"app",
"(",
"'antares.messages'",
")",
"->",
"add",
"(",
"$",
"this",
"->",
"type",
",",
"$",
"this",
"->",
"message",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Send the message to the session flash.
@return ResponseHelper
|
[
"Send",
"the",
"message",
"to",
"the",
"session",
"flash",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/helpers/ResponseHelper.php#L138-L144
|
228,451
|
antaresproject/core
|
src/utils/helpers/ResponseHelper.php
|
ResponseHelper.redirect
|
public function redirect() : RedirectResponse {
if( ! $this->notified) {
$this->notify();
}
$url = $this->url ?: app(UrlGenerator::class)->previous();
return response()->redirectTo($url);
}
|
php
|
public function redirect() : RedirectResponse {
if( ! $this->notified) {
$this->notify();
}
$url = $this->url ?: app(UrlGenerator::class)->previous();
return response()->redirectTo($url);
}
|
[
"public",
"function",
"redirect",
"(",
")",
":",
"RedirectResponse",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"notified",
")",
"{",
"$",
"this",
"->",
"notify",
"(",
")",
";",
"}",
"$",
"url",
"=",
"$",
"this",
"->",
"url",
"?",
":",
"app",
"(",
"UrlGenerator",
"::",
"class",
")",
"->",
"previous",
"(",
")",
";",
"return",
"response",
"(",
")",
"->",
"redirectTo",
"(",
"$",
"url",
")",
";",
"}"
] |
Returns redirect response with notification.
@return RedirectResponse
|
[
"Returns",
"redirect",
"response",
"with",
"notification",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/helpers/ResponseHelper.php#L151-L159
|
228,452
|
antaresproject/core
|
src/utils/helpers/ResponseHelper.php
|
ResponseHelper.resolve
|
public function resolve(Request $request) : Response {
if($request->expectsJson()) {
return $this->json();
}
return $this->redirect();
}
|
php
|
public function resolve(Request $request) : Response {
if($request->expectsJson()) {
return $this->json();
}
return $this->redirect();
}
|
[
"public",
"function",
"resolve",
"(",
"Request",
"$",
"request",
")",
":",
"Response",
"{",
"if",
"(",
"$",
"request",
"->",
"expectsJson",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"json",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"redirect",
"(",
")",
";",
"}"
] |
Returns dedicated response based on the given request.
@param Request $request
@return Response
|
[
"Returns",
"dedicated",
"response",
"based",
"on",
"the",
"given",
"request",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/helpers/ResponseHelper.php#L167-L173
|
228,453
|
antaresproject/core
|
src/components/area/src/AreaManager.php
|
AreaManager.hasAreaInUri
|
public function hasAreaInUri(): bool
{
$segment = $this->request->segment(1);
$area = $segment ? $this->getById($segment) : null;
return !!$area;
}
|
php
|
public function hasAreaInUri(): bool
{
$segment = $this->request->segment(1);
$area = $segment ? $this->getById($segment) : null;
return !!$area;
}
|
[
"public",
"function",
"hasAreaInUri",
"(",
")",
":",
"bool",
"{",
"$",
"segment",
"=",
"$",
"this",
"->",
"request",
"->",
"segment",
"(",
"1",
")",
";",
"$",
"area",
"=",
"$",
"segment",
"?",
"$",
"this",
"->",
"getById",
"(",
"$",
"segment",
")",
":",
"null",
";",
"return",
"!",
"!",
"$",
"area",
";",
"}"
] |
Checks if the route has area.
@return bool
|
[
"Checks",
"if",
"the",
"route",
"has",
"area",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/area/src/AreaManager.php#L133-L139
|
228,454
|
antaresproject/core
|
src/components/area/src/AreaManager.php
|
AreaManager.getCurrentArea
|
public function getCurrentArea(): AreaContract
{
$segment = $this->request->segment(1);
$area = $segment ? $this->getById($segment) : null;
if (!$area && $this->auth->check()) {
$user = $this->auth->user();
$areas = $user->getArea();
if (is_array($areas)) {
$area = $this->areas->getById(reset($areas));
} else {
$area = $this->areas->getById($areas);
}
}
return $area ?: $this->getDefault();
}
|
php
|
public function getCurrentArea(): AreaContract
{
$segment = $this->request->segment(1);
$area = $segment ? $this->getById($segment) : null;
if (!$area && $this->auth->check()) {
$user = $this->auth->user();
$areas = $user->getArea();
if (is_array($areas)) {
$area = $this->areas->getById(reset($areas));
} else {
$area = $this->areas->getById($areas);
}
}
return $area ?: $this->getDefault();
}
|
[
"public",
"function",
"getCurrentArea",
"(",
")",
":",
"AreaContract",
"{",
"$",
"segment",
"=",
"$",
"this",
"->",
"request",
"->",
"segment",
"(",
"1",
")",
";",
"$",
"area",
"=",
"$",
"segment",
"?",
"$",
"this",
"->",
"getById",
"(",
"$",
"segment",
")",
":",
"null",
";",
"if",
"(",
"!",
"$",
"area",
"&&",
"$",
"this",
"->",
"auth",
"->",
"check",
"(",
")",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
";",
"$",
"areas",
"=",
"$",
"user",
"->",
"getArea",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"areas",
")",
")",
"{",
"$",
"area",
"=",
"$",
"this",
"->",
"areas",
"->",
"getById",
"(",
"reset",
"(",
"$",
"areas",
")",
")",
";",
"}",
"else",
"{",
"$",
"area",
"=",
"$",
"this",
"->",
"areas",
"->",
"getById",
"(",
"$",
"areas",
")",
";",
"}",
"}",
"return",
"$",
"area",
"?",
":",
"$",
"this",
"->",
"getDefault",
"(",
")",
";",
"}"
] |
Gets an area object based on the current authentication and URI.
@return AreaContract
|
[
"Gets",
"an",
"area",
"object",
"based",
"on",
"the",
"current",
"authentication",
"and",
"URI",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/area/src/AreaManager.php#L146-L163
|
228,455
|
antaresproject/core
|
src/components/area/src/AreaManager.php
|
AreaManager.getFrontendAreas
|
public function getFrontendAreas(): AreasCollection
{
$areas = (array) Arr::get($this->config, 'routes.frontend', self::$fallbackFrontendRoutes);
$collection = new AreasCollection();
foreach ($areas as $areaId) {
$area = $this->areas->getById($areaId);
if ($area) {
$collection->add($area);
}
}
return $collection;
}
|
php
|
public function getFrontendAreas(): AreasCollection
{
$areas = (array) Arr::get($this->config, 'routes.frontend', self::$fallbackFrontendRoutes);
$collection = new AreasCollection();
foreach ($areas as $areaId) {
$area = $this->areas->getById($areaId);
if ($area) {
$collection->add($area);
}
}
return $collection;
}
|
[
"public",
"function",
"getFrontendAreas",
"(",
")",
":",
"AreasCollection",
"{",
"$",
"areas",
"=",
"(",
"array",
")",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"config",
",",
"'routes.frontend'",
",",
"self",
"::",
"$",
"fallbackFrontendRoutes",
")",
";",
"$",
"collection",
"=",
"new",
"AreasCollection",
"(",
")",
";",
"foreach",
"(",
"$",
"areas",
"as",
"$",
"areaId",
")",
"{",
"$",
"area",
"=",
"$",
"this",
"->",
"areas",
"->",
"getById",
"(",
"$",
"areaId",
")",
";",
"if",
"(",
"$",
"area",
")",
"{",
"$",
"collection",
"->",
"add",
"(",
"$",
"area",
")",
";",
"}",
"}",
"return",
"$",
"collection",
";",
"}"
] |
Returns collection of frontend areas.
@return AreasCollection
|
[
"Returns",
"collection",
"of",
"frontend",
"areas",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/area/src/AreaManager.php#L170-L183
|
228,456
|
antaresproject/core
|
src/components/area/src/AreaManager.php
|
AreaManager.getBackendAreas
|
public function getBackendAreas(): AreasCollection
{
$areas = (array) Arr::get($this->config, 'routes.backend', self::$fallbackBackendRoutes);
$collection = new AreasCollection();
foreach ($areas as $areaId) {
$area = $this->areas->getById($areaId);
if ($area) {
$collection->add($area);
}
}
return $collection;
}
|
php
|
public function getBackendAreas(): AreasCollection
{
$areas = (array) Arr::get($this->config, 'routes.backend', self::$fallbackBackendRoutes);
$collection = new AreasCollection();
foreach ($areas as $areaId) {
$area = $this->areas->getById($areaId);
if ($area) {
$collection->add($area);
}
}
return $collection;
}
|
[
"public",
"function",
"getBackendAreas",
"(",
")",
":",
"AreasCollection",
"{",
"$",
"areas",
"=",
"(",
"array",
")",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"config",
",",
"'routes.backend'",
",",
"self",
"::",
"$",
"fallbackBackendRoutes",
")",
";",
"$",
"collection",
"=",
"new",
"AreasCollection",
"(",
")",
";",
"foreach",
"(",
"$",
"areas",
"as",
"$",
"areaId",
")",
"{",
"$",
"area",
"=",
"$",
"this",
"->",
"areas",
"->",
"getById",
"(",
"$",
"areaId",
")",
";",
"if",
"(",
"$",
"area",
")",
"{",
"$",
"collection",
"->",
"add",
"(",
"$",
"area",
")",
";",
"}",
"}",
"return",
"$",
"collection",
";",
"}"
] |
Returns collection of backend areas.
@return AreasCollection
|
[
"Returns",
"collection",
"of",
"backend",
"areas",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/area/src/AreaManager.php#L190-L204
|
228,457
|
antaresproject/core
|
src/components/area/src/AreaManager.php
|
AreaManager.getByIdOrDefault
|
public function getByIdOrDefault(string $id): AreaContract
{
$area = $this->getById($id);
return $area ?: $this->getDefault();
}
|
php
|
public function getByIdOrDefault(string $id): AreaContract
{
$area = $this->getById($id);
return $area ?: $this->getDefault();
}
|
[
"public",
"function",
"getByIdOrDefault",
"(",
"string",
"$",
"id",
")",
":",
"AreaContract",
"{",
"$",
"area",
"=",
"$",
"this",
"->",
"getById",
"(",
"$",
"id",
")",
";",
"return",
"$",
"area",
"?",
":",
"$",
"this",
"->",
"getDefault",
"(",
")",
";",
"}"
] |
Returns an area object based on ID. Default area returns if not found the desired one.
@param string $id
@return AreaContract
|
[
"Returns",
"an",
"area",
"object",
"based",
"on",
"ID",
".",
"Default",
"area",
"returns",
"if",
"not",
"found",
"the",
"desired",
"one",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/area/src/AreaManager.php#L253-L258
|
228,458
|
gggeek/ggwebservices
|
classes/ggwebservicesresponse.php
|
ggWebservicesResponse.decodeStreamCommon
|
protected function decodeStreamCommon( $request, $stream, $headers=false, $cookies=array(), $statuscode="200" )
{
$this->Cookies = $cookies;
$this->Headers = $headers;
$this->StatusCode = $statuscode;
$this->ContentType = '';
$this->Charset = '';
if ( isset( $headers['content-type'] ) )
{
list ( $this->ContentType, $this->Charset ) = $this->parseContentTypeHeader( $headers['content-type'] );
}
$this->IsFault = false;
$this->FaultString = false;
$this->FaultCode = false;
}
|
php
|
protected function decodeStreamCommon( $request, $stream, $headers=false, $cookies=array(), $statuscode="200" )
{
$this->Cookies = $cookies;
$this->Headers = $headers;
$this->StatusCode = $statuscode;
$this->ContentType = '';
$this->Charset = '';
if ( isset( $headers['content-type'] ) )
{
list ( $this->ContentType, $this->Charset ) = $this->parseContentTypeHeader( $headers['content-type'] );
}
$this->IsFault = false;
$this->FaultString = false;
$this->FaultCode = false;
}
|
[
"protected",
"function",
"decodeStreamCommon",
"(",
"$",
"request",
",",
"$",
"stream",
",",
"$",
"headers",
"=",
"false",
",",
"$",
"cookies",
"=",
"array",
"(",
")",
",",
"$",
"statuscode",
"=",
"\"200\"",
")",
"{",
"$",
"this",
"->",
"Cookies",
"=",
"$",
"cookies",
";",
"$",
"this",
"->",
"Headers",
"=",
"$",
"headers",
";",
"$",
"this",
"->",
"StatusCode",
"=",
"$",
"statuscode",
";",
"$",
"this",
"->",
"ContentType",
"=",
"''",
";",
"$",
"this",
"->",
"Charset",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"headers",
"[",
"'content-type'",
"]",
")",
")",
"{",
"list",
"(",
"$",
"this",
"->",
"ContentType",
",",
"$",
"this",
"->",
"Charset",
")",
"=",
"$",
"this",
"->",
"parseContentTypeHeader",
"(",
"$",
"headers",
"[",
"'content-type'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"IsFault",
"=",
"false",
";",
"$",
"this",
"->",
"FaultString",
"=",
"false",
";",
"$",
"this",
"->",
"FaultCode",
"=",
"false",
";",
"}"
] |
Sets internal members from http data, resets response to be not faulty.
We make this code available here instead of in decodeStream, to force child classes them to write their own handlers
@param $request
@param $stream
@param bool $headers
@param array $cookies
@param string $statuscode
|
[
"Sets",
"internal",
"members",
"from",
"http",
"data",
"resets",
"response",
"to",
"be",
"not",
"faulty",
".",
"We",
"make",
"this",
"code",
"available",
"here",
"instead",
"of",
"in",
"decodeStream",
"to",
"force",
"child",
"classes",
"them",
"to",
"write",
"their",
"own",
"handlers"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggwebservicesresponse.php#L198-L213
|
228,459
|
antaresproject/core
|
src/components/auth/src/Authorization/Fluent.php
|
Fluent.exist
|
public function exist($id)
{
is_string($id) && $id = $this->getSlugFromName($id);
return isset($this->items[$id]);
}
|
php
|
public function exist($id)
{
is_string($id) && $id = $this->getSlugFromName($id);
return isset($this->items[$id]);
}
|
[
"public",
"function",
"exist",
"(",
"$",
"id",
")",
"{",
"is_string",
"(",
"$",
"id",
")",
"&&",
"$",
"id",
"=",
"$",
"this",
"->",
"getSlugFromName",
"(",
"$",
"id",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
")",
";",
"}"
] |
Check if an id is set in the collection.
@param int $id
@return bool
|
[
"Check",
"if",
"an",
"id",
"is",
"set",
"in",
"the",
"collection",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/auth/src/Authorization/Fluent.php#L172-L177
|
228,460
|
antaresproject/core
|
src/components/auth/src/Authorization/Fluent.php
|
Fluent.remove
|
public function remove($key)
{
if (is_null($key)) {
throw new InvalidArgumentException("Can't add NULL {$this->name}.");
}
if (!is_null($id = $this->search($key))) {
unset($this->items[$id]);
return true;
}
return false;
}
|
php
|
public function remove($key)
{
if (is_null($key)) {
throw new InvalidArgumentException("Can't add NULL {$this->name}.");
}
if (!is_null($id = $this->search($key))) {
unset($this->items[$id]);
return true;
}
return false;
}
|
[
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Can't add NULL {$this->name}.\"",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"id",
"=",
"$",
"this",
"->",
"search",
"(",
"$",
"key",
")",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Remove a key from collection.
@param string $key
@return bool
@throws \InvalidArgumentException
|
[
"Remove",
"a",
"key",
"from",
"collection",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/auth/src/Authorization/Fluent.php#L249-L261
|
228,461
|
antaresproject/core
|
src/components/auth/src/Authorization/Fluent.php
|
Fluent.getSlugFromName
|
protected function getSlugFromName($name)
{
if( array_key_exists($name, self::$sluggedNames) ) {
return self::$sluggedNames[$name];
}
return self::$sluggedNames[$name] = trim(Str::slug($name, '-'));
}
|
php
|
protected function getSlugFromName($name)
{
if( array_key_exists($name, self::$sluggedNames) ) {
return self::$sluggedNames[$name];
}
return self::$sluggedNames[$name] = trim(Str::slug($name, '-'));
}
|
[
"protected",
"function",
"getSlugFromName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"self",
"::",
"$",
"sluggedNames",
")",
")",
"{",
"return",
"self",
"::",
"$",
"sluggedNames",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"self",
"::",
"$",
"sluggedNames",
"[",
"$",
"name",
"]",
"=",
"trim",
"(",
"Str",
"::",
"slug",
"(",
"$",
"name",
",",
"'-'",
")",
")",
";",
"}"
] |
Get slug name.
@param string $name
@return string
|
[
"Get",
"slug",
"name",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/auth/src/Authorization/Fluent.php#L309-L316
|
228,462
|
antaresproject/core
|
src/ui/components/templates/src/Model/Components.php
|
Components.save
|
public function save(array $options = array())
{
try {
DB::transaction(function() use($options) {
$this->fill($options);
parent::save();
});
return true;
} catch (Exception $e) {
Log::emergency($e);
return false;
}
}
|
php
|
public function save(array $options = array())
{
try {
DB::transaction(function() use($options) {
$this->fill($options);
parent::save();
});
return true;
} catch (Exception $e) {
Log::emergency($e);
return false;
}
}
|
[
"public",
"function",
"save",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"try",
"{",
"DB",
"::",
"transaction",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"fill",
"(",
"$",
"options",
")",
";",
"parent",
"::",
"save",
"(",
")",
";",
"}",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Log",
"::",
"emergency",
"(",
"$",
"e",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
try to save widget
@param array $options
@return boolean
|
[
"try",
"to",
"save",
"widget"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Model/Components.php#L78-L92
|
228,463
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/WordUtils.php
|
WordUtils.abbreviate
|
public static function abbreviate(
$inputString,
$lowerLimit,
$upperLimit = -1,
$append = StringUtils::EMPTY_STR
) {
if (true === StringUtils::isEmpty($inputString)) {
return $inputString;
}
$length = StringUtils::length($inputString);
// if the $lowerLimit value is greater than the length of the string,
// set to the length of the string
if ($lowerLimit > $length) {
$lowerLimit = $length;
}
// if the $upperLimit value is -1 (i.e. no limit) or is greater than the
// length of the string, set to the length of the string
if ((-1 === $upperLimit) || $upperLimit > $length) {
$upperLimit = $length;
}
// if $upperLimit is less than $iLower, raise it to lower
if ($upperLimit < $lowerLimit) {
$upperLimit = $lowerLimit;
}
$index = StringUtils::indexOf($inputString, ' ', $lowerLimit);
if (-1 === $index) {
$result = StringUtils::substring($inputString, 0, $upperLimit);
if ($upperLimit !== $length) {
// only if abbreviation has occured do we append the $append
// value
$result .= $append;
}
} elseif ($index > $upperLimit) {
$result = StringUtils::substring($inputString, 0, $upperLimit);
$result .= $append;
} else {
$result = StringUtils::substring($inputString, 0, $index);
$result .= $append;
}
return $result;
}
|
php
|
public static function abbreviate(
$inputString,
$lowerLimit,
$upperLimit = -1,
$append = StringUtils::EMPTY_STR
) {
if (true === StringUtils::isEmpty($inputString)) {
return $inputString;
}
$length = StringUtils::length($inputString);
// if the $lowerLimit value is greater than the length of the string,
// set to the length of the string
if ($lowerLimit > $length) {
$lowerLimit = $length;
}
// if the $upperLimit value is -1 (i.e. no limit) or is greater than the
// length of the string, set to the length of the string
if ((-1 === $upperLimit) || $upperLimit > $length) {
$upperLimit = $length;
}
// if $upperLimit is less than $iLower, raise it to lower
if ($upperLimit < $lowerLimit) {
$upperLimit = $lowerLimit;
}
$index = StringUtils::indexOf($inputString, ' ', $lowerLimit);
if (-1 === $index) {
$result = StringUtils::substring($inputString, 0, $upperLimit);
if ($upperLimit !== $length) {
// only if abbreviation has occured do we append the $append
// value
$result .= $append;
}
} elseif ($index > $upperLimit) {
$result = StringUtils::substring($inputString, 0, $upperLimit);
$result .= $append;
} else {
$result = StringUtils::substring($inputString, 0, $index);
$result .= $append;
}
return $result;
}
|
[
"public",
"static",
"function",
"abbreviate",
"(",
"$",
"inputString",
",",
"$",
"lowerLimit",
",",
"$",
"upperLimit",
"=",
"-",
"1",
",",
"$",
"append",
"=",
"StringUtils",
"::",
"EMPTY_STR",
")",
"{",
"if",
"(",
"true",
"===",
"StringUtils",
"::",
"isEmpty",
"(",
"$",
"inputString",
")",
")",
"{",
"return",
"$",
"inputString",
";",
"}",
"$",
"length",
"=",
"StringUtils",
"::",
"length",
"(",
"$",
"inputString",
")",
";",
"// if the $lowerLimit value is greater than the length of the string,",
"// set to the length of the string",
"if",
"(",
"$",
"lowerLimit",
">",
"$",
"length",
")",
"{",
"$",
"lowerLimit",
"=",
"$",
"length",
";",
"}",
"// if the $upperLimit value is -1 (i.e. no limit) or is greater than the",
"// length of the string, set to the length of the string",
"if",
"(",
"(",
"-",
"1",
"===",
"$",
"upperLimit",
")",
"||",
"$",
"upperLimit",
">",
"$",
"length",
")",
"{",
"$",
"upperLimit",
"=",
"$",
"length",
";",
"}",
"// if $upperLimit is less than $iLower, raise it to lower",
"if",
"(",
"$",
"upperLimit",
"<",
"$",
"lowerLimit",
")",
"{",
"$",
"upperLimit",
"=",
"$",
"lowerLimit",
";",
"}",
"$",
"index",
"=",
"StringUtils",
"::",
"indexOf",
"(",
"$",
"inputString",
",",
"' '",
",",
"$",
"lowerLimit",
")",
";",
"if",
"(",
"-",
"1",
"===",
"$",
"index",
")",
"{",
"$",
"result",
"=",
"StringUtils",
"::",
"substring",
"(",
"$",
"inputString",
",",
"0",
",",
"$",
"upperLimit",
")",
";",
"if",
"(",
"$",
"upperLimit",
"!==",
"$",
"length",
")",
"{",
"// only if abbreviation has occured do we append the $append",
"// value",
"$",
"result",
".=",
"$",
"append",
";",
"}",
"}",
"elseif",
"(",
"$",
"index",
">",
"$",
"upperLimit",
")",
"{",
"$",
"result",
"=",
"StringUtils",
"::",
"substring",
"(",
"$",
"inputString",
",",
"0",
",",
"$",
"upperLimit",
")",
";",
"$",
"result",
".=",
"$",
"append",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"StringUtils",
"::",
"substring",
"(",
"$",
"inputString",
",",
"0",
",",
"$",
"index",
")",
";",
"$",
"result",
".=",
"$",
"append",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Abbreviates a string nicely.
This method searches for the first space after the lower limit and
abbreviates the `string` there. It will also append any `string` passed
as a parameter to the end of the `string`.
The upper limit can be specified to forcibly abbreviate a `string`.
@param string $inputString The `string` to be abbreviated. If `null` is
passed, `null` is returned. If the empty `string` is passed, the empty
`string` is returned.
@param integer $lowerLimit The lower limit.
@param integer $upperLimit The upper limit; specify `-1` if no limit is
desired. If the upper limit is lower than the lower limit, it will be
adjusted to be the same as the lower limit.
@param string $append The `string` to be appended to the end of the
abbreviated `string`. This is appended ONLY if the string was indeed
abbreviated. The append does not count towards the lower or upper
limits.
@return string|null The abbreviated `string` or `null` if `null` `string`
input.
|
[
"Abbreviates",
"a",
"string",
"nicely",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/WordUtils.php#L73-L121
|
228,464
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/WordUtils.php
|
WordUtils.capitalizeFully
|
public static function capitalizeFully($inputString)
{
$inputStringLower = StringUtils::lowerCase($inputString);
$result = self::capitalize($inputStringLower);
return $result;
}
|
php
|
public static function capitalizeFully($inputString)
{
$inputStringLower = StringUtils::lowerCase($inputString);
$result = self::capitalize($inputStringLower);
return $result;
}
|
[
"public",
"static",
"function",
"capitalizeFully",
"(",
"$",
"inputString",
")",
"{",
"$",
"inputStringLower",
"=",
"StringUtils",
"::",
"lowerCase",
"(",
"$",
"inputString",
")",
";",
"$",
"result",
"=",
"self",
"::",
"capitalize",
"(",
"$",
"inputStringLower",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Converts all the whitespace separated words in a `string` into
capitalized words, that is each word is made up of a titlecase character
and then a series of lowercase characters.
A `null` input `string` returns `null`.
Capitalization uses the Unicode title case, normally equivalent to upper
case.
WordUtils::capitalizeFully(null); // null
WordUtils::capitalizeFully(''); // ''
WordUtils::capitalizeFully('i am FINE'); // 'I Am Fine'
@param string $inputString The `string` to capitalize.
@return string|null The capitalized `string` or `null` if `null` `string`
input.
|
[
"Converts",
"all",
"the",
"whitespace",
"separated",
"words",
"in",
"a",
"string",
"into",
"capitalized",
"words",
"that",
"is",
"each",
"word",
"is",
"made",
"up",
"of",
"a",
"titlecase",
"character",
"and",
"then",
"a",
"series",
"of",
"lowercase",
"characters",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/WordUtils.php#L171-L177
|
228,465
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/WordUtils.php
|
WordUtils.uncapitalize
|
public static function uncapitalize($inputString)
{
$func = function (array $matches) {
return StringUtils::lowerCase($matches[0]);
};
return \preg_replace_callback(
'~\b\w~',
$func,
$inputString
);
}
|
php
|
public static function uncapitalize($inputString)
{
$func = function (array $matches) {
return StringUtils::lowerCase($matches[0]);
};
return \preg_replace_callback(
'~\b\w~',
$func,
$inputString
);
}
|
[
"public",
"static",
"function",
"uncapitalize",
"(",
"$",
"inputString",
")",
"{",
"$",
"func",
"=",
"function",
"(",
"array",
"$",
"matches",
")",
"{",
"return",
"StringUtils",
"::",
"lowerCase",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
";",
"}",
";",
"return",
"\\",
"preg_replace_callback",
"(",
"'~\\b\\w~'",
",",
"$",
"func",
",",
"$",
"inputString",
")",
";",
"}"
] |
Uncapitalizes all the whitespace separated words in a `string`.
Only the first letter of each word is changed. A `null` input `string`
returns `null`.
WordUtils::uncapitalize(null); // null
WordUtils::uncapitalize(''); // ''
WordUtils::uncapitalize('I Am FINE'); // 'i am fINE'
@param string $inputString The `string` to uncapitalize.
@return string The uncapitalized `string` or `null` if `null` `string`
input.
@see WordUtils::capitalize
|
[
"Uncapitalizes",
"all",
"the",
"whitespace",
"separated",
"words",
"in",
"a",
"string",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/WordUtils.php#L195-L206
|
228,466
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/WordUtils.php
|
WordUtils.initials
|
public static function initials($inputString, array $delimiters = null)
{
if (true === StringUtils::isEmpty($inputString)) {
return $inputString;
}
if ((null !== $delimiters) && (0 === \count($delimiters))) {
return StringUtils::EMPTY_STR;
}
$inputStringLen = StringUtils::length($inputString);
$buffer = array();
$lastWasGap = true;
for ($i = 0; $i < $inputStringLen; ++$i) {
$char = StringUtils::charAt($inputString, $i);
$delimiter = self::isDelimiter($char, $delimiters);
if (true === $delimiter) {
$lastWasGap = true;
} elseif (true === $lastWasGap) {
$buffer[] = $char;
$lastWasGap = false;
}
}
return \implode($buffer);
}
|
php
|
public static function initials($inputString, array $delimiters = null)
{
if (true === StringUtils::isEmpty($inputString)) {
return $inputString;
}
if ((null !== $delimiters) && (0 === \count($delimiters))) {
return StringUtils::EMPTY_STR;
}
$inputStringLen = StringUtils::length($inputString);
$buffer = array();
$lastWasGap = true;
for ($i = 0; $i < $inputStringLen; ++$i) {
$char = StringUtils::charAt($inputString, $i);
$delimiter = self::isDelimiter($char, $delimiters);
if (true === $delimiter) {
$lastWasGap = true;
} elseif (true === $lastWasGap) {
$buffer[] = $char;
$lastWasGap = false;
}
}
return \implode($buffer);
}
|
[
"public",
"static",
"function",
"initials",
"(",
"$",
"inputString",
",",
"array",
"$",
"delimiters",
"=",
"null",
")",
"{",
"if",
"(",
"true",
"===",
"StringUtils",
"::",
"isEmpty",
"(",
"$",
"inputString",
")",
")",
"{",
"return",
"$",
"inputString",
";",
"}",
"if",
"(",
"(",
"null",
"!==",
"$",
"delimiters",
")",
"&&",
"(",
"0",
"===",
"\\",
"count",
"(",
"$",
"delimiters",
")",
")",
")",
"{",
"return",
"StringUtils",
"::",
"EMPTY_STR",
";",
"}",
"$",
"inputStringLen",
"=",
"StringUtils",
"::",
"length",
"(",
"$",
"inputString",
")",
";",
"$",
"buffer",
"=",
"array",
"(",
")",
";",
"$",
"lastWasGap",
"=",
"true",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"inputStringLen",
";",
"++",
"$",
"i",
")",
"{",
"$",
"char",
"=",
"StringUtils",
"::",
"charAt",
"(",
"$",
"inputString",
",",
"$",
"i",
")",
";",
"$",
"delimiter",
"=",
"self",
"::",
"isDelimiter",
"(",
"$",
"char",
",",
"$",
"delimiters",
")",
";",
"if",
"(",
"true",
"===",
"$",
"delimiter",
")",
"{",
"$",
"lastWasGap",
"=",
"true",
";",
"}",
"elseif",
"(",
"true",
"===",
"$",
"lastWasGap",
")",
"{",
"$",
"buffer",
"[",
"]",
"=",
"$",
"char",
";",
"$",
"lastWasGap",
"=",
"false",
";",
"}",
"}",
"return",
"\\",
"implode",
"(",
"$",
"buffer",
")",
";",
"}"
] |
Extracts the initial letters from each word in the `string`.
The first letter of the string and all first letters after the defined
delimiters are returned as a new string. Their case is not changed.
If the delimiters array is `null`, then Whitespace is used.
A `null` input `string` returns `null`.
An empty delimiter `array` returns an empty `string`.
WordUtils::initials(null, null); // null
WordUtils::initials('', null); // ''
WordUtils::initials('Ben John Lee', null); // 'BJL'
WordUtils::initials('Ben J.Lee', null); // 'BJ'
WordUtils::initials('Ben J.Lee', [' ','.']); // 'BJL'
@param string $inputString The `string` to get initials from.
@param array|null $delimiters Set of characters to determine words,
`null` means whitespace.
@return string|null `string` of initial letters or `null` if `null`
`string` input.
|
[
"Extracts",
"the",
"initial",
"letters",
"from",
"each",
"word",
"in",
"the",
"string",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/WordUtils.php#L231-L258
|
228,467
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/WordUtils.php
|
WordUtils.isDelimiter
|
private static function isDelimiter($char, array $delimiters = null)
{
if (null === $delimiters) {
return \ctype_space($char);
}
foreach ($delimiters as $delimiter) {
if ($char === $delimiter) {
return true;
}
}
return false;
}
|
php
|
private static function isDelimiter($char, array $delimiters = null)
{
if (null === $delimiters) {
return \ctype_space($char);
}
foreach ($delimiters as $delimiter) {
if ($char === $delimiter) {
return true;
}
}
return false;
}
|
[
"private",
"static",
"function",
"isDelimiter",
"(",
"$",
"char",
",",
"array",
"$",
"delimiters",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"delimiters",
")",
"{",
"return",
"\\",
"ctype_space",
"(",
"$",
"char",
")",
";",
"}",
"foreach",
"(",
"$",
"delimiters",
"as",
"$",
"delimiter",
")",
"{",
"if",
"(",
"$",
"char",
"===",
"$",
"delimiter",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Checks whether the specified string is a delimiter.
@param string $char The string to check.
@param array|null $delimiters The delimiters.
@return boolean `true` if it is a delimiter; `false` otherwise.
|
[
"Checks",
"whether",
"the",
"specified",
"string",
"is",
"a",
"delimiter",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/WordUtils.php#L268-L281
|
228,468
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/WordUtils.php
|
WordUtils.swapCase
|
public static function swapCase($inputString)
{
if (true === StringUtils::isEmpty($inputString)) {
return $inputString;
}
$buffer = \str_split($inputString);
$length = \count($buffer);
for ($i = 0; $i < $length; ++$i) {
$char = $buffer[$i];
if (true === \ctype_upper($char)) {
$buffer[$i] = StringUtils::lowerCase($char);
} elseif (true === \ctype_lower($char)) {
$buffer[$i] = StringUtils::upperCase($char);
}
}
return \implode($buffer);
}
|
php
|
public static function swapCase($inputString)
{
if (true === StringUtils::isEmpty($inputString)) {
return $inputString;
}
$buffer = \str_split($inputString);
$length = \count($buffer);
for ($i = 0; $i < $length; ++$i) {
$char = $buffer[$i];
if (true === \ctype_upper($char)) {
$buffer[$i] = StringUtils::lowerCase($char);
} elseif (true === \ctype_lower($char)) {
$buffer[$i] = StringUtils::upperCase($char);
}
}
return \implode($buffer);
}
|
[
"public",
"static",
"function",
"swapCase",
"(",
"$",
"inputString",
")",
"{",
"if",
"(",
"true",
"===",
"StringUtils",
"::",
"isEmpty",
"(",
"$",
"inputString",
")",
")",
"{",
"return",
"$",
"inputString",
";",
"}",
"$",
"buffer",
"=",
"\\",
"str_split",
"(",
"$",
"inputString",
")",
";",
"$",
"length",
"=",
"\\",
"count",
"(",
"$",
"buffer",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"length",
";",
"++",
"$",
"i",
")",
"{",
"$",
"char",
"=",
"$",
"buffer",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"true",
"===",
"\\",
"ctype_upper",
"(",
"$",
"char",
")",
")",
"{",
"$",
"buffer",
"[",
"$",
"i",
"]",
"=",
"StringUtils",
"::",
"lowerCase",
"(",
"$",
"char",
")",
";",
"}",
"elseif",
"(",
"true",
"===",
"\\",
"ctype_lower",
"(",
"$",
"char",
")",
")",
"{",
"$",
"buffer",
"[",
"$",
"i",
"]",
"=",
"StringUtils",
"::",
"upperCase",
"(",
"$",
"char",
")",
";",
"}",
"}",
"return",
"\\",
"implode",
"(",
"$",
"buffer",
")",
";",
"}"
] |
Swaps the case of a `string` using a word based algorithm.
* Upper case character converts to Lower case
* Lower case character converts to Upper case
A `null` input `string` returns `null`.
WordUtils::swapCase(null); // null
WordUtils::swapCase(''); // ''
WordUtils::swapCase('The dog has a BONE); // 'tHE DOG HAS A bone'
@param string $inputString The `string` to swap case.
@return string|null The changed `string` or `null` if `null` `string`
input.
|
[
"Swaps",
"the",
"case",
"of",
"a",
"string",
"using",
"a",
"word",
"based",
"algorithm",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/WordUtils.php#L300-L320
|
228,469
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/WordUtils.php
|
WordUtils.wrap
|
public static function wrap(
$inputString,
$wrapLength,
$newLineInsertion = null,
$wrapLongWords = false
) {
if (null === $inputString) {
return null;
}
if (null === $newLineInsertion) {
$newLineInsertion = \PHP_EOL;
}
if (1 > $wrapLength) {
$wrapLength = 1;
}
$wordWrap = \wordwrap(
StringUtils::stripStart($inputString, null),
$wrapLength,
$newLineInsertion,
$wrapLongWords
);
$result = StringUtils::EMPTY_STR;
$split = StringUtils::split($wordWrap, $newLineInsertion);
foreach ($split as $fragment) {
$result .= StringUtils::stripStart($fragment, null) . $newLineInsertion;
}
return StringUtils::removeEnd($result, $newLineInsertion);
}
|
php
|
public static function wrap(
$inputString,
$wrapLength,
$newLineInsertion = null,
$wrapLongWords = false
) {
if (null === $inputString) {
return null;
}
if (null === $newLineInsertion) {
$newLineInsertion = \PHP_EOL;
}
if (1 > $wrapLength) {
$wrapLength = 1;
}
$wordWrap = \wordwrap(
StringUtils::stripStart($inputString, null),
$wrapLength,
$newLineInsertion,
$wrapLongWords
);
$result = StringUtils::EMPTY_STR;
$split = StringUtils::split($wordWrap, $newLineInsertion);
foreach ($split as $fragment) {
$result .= StringUtils::stripStart($fragment, null) . $newLineInsertion;
}
return StringUtils::removeEnd($result, $newLineInsertion);
}
|
[
"public",
"static",
"function",
"wrap",
"(",
"$",
"inputString",
",",
"$",
"wrapLength",
",",
"$",
"newLineInsertion",
"=",
"null",
",",
"$",
"wrapLongWords",
"=",
"false",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"inputString",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"newLineInsertion",
")",
"{",
"$",
"newLineInsertion",
"=",
"\\",
"PHP_EOL",
";",
"}",
"if",
"(",
"1",
">",
"$",
"wrapLength",
")",
"{",
"$",
"wrapLength",
"=",
"1",
";",
"}",
"$",
"wordWrap",
"=",
"\\",
"wordwrap",
"(",
"StringUtils",
"::",
"stripStart",
"(",
"$",
"inputString",
",",
"null",
")",
",",
"$",
"wrapLength",
",",
"$",
"newLineInsertion",
",",
"$",
"wrapLongWords",
")",
";",
"$",
"result",
"=",
"StringUtils",
"::",
"EMPTY_STR",
";",
"$",
"split",
"=",
"StringUtils",
"::",
"split",
"(",
"$",
"wordWrap",
",",
"$",
"newLineInsertion",
")",
";",
"foreach",
"(",
"$",
"split",
"as",
"$",
"fragment",
")",
"{",
"$",
"result",
".=",
"StringUtils",
"::",
"stripStart",
"(",
"$",
"fragment",
",",
"null",
")",
".",
"$",
"newLineInsertion",
";",
"}",
"return",
"StringUtils",
"::",
"removeEnd",
"(",
"$",
"result",
",",
"$",
"newLineInsertion",
")",
";",
"}"
] |
Wraps a single line of text, identifying words by `' '`.
Leading spaces on a new line are stripped. Trailing spaces are not
stripped.
WordUtils::wrap(null, null, null, null); // null
WordUtils::wrap('', null, null, null); // ''
@param string $inputString The `string` to be word wrapped.
@param integer $wrapLength The column to wrap the words at, less than
`1` is treated as `1`.
@param string|null $newLineInsertion The `string` to insert for a new
line, `null` uses the system property line separator.
@param boolean $wrapLongWords `true` if long words (such as URLs) should
be wrapped.
@return string|null A line with newlines inserted, `null` if `null`
input.
|
[
"Wraps",
"a",
"single",
"line",
"of",
"text",
"identifying",
"words",
"by",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/WordUtils.php#L346-L379
|
228,470
|
coincheckjp/coincheck-php
|
lib/Coincheck/Deposit.php
|
Deposit.all
|
public function all($params = array())
{
$arr = array(
"currency" => $params["currency"]
);
$rawResponse = $this->client->request('get', 'api/deposit_money', $arr);
return $rawResponse;
}
|
php
|
public function all($params = array())
{
$arr = array(
"currency" => $params["currency"]
);
$rawResponse = $this->client->request('get', 'api/deposit_money', $arr);
return $rawResponse;
}
|
[
"public",
"function",
"all",
"(",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"arr",
"=",
"array",
"(",
"\"currency\"",
"=>",
"$",
"params",
"[",
"\"currency\"",
"]",
")",
";",
"$",
"rawResponse",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'get'",
",",
"'api/deposit_money'",
",",
"$",
"arr",
")",
";",
"return",
"$",
"rawResponse",
";",
"}"
] |
You Get Deposit history
@param mixed
@return Json Array
|
[
"You",
"Get",
"Deposit",
"history"
] |
5991003cb0ae827697888aeebd0aea0267fad7fa
|
https://github.com/coincheckjp/coincheck-php/blob/5991003cb0ae827697888aeebd0aea0267fad7fa/lib/Coincheck/Deposit.php#L20-L27
|
228,471
|
coincheckjp/coincheck-php
|
lib/Coincheck/Deposit.php
|
Deposit.fast
|
public function fast($params = array())
{
$arr = array(
"id" => $params["id"]
);
$rawResponse = $this->client->request('post', 'api/deposit_money/' . $arr["id"] . "/fast", $arr);
return $rawResponse;
}
|
php
|
public function fast($params = array())
{
$arr = array(
"id" => $params["id"]
);
$rawResponse = $this->client->request('post', 'api/deposit_money/' . $arr["id"] . "/fast", $arr);
return $rawResponse;
}
|
[
"public",
"function",
"fast",
"(",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"arr",
"=",
"array",
"(",
"\"id\"",
"=>",
"$",
"params",
"[",
"\"id\"",
"]",
")",
";",
"$",
"rawResponse",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'post'",
",",
"'api/deposit_money/'",
".",
"$",
"arr",
"[",
"\"id\"",
"]",
".",
"\"/fast\"",
",",
"$",
"arr",
")",
";",
"return",
"$",
"rawResponse",
";",
"}"
] |
Deposit Bitcoin Faster
@param mixed
@return Json Array
|
[
"Deposit",
"Bitcoin",
"Faster"
] |
5991003cb0ae827697888aeebd0aea0267fad7fa
|
https://github.com/coincheckjp/coincheck-php/blob/5991003cb0ae827697888aeebd0aea0267fad7fa/lib/Coincheck/Deposit.php#L35-L42
|
228,472
|
joomla-framework/google-api
|
src/Embed/Analytics.php
|
Analytics.deleteCall
|
public function deleteCall($index = null)
{
$calls = $this->listCalls();
if ($index === null)
{
$index = \count($calls) - 1;
}
$call = $calls[$index];
unset($calls[$index]);
$calls = array_values($calls);
$this->setOption('calls', $calls);
return $call;
}
|
php
|
public function deleteCall($index = null)
{
$calls = $this->listCalls();
if ($index === null)
{
$index = \count($calls) - 1;
}
$call = $calls[$index];
unset($calls[$index]);
$calls = array_values($calls);
$this->setOption('calls', $calls);
return $call;
}
|
[
"public",
"function",
"deleteCall",
"(",
"$",
"index",
"=",
"null",
")",
"{",
"$",
"calls",
"=",
"$",
"this",
"->",
"listCalls",
"(",
")",
";",
"if",
"(",
"$",
"index",
"===",
"null",
")",
"{",
"$",
"index",
"=",
"\\",
"count",
"(",
"$",
"calls",
")",
"-",
"1",
";",
"}",
"$",
"call",
"=",
"$",
"calls",
"[",
"$",
"index",
"]",
";",
"unset",
"(",
"$",
"calls",
"[",
"$",
"index",
"]",
")",
";",
"$",
"calls",
"=",
"array_values",
"(",
"$",
"calls",
")",
";",
"$",
"this",
"->",
"setOption",
"(",
"'calls'",
",",
"$",
"calls",
")",
";",
"return",
"$",
"call",
";",
"}"
] |
Delete a call from the stack
@param integer $index Index of call to delete (defaults to last added call)
@return array The deleted call
@since 1.0
|
[
"Delete",
"a",
"call",
"from",
"the",
"stack"
] |
c78f06cfaba3f0dfc3ce411a335b417a5f0ee904
|
https://github.com/joomla-framework/google-api/blob/c78f06cfaba3f0dfc3ce411a335b417a5f0ee904/src/Embed/Analytics.php#L132-L147
|
228,473
|
antaresproject/core
|
src/components/auth/src/Authorization/Authorization.php
|
Authorization.attach
|
public function attach(Provider $memory = null)
{
if ($this->attached() && $memory !== $this->memory) {
//throw new RuntimeException("Unable to assign multiple Antares\Memory instance.");
}
if (!is_null($memory)) {
$this->setMemoryProvider($memory);
$this->initiate();
}
}
|
php
|
public function attach(Provider $memory = null)
{
if ($this->attached() && $memory !== $this->memory) {
//throw new RuntimeException("Unable to assign multiple Antares\Memory instance.");
}
if (!is_null($memory)) {
$this->setMemoryProvider($memory);
$this->initiate();
}
}
|
[
"public",
"function",
"attach",
"(",
"Provider",
"$",
"memory",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"attached",
"(",
")",
"&&",
"$",
"memory",
"!==",
"$",
"this",
"->",
"memory",
")",
"{",
"//throw new RuntimeException(\"Unable to assign multiple Antares\\Memory instance.\");",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"memory",
")",
")",
"{",
"$",
"this",
"->",
"setMemoryProvider",
"(",
"$",
"memory",
")",
";",
"$",
"this",
"->",
"initiate",
"(",
")",
";",
"}",
"}"
] |
Bind current ACL instance with a Memory instance.
@param \Antares\Contracts\Memory\Provider $memory
@return void
@throws \RuntimeException if $memory has been attached.
|
[
"Bind",
"current",
"ACL",
"instance",
"with",
"a",
"Memory",
"instance",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/auth/src/Authorization/Authorization.php#L71-L82
|
228,474
|
antaresproject/core
|
src/components/auth/src/Authorization/Authorization.php
|
Authorization.initiate
|
protected function initiate()
{
$name = $this->name;
$data = ['acl' => [], 'actions' => [], 'roles' => []];
$data = array_merge($data, $this->memory->get("acl_{$name}", []));
if (empty($data['roles'])) {
$roles = $this->memory->get('acl_antares.roles');
$data['roles'] = $roles == null ? [] : $roles;
}
$this->roles->attachKeyValuePair($data['roles']);
$this->actions->attachKeyValuePair($data['actions']);
foreach ($data['acl'] as $id => $allow) {
list($role, $action) = explode(':', $id);
$this->assign($role, $action, $allow);
}
}
|
php
|
protected function initiate()
{
$name = $this->name;
$data = ['acl' => [], 'actions' => [], 'roles' => []];
$data = array_merge($data, $this->memory->get("acl_{$name}", []));
if (empty($data['roles'])) {
$roles = $this->memory->get('acl_antares.roles');
$data['roles'] = $roles == null ? [] : $roles;
}
$this->roles->attachKeyValuePair($data['roles']);
$this->actions->attachKeyValuePair($data['actions']);
foreach ($data['acl'] as $id => $allow) {
list($role, $action) = explode(':', $id);
$this->assign($role, $action, $allow);
}
}
|
[
"protected",
"function",
"initiate",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"name",
";",
"$",
"data",
"=",
"[",
"'acl'",
"=>",
"[",
"]",
",",
"'actions'",
"=>",
"[",
"]",
",",
"'roles'",
"=>",
"[",
"]",
"]",
";",
"$",
"data",
"=",
"array_merge",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"memory",
"->",
"get",
"(",
"\"acl_{$name}\"",
",",
"[",
"]",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"data",
"[",
"'roles'",
"]",
")",
")",
"{",
"$",
"roles",
"=",
"$",
"this",
"->",
"memory",
"->",
"get",
"(",
"'acl_antares.roles'",
")",
";",
"$",
"data",
"[",
"'roles'",
"]",
"=",
"$",
"roles",
"==",
"null",
"?",
"[",
"]",
":",
"$",
"roles",
";",
"}",
"$",
"this",
"->",
"roles",
"->",
"attachKeyValuePair",
"(",
"$",
"data",
"[",
"'roles'",
"]",
")",
";",
"$",
"this",
"->",
"actions",
"->",
"attachKeyValuePair",
"(",
"$",
"data",
"[",
"'actions'",
"]",
")",
";",
"foreach",
"(",
"$",
"data",
"[",
"'acl'",
"]",
"as",
"$",
"id",
"=>",
"$",
"allow",
")",
"{",
"list",
"(",
"$",
"role",
",",
"$",
"action",
")",
"=",
"explode",
"(",
"':'",
",",
"$",
"id",
")",
";",
"$",
"this",
"->",
"assign",
"(",
"$",
"role",
",",
"$",
"action",
",",
"$",
"allow",
")",
";",
"}",
"}"
] |
Initiate acl data from memory.
@return void
|
[
"Initiate",
"acl",
"data",
"from",
"memory",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/auth/src/Authorization/Authorization.php#L89-L106
|
228,475
|
antaresproject/core
|
src/components/auth/src/Authorization/Authorization.php
|
Authorization.save
|
public function save($descriptions = null, $categories = null)
{
if ($this->attached()) {
$name = $this->name;
$this->memory->put("acl_{$name}", [
'acl' => $this->acl,
'actions' => $this->actions->get(),
'roles' => $this->roles->get(),
'descriptions' => $descriptions,
'categories' => $categories
]);
}
return $this;
}
|
php
|
public function save($descriptions = null, $categories = null)
{
if ($this->attached()) {
$name = $this->name;
$this->memory->put("acl_{$name}", [
'acl' => $this->acl,
'actions' => $this->actions->get(),
'roles' => $this->roles->get(),
'descriptions' => $descriptions,
'categories' => $categories
]);
}
return $this;
}
|
[
"public",
"function",
"save",
"(",
"$",
"descriptions",
"=",
"null",
",",
"$",
"categories",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"attached",
"(",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"name",
";",
"$",
"this",
"->",
"memory",
"->",
"put",
"(",
"\"acl_{$name}\"",
",",
"[",
"'acl'",
"=>",
"$",
"this",
"->",
"acl",
",",
"'actions'",
"=>",
"$",
"this",
"->",
"actions",
"->",
"get",
"(",
")",
",",
"'roles'",
"=>",
"$",
"this",
"->",
"roles",
"->",
"get",
"(",
")",
",",
"'descriptions'",
"=>",
"$",
"descriptions",
",",
"'categories'",
"=>",
"$",
"categories",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Saves authorization changes
@return \Antares\Authorization\Authorization
|
[
"Saves",
"authorization",
"changes"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/auth/src/Authorization/Authorization.php#L218-L231
|
228,476
|
antaresproject/core
|
src/utils/security/src/Scope/AccessScope.php
|
AccessScope.apply
|
public function apply(Builder $builder, Model $model)
{
$column = $this->getPolicyColumn($model);
if (is_null($column) && get_class($model) !== \Antares\Model\User::class) {
return;
}
if (!auth()->user()) {
return;
}
$id = auth()->user()->roles->first()->id;
$elements = Cache::remember('roles1-' . $id, 5, function() use($id) {
$roles = app(Role::class)->withTrashed()->orderby('parent_id')->get()->toArray();
return $this->getLowerRoles($roles, $id);
});
$uid = user()->id;
if (get_class($model) === \Antares\Model\User::class) {
if (empty($elements)) {
$builder->whereRaw("(tbl_users.id is null or tbl_users.id=?)", [$uid]);
} else {
$in = implode(',', array_values($elements));
$builder->whereRaw("(tbl_users.id is null or tbl_users.id=? or tbl_users.id in (select user_id from tbl_user_role where role_id in({$in})))", [$uid]);
}
} elseif (!empty($elements)) {
$in = implode(',', array_values($elements));
$builder->whereRaw("(user_id is null or user_id=? or user_id in (select user_id from tbl_user_role where role_id in({$in})))", [$uid]);
}
}
|
php
|
public function apply(Builder $builder, Model $model)
{
$column = $this->getPolicyColumn($model);
if (is_null($column) && get_class($model) !== \Antares\Model\User::class) {
return;
}
if (!auth()->user()) {
return;
}
$id = auth()->user()->roles->first()->id;
$elements = Cache::remember('roles1-' . $id, 5, function() use($id) {
$roles = app(Role::class)->withTrashed()->orderby('parent_id')->get()->toArray();
return $this->getLowerRoles($roles, $id);
});
$uid = user()->id;
if (get_class($model) === \Antares\Model\User::class) {
if (empty($elements)) {
$builder->whereRaw("(tbl_users.id is null or tbl_users.id=?)", [$uid]);
} else {
$in = implode(',', array_values($elements));
$builder->whereRaw("(tbl_users.id is null or tbl_users.id=? or tbl_users.id in (select user_id from tbl_user_role where role_id in({$in})))", [$uid]);
}
} elseif (!empty($elements)) {
$in = implode(',', array_values($elements));
$builder->whereRaw("(user_id is null or user_id=? or user_id in (select user_id from tbl_user_role where role_id in({$in})))", [$uid]);
}
}
|
[
"public",
"function",
"apply",
"(",
"Builder",
"$",
"builder",
",",
"Model",
"$",
"model",
")",
"{",
"$",
"column",
"=",
"$",
"this",
"->",
"getPolicyColumn",
"(",
"$",
"model",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"column",
")",
"&&",
"get_class",
"(",
"$",
"model",
")",
"!==",
"\\",
"Antares",
"\\",
"Model",
"\\",
"User",
"::",
"class",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"auth",
"(",
")",
"->",
"user",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"id",
"=",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"roles",
"->",
"first",
"(",
")",
"->",
"id",
";",
"$",
"elements",
"=",
"Cache",
"::",
"remember",
"(",
"'roles1-'",
".",
"$",
"id",
",",
"5",
",",
"function",
"(",
")",
"use",
"(",
"$",
"id",
")",
"{",
"$",
"roles",
"=",
"app",
"(",
"Role",
"::",
"class",
")",
"->",
"withTrashed",
"(",
")",
"->",
"orderby",
"(",
"'parent_id'",
")",
"->",
"get",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getLowerRoles",
"(",
"$",
"roles",
",",
"$",
"id",
")",
";",
"}",
")",
";",
"$",
"uid",
"=",
"user",
"(",
")",
"->",
"id",
";",
"if",
"(",
"get_class",
"(",
"$",
"model",
")",
"===",
"\\",
"Antares",
"\\",
"Model",
"\\",
"User",
"::",
"class",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"elements",
")",
")",
"{",
"$",
"builder",
"->",
"whereRaw",
"(",
"\"(tbl_users.id is null or tbl_users.id=?)\"",
",",
"[",
"$",
"uid",
"]",
")",
";",
"}",
"else",
"{",
"$",
"in",
"=",
"implode",
"(",
"','",
",",
"array_values",
"(",
"$",
"elements",
")",
")",
";",
"$",
"builder",
"->",
"whereRaw",
"(",
"\"(tbl_users.id is null or tbl_users.id=? or tbl_users.id in (select user_id from tbl_user_role where role_id in({$in})))\"",
",",
"[",
"$",
"uid",
"]",
")",
";",
"}",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"elements",
")",
")",
"{",
"$",
"in",
"=",
"implode",
"(",
"','",
",",
"array_values",
"(",
"$",
"elements",
")",
")",
";",
"$",
"builder",
"->",
"whereRaw",
"(",
"\"(user_id is null or user_id=? or user_id in (select user_id from tbl_user_role where role_id in({$in})))\"",
",",
"[",
"$",
"uid",
"]",
")",
";",
"}",
"}"
] |
apply active logs global scope
@param Builder $builder
@param Model $model
|
[
"apply",
"active",
"logs",
"global",
"scope"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/security/src/Scope/AccessScope.php#L48-L76
|
228,477
|
antaresproject/core
|
src/utils/security/src/Scope/AccessScope.php
|
AccessScope.getPolicyColumn
|
protected function getPolicyColumn(Model $model)
{
$connection = $model->getConnection();
$table = $connection->getTablePrefix() . $model->getTable();
$schema = $connection->getDoctrineSchemaManager($table);
$columns = Cache::remember('keys_' . $table, 30, function() use($model) {
return Schema::getColumnListing($model->getTable());
});
$column = null;
foreach (self::$patternedColumns as $name) {
if (!is_null($column)) {
break;
}
$column = array_search($name, $columns) !== false ? $name : null;
}
if (is_null($column)) {
foreach ($schema->listTableForeignKeys($table) as $foreignKeyConstraint) {
if ($foreignKeyConstraint->getForeignTableName() !== 'tbl_users') {
continue;
}
$column = current($foreignKeyConstraint->getLocalColumns());
}
}
return $column;
}
|
php
|
protected function getPolicyColumn(Model $model)
{
$connection = $model->getConnection();
$table = $connection->getTablePrefix() . $model->getTable();
$schema = $connection->getDoctrineSchemaManager($table);
$columns = Cache::remember('keys_' . $table, 30, function() use($model) {
return Schema::getColumnListing($model->getTable());
});
$column = null;
foreach (self::$patternedColumns as $name) {
if (!is_null($column)) {
break;
}
$column = array_search($name, $columns) !== false ? $name : null;
}
if (is_null($column)) {
foreach ($schema->listTableForeignKeys($table) as $foreignKeyConstraint) {
if ($foreignKeyConstraint->getForeignTableName() !== 'tbl_users') {
continue;
}
$column = current($foreignKeyConstraint->getLocalColumns());
}
}
return $column;
}
|
[
"protected",
"function",
"getPolicyColumn",
"(",
"Model",
"$",
"model",
")",
"{",
"$",
"connection",
"=",
"$",
"model",
"->",
"getConnection",
"(",
")",
";",
"$",
"table",
"=",
"$",
"connection",
"->",
"getTablePrefix",
"(",
")",
".",
"$",
"model",
"->",
"getTable",
"(",
")",
";",
"$",
"schema",
"=",
"$",
"connection",
"->",
"getDoctrineSchemaManager",
"(",
"$",
"table",
")",
";",
"$",
"columns",
"=",
"Cache",
"::",
"remember",
"(",
"'keys_'",
".",
"$",
"table",
",",
"30",
",",
"function",
"(",
")",
"use",
"(",
"$",
"model",
")",
"{",
"return",
"Schema",
"::",
"getColumnListing",
"(",
"$",
"model",
"->",
"getTable",
"(",
")",
")",
";",
"}",
")",
";",
"$",
"column",
"=",
"null",
";",
"foreach",
"(",
"self",
"::",
"$",
"patternedColumns",
"as",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"column",
")",
")",
"{",
"break",
";",
"}",
"$",
"column",
"=",
"array_search",
"(",
"$",
"name",
",",
"$",
"columns",
")",
"!==",
"false",
"?",
"$",
"name",
":",
"null",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"column",
")",
")",
"{",
"foreach",
"(",
"$",
"schema",
"->",
"listTableForeignKeys",
"(",
"$",
"table",
")",
"as",
"$",
"foreignKeyConstraint",
")",
"{",
"if",
"(",
"$",
"foreignKeyConstraint",
"->",
"getForeignTableName",
"(",
")",
"!==",
"'tbl_users'",
")",
"{",
"continue",
";",
"}",
"$",
"column",
"=",
"current",
"(",
"$",
"foreignKeyConstraint",
"->",
"getLocalColumns",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"column",
";",
"}"
] |
get column name which can be used as user connector
@param Model $model
@return String
|
[
"get",
"column",
"name",
"which",
"can",
"be",
"used",
"as",
"user",
"connector"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/security/src/Scope/AccessScope.php#L84-L112
|
228,478
|
antaresproject/core
|
src/components/publisher/src/AssetManager.php
|
AssetManager.foundation
|
public function foundation()
{
$path = rtrim($this->app->make('path.base'), '/') . '/src/core/foundation/resources/public';
if (!$this->app->make('files')->isDirectory($path)) {
return false;
}
try {
return $this->publish('antares/foundation', $path);
} catch (Exception $e) {
Log::emergency($e);
throw new FilePermissionException("Unable to publish [{$path}].");
}
}
|
php
|
public function foundation()
{
$path = rtrim($this->app->make('path.base'), '/') . '/src/core/foundation/resources/public';
if (!$this->app->make('files')->isDirectory($path)) {
return false;
}
try {
return $this->publish('antares/foundation', $path);
} catch (Exception $e) {
Log::emergency($e);
throw new FilePermissionException("Unable to publish [{$path}].");
}
}
|
[
"public",
"function",
"foundation",
"(",
")",
"{",
"$",
"path",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'path.base'",
")",
",",
"'/'",
")",
".",
"'/src/core/foundation/resources/public'",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'files'",
")",
"->",
"isDirectory",
"(",
"$",
"path",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"return",
"$",
"this",
"->",
"publish",
"(",
"'antares/foundation'",
",",
"$",
"path",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Log",
"::",
"emergency",
"(",
"$",
"e",
")",
";",
"throw",
"new",
"FilePermissionException",
"(",
"\"Unable to publish [{$path}].\"",
")",
";",
"}",
"}"
] |
Migrate Antares.
@return mixed
@throws FilePermissionException
|
[
"Migrate",
"Antares",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/publisher/src/AssetManager.php#L105-L119
|
228,479
|
antaresproject/core
|
src/components/publisher/src/AssetManager.php
|
AssetManager.delete
|
public function delete($name)
{
$path = public_path() . DIRECTORY_SEPARATOR . 'packages' . DIRECTORY_SEPARATOR . $name;
if (!$this->app->make('files')->isDirectory($path)) {
return false;
}
try {
return $this->publisher->delete($path);
} catch (Exception $ex) {
Log::emergency($ex);
throw new Exception("Unable to delete [{$path}].");
}
}
|
php
|
public function delete($name)
{
$path = public_path() . DIRECTORY_SEPARATOR . 'packages' . DIRECTORY_SEPARATOR . $name;
if (!$this->app->make('files')->isDirectory($path)) {
return false;
}
try {
return $this->publisher->delete($path);
} catch (Exception $ex) {
Log::emergency($ex);
throw new Exception("Unable to delete [{$path}].");
}
}
|
[
"public",
"function",
"delete",
"(",
"$",
"name",
")",
"{",
"$",
"path",
"=",
"public_path",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"'packages'",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"name",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'files'",
")",
"->",
"isDirectory",
"(",
"$",
"path",
")",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"return",
"$",
"this",
"->",
"publisher",
"->",
"delete",
"(",
"$",
"path",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"Log",
"::",
"emergency",
"(",
"$",
"ex",
")",
";",
"throw",
"new",
"Exception",
"(",
"\"Unable to delete [{$path}].\"",
")",
";",
"}",
"}"
] |
deletes published extension asset
@param String $name
@return boolean
@throws Exception
|
[
"deletes",
"published",
"extension",
"asset"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/publisher/src/AssetManager.php#L148-L161
|
228,480
|
antaresproject/core
|
src/components/model/src/Traits/MetableTrait.php
|
MetableTrait.getMetaAttribute
|
public function getMetaAttribute($value)
{
$meta = [];
if (! is_null($value)) {
$meta = json_decode($value, true);
}
return new Meta($meta);
}
|
php
|
public function getMetaAttribute($value)
{
$meta = [];
if (! is_null($value)) {
$meta = json_decode($value, true);
}
return new Meta($meta);
}
|
[
"public",
"function",
"getMetaAttribute",
"(",
"$",
"value",
")",
"{",
"$",
"meta",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"$",
"meta",
"=",
"json_decode",
"(",
"$",
"value",
",",
"true",
")",
";",
"}",
"return",
"new",
"Meta",
"(",
"$",
"meta",
")",
";",
"}"
] |
`meta` field accessor.
@param mixed $value
@return \Antares\Model\Value\Meta
|
[
"meta",
"field",
"accessor",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/model/src/Traits/MetableTrait.php#L35-L44
|
228,481
|
antaresproject/core
|
src/foundation/src/Foundation.php
|
Foundation.createAdminMenu
|
protected function createAdminMenu()
{
$config = config('menu');
$events = $this->app->make('events');
foreach ($config as $event => $ordered) {
foreach ($ordered as $name => $value) {
if (is_numeric($name)) {
$events->listen($event, $value);
} else {
$events->listen($event, $name, $value);
}
}
}
}
|
php
|
protected function createAdminMenu()
{
$config = config('menu');
$events = $this->app->make('events');
foreach ($config as $event => $ordered) {
foreach ($ordered as $name => $value) {
if (is_numeric($name)) {
$events->listen($event, $value);
} else {
$events->listen($event, $name, $value);
}
}
}
}
|
[
"protected",
"function",
"createAdminMenu",
"(",
")",
"{",
"$",
"config",
"=",
"config",
"(",
"'menu'",
")",
";",
"$",
"events",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'events'",
")",
";",
"foreach",
"(",
"$",
"config",
"as",
"$",
"event",
"=>",
"$",
"ordered",
")",
"{",
"foreach",
"(",
"$",
"ordered",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"name",
")",
")",
"{",
"$",
"events",
"->",
"listen",
"(",
"$",
"event",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"events",
"->",
"listen",
"(",
"$",
"event",
",",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"}"
] |
Create Administration Menu for Antares.
@return void
|
[
"Create",
"Administration",
"Menu",
"for",
"Antares",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Foundation.php#L199-L213
|
228,482
|
antaresproject/core
|
src/components/extension/src/SettingsFormResolver.php
|
SettingsFormResolver.tryGetSettingsForm
|
public function tryGetSettingsForm(ExtensionContract $extension) : SettingsFormContract {
$className = $extension->getRootNamespace() . self::$formClassName;
if( ! class_exists($className) ) {
throw new InvalidArgumentException('The provided class name [' . $className . '] does not exist.');
}
$instance = $this->container->make($className);
if($instance instanceof SettingsFormContract) {
return $instance;
}
throw new DomainException('The instance of the found class does not implement a valid interface.');
}
|
php
|
public function tryGetSettingsForm(ExtensionContract $extension) : SettingsFormContract {
$className = $extension->getRootNamespace() . self::$formClassName;
if( ! class_exists($className) ) {
throw new InvalidArgumentException('The provided class name [' . $className . '] does not exist.');
}
$instance = $this->container->make($className);
if($instance instanceof SettingsFormContract) {
return $instance;
}
throw new DomainException('The instance of the found class does not implement a valid interface.');
}
|
[
"public",
"function",
"tryGetSettingsForm",
"(",
"ExtensionContract",
"$",
"extension",
")",
":",
"SettingsFormContract",
"{",
"$",
"className",
"=",
"$",
"extension",
"->",
"getRootNamespace",
"(",
")",
".",
"self",
"::",
"$",
"formClassName",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The provided class name ['",
".",
"$",
"className",
".",
"'] does not exist.'",
")",
";",
"}",
"$",
"instance",
"=",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"$",
"className",
")",
";",
"if",
"(",
"$",
"instance",
"instanceof",
"SettingsFormContract",
")",
"{",
"return",
"$",
"instance",
";",
"}",
"throw",
"new",
"DomainException",
"(",
"'The instance of the found class does not implement a valid interface.'",
")",
";",
"}"
] |
Returns the instance of settings form by the given extension.
@param ExtensionContract $extension
@return SettingsFormContract
@throws InvalidArgumentException
@throws DomainException
|
[
"Returns",
"the",
"instance",
"of",
"settings",
"form",
"by",
"the",
"given",
"extension",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/SettingsFormResolver.php#L57-L71
|
228,483
|
antaresproject/core
|
src/ui/components/templates/src/TemplateFinder.php
|
TemplateFinder.parseThemeNameFromPath
|
protected function parseThemeNameFromPath($path)
{
$path = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $path);
$path = explode(DIRECTORY_SEPARATOR, $path);
return array_pop($path);
}
|
php
|
protected function parseThemeNameFromPath($path)
{
$path = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $path);
$path = explode(DIRECTORY_SEPARATOR, $path);
return array_pop($path);
}
|
[
"protected",
"function",
"parseThemeNameFromPath",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"str_replace",
"(",
"[",
"'\\\\'",
",",
"'/'",
"]",
",",
"DIRECTORY_SEPARATOR",
",",
"$",
"path",
")",
";",
"$",
"path",
"=",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"path",
")",
";",
"return",
"array_pop",
"(",
"$",
"path",
")",
";",
"}"
] |
Gets folder name from full path.
@param String $path
@return String
|
[
"Gets",
"folder",
"name",
"from",
"full",
"path",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/TemplateFinder.php#L86-L92
|
228,484
|
antaresproject/core
|
src/components/memory/src/MemoryManager.php
|
MemoryManager.createSessionDriver
|
protected function createSessionDriver($name)
{
$config = Arr::get($this->config, "session.{$name}", []);
return $this->createProvider(new Session($name, $config));
}
|
php
|
protected function createSessionDriver($name)
{
$config = Arr::get($this->config, "session.{$name}", []);
return $this->createProvider(new Session($name, $config));
}
|
[
"protected",
"function",
"createSessionDriver",
"(",
"$",
"name",
")",
"{",
"$",
"config",
"=",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"config",
",",
"\"session.{$name}\"",
",",
"[",
"]",
")",
";",
"return",
"$",
"this",
"->",
"createProvider",
"(",
"new",
"Session",
"(",
"$",
"name",
",",
"$",
"config",
")",
")",
";",
"}"
] |
Create Session driver.
@param string $name
@return \Antares\Contracts\Memory\Provider
|
[
"Create",
"Session",
"driver",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/src/MemoryManager.php#L82-L86
|
228,485
|
antaresproject/core
|
src/components/memory/src/MemoryManager.php
|
MemoryManager.createRegistryDriver
|
protected function createRegistryDriver($name)
{
$config = Arr::get($this->config, "registry.{$name}", []);
$cache = $this->getCacheRepository($config);
return $this->createProvider(Registry::getInstance($name, $config, $this->app, $cache));
}
|
php
|
protected function createRegistryDriver($name)
{
$config = Arr::get($this->config, "registry.{$name}", []);
$cache = $this->getCacheRepository($config);
return $this->createProvider(Registry::getInstance($name, $config, $this->app, $cache));
}
|
[
"protected",
"function",
"createRegistryDriver",
"(",
"$",
"name",
")",
"{",
"$",
"config",
"=",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"config",
",",
"\"registry.{$name}\"",
",",
"[",
"]",
")",
";",
"$",
"cache",
"=",
"$",
"this",
"->",
"getCacheRepository",
"(",
"$",
"config",
")",
";",
"return",
"$",
"this",
"->",
"createProvider",
"(",
"Registry",
"::",
"getInstance",
"(",
"$",
"name",
",",
"$",
"config",
",",
"$",
"this",
"->",
"app",
",",
"$",
"cache",
")",
")",
";",
"}"
] |
Create Registry driver.
@param string $name
@return \Antares\Contracts\Memory\Provider
|
[
"Create",
"Registry",
"driver",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/src/MemoryManager.php#L121-L127
|
228,486
|
antaresproject/core
|
src/components/memory/src/MemoryManager.php
|
MemoryManager.createComponentDriver
|
protected function createComponentDriver($name)
{
$config = Arr::get($this->config, "component.{$name}", []);
$cache = $this->getCacheRepository($config);
return $this->createProvider(new Component($name, $config, $this->app, $cache));
}
|
php
|
protected function createComponentDriver($name)
{
$config = Arr::get($this->config, "component.{$name}", []);
$cache = $this->getCacheRepository($config);
return $this->createProvider(new Component($name, $config, $this->app, $cache));
}
|
[
"protected",
"function",
"createComponentDriver",
"(",
"$",
"name",
")",
"{",
"$",
"config",
"=",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"config",
",",
"\"component.{$name}\"",
",",
"[",
"]",
")",
";",
"$",
"cache",
"=",
"$",
"this",
"->",
"getCacheRepository",
"(",
"$",
"config",
")",
";",
"return",
"$",
"this",
"->",
"createProvider",
"(",
"new",
"Component",
"(",
"$",
"name",
",",
"$",
"config",
",",
"$",
"this",
"->",
"app",
",",
"$",
"cache",
")",
")",
";",
"}"
] |
Create Component driver.
@param string $name
@return \Antares\Contracts\Memory\Provider
|
[
"Create",
"Component",
"driver",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/src/MemoryManager.php#L134-L139
|
228,487
|
antaresproject/core
|
src/components/memory/src/MemoryManager.php
|
MemoryManager.createPrimaryDriver
|
protected function createPrimaryDriver($name)
{
$config = Arr::get($this->config, "primary", []);
$cache = $this->getCacheRepository($config);
return $this->createProvider(new Handlers\Primary($name, $config, $this->app, $cache));
}
|
php
|
protected function createPrimaryDriver($name)
{
$config = Arr::get($this->config, "primary", []);
$cache = $this->getCacheRepository($config);
return $this->createProvider(new Handlers\Primary($name, $config, $this->app, $cache));
}
|
[
"protected",
"function",
"createPrimaryDriver",
"(",
"$",
"name",
")",
"{",
"$",
"config",
"=",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"config",
",",
"\"primary\"",
",",
"[",
"]",
")",
";",
"$",
"cache",
"=",
"$",
"this",
"->",
"getCacheRepository",
"(",
"$",
"config",
")",
";",
"return",
"$",
"this",
"->",
"createProvider",
"(",
"new",
"Handlers",
"\\",
"Primary",
"(",
"$",
"name",
",",
"$",
"config",
",",
"$",
"this",
"->",
"app",
",",
"$",
"cache",
")",
")",
";",
"}"
] |
Create Primary driver.
@param string $name
@return \Antares\Contracts\Memory\Provider
|
[
"Create",
"Primary",
"driver",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/src/MemoryManager.php#L146-L152
|
228,488
|
24aitor/Localizer
|
src/Builder.php
|
Builder.allowedLanguages
|
public static function allowedLanguages()
{
if (config('localizer.allowed_langs')) {
return self::addNames(array_merge(config('localizer.allowed_langs'), [config('localizer.default_lang')]));
} else {
return self::addNames([config('localizer.default_lang')]);
}
}
|
php
|
public static function allowedLanguages()
{
if (config('localizer.allowed_langs')) {
return self::addNames(array_merge(config('localizer.allowed_langs'), [config('localizer.default_lang')]));
} else {
return self::addNames([config('localizer.default_lang')]);
}
}
|
[
"public",
"static",
"function",
"allowedLanguages",
"(",
")",
"{",
"if",
"(",
"config",
"(",
"'localizer.allowed_langs'",
")",
")",
"{",
"return",
"self",
"::",
"addNames",
"(",
"array_merge",
"(",
"config",
"(",
"'localizer.allowed_langs'",
")",
",",
"[",
"config",
"(",
"'localizer.default_lang'",
")",
"]",
")",
")",
";",
"}",
"else",
"{",
"return",
"self",
"::",
"addNames",
"(",
"[",
"config",
"(",
"'localizer.default_lang'",
")",
"]",
")",
";",
"}",
"}"
] |
Get all allowed languages.
@return array
|
[
"Get",
"all",
"allowed",
"languages",
"."
] |
3f234dfeab1030119148ece01f61d79dba27ac67
|
https://github.com/24aitor/Localizer/blob/3f234dfeab1030119148ece01f61d79dba27ac67/src/Builder.php#L14-L21
|
228,489
|
24aitor/Localizer
|
src/Builder.php
|
Builder.getCode
|
public static function getCode($name = 'default')
{
if ($name == 'default') {
$name = self::getLanguage();
}
return self::addCodes([$name])[$name];
}
|
php
|
public static function getCode($name = 'default')
{
if ($name == 'default') {
$name = self::getLanguage();
}
return self::addCodes([$name])[$name];
}
|
[
"public",
"static",
"function",
"getCode",
"(",
"$",
"name",
"=",
"'default'",
")",
"{",
"if",
"(",
"$",
"name",
"==",
"'default'",
")",
"{",
"$",
"name",
"=",
"self",
"::",
"getLanguage",
"(",
")",
";",
"}",
"return",
"self",
"::",
"addCodes",
"(",
"[",
"$",
"name",
"]",
")",
"[",
"$",
"name",
"]",
";",
"}"
] |
Returns the current language code.
@return string
|
[
"Returns",
"the",
"current",
"language",
"code",
"."
] |
3f234dfeab1030119148ece01f61d79dba27ac67
|
https://github.com/24aitor/Localizer/blob/3f234dfeab1030119148ece01f61d79dba27ac67/src/Builder.php#L122-L129
|
228,490
|
24aitor/Localizer
|
src/Builder.php
|
Builder.getLanguage
|
public static function getLanguage($code = 'default')
{
if ($code == 'default') {
$code = App::getLocale();
}
return self::addNames([$code])[$code];
}
|
php
|
public static function getLanguage($code = 'default')
{
if ($code == 'default') {
$code = App::getLocale();
}
return self::addNames([$code])[$code];
}
|
[
"public",
"static",
"function",
"getLanguage",
"(",
"$",
"code",
"=",
"'default'",
")",
"{",
"if",
"(",
"$",
"code",
"==",
"'default'",
")",
"{",
"$",
"code",
"=",
"App",
"::",
"getLocale",
"(",
")",
";",
"}",
"return",
"self",
"::",
"addNames",
"(",
"[",
"$",
"code",
"]",
")",
"[",
"$",
"code",
"]",
";",
"}"
] |
Returns the language name.
@return string
|
[
"Returns",
"the",
"language",
"name",
"."
] |
3f234dfeab1030119148ece01f61d79dba27ac67
|
https://github.com/24aitor/Localizer/blob/3f234dfeab1030119148ece01f61d79dba27ac67/src/Builder.php#L136-L143
|
228,491
|
antaresproject/core
|
src/components/html/src/Form/FormBuilder.php
|
FormBuilder.clientSubmit
|
protected function clientSubmit($buttons)
{
if (empty($buttons)) {
return false;
}
$scripts = false;
foreach ($buttons as $button) {
if (array_get($button instanceof AbstractType ? $button->getAttributes() : $button->attributes, 'type') !== 'submit' or array_get($button instanceof AbstractType ? $button->getAttributes() : $button->attributes, 'disable_client_submit', false) == true
) {
continue;
}
$atttibutes = $button instanceof AbstractType ? $button->getAttributes() : $button->attributes;
if (isset($atttibutes['disable_client_submit'])) {
unset($atttibutes['disable_client_submit']);
}
$atttibutes['class'] = array_get($atttibutes, 'class', '') . ' client-submit';
$atttibutes['data-title'] = trans('antares/foundation::messages.are_you_sure');
$button->attributes = $button instanceof AbstractType ? $button->getAttributes() : $button->attributes;
$scripts = true;
}
if ($scripts) {
publish(null, '/packages/core/js/submitter.js');
}
return $buttons;
}
|
php
|
protected function clientSubmit($buttons)
{
if (empty($buttons)) {
return false;
}
$scripts = false;
foreach ($buttons as $button) {
if (array_get($button instanceof AbstractType ? $button->getAttributes() : $button->attributes, 'type') !== 'submit' or array_get($button instanceof AbstractType ? $button->getAttributes() : $button->attributes, 'disable_client_submit', false) == true
) {
continue;
}
$atttibutes = $button instanceof AbstractType ? $button->getAttributes() : $button->attributes;
if (isset($atttibutes['disable_client_submit'])) {
unset($atttibutes['disable_client_submit']);
}
$atttibutes['class'] = array_get($atttibutes, 'class', '') . ' client-submit';
$atttibutes['data-title'] = trans('antares/foundation::messages.are_you_sure');
$button->attributes = $button instanceof AbstractType ? $button->getAttributes() : $button->attributes;
$scripts = true;
}
if ($scripts) {
publish(null, '/packages/core/js/submitter.js');
}
return $buttons;
}
|
[
"protected",
"function",
"clientSubmit",
"(",
"$",
"buttons",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"buttons",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"scripts",
"=",
"false",
";",
"foreach",
"(",
"$",
"buttons",
"as",
"$",
"button",
")",
"{",
"if",
"(",
"array_get",
"(",
"$",
"button",
"instanceof",
"AbstractType",
"?",
"$",
"button",
"->",
"getAttributes",
"(",
")",
":",
"$",
"button",
"->",
"attributes",
",",
"'type'",
")",
"!==",
"'submit'",
"or",
"array_get",
"(",
"$",
"button",
"instanceof",
"AbstractType",
"?",
"$",
"button",
"->",
"getAttributes",
"(",
")",
":",
"$",
"button",
"->",
"attributes",
",",
"'disable_client_submit'",
",",
"false",
")",
"==",
"true",
")",
"{",
"continue",
";",
"}",
"$",
"atttibutes",
"=",
"$",
"button",
"instanceof",
"AbstractType",
"?",
"$",
"button",
"->",
"getAttributes",
"(",
")",
":",
"$",
"button",
"->",
"attributes",
";",
"if",
"(",
"isset",
"(",
"$",
"atttibutes",
"[",
"'disable_client_submit'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"atttibutes",
"[",
"'disable_client_submit'",
"]",
")",
";",
"}",
"$",
"atttibutes",
"[",
"'class'",
"]",
"=",
"array_get",
"(",
"$",
"atttibutes",
",",
"'class'",
",",
"''",
")",
".",
"' client-submit'",
";",
"$",
"atttibutes",
"[",
"'data-title'",
"]",
"=",
"trans",
"(",
"'antares/foundation::messages.are_you_sure'",
")",
";",
"$",
"button",
"->",
"attributes",
"=",
"$",
"button",
"instanceof",
"AbstractType",
"?",
"$",
"button",
"->",
"getAttributes",
"(",
")",
":",
"$",
"button",
"->",
"attributes",
";",
"$",
"scripts",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"scripts",
")",
"{",
"publish",
"(",
"null",
",",
"'/packages/core/js/submitter.js'",
")",
";",
"}",
"return",
"$",
"buttons",
";",
"}"
] |
Whether form can be submited by Ctrl+Enter
@param array $buttons
@return boolean
|
[
"Whether",
"form",
"can",
"be",
"submited",
"by",
"Ctrl",
"+",
"Enter"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/FormBuilder.php#L176-L202
|
228,492
|
antaresproject/core
|
src/components/html/src/Form/FormBuilder.php
|
FormBuilder.addHiddenKey
|
protected function addHiddenKey(GridContract $grid)
{
$fieldsets = $grid->fieldsets();
if ($fieldsets->isEmpty()) {
return false;
}
$name = $fieldsets->first()->name;
$name instanceof Closure and $name = sprintf('fieldset-%d', $fieldsets->count());
$slugged = str_slug($name);
$grid->hidden('key', function($field) use($slugged) {
$control = Memory::make('runtime')->get('control');
$field->value = $this->hiddenKey = Crypt::encrypt(implode('::', [$control['component'], $control['action'], $control['method'], $slugged]));
return $field;
});
return true;
}
|
php
|
protected function addHiddenKey(GridContract $grid)
{
$fieldsets = $grid->fieldsets();
if ($fieldsets->isEmpty()) {
return false;
}
$name = $fieldsets->first()->name;
$name instanceof Closure and $name = sprintf('fieldset-%d', $fieldsets->count());
$slugged = str_slug($name);
$grid->hidden('key', function($field) use($slugged) {
$control = Memory::make('runtime')->get('control');
$field->value = $this->hiddenKey = Crypt::encrypt(implode('::', [$control['component'], $control['action'], $control['method'], $slugged]));
return $field;
});
return true;
}
|
[
"protected",
"function",
"addHiddenKey",
"(",
"GridContract",
"$",
"grid",
")",
"{",
"$",
"fieldsets",
"=",
"$",
"grid",
"->",
"fieldsets",
"(",
")",
";",
"if",
"(",
"$",
"fieldsets",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"name",
"=",
"$",
"fieldsets",
"->",
"first",
"(",
")",
"->",
"name",
";",
"$",
"name",
"instanceof",
"Closure",
"and",
"$",
"name",
"=",
"sprintf",
"(",
"'fieldset-%d'",
",",
"$",
"fieldsets",
"->",
"count",
"(",
")",
")",
";",
"$",
"slugged",
"=",
"str_slug",
"(",
"$",
"name",
")",
";",
"$",
"grid",
"->",
"hidden",
"(",
"'key'",
",",
"function",
"(",
"$",
"field",
")",
"use",
"(",
"$",
"slugged",
")",
"{",
"$",
"control",
"=",
"Memory",
"::",
"make",
"(",
"'runtime'",
")",
"->",
"get",
"(",
"'control'",
")",
";",
"$",
"field",
"->",
"value",
"=",
"$",
"this",
"->",
"hiddenKey",
"=",
"Crypt",
"::",
"encrypt",
"(",
"implode",
"(",
"'::'",
",",
"[",
"$",
"control",
"[",
"'component'",
"]",
",",
"$",
"control",
"[",
"'action'",
"]",
",",
"$",
"control",
"[",
"'method'",
"]",
",",
"$",
"slugged",
"]",
")",
")",
";",
"return",
"$",
"field",
";",
"}",
")",
";",
"return",
"true",
";",
"}"
] |
append hidden key with resource info
@param GridContract $grid
@return boolean
|
[
"append",
"hidden",
"key",
"with",
"resource",
"info"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/FormBuilder.php#L210-L225
|
228,493
|
antaresproject/core
|
src/components/html/src/Form/FormBuilder.php
|
FormBuilder.setCustomFieldsValidator
|
public function setCustomFieldsValidator($on, $event, array $attributes = array())
{
$this->customFieldsValidator[$on] = [$event => $attributes];
return $this;
}
|
php
|
public function setCustomFieldsValidator($on, $event, array $attributes = array())
{
$this->customFieldsValidator[$on] = [$event => $attributes];
return $this;
}
|
[
"public",
"function",
"setCustomFieldsValidator",
"(",
"$",
"on",
",",
"$",
"event",
",",
"array",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"customFieldsValidator",
"[",
"$",
"on",
"]",
"=",
"[",
"$",
"event",
"=>",
"$",
"attributes",
"]",
";",
"return",
"$",
"this",
";",
"}"
] |
custom fields validator setter
@param String $on
@param String $event
@param array $attributes
@return \Antares\Html\Form\FormBuilder
|
[
"custom",
"fields",
"validator",
"setter"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/FormBuilder.php#L245-L249
|
228,494
|
antaresproject/core
|
src/components/html/src/Form/FormBuilder.php
|
FormBuilder.isValid
|
public function isValid($sendHeaders = true)
{
app(\Antares\Html\Adapter\CustomfieldAdapter::class)->adapt($this->grid);
$decryptedKey = is_null($key = Input::get('key')) ? null : Crypt::decrypt($key);
if ($this->grid->ajaxable !== false && !$this->container->make('antares.request')->shouldMakeApiResponse()) {
$clientScript = $this->clientScript->addClientValidation($this->grid);
$fieldsets = $clientScript['fieldsets'];
$this->fieldPermissionAdapter->resolveFields($fieldsets, $decryptedKey);
$this->rules($fieldsets);
} else {
$fieldsets = $this->grid->fieldsets();
$this->fieldPermissionAdapter->resolveFields($fieldsets, $decryptedKey);
$this->rules($fieldsets);
}
$validator = $this->validator->with($this->grid);
$validator->withCustomFields($this->customFieldsValidator);
$result = $validator->validate($sendHeaders);
$this->messageBag = $validator->getMessageBag();
return $result;
}
|
php
|
public function isValid($sendHeaders = true)
{
app(\Antares\Html\Adapter\CustomfieldAdapter::class)->adapt($this->grid);
$decryptedKey = is_null($key = Input::get('key')) ? null : Crypt::decrypt($key);
if ($this->grid->ajaxable !== false && !$this->container->make('antares.request')->shouldMakeApiResponse()) {
$clientScript = $this->clientScript->addClientValidation($this->grid);
$fieldsets = $clientScript['fieldsets'];
$this->fieldPermissionAdapter->resolveFields($fieldsets, $decryptedKey);
$this->rules($fieldsets);
} else {
$fieldsets = $this->grid->fieldsets();
$this->fieldPermissionAdapter->resolveFields($fieldsets, $decryptedKey);
$this->rules($fieldsets);
}
$validator = $this->validator->with($this->grid);
$validator->withCustomFields($this->customFieldsValidator);
$result = $validator->validate($sendHeaders);
$this->messageBag = $validator->getMessageBag();
return $result;
}
|
[
"public",
"function",
"isValid",
"(",
"$",
"sendHeaders",
"=",
"true",
")",
"{",
"app",
"(",
"\\",
"Antares",
"\\",
"Html",
"\\",
"Adapter",
"\\",
"CustomfieldAdapter",
"::",
"class",
")",
"->",
"adapt",
"(",
"$",
"this",
"->",
"grid",
")",
";",
"$",
"decryptedKey",
"=",
"is_null",
"(",
"$",
"key",
"=",
"Input",
"::",
"get",
"(",
"'key'",
")",
")",
"?",
"null",
":",
"Crypt",
"::",
"decrypt",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"this",
"->",
"grid",
"->",
"ajaxable",
"!==",
"false",
"&&",
"!",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"'antares.request'",
")",
"->",
"shouldMakeApiResponse",
"(",
")",
")",
"{",
"$",
"clientScript",
"=",
"$",
"this",
"->",
"clientScript",
"->",
"addClientValidation",
"(",
"$",
"this",
"->",
"grid",
")",
";",
"$",
"fieldsets",
"=",
"$",
"clientScript",
"[",
"'fieldsets'",
"]",
";",
"$",
"this",
"->",
"fieldPermissionAdapter",
"->",
"resolveFields",
"(",
"$",
"fieldsets",
",",
"$",
"decryptedKey",
")",
";",
"$",
"this",
"->",
"rules",
"(",
"$",
"fieldsets",
")",
";",
"}",
"else",
"{",
"$",
"fieldsets",
"=",
"$",
"this",
"->",
"grid",
"->",
"fieldsets",
"(",
")",
";",
"$",
"this",
"->",
"fieldPermissionAdapter",
"->",
"resolveFields",
"(",
"$",
"fieldsets",
",",
"$",
"decryptedKey",
")",
";",
"$",
"this",
"->",
"rules",
"(",
"$",
"fieldsets",
")",
";",
"}",
"$",
"validator",
"=",
"$",
"this",
"->",
"validator",
"->",
"with",
"(",
"$",
"this",
"->",
"grid",
")",
";",
"$",
"validator",
"->",
"withCustomFields",
"(",
"$",
"this",
"->",
"customFieldsValidator",
")",
";",
"$",
"result",
"=",
"$",
"validator",
"->",
"validate",
"(",
"$",
"sendHeaders",
")",
";",
"$",
"this",
"->",
"messageBag",
"=",
"$",
"validator",
"->",
"getMessageBag",
"(",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
does the form is valid
@return mixed
|
[
"does",
"the",
"form",
"is",
"valid"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/FormBuilder.php#L256-L281
|
228,495
|
antaresproject/core
|
src/components/html/src/Form/FormBuilder.php
|
FormBuilder.rules
|
protected function rules(Collection $fieldsets)
{
$grid = $this->grid;
if (!empty($grid->rules)) {
$controls = [];
foreach ($fieldsets as $fieldset) {
foreach ($fieldset->controls() as $control) {
array_push(
$controls, method_exists($control, 'getName') ? $control->getName() : $control->name
);
}
}
$rulesDispatcher = new RulesDispatcher($grid->rules);
$this->grid->rules($rulesDispatcher->getSupported($controls));
}
}
|
php
|
protected function rules(Collection $fieldsets)
{
$grid = $this->grid;
if (!empty($grid->rules)) {
$controls = [];
foreach ($fieldsets as $fieldset) {
foreach ($fieldset->controls() as $control) {
array_push(
$controls, method_exists($control, 'getName') ? $control->getName() : $control->name
);
}
}
$rulesDispatcher = new RulesDispatcher($grid->rules);
$this->grid->rules($rulesDispatcher->getSupported($controls));
}
}
|
[
"protected",
"function",
"rules",
"(",
"Collection",
"$",
"fieldsets",
")",
"{",
"$",
"grid",
"=",
"$",
"this",
"->",
"grid",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"grid",
"->",
"rules",
")",
")",
"{",
"$",
"controls",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fieldsets",
"as",
"$",
"fieldset",
")",
"{",
"foreach",
"(",
"$",
"fieldset",
"->",
"controls",
"(",
")",
"as",
"$",
"control",
")",
"{",
"array_push",
"(",
"$",
"controls",
",",
"method_exists",
"(",
"$",
"control",
",",
"'getName'",
")",
"?",
"$",
"control",
"->",
"getName",
"(",
")",
":",
"$",
"control",
"->",
"name",
")",
";",
"}",
"}",
"$",
"rulesDispatcher",
"=",
"new",
"RulesDispatcher",
"(",
"$",
"grid",
"->",
"rules",
")",
";",
"$",
"this",
"->",
"grid",
"->",
"rules",
"(",
"$",
"rulesDispatcher",
"->",
"getSupported",
"(",
"$",
"controls",
")",
")",
";",
"}",
"}"
] |
verify rules settings depends on controls visibility
@param Collection $fieldsets
|
[
"verify",
"rules",
"settings",
"depends",
"on",
"controls",
"visibility"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/FormBuilder.php#L298-L313
|
228,496
|
antaresproject/core
|
src/components/html/src/Form/FormBuilder.php
|
FormBuilder.getData
|
public function getData()
{
$fieldsets = $this->grid->fieldsets;
$controls = [];
foreach ($fieldsets as $fieldset) {
foreach ($fieldset->controls() as $control) {
array_push($controls, $control->name);
}
}
$keys = $this->resolveWithMultiples($controls);
return array_only(inputs(), $keys);
}
|
php
|
public function getData()
{
$fieldsets = $this->grid->fieldsets;
$controls = [];
foreach ($fieldsets as $fieldset) {
foreach ($fieldset->controls() as $control) {
array_push($controls, $control->name);
}
}
$keys = $this->resolveWithMultiples($controls);
return array_only(inputs(), $keys);
}
|
[
"public",
"function",
"getData",
"(",
")",
"{",
"$",
"fieldsets",
"=",
"$",
"this",
"->",
"grid",
"->",
"fieldsets",
";",
"$",
"controls",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fieldsets",
"as",
"$",
"fieldset",
")",
"{",
"foreach",
"(",
"$",
"fieldset",
"->",
"controls",
"(",
")",
"as",
"$",
"control",
")",
"{",
"array_push",
"(",
"$",
"controls",
",",
"$",
"control",
"->",
"name",
")",
";",
"}",
"}",
"$",
"keys",
"=",
"$",
"this",
"->",
"resolveWithMultiples",
"(",
"$",
"controls",
")",
";",
"return",
"array_only",
"(",
"inputs",
"(",
")",
",",
"$",
"keys",
")",
";",
"}"
] |
gets data from post by form controls
@return array
|
[
"gets",
"data",
"from",
"post",
"by",
"form",
"controls"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/FormBuilder.php#L320-L331
|
228,497
|
antaresproject/core
|
src/components/html/src/Form/FormBuilder.php
|
FormBuilder.resolveWithMultiples
|
protected function resolveWithMultiples(array $controlKeys = array())
{
$return = [];
foreach ($controlKeys as $key) {
preg_match_all("/\[[^\]]*\]/", $key, $matches);
if (isset($matches[0])) {
$key = str_replace(is_array($matches[0]) ? implode('', $matches[0]) : $matches[0], '', $key);
}
array_push($return, $key);
}
return array_unique($return);
}
|
php
|
protected function resolveWithMultiples(array $controlKeys = array())
{
$return = [];
foreach ($controlKeys as $key) {
preg_match_all("/\[[^\]]*\]/", $key, $matches);
if (isset($matches[0])) {
$key = str_replace(is_array($matches[0]) ? implode('', $matches[0]) : $matches[0], '', $key);
}
array_push($return, $key);
}
return array_unique($return);
}
|
[
"protected",
"function",
"resolveWithMultiples",
"(",
"array",
"$",
"controlKeys",
"=",
"array",
"(",
")",
")",
"{",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"controlKeys",
"as",
"$",
"key",
")",
"{",
"preg_match_all",
"(",
"\"/\\[[^\\]]*\\]/\"",
",",
"$",
"key",
",",
"$",
"matches",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
")",
"{",
"$",
"key",
"=",
"str_replace",
"(",
"is_array",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
"?",
"implode",
"(",
"''",
",",
"$",
"matches",
"[",
"0",
"]",
")",
":",
"$",
"matches",
"[",
"0",
"]",
",",
"''",
",",
"$",
"key",
")",
";",
"}",
"array_push",
"(",
"$",
"return",
",",
"$",
"key",
")",
";",
"}",
"return",
"array_unique",
"(",
"$",
"return",
")",
";",
"}"
] |
resolve form keys with multiple fields
@param array $controlKeys
@return array
|
[
"resolve",
"form",
"keys",
"with",
"multiple",
"fields"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/FormBuilder.php#L339-L350
|
228,498
|
antaresproject/core
|
src/components/notifier/src/Adapter/FastSmsAdapter.php
|
FastSmsAdapter.validate
|
protected function validate()
{
$result = $this->request($action = 'CheckCredits');
if ((int) $result <= 0) {
throw new Exception($this->config['codes']['-100']);
}
return $result;
}
|
php
|
protected function validate()
{
$result = $this->request($action = 'CheckCredits');
if ((int) $result <= 0) {
throw new Exception($this->config['codes']['-100']);
}
return $result;
}
|
[
"protected",
"function",
"validate",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"action",
"=",
"'CheckCredits'",
")",
";",
"if",
"(",
"(",
"int",
")",
"$",
"result",
"<=",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"this",
"->",
"config",
"[",
"'codes'",
"]",
"[",
"'-100'",
"]",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Validates whether connection to gateway is established
@return mixed
@throws Exception
|
[
"Validates",
"whether",
"connection",
"to",
"gateway",
"is",
"established"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/notifier/src/Adapter/FastSmsAdapter.php#L97-L104
|
228,499
|
antaresproject/core
|
src/components/notifier/src/Adapter/FastSmsAdapter.php
|
FastSmsAdapter.request
|
protected function request($action = '', array $params = [])
{
$params['Token'] = $this->config['api']['token'];
if ($action !== '') {
$params['Action'] = $action;
}
$query = http_build_query($params);
$url = $this->config['api']['url'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($ch);
curl_close($ch);
if (!$result) {
throw new Exception('Connection failed. Reason unknown.');
}
return $result;
}
|
php
|
protected function request($action = '', array $params = [])
{
$params['Token'] = $this->config['api']['token'];
if ($action !== '') {
$params['Action'] = $action;
}
$query = http_build_query($params);
$url = $this->config['api']['url'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$result = curl_exec($ch);
curl_close($ch);
if (!$result) {
throw new Exception('Connection failed. Reason unknown.');
}
return $result;
}
|
[
"protected",
"function",
"request",
"(",
"$",
"action",
"=",
"''",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"[",
"'Token'",
"]",
"=",
"$",
"this",
"->",
"config",
"[",
"'api'",
"]",
"[",
"'token'",
"]",
";",
"if",
"(",
"$",
"action",
"!==",
"''",
")",
"{",
"$",
"params",
"[",
"'Action'",
"]",
"=",
"$",
"action",
";",
"}",
"$",
"query",
"=",
"http_build_query",
"(",
"$",
"params",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"config",
"[",
"'api'",
"]",
"[",
"'url'",
"]",
";",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HEADER",
",",
"0",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POST",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"query",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_SSL_VERIFYPEER",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_TIMEOUT",
",",
"60",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_SSL_VERIFYHOST",
",",
"0",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_SSL_VERIFYPEER",
",",
"0",
")",
";",
"$",
"result",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"curl_close",
"(",
"$",
"ch",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Connection failed. Reason unknown.'",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Creates request to sms gateway
@param String $action
@param array $params
@return mixed
@throws Exception
|
[
"Creates",
"request",
"to",
"sms",
"gateway"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/notifier/src/Adapter/FastSmsAdapter.php#L114-L147
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.