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,500
|
antaresproject/core
|
src/utils/form/src/Traits/SelectTypeFunctionsTrait.php
|
SelectTypeFunctionsTrait.setSearch
|
public function setSearch(bool $search): self
{
if (!$this instanceof Attributable) {
return $this;
}
$searchOption = 'data-selectAR--search';
$search ? $this->setAttribute($searchOption, true) : $this->removeAttribute($searchOption);
if ($this->hasAttribute('data-selectAR')) {
$this->removeAttribute('data-selectAR');
}
return $this;
}
|
php
|
public function setSearch(bool $search): self
{
if (!$this instanceof Attributable) {
return $this;
}
$searchOption = 'data-selectAR--search';
$search ? $this->setAttribute($searchOption, true) : $this->removeAttribute($searchOption);
if ($this->hasAttribute('data-selectAR')) {
$this->removeAttribute('data-selectAR');
}
return $this;
}
|
[
"public",
"function",
"setSearch",
"(",
"bool",
"$",
"search",
")",
":",
"self",
"{",
"if",
"(",
"!",
"$",
"this",
"instanceof",
"Attributable",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"searchOption",
"=",
"'data-selectAR--search'",
";",
"$",
"search",
"?",
"$",
"this",
"->",
"setAttribute",
"(",
"$",
"searchOption",
",",
"true",
")",
":",
"$",
"this",
"->",
"removeAttribute",
"(",
"$",
"searchOption",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasAttribute",
"(",
"'data-selectAR'",
")",
")",
"{",
"$",
"this",
"->",
"removeAttribute",
"(",
"'data-selectAR'",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Turn on or off search feature for this select
@param bool $search
@return $this|bool
|
[
"Turn",
"on",
"or",
"off",
"search",
"feature",
"for",
"this",
"select"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/form/src/Traits/SelectTypeFunctionsTrait.php#L57-L71
|
228,501
|
antaresproject/core
|
src/foundation/src/Listeners/DatatableDependableActions.php
|
DatatableDependableActions.getActions
|
protected function getActions($row)
{
$classname = get_class($row);
return (array_key_exists($classname, $this->actions)) ? array_get($this->actions, $classname, []) : [];
}
|
php
|
protected function getActions($row)
{
$classname = get_class($row);
return (array_key_exists($classname, $this->actions)) ? array_get($this->actions, $classname, []) : [];
}
|
[
"protected",
"function",
"getActions",
"(",
"$",
"row",
")",
"{",
"$",
"classname",
"=",
"get_class",
"(",
"$",
"row",
")",
";",
"return",
"(",
"array_key_exists",
"(",
"$",
"classname",
",",
"$",
"this",
"->",
"actions",
")",
")",
"?",
"array_get",
"(",
"$",
"this",
"->",
"actions",
",",
"$",
"classname",
",",
"[",
"]",
")",
":",
"[",
"]",
";",
"}"
] |
Gets datatable actions
@param \Illuminate\Database\Eloquent\Model $row
@return array
|
[
"Gets",
"datatable",
"actions"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Listeners/DatatableDependableActions.php#L85-L89
|
228,502
|
lawoole/framework
|
src/Homer/Components/ReferenceComponent.php
|
ReferenceComponent.refer
|
public function refer()
{
if ($this->context == null) {
throw new LogicException('Context must be set before refer to the service.');
}
if ($this->proxyFactory == null) {
throw new LogicException('Proxy factory must be set before refer to the service.');
}
if ($this->clientFactory == null) {
throw new LogicException('Client factory must be set before refer to the service.');
}
$identify = $this->config['id'] ?? $this->config['interface'] ?? null;
$this->container->instance($identify, $this->getProxy());
}
|
php
|
public function refer()
{
if ($this->context == null) {
throw new LogicException('Context must be set before refer to the service.');
}
if ($this->proxyFactory == null) {
throw new LogicException('Proxy factory must be set before refer to the service.');
}
if ($this->clientFactory == null) {
throw new LogicException('Client factory must be set before refer to the service.');
}
$identify = $this->config['id'] ?? $this->config['interface'] ?? null;
$this->container->instance($identify, $this->getProxy());
}
|
[
"public",
"function",
"refer",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"context",
"==",
"null",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Context must be set before refer to the service.'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"proxyFactory",
"==",
"null",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Proxy factory must be set before refer to the service.'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"clientFactory",
"==",
"null",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Client factory must be set before refer to the service.'",
")",
";",
"}",
"$",
"identify",
"=",
"$",
"this",
"->",
"config",
"[",
"'id'",
"]",
"??",
"$",
"this",
"->",
"config",
"[",
"'interface'",
"]",
"??",
"null",
";",
"$",
"this",
"->",
"container",
"->",
"instance",
"(",
"$",
"identify",
",",
"$",
"this",
"->",
"getProxy",
"(",
")",
")",
";",
"}"
] |
Reference the interface.
|
[
"Reference",
"the",
"interface",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Components/ReferenceComponent.php#L86-L103
|
228,503
|
lawoole/framework
|
src/Homer/Components/ReferenceComponent.php
|
ReferenceComponent.getProxy
|
public function getProxy()
{
if ($this->proxy !== null) {
return $this->proxy;
}
return $this->proxy = $this->createProxy();
}
|
php
|
public function getProxy()
{
if ($this->proxy !== null) {
return $this->proxy;
}
return $this->proxy = $this->createProxy();
}
|
[
"public",
"function",
"getProxy",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"proxy",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"proxy",
";",
"}",
"return",
"$",
"this",
"->",
"proxy",
"=",
"$",
"this",
"->",
"createProxy",
"(",
")",
";",
"}"
] |
Get the calling proxy of interface.
@return mixed
|
[
"Get",
"the",
"calling",
"proxy",
"of",
"interface",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Components/ReferenceComponent.php#L110-L117
|
228,504
|
lawoole/framework
|
src/Homer/Components/ReferenceComponent.php
|
ReferenceComponent.createProxy
|
protected function createProxy()
{
$config = $this->config;
$interface = Arr::pull($config, 'interface');
$client = $this->clientFactory->client(Arr::pull($config, 'client'));
$invoker = new RemoteInvoker($this->context, $client, $interface, $config);
$invoker = $this->withMiddleware($invoker, $interface, $config);
return $this->proxyFactory->proxy($invoker);
}
|
php
|
protected function createProxy()
{
$config = $this->config;
$interface = Arr::pull($config, 'interface');
$client = $this->clientFactory->client(Arr::pull($config, 'client'));
$invoker = new RemoteInvoker($this->context, $client, $interface, $config);
$invoker = $this->withMiddleware($invoker, $interface, $config);
return $this->proxyFactory->proxy($invoker);
}
|
[
"protected",
"function",
"createProxy",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
";",
"$",
"interface",
"=",
"Arr",
"::",
"pull",
"(",
"$",
"config",
",",
"'interface'",
")",
";",
"$",
"client",
"=",
"$",
"this",
"->",
"clientFactory",
"->",
"client",
"(",
"Arr",
"::",
"pull",
"(",
"$",
"config",
",",
"'client'",
")",
")",
";",
"$",
"invoker",
"=",
"new",
"RemoteInvoker",
"(",
"$",
"this",
"->",
"context",
",",
"$",
"client",
",",
"$",
"interface",
",",
"$",
"config",
")",
";",
"$",
"invoker",
"=",
"$",
"this",
"->",
"withMiddleware",
"(",
"$",
"invoker",
",",
"$",
"interface",
",",
"$",
"config",
")",
";",
"return",
"$",
"this",
"->",
"proxyFactory",
"->",
"proxy",
"(",
"$",
"invoker",
")",
";",
"}"
] |
Create the calling proxy.
@return mixed
|
[
"Create",
"the",
"calling",
"proxy",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Components/ReferenceComponent.php#L124-L137
|
228,505
|
antaresproject/core
|
src/ui/components/datatables/src/Session/PerPage.php
|
PerPage.get
|
public function get(DataTable $datatable)
{
if (php_sapi_name() === 'cli') {
return 10;
}
if (!$this->request->hasSession()) {
return;
}
$key = $this->getSessionKey(get_class($datatable));
$perPage = $this->getFromSession($key, (int) request('length', $datatable->perPage));
return is_null($perPage) ? 10 : $perPage;
}
|
php
|
public function get(DataTable $datatable)
{
if (php_sapi_name() === 'cli') {
return 10;
}
if (!$this->request->hasSession()) {
return;
}
$key = $this->getSessionKey(get_class($datatable));
$perPage = $this->getFromSession($key, (int) request('length', $datatable->perPage));
return is_null($perPage) ? 10 : $perPage;
}
|
[
"public",
"function",
"get",
"(",
"DataTable",
"$",
"datatable",
")",
"{",
"if",
"(",
"php_sapi_name",
"(",
")",
"===",
"'cli'",
")",
"{",
"return",
"10",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"request",
"->",
"hasSession",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"key",
"=",
"$",
"this",
"->",
"getSessionKey",
"(",
"get_class",
"(",
"$",
"datatable",
")",
")",
";",
"$",
"perPage",
"=",
"$",
"this",
"->",
"getFromSession",
"(",
"$",
"key",
",",
"(",
"int",
")",
"request",
"(",
"'length'",
",",
"$",
"datatable",
"->",
"perPage",
")",
")",
";",
"return",
"is_null",
"(",
"$",
"perPage",
")",
"?",
"10",
":",
"$",
"perPage",
";",
"}"
] |
Session perpage getter
@param DataTable $datatable
@return mixed
|
[
"Session",
"perpage",
"getter"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Session/PerPage.php#L34-L46
|
228,506
|
antaresproject/core
|
src/ui/components/templates/src/Processor/UpdateProcessor.php
|
UpdateProcessor.edit
|
public function edit(Listener $listener, $id)
{
$eloquent = with(new Eloquent())->findOrNew($id);
$name = $eloquent->name;
$raw = app('antares.memory')->make('ui-components')->raw();
$data = isset($raw[$name]['data']) ? $raw[$name]['data'] : [];
if (!empty($data)) {
foreach ($data as $attribute => $value) {
$eloquent->{$attribute} = $value;
}
}
$form = $this->presenter->form($name, $eloquent, "antares::ui-components/updater");
return $listener->showComponentUpdater($id, compact('form'));
}
|
php
|
public function edit(Listener $listener, $id)
{
$eloquent = with(new Eloquent())->findOrNew($id);
$name = $eloquent->name;
$raw = app('antares.memory')->make('ui-components')->raw();
$data = isset($raw[$name]['data']) ? $raw[$name]['data'] : [];
if (!empty($data)) {
foreach ($data as $attribute => $value) {
$eloquent->{$attribute} = $value;
}
}
$form = $this->presenter->form($name, $eloquent, "antares::ui-components/updater");
return $listener->showComponentUpdater($id, compact('form'));
}
|
[
"public",
"function",
"edit",
"(",
"Listener",
"$",
"listener",
",",
"$",
"id",
")",
"{",
"$",
"eloquent",
"=",
"with",
"(",
"new",
"Eloquent",
"(",
")",
")",
"->",
"findOrNew",
"(",
"$",
"id",
")",
";",
"$",
"name",
"=",
"$",
"eloquent",
"->",
"name",
";",
"$",
"raw",
"=",
"app",
"(",
"'antares.memory'",
")",
"->",
"make",
"(",
"'ui-components'",
")",
"->",
"raw",
"(",
")",
";",
"$",
"data",
"=",
"isset",
"(",
"$",
"raw",
"[",
"$",
"name",
"]",
"[",
"'data'",
"]",
")",
"?",
"$",
"raw",
"[",
"$",
"name",
"]",
"[",
"'data'",
"]",
":",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"attribute",
"=>",
"$",
"value",
")",
"{",
"$",
"eloquent",
"->",
"{",
"$",
"attribute",
"}",
"=",
"$",
"value",
";",
"}",
"}",
"$",
"form",
"=",
"$",
"this",
"->",
"presenter",
"->",
"form",
"(",
"$",
"name",
",",
"$",
"eloquent",
",",
"\"antares::ui-components/updater\"",
")",
";",
"return",
"$",
"listener",
"->",
"showComponentUpdater",
"(",
"$",
"id",
",",
"compact",
"(",
"'form'",
")",
")",
";",
"}"
] |
Shows create form
@param Listener $listener
@return mixed
|
[
"Shows",
"create",
"form"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Processor/UpdateProcessor.php#L49-L62
|
228,507
|
antaresproject/core
|
src/ui/components/templates/src/Processor/UpdateProcessor.php
|
UpdateProcessor.update
|
public function update(Listener $listener, $id, array $input)
{
$model = with(new Eloquent())->findOrNew($id);
$memory = app('antares.memory')->make('ui-components');
$className = $memory->get($model->name . '.name');
$component = with(new $className($model->id));
$rules = $component->getRules();
if (empty($rules)) {
return Response::json([], 200);
}
$validation = ValidatorFacade::make($input, $rules);
if ($validation->fails()) {
if (app('request')->ajax()) {
return Response::json($validation->getMessageBag()->getMessages(), 200);
}
return $listener->whenValidationFailed($validation->getMessageBag());
} else {
$controls = $component->controls();
$value = unserialize($model->value);
$value['data'] = array_only($input, $controls);
$model->value = serialize($value);
$model->save();
$memory->getHandler()->forgetCache($this->getResource());
return Response::json([], 200);
}
}
|
php
|
public function update(Listener $listener, $id, array $input)
{
$model = with(new Eloquent())->findOrNew($id);
$memory = app('antares.memory')->make('ui-components');
$className = $memory->get($model->name . '.name');
$component = with(new $className($model->id));
$rules = $component->getRules();
if (empty($rules)) {
return Response::json([], 200);
}
$validation = ValidatorFacade::make($input, $rules);
if ($validation->fails()) {
if (app('request')->ajax()) {
return Response::json($validation->getMessageBag()->getMessages(), 200);
}
return $listener->whenValidationFailed($validation->getMessageBag());
} else {
$controls = $component->controls();
$value = unserialize($model->value);
$value['data'] = array_only($input, $controls);
$model->value = serialize($value);
$model->save();
$memory->getHandler()->forgetCache($this->getResource());
return Response::json([], 200);
}
}
|
[
"public",
"function",
"update",
"(",
"Listener",
"$",
"listener",
",",
"$",
"id",
",",
"array",
"$",
"input",
")",
"{",
"$",
"model",
"=",
"with",
"(",
"new",
"Eloquent",
"(",
")",
")",
"->",
"findOrNew",
"(",
"$",
"id",
")",
";",
"$",
"memory",
"=",
"app",
"(",
"'antares.memory'",
")",
"->",
"make",
"(",
"'ui-components'",
")",
";",
"$",
"className",
"=",
"$",
"memory",
"->",
"get",
"(",
"$",
"model",
"->",
"name",
".",
"'.name'",
")",
";",
"$",
"component",
"=",
"with",
"(",
"new",
"$",
"className",
"(",
"$",
"model",
"->",
"id",
")",
")",
";",
"$",
"rules",
"=",
"$",
"component",
"->",
"getRules",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"rules",
")",
")",
"{",
"return",
"Response",
"::",
"json",
"(",
"[",
"]",
",",
"200",
")",
";",
"}",
"$",
"validation",
"=",
"ValidatorFacade",
"::",
"make",
"(",
"$",
"input",
",",
"$",
"rules",
")",
";",
"if",
"(",
"$",
"validation",
"->",
"fails",
"(",
")",
")",
"{",
"if",
"(",
"app",
"(",
"'request'",
")",
"->",
"ajax",
"(",
")",
")",
"{",
"return",
"Response",
"::",
"json",
"(",
"$",
"validation",
"->",
"getMessageBag",
"(",
")",
"->",
"getMessages",
"(",
")",
",",
"200",
")",
";",
"}",
"return",
"$",
"listener",
"->",
"whenValidationFailed",
"(",
"$",
"validation",
"->",
"getMessageBag",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"controls",
"=",
"$",
"component",
"->",
"controls",
"(",
")",
";",
"$",
"value",
"=",
"unserialize",
"(",
"$",
"model",
"->",
"value",
")",
";",
"$",
"value",
"[",
"'data'",
"]",
"=",
"array_only",
"(",
"$",
"input",
",",
"$",
"controls",
")",
";",
"$",
"model",
"->",
"value",
"=",
"serialize",
"(",
"$",
"value",
")",
";",
"$",
"model",
"->",
"save",
"(",
")",
";",
"$",
"memory",
"->",
"getHandler",
"(",
")",
"->",
"forgetCache",
"(",
"$",
"this",
"->",
"getResource",
"(",
")",
")",
";",
"return",
"Response",
"::",
"json",
"(",
"[",
"]",
",",
"200",
")",
";",
"}",
"}"
] |
Updates ui component attributes
@param Listener $listener
@param mixed $id
@param array $input
@return Response
|
[
"Updates",
"ui",
"component",
"attributes"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Processor/UpdateProcessor.php#L72-L99
|
228,508
|
antaresproject/core
|
src/components/html/src/Provider/Provider.php
|
Provider.ids
|
public function ids()
{
$keyMap = $this->getHandler()->getKeyMap();
$return = [];
foreach ($keyMap as $name => $values) {
$return = array_add($return, $name, $values['id']);
}
return $return;
}
|
php
|
public function ids()
{
$keyMap = $this->getHandler()->getKeyMap();
$return = [];
foreach ($keyMap as $name => $values) {
$return = array_add($return, $name, $values['id']);
}
return $return;
}
|
[
"public",
"function",
"ids",
"(",
")",
"{",
"$",
"keyMap",
"=",
"$",
"this",
"->",
"getHandler",
"(",
")",
"->",
"getKeyMap",
"(",
")",
";",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"keyMap",
"as",
"$",
"name",
"=>",
"$",
"values",
")",
"{",
"$",
"return",
"=",
"array_add",
"(",
"$",
"return",
",",
"$",
"name",
",",
"$",
"values",
"[",
"'id'",
"]",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
get ids based on key map
@return type
|
[
"get",
"ids",
"based",
"on",
"key",
"map"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Provider/Provider.php#L35-L43
|
228,509
|
antaresproject/core
|
src/components/html/src/Provider/Provider.php
|
Provider.id
|
public function id($key = null, $default = null)
{
$element = $this->getHandler()->getKeyMapElement($key, $default);
return is_array($element) && array_key_exists('id', $element) ? (int) $element['id'] : $default;
}
|
php
|
public function id($key = null, $default = null)
{
$element = $this->getHandler()->getKeyMapElement($key, $default);
return is_array($element) && array_key_exists('id', $element) ? (int) $element['id'] : $default;
}
|
[
"public",
"function",
"id",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"getHandler",
"(",
")",
"->",
"getKeyMapElement",
"(",
"$",
"key",
",",
"$",
"default",
")",
";",
"return",
"is_array",
"(",
"$",
"element",
")",
"&&",
"array_key_exists",
"(",
"'id'",
",",
"$",
"element",
")",
"?",
"(",
"int",
")",
"$",
"element",
"[",
"'id'",
"]",
":",
"$",
"default",
";",
"}"
] |
get single key instance
@param String $key
@param mixed $default
@return mixed
|
[
"get",
"single",
"key",
"instance"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Provider/Provider.php#L52-L56
|
228,510
|
antaresproject/core
|
src/components/html/src/Provider/Provider.php
|
Provider.getNameById
|
public function getNameById($id, $default = null)
{
$keyMap = $this->getHandler()->getKeyMap();
if (empty($keyMap)) {
return $default;
}
foreach ($keyMap as $name => $value) {
if (isset($value['id']) && $value['id'] == $id) {
return $name;
}
}
return $default;
}
|
php
|
public function getNameById($id, $default = null)
{
$keyMap = $this->getHandler()->getKeyMap();
if (empty($keyMap)) {
return $default;
}
foreach ($keyMap as $name => $value) {
if (isset($value['id']) && $value['id'] == $id) {
return $name;
}
}
return $default;
}
|
[
"public",
"function",
"getNameById",
"(",
"$",
"id",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"keyMap",
"=",
"$",
"this",
"->",
"getHandler",
"(",
")",
"->",
"getKeyMap",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"keyMap",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"foreach",
"(",
"$",
"keyMap",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"value",
"[",
"'id'",
"]",
")",
"&&",
"$",
"value",
"[",
"'id'",
"]",
"==",
"$",
"id",
")",
"{",
"return",
"$",
"name",
";",
"}",
"}",
"return",
"$",
"default",
";",
"}"
] |
gets name by id
@param numeric $id
@param mixed $default
@return mixed
|
[
"gets",
"name",
"by",
"id"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Provider/Provider.php#L65-L77
|
228,511
|
antaresproject/core
|
src/ui/components/datatables/src/Engines/BaseEngine.php
|
BaseEngine.setupKeyword
|
public function setupKeyword($value)
{
if ($this->isSmartSearch()) {
$keyword = '%' . $value . '%';
if ($this->isWildcard()) {
$keyword = $this->wildcardLikeString($value);
}
// remove escaping slash added on js script request
$keyword = str_replace('\\', '%', $keyword);
return $keyword;
}
return $value;
}
|
php
|
public function setupKeyword($value)
{
if ($this->isSmartSearch()) {
$keyword = '%' . $value . '%';
if ($this->isWildcard()) {
$keyword = $this->wildcardLikeString($value);
}
// remove escaping slash added on js script request
$keyword = str_replace('\\', '%', $keyword);
return $keyword;
}
return $value;
}
|
[
"public",
"function",
"setupKeyword",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isSmartSearch",
"(",
")",
")",
"{",
"$",
"keyword",
"=",
"'%'",
".",
"$",
"value",
".",
"'%'",
";",
"if",
"(",
"$",
"this",
"->",
"isWildcard",
"(",
")",
")",
"{",
"$",
"keyword",
"=",
"$",
"this",
"->",
"wildcardLikeString",
"(",
"$",
"value",
")",
";",
"}",
"// remove escaping slash added on js script request",
"$",
"keyword",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'%'",
",",
"$",
"keyword",
")",
";",
"return",
"$",
"keyword",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Setup search keyword.
@param string $value
@return string
|
[
"Setup",
"search",
"keyword",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Engines/BaseEngine.php#L210-L224
|
228,512
|
antaresproject/core
|
src/ui/components/datatables/src/Engines/BaseEngine.php
|
BaseEngine.wildcardLikeString
|
public function wildcardLikeString($str, $lowercase = true)
{
$wild = '%';
$length = Str::length($str);
if ($length) {
for ($i = 0; $i < $length; $i++) {
$wild .= $str[$i] . '%';
}
}
if ($lowercase) {
$wild = Str::lower($wild);
}
return $wild;
}
|
php
|
public function wildcardLikeString($str, $lowercase = true)
{
$wild = '%';
$length = Str::length($str);
if ($length) {
for ($i = 0; $i < $length; $i++) {
$wild .= $str[$i] . '%';
}
}
if ($lowercase) {
$wild = Str::lower($wild);
}
return $wild;
}
|
[
"public",
"function",
"wildcardLikeString",
"(",
"$",
"str",
",",
"$",
"lowercase",
"=",
"true",
")",
"{",
"$",
"wild",
"=",
"'%'",
";",
"$",
"length",
"=",
"Str",
"::",
"length",
"(",
"$",
"str",
")",
";",
"if",
"(",
"$",
"length",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"length",
";",
"$",
"i",
"++",
")",
"{",
"$",
"wild",
".=",
"$",
"str",
"[",
"$",
"i",
"]",
".",
"'%'",
";",
"}",
"}",
"if",
"(",
"$",
"lowercase",
")",
"{",
"$",
"wild",
"=",
"Str",
"::",
"lower",
"(",
"$",
"wild",
")",
";",
"}",
"return",
"$",
"wild",
";",
"}"
] |
Adds % wildcards to the given string.
@param string $str
@param bool $lowercase
@return string
|
[
"Adds",
"%",
"wildcards",
"to",
"the",
"given",
"string",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Engines/BaseEngine.php#L253-L267
|
228,513
|
antaresproject/core
|
src/ui/components/datatables/src/Engines/BaseEngine.php
|
BaseEngine.prefixColumn
|
public function prefixColumn($column)
{
$table_names = $this->tableNames();
if (count(
array_filter($table_names, function ($value) use (&$column) {
return strpos($column, $value . '.') === 0;
})
)) {
// the column starts with one of the table names
$column = $this->prefix . $column;
}
return $column;
}
|
php
|
public function prefixColumn($column)
{
$table_names = $this->tableNames();
if (count(
array_filter($table_names, function ($value) use (&$column) {
return strpos($column, $value . '.') === 0;
})
)) {
// the column starts with one of the table names
$column = $this->prefix . $column;
}
return $column;
}
|
[
"public",
"function",
"prefixColumn",
"(",
"$",
"column",
")",
"{",
"$",
"table_names",
"=",
"$",
"this",
"->",
"tableNames",
"(",
")",
";",
"if",
"(",
"count",
"(",
"array_filter",
"(",
"$",
"table_names",
",",
"function",
"(",
"$",
"value",
")",
"use",
"(",
"&",
"$",
"column",
")",
"{",
"return",
"strpos",
"(",
"$",
"column",
",",
"$",
"value",
".",
"'.'",
")",
"===",
"0",
";",
"}",
")",
")",
")",
"{",
"// the column starts with one of the table names",
"$",
"column",
"=",
"$",
"this",
"->",
"prefix",
".",
"$",
"column",
";",
"}",
"return",
"$",
"column",
";",
"}"
] |
Will prefix column if needed.
@param string $column
@return string
|
[
"Will",
"prefix",
"column",
"if",
"needed",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Engines/BaseEngine.php#L275-L288
|
228,514
|
antaresproject/core
|
src/ui/components/datatables/src/Engines/BaseEngine.php
|
BaseEngine.tableNames
|
public function tableNames()
{
$names = [];
$query = $this->getQueryBuilder();
$names[] = $query->from;
$joins = $query->joins ?: [];
$databasePrefix = $this->prefix;
foreach ($joins as $join) {
$table = preg_split('/ as /i', $join->table);
$names[] = $table[0];
if (isset($table[1]) && !empty($databasePrefix) && strpos($table[1], $databasePrefix) == 0) {
$names[] = preg_replace('/^' . $databasePrefix . '/', '', $table[1]);
}
}
return $names;
}
|
php
|
public function tableNames()
{
$names = [];
$query = $this->getQueryBuilder();
$names[] = $query->from;
$joins = $query->joins ?: [];
$databasePrefix = $this->prefix;
foreach ($joins as $join) {
$table = preg_split('/ as /i', $join->table);
$names[] = $table[0];
if (isset($table[1]) && !empty($databasePrefix) && strpos($table[1], $databasePrefix) == 0) {
$names[] = preg_replace('/^' . $databasePrefix . '/', '', $table[1]);
}
}
return $names;
}
|
[
"public",
"function",
"tableNames",
"(",
")",
"{",
"$",
"names",
"=",
"[",
"]",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"names",
"[",
"]",
"=",
"$",
"query",
"->",
"from",
";",
"$",
"joins",
"=",
"$",
"query",
"->",
"joins",
"?",
":",
"[",
"]",
";",
"$",
"databasePrefix",
"=",
"$",
"this",
"->",
"prefix",
";",
"foreach",
"(",
"$",
"joins",
"as",
"$",
"join",
")",
"{",
"$",
"table",
"=",
"preg_split",
"(",
"'/ as /i'",
",",
"$",
"join",
"->",
"table",
")",
";",
"$",
"names",
"[",
"]",
"=",
"$",
"table",
"[",
"0",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"table",
"[",
"1",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"databasePrefix",
")",
"&&",
"strpos",
"(",
"$",
"table",
"[",
"1",
"]",
",",
"$",
"databasePrefix",
")",
"==",
"0",
")",
"{",
"$",
"names",
"[",
"]",
"=",
"preg_replace",
"(",
"'/^'",
".",
"$",
"databasePrefix",
".",
"'/'",
",",
"''",
",",
"$",
"table",
"[",
"1",
"]",
")",
";",
"}",
"}",
"return",
"$",
"names",
";",
"}"
] |
Will look through the query and all it's joins to determine the table names.
@return array
|
[
"Will",
"look",
"through",
"the",
"query",
"and",
"all",
"it",
"s",
"joins",
"to",
"determine",
"the",
"table",
"names",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Engines/BaseEngine.php#L295-L311
|
228,515
|
antaresproject/core
|
src/ui/components/datatables/src/Engines/BaseEngine.php
|
BaseEngine.getQueryBuilder
|
public function getQueryBuilder($instance = null)
{
if (!$instance) {
$instance = $this->query;
}
if ($this->isQueryBuilder()) {
return $instance;
}
return $instance->getQuery();
}
|
php
|
public function getQueryBuilder($instance = null)
{
if (!$instance) {
$instance = $this->query;
}
if ($this->isQueryBuilder()) {
return $instance;
}
return $instance->getQuery();
}
|
[
"public",
"function",
"getQueryBuilder",
"(",
"$",
"instance",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"instance",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"query",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"isQueryBuilder",
"(",
")",
")",
"{",
"return",
"$",
"instance",
";",
"}",
"return",
"$",
"instance",
"->",
"getQuery",
"(",
")",
";",
"}"
] |
Get Query Builder object.
@param mixed $instance
@return mixed
|
[
"Get",
"Query",
"Builder",
"object",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Engines/BaseEngine.php#L319-L330
|
228,516
|
antaresproject/core
|
src/ui/components/datatables/src/Engines/BaseEngine.php
|
BaseEngine.removeColumn
|
public function removeColumn()
{
$names = func_get_args();
$this->columnDef['excess'] = array_merge($this->columnDef['excess'], $names);
return $this;
}
|
php
|
public function removeColumn()
{
$names = func_get_args();
$this->columnDef['excess'] = array_merge($this->columnDef['excess'], $names);
return $this;
}
|
[
"public",
"function",
"removeColumn",
"(",
")",
"{",
"$",
"names",
"=",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"columnDef",
"[",
"'excess'",
"]",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"columnDef",
"[",
"'excess'",
"]",
",",
"$",
"names",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Remove column from collection.
@return $this
|
[
"Remove",
"column",
"from",
"collection",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Engines/BaseEngine.php#L378-L384
|
228,517
|
antaresproject/core
|
src/ui/components/datatables/src/Engines/BaseEngine.php
|
BaseEngine.filterColumn
|
public function filterColumn($column, $method)
{
$params = func_get_args();
$this->columnDef['filter'][$column] = ['method' => $method, 'parameters' => array_splice($params, 2)];
return $this;
}
|
php
|
public function filterColumn($column, $method)
{
$params = func_get_args();
$this->columnDef['filter'][$column] = ['method' => $method, 'parameters' => array_splice($params, 2)];
return $this;
}
|
[
"public",
"function",
"filterColumn",
"(",
"$",
"column",
",",
"$",
"method",
")",
"{",
"$",
"params",
"=",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"columnDef",
"[",
"'filter'",
"]",
"[",
"$",
"column",
"]",
"=",
"[",
"'method'",
"=>",
"$",
"method",
",",
"'parameters'",
"=>",
"array_splice",
"(",
"$",
"params",
",",
"2",
")",
"]",
";",
"return",
"$",
"this",
";",
"}"
] |
Override default column filter search.
@param string $column
@param string|Closure $method
@return $this
@internal param $mixed ...,... All the individual parameters required for specified $method
@internal string $1 Special variable that returns the requested search keyword.
|
[
"Override",
"default",
"column",
"filter",
"search",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Engines/BaseEngine.php#L514-L519
|
228,518
|
antaresproject/core
|
src/ui/components/datatables/src/Engines/BaseEngine.php
|
BaseEngine.orderColumn
|
public function orderColumn($column, $sql, $bindings = [])
{
$this->columnDef['order'][$column] = ['method' => 'orderByRaw', 'parameters' => [$sql, $bindings]];
return $this;
}
|
php
|
public function orderColumn($column, $sql, $bindings = [])
{
$this->columnDef['order'][$column] = ['method' => 'orderByRaw', 'parameters' => [$sql, $bindings]];
return $this;
}
|
[
"public",
"function",
"orderColumn",
"(",
"$",
"column",
",",
"$",
"sql",
",",
"$",
"bindings",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"columnDef",
"[",
"'order'",
"]",
"[",
"$",
"column",
"]",
"=",
"[",
"'method'",
"=>",
"'orderByRaw'",
",",
"'parameters'",
"=>",
"[",
"$",
"sql",
",",
"$",
"bindings",
"]",
"]",
";",
"return",
"$",
"this",
";",
"}"
] |
Override default column ordering.
@param string $column
@param string $sql
@param array $bindings
@return $this
@internal string $1 Special variable that returns the requested order direction of the column.
|
[
"Override",
"default",
"column",
"ordering",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Engines/BaseEngine.php#L530-L535
|
228,519
|
antaresproject/core
|
src/ui/components/datatables/src/Engines/BaseEngine.php
|
BaseEngine.getProcessedData
|
private function getProcessedData($object = false)
{
$processor = new DataProcessor(
$this->results(), $this->columnDef, $this->templates
);
return $processor->process($object);
}
|
php
|
private function getProcessedData($object = false)
{
$processor = new DataProcessor(
$this->results(), $this->columnDef, $this->templates
);
return $processor->process($object);
}
|
[
"private",
"function",
"getProcessedData",
"(",
"$",
"object",
"=",
"false",
")",
"{",
"$",
"processor",
"=",
"new",
"DataProcessor",
"(",
"$",
"this",
"->",
"results",
"(",
")",
",",
"$",
"this",
"->",
"columnDef",
",",
"$",
"this",
"->",
"templates",
")",
";",
"return",
"$",
"processor",
"->",
"process",
"(",
"$",
"object",
")",
";",
"}"
] |
Get processed data
@param bool|false $object
@return array
|
[
"Get",
"processed",
"data"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Engines/BaseEngine.php#L684-L691
|
228,520
|
antaresproject/core
|
src/ui/components/datatables/src/Engines/BaseEngine.php
|
BaseEngine.overrideGlobalSearch
|
public function overrideGlobalSearch(\Closure $callback, $parameters)
{
$this->autoFilter = false;
$this->isFilterApplied = true;
$this->filterCallback = $callback;
$this->filterCallbackParameters = $parameters;
}
|
php
|
public function overrideGlobalSearch(\Closure $callback, $parameters)
{
$this->autoFilter = false;
$this->isFilterApplied = true;
$this->filterCallback = $callback;
$this->filterCallbackParameters = $parameters;
}
|
[
"public",
"function",
"overrideGlobalSearch",
"(",
"\\",
"Closure",
"$",
"callback",
",",
"$",
"parameters",
")",
"{",
"$",
"this",
"->",
"autoFilter",
"=",
"false",
";",
"$",
"this",
"->",
"isFilterApplied",
"=",
"true",
";",
"$",
"this",
"->",
"filterCallback",
"=",
"$",
"callback",
";",
"$",
"this",
"->",
"filterCallbackParameters",
"=",
"$",
"parameters",
";",
"}"
] |
Update flags to disable global search
@param \Closure $callback
@param mixed $parameters
@return void
|
[
"Update",
"flags",
"to",
"disable",
"global",
"search"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Engines/BaseEngine.php#L724-L730
|
228,521
|
antaresproject/core
|
src/ui/components/datatables/src/Engines/BaseEngine.php
|
BaseEngine.getColumnName
|
public function getColumnName($index, $wantsAlias = false)
{
$column = $this->request->columnName($index);
// DataTables is using make(false)
if (is_numeric($column)) {
$column = $this->getColumnNameByIndex($index);
}
if (Str::contains(Str::upper($column), ' AS ')) {
$column = $this->extractColumnName($column, $wantsAlias);
}
return $column;
}
|
php
|
public function getColumnName($index, $wantsAlias = false)
{
$column = $this->request->columnName($index);
// DataTables is using make(false)
if (is_numeric($column)) {
$column = $this->getColumnNameByIndex($index);
}
if (Str::contains(Str::upper($column), ' AS ')) {
$column = $this->extractColumnName($column, $wantsAlias);
}
return $column;
}
|
[
"public",
"function",
"getColumnName",
"(",
"$",
"index",
",",
"$",
"wantsAlias",
"=",
"false",
")",
"{",
"$",
"column",
"=",
"$",
"this",
"->",
"request",
"->",
"columnName",
"(",
"$",
"index",
")",
";",
"// DataTables is using make(false)",
"if",
"(",
"is_numeric",
"(",
"$",
"column",
")",
")",
"{",
"$",
"column",
"=",
"$",
"this",
"->",
"getColumnNameByIndex",
"(",
"$",
"index",
")",
";",
"}",
"if",
"(",
"Str",
"::",
"contains",
"(",
"Str",
"::",
"upper",
"(",
"$",
"column",
")",
",",
"' AS '",
")",
")",
"{",
"$",
"column",
"=",
"$",
"this",
"->",
"extractColumnName",
"(",
"$",
"column",
",",
"$",
"wantsAlias",
")",
";",
"}",
"return",
"$",
"column",
";",
"}"
] |
Get column name to be use for filtering and sorting.
@param integer $index
@param bool $wantsAlias
@return string
|
[
"Get",
"column",
"name",
"to",
"be",
"use",
"for",
"filtering",
"and",
"sorting",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Engines/BaseEngine.php#L840-L854
|
228,522
|
antaresproject/core
|
src/components/model/src/Eloquent.php
|
Eloquent.dependableActions
|
public function dependableActions()
{
$actions = config('dependable_actions.' . get_called_class(), []);
$return = [];
foreach ($actions as $action) {
if (!$action instanceof Closure) {
continue;
}
$return[] = call_user_func($action, $this);
}
return $return;
}
|
php
|
public function dependableActions()
{
$actions = config('dependable_actions.' . get_called_class(), []);
$return = [];
foreach ($actions as $action) {
if (!$action instanceof Closure) {
continue;
}
$return[] = call_user_func($action, $this);
}
return $return;
}
|
[
"public",
"function",
"dependableActions",
"(",
")",
"{",
"$",
"actions",
"=",
"config",
"(",
"'dependable_actions.'",
".",
"get_called_class",
"(",
")",
",",
"[",
"]",
")",
";",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"action",
")",
"{",
"if",
"(",
"!",
"$",
"action",
"instanceof",
"Closure",
")",
"{",
"continue",
";",
"}",
"$",
"return",
"[",
"]",
"=",
"call_user_func",
"(",
"$",
"action",
",",
"$",
"this",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Get dependable actions
@return array
|
[
"Get",
"dependable",
"actions"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/model/src/Eloquent.php#L94-L106
|
228,523
|
antaresproject/core
|
src/ui/components/templates/src/TemplateManifest.php
|
TemplateManifest.generateManifestConfig
|
protected function generateManifestConfig(array $jsonable)
{
$manifest = [];
foreach ($this->manifestOptions as $key => $default) {
$manifest["{$key}"] = Arr::get($jsonable, $key, $default);
}
return $manifest;
}
|
php
|
protected function generateManifestConfig(array $jsonable)
{
$manifest = [];
foreach ($this->manifestOptions as $key => $default) {
$manifest["{$key}"] = Arr::get($jsonable, $key, $default);
}
return $manifest;
}
|
[
"protected",
"function",
"generateManifestConfig",
"(",
"array",
"$",
"jsonable",
")",
"{",
"$",
"manifest",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"manifestOptions",
"as",
"$",
"key",
"=>",
"$",
"default",
")",
"{",
"$",
"manifest",
"[",
"\"{$key}\"",
"]",
"=",
"Arr",
"::",
"get",
"(",
"$",
"jsonable",
",",
"$",
"key",
",",
"$",
"default",
")",
";",
"}",
"return",
"$",
"manifest",
";",
"}"
] |
Generate a proper manifest configuration for the template.
@param array $jsonable
@return array
|
[
"Generate",
"a",
"proper",
"manifest",
"configuration",
"for",
"the",
"template",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/TemplateManifest.php#L116-L124
|
228,524
|
antaresproject/core
|
src/components/html/src/Form/Grid.php
|
Grid.findFieldsetOrCreateNew
|
public function findFieldsetOrCreateNew($name, Closure $callback = null)
{
foreach ($this->fieldsets as $fieldset) {
if ($fieldset->getName() === $name) {
$fieldset->update($callback);
return $this->fieldsets;
}
}
return $this->fieldset($name, $callback);
}
|
php
|
public function findFieldsetOrCreateNew($name, Closure $callback = null)
{
foreach ($this->fieldsets as $fieldset) {
if ($fieldset->getName() === $name) {
$fieldset->update($callback);
return $this->fieldsets;
}
}
return $this->fieldset($name, $callback);
}
|
[
"public",
"function",
"findFieldsetOrCreateNew",
"(",
"$",
"name",
",",
"Closure",
"$",
"callback",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"fieldsets",
"as",
"$",
"fieldset",
")",
"{",
"if",
"(",
"$",
"fieldset",
"->",
"getName",
"(",
")",
"===",
"$",
"name",
")",
"{",
"$",
"fieldset",
"->",
"update",
"(",
"$",
"callback",
")",
";",
"return",
"$",
"this",
"->",
"fieldsets",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"fieldset",
"(",
"$",
"name",
",",
"$",
"callback",
")",
";",
"}"
] |
Find the existing Fieldset. It not exists then create a new instance.
@param string $name
@param Closure|null $callback
@return \Antares\Contracts\Html\Form\Fieldset
|
[
"Find",
"the",
"existing",
"Fieldset",
".",
"It",
"not",
"exists",
"then",
"create",
"a",
"new",
"instance",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/Grid.php#L331-L342
|
228,525
|
antaresproject/core
|
src/components/html/src/Form/Grid.php
|
Grid.find
|
public function find($name)
{
if (Str::contains($name, '.')) {
list($fieldset, $control) = explode('.', $name, 2);
} else {
$fieldset = 'fieldset-0';
$control = $name;
}
if (!array_key_exists($fieldset, $this->keyMap)) {
throw new InvalidArgumentException("Name [{$name}] is not available.");
}
return $this->keyMap[$fieldset]->of($control);
}
|
php
|
public function find($name)
{
if (Str::contains($name, '.')) {
list($fieldset, $control) = explode('.', $name, 2);
} else {
$fieldset = 'fieldset-0';
$control = $name;
}
if (!array_key_exists($fieldset, $this->keyMap)) {
throw new InvalidArgumentException("Name [{$name}] is not available.");
}
return $this->keyMap[$fieldset]->of($control);
}
|
[
"public",
"function",
"find",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"Str",
"::",
"contains",
"(",
"$",
"name",
",",
"'.'",
")",
")",
"{",
"list",
"(",
"$",
"fieldset",
",",
"$",
"control",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"name",
",",
"2",
")",
";",
"}",
"else",
"{",
"$",
"fieldset",
"=",
"'fieldset-0'",
";",
"$",
"control",
"=",
"$",
"name",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"fieldset",
",",
"$",
"this",
"->",
"keyMap",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Name [{$name}] is not available.\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"keyMap",
"[",
"$",
"fieldset",
"]",
"->",
"of",
"(",
"$",
"control",
")",
";",
"}"
] |
Find control that match the given id.
@param string $name
@return Field|null
@throws \InvalidArgumentException
|
[
"Find",
"control",
"that",
"match",
"the",
"given",
"id",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/Grid.php#L353-L367
|
228,526
|
antaresproject/core
|
src/components/html/src/Form/Grid.php
|
Grid.resourced
|
public function resourced($url, Model $model, array $attributes = [])
{
$method = 'POST';
if ($model->exists) {
$url = "{$url}/{$model->getKey()}";
$method = 'PUT';
}
array_set($attributes, 'method', $method);
$this->with($model);
$this->attributes(array_merge($attributes, [
'url' => handles($url),
'method' => $method,
]));
return $this;
}
|
php
|
public function resourced($url, Model $model, array $attributes = [])
{
$method = 'POST';
if ($model->exists) {
$url = "{$url}/{$model->getKey()}";
$method = 'PUT';
}
array_set($attributes, 'method', $method);
$this->with($model);
$this->attributes(array_merge($attributes, [
'url' => handles($url),
'method' => $method,
]));
return $this;
}
|
[
"public",
"function",
"resourced",
"(",
"$",
"url",
",",
"Model",
"$",
"model",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"method",
"=",
"'POST'",
";",
"if",
"(",
"$",
"model",
"->",
"exists",
")",
"{",
"$",
"url",
"=",
"\"{$url}/{$model->getKey()}\"",
";",
"$",
"method",
"=",
"'PUT'",
";",
"}",
"array_set",
"(",
"$",
"attributes",
",",
"'method'",
",",
"$",
"method",
")",
";",
"$",
"this",
"->",
"with",
"(",
"$",
"model",
")",
";",
"$",
"this",
"->",
"attributes",
"(",
"array_merge",
"(",
"$",
"attributes",
",",
"[",
"'url'",
"=>",
"handles",
"(",
"$",
"url",
")",
",",
"'method'",
"=>",
"$",
"method",
",",
"]",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
form params builder without listener
@param String $url
@param Model $model
@param array $attributes
@return \Antares\Html\Form\Grid
|
[
"form",
"params",
"builder",
"without",
"listener"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/Grid.php#L427-L441
|
228,527
|
antaresproject/core
|
src/components/html/src/Form/Grid.php
|
Grid.simple
|
public function simple($url, array $attributes = [], $model = null)
{
$method = Arr::get($attributes, 'method', 'POST');
$this->attributes(array_merge($attributes, [
'url' => $url,
'method' => $method,
]));
$this->with($model);
return $this;
}
|
php
|
public function simple($url, array $attributes = [], $model = null)
{
$method = Arr::get($attributes, 'method', 'POST');
$this->attributes(array_merge($attributes, [
'url' => $url,
'method' => $method,
]));
$this->with($model);
return $this;
}
|
[
"public",
"function",
"simple",
"(",
"$",
"url",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
",",
"$",
"model",
"=",
"null",
")",
"{",
"$",
"method",
"=",
"Arr",
"::",
"get",
"(",
"$",
"attributes",
",",
"'method'",
",",
"'POST'",
")",
";",
"$",
"this",
"->",
"attributes",
"(",
"array_merge",
"(",
"$",
"attributes",
",",
"[",
"'url'",
"=>",
"$",
"url",
",",
"'method'",
"=>",
"$",
"method",
",",
"]",
")",
")",
";",
"$",
"this",
"->",
"with",
"(",
"$",
"model",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
attach simple form configuration
@param String $url
@param array $attributes
@param Model $model
@return Grid
|
[
"attach",
"simple",
"form",
"configuration"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/Grid.php#L474-L483
|
228,528
|
rollerworks/RouteAutowiringBundle
|
src/RouteImporter.php
|
RouteImporter.addResource
|
public function addResource(ResourceInterface $resource)
{
$resourceStr = (string) $resource;
$this->container->register(RouteAutowiringExtension::EXTENSION_ALIAS.'.resources.'.sha1($resourceStr), get_class($resource))
->setPublic(false)
->setArguments([$resourceStr])
->addTag(RouteResourcePass::TAG_NAME);
return $this;
}
|
php
|
public function addResource(ResourceInterface $resource)
{
$resourceStr = (string) $resource;
$this->container->register(RouteAutowiringExtension::EXTENSION_ALIAS.'.resources.'.sha1($resourceStr), get_class($resource))
->setPublic(false)
->setArguments([$resourceStr])
->addTag(RouteResourcePass::TAG_NAME);
return $this;
}
|
[
"public",
"function",
"addResource",
"(",
"ResourceInterface",
"$",
"resource",
")",
"{",
"$",
"resourceStr",
"=",
"(",
"string",
")",
"$",
"resource",
";",
"$",
"this",
"->",
"container",
"->",
"register",
"(",
"RouteAutowiringExtension",
"::",
"EXTENSION_ALIAS",
".",
"'.resources.'",
".",
"sha1",
"(",
"$",
"resourceStr",
")",
",",
"get_class",
"(",
"$",
"resource",
")",
")",
"->",
"setPublic",
"(",
"false",
")",
"->",
"setArguments",
"(",
"[",
"$",
"resourceStr",
"]",
")",
"->",
"addTag",
"(",
"RouteResourcePass",
"::",
"TAG_NAME",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add resource to track for changes.
@param ResourceInterface $resource
@return $this The current instance
|
[
"Add",
"resource",
"to",
"track",
"for",
"changes",
"."
] |
8b429a306ceef5e1d795359a20afaf1b0606fd60
|
https://github.com/rollerworks/RouteAutowiringBundle/blob/8b429a306ceef5e1d795359a20afaf1b0606fd60/src/RouteImporter.php#L72-L82
|
228,529
|
rollerworks/RouteAutowiringBundle
|
src/RouteImporter.php
|
RouteImporter.import
|
public function import($resource, $slot = null, $type = null)
{
if (null === $slot) {
$slot = $this->defaultSlot;
}
if (null === $slot) {
throw new \InvalidArgumentException(sprintf('No slot provided for resource "%s".', $resource));
}
$hash = sha1($slot.'~'.$resource.($type ? '~'.$type : ''));
$this->container->register(RouteAutowiringExtension::EXTENSION_ALIAS.'.'.$hash, RouteResource::class)
->setPublic(false)
->setArguments([$resource, $type])
->addTag(RouteAutowiringPass::TAG_NAME, ['slot' => $slot]);
return $this;
}
|
php
|
public function import($resource, $slot = null, $type = null)
{
if (null === $slot) {
$slot = $this->defaultSlot;
}
if (null === $slot) {
throw new \InvalidArgumentException(sprintf('No slot provided for resource "%s".', $resource));
}
$hash = sha1($slot.'~'.$resource.($type ? '~'.$type : ''));
$this->container->register(RouteAutowiringExtension::EXTENSION_ALIAS.'.'.$hash, RouteResource::class)
->setPublic(false)
->setArguments([$resource, $type])
->addTag(RouteAutowiringPass::TAG_NAME, ['slot' => $slot]);
return $this;
}
|
[
"public",
"function",
"import",
"(",
"$",
"resource",
",",
"$",
"slot",
"=",
"null",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"slot",
")",
"{",
"$",
"slot",
"=",
"$",
"this",
"->",
"defaultSlot",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"slot",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'No slot provided for resource \"%s\".'",
",",
"$",
"resource",
")",
")",
";",
"}",
"$",
"hash",
"=",
"sha1",
"(",
"$",
"slot",
".",
"'~'",
".",
"$",
"resource",
".",
"(",
"$",
"type",
"?",
"'~'",
".",
"$",
"type",
":",
"''",
")",
")",
";",
"$",
"this",
"->",
"container",
"->",
"register",
"(",
"RouteAutowiringExtension",
"::",
"EXTENSION_ALIAS",
".",
"'.'",
".",
"$",
"hash",
",",
"RouteResource",
"::",
"class",
")",
"->",
"setPublic",
"(",
"false",
")",
"->",
"setArguments",
"(",
"[",
"$",
"resource",
",",
"$",
"type",
"]",
")",
"->",
"addTag",
"(",
"RouteAutowiringPass",
"::",
"TAG_NAME",
",",
"[",
"'slot'",
"=>",
"$",
"slot",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Import a routing file into to the routing-slot.
The route resource is registered as private service.
@param string|array $resource resource to import (depends on the actual type)
@param string|null $slot The routing-slot to import to.
Uses the default when none is provided.
@param string|null $type the type of the resource (optional),
required if the type is not auto guessable
@throws \InvalidArgumentException when no (default) slot is provided
@return $this The current instance
|
[
"Import",
"a",
"routing",
"file",
"into",
"to",
"the",
"routing",
"-",
"slot",
"."
] |
8b429a306ceef5e1d795359a20afaf1b0606fd60
|
https://github.com/rollerworks/RouteAutowiringBundle/blob/8b429a306ceef5e1d795359a20afaf1b0606fd60/src/RouteImporter.php#L129-L147
|
228,530
|
antaresproject/customfields
|
src/Model/Field.php
|
Field.getFlattenValidators
|
public function getFlattenValidators()
{
if (!$this->exists) {
return [];
}
$validators = $this->validators;
$return = [];
if (!empty($validators)) {
foreach ($validators as $validator) {
$return[$validator->validator_id] = $validator->value;
}
}
return $return;
}
|
php
|
public function getFlattenValidators()
{
if (!$this->exists) {
return [];
}
$validators = $this->validators;
$return = [];
if (!empty($validators)) {
foreach ($validators as $validator) {
$return[$validator->validator_id] = $validator->value;
}
}
return $return;
}
|
[
"public",
"function",
"getFlattenValidators",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"validators",
"=",
"$",
"this",
"->",
"validators",
";",
"$",
"return",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"validators",
")",
")",
"{",
"foreach",
"(",
"$",
"validators",
"as",
"$",
"validator",
")",
"{",
"$",
"return",
"[",
"$",
"validator",
"->",
"validator_id",
"]",
"=",
"$",
"validator",
"->",
"value",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] |
get flatten validators attached to field
@return array
|
[
"get",
"flatten",
"validators",
"attached",
"to",
"field"
] |
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
|
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Model/Field.php#L132-L146
|
228,531
|
antaresproject/core
|
src/foundation/src/Http/Controllers/DashboardController.php
|
DashboardController.show
|
public function show(GridStackAdapter $gridStackAdapter)
{
$gridStackAdapter->scripts();
view()->share('content_class', 'app-content--gridstack page-dashboard page-dashboard-html widgets-html-page');
return $this->processor->show($this);
}
|
php
|
public function show(GridStackAdapter $gridStackAdapter)
{
$gridStackAdapter->scripts();
view()->share('content_class', 'app-content--gridstack page-dashboard page-dashboard-html widgets-html-page');
return $this->processor->show($this);
}
|
[
"public",
"function",
"show",
"(",
"GridStackAdapter",
"$",
"gridStackAdapter",
")",
"{",
"$",
"gridStackAdapter",
"->",
"scripts",
"(",
")",
";",
"view",
"(",
")",
"->",
"share",
"(",
"'content_class'",
",",
"'app-content--gridstack page-dashboard page-dashboard-html widgets-html-page'",
")",
";",
"return",
"$",
"this",
"->",
"processor",
"->",
"show",
"(",
"$",
"this",
")",
";",
"}"
] |
Show User Dashboard.
GET (:antares)/
@param GridStackAdapter $gridStackAdapter
@return mixed
|
[
"Show",
"User",
"Dashboard",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Controllers/DashboardController.php#L79-L84
|
228,532
|
antaresproject/core
|
src/foundation/src/Http/Controllers/DashboardController.php
|
DashboardController.showDashboard
|
public function showDashboard()
{
set_meta('title', trans('antares/foundation::title.home'));
$this->app->make('events')->fire('version.check');
$this->app->make('events')->fire(new VersionCheck());
if (!auth()->guest() && auth()->user()->hasRoles('member')) {
return view('antares/foundation::dashboard.member');
}
return view('antares/foundation::dashboard.index');
}
|
php
|
public function showDashboard()
{
set_meta('title', trans('antares/foundation::title.home'));
$this->app->make('events')->fire('version.check');
$this->app->make('events')->fire(new VersionCheck());
if (!auth()->guest() && auth()->user()->hasRoles('member')) {
return view('antares/foundation::dashboard.member');
}
return view('antares/foundation::dashboard.index');
}
|
[
"public",
"function",
"showDashboard",
"(",
")",
"{",
"set_meta",
"(",
"'title'",
",",
"trans",
"(",
"'antares/foundation::title.home'",
")",
")",
";",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'events'",
")",
"->",
"fire",
"(",
"'version.check'",
")",
";",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'events'",
")",
"->",
"fire",
"(",
"new",
"VersionCheck",
"(",
")",
")",
";",
"if",
"(",
"!",
"auth",
"(",
")",
"->",
"guest",
"(",
")",
"&&",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"hasRoles",
"(",
"'member'",
")",
")",
"{",
"return",
"view",
"(",
"'antares/foundation::dashboard.member'",
")",
";",
"}",
"return",
"view",
"(",
"'antares/foundation::dashboard.index'",
")",
";",
"}"
] |
Response to show dashboard.
@return mixed
|
[
"Response",
"to",
"show",
"dashboard",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Controllers/DashboardController.php#L127-L137
|
228,533
|
antaresproject/core
|
src/components/support/src/Support/Str.php
|
Str.prepareBinding
|
protected static function prepareBinding(array $replacements = [], $prefix = '{', $suffix = '}')
{
$replacements = Arr::dot($replacements);
$bindings = [];
foreach ($replacements as $key => $value) {
$bindings["{$prefix}{$key}{$suffix}"] = $value;
}
return $bindings;
}
|
php
|
protected static function prepareBinding(array $replacements = [], $prefix = '{', $suffix = '}')
{
$replacements = Arr::dot($replacements);
$bindings = [];
foreach ($replacements as $key => $value) {
$bindings["{$prefix}{$key}{$suffix}"] = $value;
}
return $bindings;
}
|
[
"protected",
"static",
"function",
"prepareBinding",
"(",
"array",
"$",
"replacements",
"=",
"[",
"]",
",",
"$",
"prefix",
"=",
"'{'",
",",
"$",
"suffix",
"=",
"'}'",
")",
"{",
"$",
"replacements",
"=",
"Arr",
"::",
"dot",
"(",
"$",
"replacements",
")",
";",
"$",
"bindings",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"replacements",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"bindings",
"[",
"\"{$prefix}{$key}{$suffix}\"",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"bindings",
";",
"}"
] |
Prepare bindings for text replacement.
@param array $replacements
@param string $prefix
@param string $suffix
@return array
|
[
"Prepare",
"bindings",
"for",
"text",
"replacement",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Support/Str.php#L76-L86
|
228,534
|
antaresproject/core
|
src/components/support/src/Support/Str.php
|
Str.searchable
|
public static function searchable($text, $wildcard = '*', $replacement = '%')
{
if (! static::contains($text, $wildcard)) {
return [
"{$text}",
"{$text}{$replacement}",
"{$replacement}{$text}",
"{$replacement}{$text}{$replacement}",
];
}
return [str_replace($wildcard, $replacement, $text)];
}
|
php
|
public static function searchable($text, $wildcard = '*', $replacement = '%')
{
if (! static::contains($text, $wildcard)) {
return [
"{$text}",
"{$text}{$replacement}",
"{$replacement}{$text}",
"{$replacement}{$text}{$replacement}",
];
}
return [str_replace($wildcard, $replacement, $text)];
}
|
[
"public",
"static",
"function",
"searchable",
"(",
"$",
"text",
",",
"$",
"wildcard",
"=",
"'*'",
",",
"$",
"replacement",
"=",
"'%'",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"contains",
"(",
"$",
"text",
",",
"$",
"wildcard",
")",
")",
"{",
"return",
"[",
"\"{$text}\"",
",",
"\"{$text}{$replacement}\"",
",",
"\"{$replacement}{$text}\"",
",",
"\"{$replacement}{$text}{$replacement}\"",
",",
"]",
";",
"}",
"return",
"[",
"str_replace",
"(",
"$",
"wildcard",
",",
"$",
"replacement",
",",
"$",
"text",
")",
"]",
";",
"}"
] |
Convert basic string to searchable result.
@param string $text
@param string $wildcard
@param string $replacement
@return array
|
[
"Convert",
"basic",
"string",
"to",
"searchable",
"result",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Support/Str.php#L97-L109
|
228,535
|
antaresproject/customfields
|
src/Memory/FormsRepository.php
|
FormsRepository.retrieveAll
|
public function retrieveAll()
{
if (empty($this->forms)) {
$data = $this->getModel()->get();
$this->forms = $this->processRetrievedData($data);
}
return $this->forms;
}
|
php
|
public function retrieveAll()
{
if (empty($this->forms)) {
$data = $this->getModel()->get();
$this->forms = $this->processRetrievedData($data);
}
return $this->forms;
}
|
[
"public",
"function",
"retrieveAll",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"forms",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"get",
"(",
")",
";",
"$",
"this",
"->",
"forms",
"=",
"$",
"this",
"->",
"processRetrievedData",
"(",
"$",
"data",
")",
";",
"}",
"return",
"$",
"this",
"->",
"forms",
";",
"}"
] |
Get forms configuration from database
@return mixed
|
[
"Get",
"forms",
"configuration",
"from",
"database"
] |
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
|
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Memory/FormsRepository.php#L218-L225
|
228,536
|
lawoole/framework
|
src/Server/Server.php
|
Server.initialize
|
protected function initialize(array $config)
{
$this->swooleServer = $this->createSwooleServer($config);
$this->configureDefaultServerSocket();
$this->setOptions($config['options'] ?? []);
$this->registerEventCallbacks($this->serverEvents);
$this->events->dispatch(new Events\ServerCreated($this));
}
|
php
|
protected function initialize(array $config)
{
$this->swooleServer = $this->createSwooleServer($config);
$this->configureDefaultServerSocket();
$this->setOptions($config['options'] ?? []);
$this->registerEventCallbacks($this->serverEvents);
$this->events->dispatch(new Events\ServerCreated($this));
}
|
[
"protected",
"function",
"initialize",
"(",
"array",
"$",
"config",
")",
"{",
"$",
"this",
"->",
"swooleServer",
"=",
"$",
"this",
"->",
"createSwooleServer",
"(",
"$",
"config",
")",
";",
"$",
"this",
"->",
"configureDefaultServerSocket",
"(",
")",
";",
"$",
"this",
"->",
"setOptions",
"(",
"$",
"config",
"[",
"'options'",
"]",
"??",
"[",
"]",
")",
";",
"$",
"this",
"->",
"registerEventCallbacks",
"(",
"$",
"this",
"->",
"serverEvents",
")",
";",
"$",
"this",
"->",
"events",
"->",
"dispatch",
"(",
"new",
"Events",
"\\",
"ServerCreated",
"(",
"$",
"this",
")",
")",
";",
"}"
] |
Initialize the server.
@param array $config
|
[
"Initialize",
"the",
"server",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/Server.php#L116-L127
|
228,537
|
lawoole/framework
|
src/Server/Server.php
|
Server.createSwooleServer
|
protected function createSwooleServer(array $config)
{
return new SwooleServer(
$this->serverSocket->getHost(),
$this->serverSocket->getPort(),
$this->parseServerMode($config),
$this->serverSocket->getSocketType()
);
}
|
php
|
protected function createSwooleServer(array $config)
{
return new SwooleServer(
$this->serverSocket->getHost(),
$this->serverSocket->getPort(),
$this->parseServerMode($config),
$this->serverSocket->getSocketType()
);
}
|
[
"protected",
"function",
"createSwooleServer",
"(",
"array",
"$",
"config",
")",
"{",
"return",
"new",
"SwooleServer",
"(",
"$",
"this",
"->",
"serverSocket",
"->",
"getHost",
"(",
")",
",",
"$",
"this",
"->",
"serverSocket",
"->",
"getPort",
"(",
")",
",",
"$",
"this",
"->",
"parseServerMode",
"(",
"$",
"config",
")",
",",
"$",
"this",
"->",
"serverSocket",
"->",
"getSocketType",
"(",
")",
")",
";",
"}"
] |
Create the Swoole server instance.
@param array $config
@return \Swoole\Server
|
[
"Create",
"the",
"Swoole",
"server",
"instance",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/Server.php#L136-L144
|
228,538
|
lawoole/framework
|
src/Server/Server.php
|
Server.setOptions
|
public function setOptions(array $options = [])
{
if ($this->isRunning()) {
throw new LogicException('Options cannot be set while the server is running.');
}
$this->options = array_diff_key($this->options, $options) + $options;
$this->swooleServer->set($this->options);
}
|
php
|
public function setOptions(array $options = [])
{
if ($this->isRunning()) {
throw new LogicException('Options cannot be set while the server is running.');
}
$this->options = array_diff_key($this->options, $options) + $options;
$this->swooleServer->set($this->options);
}
|
[
"public",
"function",
"setOptions",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isRunning",
"(",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Options cannot be set while the server is running.'",
")",
";",
"}",
"$",
"this",
"->",
"options",
"=",
"array_diff_key",
"(",
"$",
"this",
"->",
"options",
",",
"$",
"options",
")",
"+",
"$",
"options",
";",
"$",
"this",
"->",
"swooleServer",
"->",
"set",
"(",
"$",
"this",
"->",
"options",
")",
";",
"}"
] |
Set the server options.
@param array $options
|
[
"Set",
"the",
"server",
"options",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/Server.php#L190-L199
|
228,539
|
lawoole/framework
|
src/Server/Server.php
|
Server.listen
|
public function listen(ServerSocketContract $serverSocket)
{
if ($this->isRunning()) {
throw new LogicException('Cannot add listening while the server is serving.');
}
if ($serverSocket->isBound()) {
throw new LogicException('The server socket can be bound to server only once.');
}
$address = "{$serverSocket->getHost()}:{$serverSocket->getPort()}";
if (isset($this->serverSockets[$address])) {
throw new LogicException('The same address has been listened before.');
}
$swoolePort = $this->swooleServer->listen(
$serverSocket->getHost(),
$serverSocket->getPort(),
$serverSocket->getSocketType()
);
if ($swoolePort == false) {
$errorCode = $this->swooleServer->getLastError();
throw new RuntimeException(sprintf(
'Listen %s%s fail, error code %d', $serverSocket->getHost(),
$serverSocket->getPort() ? ':'.$serverSocket->getPort() : '', $errorCode
), $errorCode);
}
$this->serverSockets[$address] = $serverSocket;
$serverSocket->listen($this, $swoolePort);
}
|
php
|
public function listen(ServerSocketContract $serverSocket)
{
if ($this->isRunning()) {
throw new LogicException('Cannot add listening while the server is serving.');
}
if ($serverSocket->isBound()) {
throw new LogicException('The server socket can be bound to server only once.');
}
$address = "{$serverSocket->getHost()}:{$serverSocket->getPort()}";
if (isset($this->serverSockets[$address])) {
throw new LogicException('The same address has been listened before.');
}
$swoolePort = $this->swooleServer->listen(
$serverSocket->getHost(),
$serverSocket->getPort(),
$serverSocket->getSocketType()
);
if ($swoolePort == false) {
$errorCode = $this->swooleServer->getLastError();
throw new RuntimeException(sprintf(
'Listen %s%s fail, error code %d', $serverSocket->getHost(),
$serverSocket->getPort() ? ':'.$serverSocket->getPort() : '', $errorCode
), $errorCode);
}
$this->serverSockets[$address] = $serverSocket;
$serverSocket->listen($this, $swoolePort);
}
|
[
"public",
"function",
"listen",
"(",
"ServerSocketContract",
"$",
"serverSocket",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isRunning",
"(",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Cannot add listening while the server is serving.'",
")",
";",
"}",
"if",
"(",
"$",
"serverSocket",
"->",
"isBound",
"(",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'The server socket can be bound to server only once.'",
")",
";",
"}",
"$",
"address",
"=",
"\"{$serverSocket->getHost()}:{$serverSocket->getPort()}\"",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"serverSockets",
"[",
"$",
"address",
"]",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'The same address has been listened before.'",
")",
";",
"}",
"$",
"swoolePort",
"=",
"$",
"this",
"->",
"swooleServer",
"->",
"listen",
"(",
"$",
"serverSocket",
"->",
"getHost",
"(",
")",
",",
"$",
"serverSocket",
"->",
"getPort",
"(",
")",
",",
"$",
"serverSocket",
"->",
"getSocketType",
"(",
")",
")",
";",
"if",
"(",
"$",
"swoolePort",
"==",
"false",
")",
"{",
"$",
"errorCode",
"=",
"$",
"this",
"->",
"swooleServer",
"->",
"getLastError",
"(",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Listen %s%s fail, error code %d'",
",",
"$",
"serverSocket",
"->",
"getHost",
"(",
")",
",",
"$",
"serverSocket",
"->",
"getPort",
"(",
")",
"?",
"':'",
".",
"$",
"serverSocket",
"->",
"getPort",
"(",
")",
":",
"''",
",",
"$",
"errorCode",
")",
",",
"$",
"errorCode",
")",
";",
"}",
"$",
"this",
"->",
"serverSockets",
"[",
"$",
"address",
"]",
"=",
"$",
"serverSocket",
";",
"$",
"serverSocket",
"->",
"listen",
"(",
"$",
"this",
",",
"$",
"swoolePort",
")",
";",
"}"
] |
Add a listening defined in the given server socket.
@param \Lawoole\Contracts\Server\ServerSocket $serverSocket
|
[
"Add",
"a",
"listening",
"defined",
"in",
"the",
"given",
"server",
"socket",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/Server.php#L216-L250
|
228,540
|
lawoole/framework
|
src/Server/Server.php
|
Server.fork
|
public function fork(ProcessContract $process)
{
$this->swooleServer->addProcess($process->getSwooleProcess());
$process->bind($this);
}
|
php
|
public function fork(ProcessContract $process)
{
$this->swooleServer->addProcess($process->getSwooleProcess());
$process->bind($this);
}
|
[
"public",
"function",
"fork",
"(",
"ProcessContract",
"$",
"process",
")",
"{",
"$",
"this",
"->",
"swooleServer",
"->",
"addProcess",
"(",
"$",
"process",
"->",
"getSwooleProcess",
"(",
")",
")",
";",
"$",
"process",
"->",
"bind",
"(",
"$",
"this",
")",
";",
"}"
] |
Add a child process managed by the server.
@param \Lawoole\Contracts\Server\Process $process
|
[
"Add",
"a",
"child",
"process",
"managed",
"by",
"the",
"server",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/Server.php#L257-L262
|
228,541
|
lawoole/framework
|
src/Server/Server.php
|
Server.reportWorkerError
|
protected function reportWorkerError($workerId, $workerPid, $exitCode, $signal)
{
$this->handleException(new WorkerExitUnexpectedException(sprintf(
'The worker %d quit unexpected with exit code %d, signal %d, pid %d.',
$workerId, $exitCode, $signal, $workerPid
)));
}
|
php
|
protected function reportWorkerError($workerId, $workerPid, $exitCode, $signal)
{
$this->handleException(new WorkerExitUnexpectedException(sprintf(
'The worker %d quit unexpected with exit code %d, signal %d, pid %d.',
$workerId, $exitCode, $signal, $workerPid
)));
}
|
[
"protected",
"function",
"reportWorkerError",
"(",
"$",
"workerId",
",",
"$",
"workerPid",
",",
"$",
"exitCode",
",",
"$",
"signal",
")",
"{",
"$",
"this",
"->",
"handleException",
"(",
"new",
"WorkerExitUnexpectedException",
"(",
"sprintf",
"(",
"'The worker %d quit unexpected with exit code %d, signal %d, pid %d.'",
",",
"$",
"workerId",
",",
"$",
"exitCode",
",",
"$",
"signal",
",",
"$",
"workerPid",
")",
")",
")",
";",
"}"
] |
Report worker exit
@param int $workerId
@param int $workerPid
@param int $exitCode
@param int $signal
|
[
"Report",
"worker",
"exit"
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/Server.php#L569-L575
|
228,542
|
gggeek/ggwebservices
|
classes/ggezwebservices.php
|
ggeZWebservices.isLoggingEnabled
|
static function isLoggingEnabled( $debuglevel )
{
$logging =& self::$debuglevel;
if ( $logging < 0 )
{
$logging = 0; // shall we init to 1 or 2 ?
$ini = eZINI::instance( 'wsproviders.ini' );
if ( $ini->hasvariable( 'GeneralSettings', 'Logging' ) )
{
$level = $ini->variable( 'GeneralSettings', 'Logging' );
if ( array_key_exists( $level, self::$errorlevels ) )
{
$logging = self::$errorlevels[$level];
}
}
//ggeZWebservicesClient::$debuglevel = $logging;
}
if ( !array_key_exists( $debuglevel, self::$errorlevels ) )
{
return false;
}
return self::$errorlevels[$debuglevel] <= $logging;
}
|
php
|
static function isLoggingEnabled( $debuglevel )
{
$logging =& self::$debuglevel;
if ( $logging < 0 )
{
$logging = 0; // shall we init to 1 or 2 ?
$ini = eZINI::instance( 'wsproviders.ini' );
if ( $ini->hasvariable( 'GeneralSettings', 'Logging' ) )
{
$level = $ini->variable( 'GeneralSettings', 'Logging' );
if ( array_key_exists( $level, self::$errorlevels ) )
{
$logging = self::$errorlevels[$level];
}
}
//ggeZWebservicesClient::$debuglevel = $logging;
}
if ( !array_key_exists( $debuglevel, self::$errorlevels ) )
{
return false;
}
return self::$errorlevels[$debuglevel] <= $logging;
}
|
[
"static",
"function",
"isLoggingEnabled",
"(",
"$",
"debuglevel",
")",
"{",
"$",
"logging",
"=",
"&",
"self",
"::",
"$",
"debuglevel",
";",
"if",
"(",
"$",
"logging",
"<",
"0",
")",
"{",
"$",
"logging",
"=",
"0",
";",
"// shall we init to 1 or 2 ?",
"$",
"ini",
"=",
"eZINI",
"::",
"instance",
"(",
"'wsproviders.ini'",
")",
";",
"if",
"(",
"$",
"ini",
"->",
"hasvariable",
"(",
"'GeneralSettings'",
",",
"'Logging'",
")",
")",
"{",
"$",
"level",
"=",
"$",
"ini",
"->",
"variable",
"(",
"'GeneralSettings'",
",",
"'Logging'",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"level",
",",
"self",
"::",
"$",
"errorlevels",
")",
")",
"{",
"$",
"logging",
"=",
"self",
"::",
"$",
"errorlevels",
"[",
"$",
"level",
"]",
";",
"}",
"}",
"//ggeZWebservicesClient::$debuglevel = $logging;",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"debuglevel",
",",
"self",
"::",
"$",
"errorlevels",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"self",
"::",
"$",
"errorlevels",
"[",
"$",
"debuglevel",
"]",
"<=",
"$",
"logging",
";",
"}"
] |
Return true if logging is enabled.
|
[
"Return",
"true",
"if",
"logging",
"is",
"enabled",
"."
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggezwebservices.php#L91-L113
|
228,543
|
gggeek/ggwebservices
|
classes/ggezwebservices.php
|
ggeZWebservices.methodsXSD
|
static function methodsXSD( $server, $methods, $service_name='', $return_url=false )
{
$cachedir = eZSys::cacheDirectory() . '/webservices';
// make sure our cache file names do not collide with wsdl ones (see methodsWSDL)
$cachefilename = $cachedir . '/' . md5( "xsd,1," . implode( ',', $methods ) );
$cachefile = eZClusterFileHandler::instance( $cachefilename );
if ( $cachefile->exists() )
{
if ( $return_url )
{
$cachefile->fetch();
return $cachefilename;
}
$wsdl = $cachefile->fetchContents();
}
else
{
//$wsdl_strings = array();
$wsdl_functions = array();
foreach ( $methods as $method )
{
$wsdl = $server->userWsdl( $method );
if ( $wsdl == null )
{
$sigs = $server->methodSignatures( $method );
$wsdl_functions[$method] = array(
//'name' => $function,
'params' => $sigs[0]['in'],
'returntype' => $sigs[0]['out'],
//'documentation' => $server->methodDescription( $method )
);
}
}
// wsdl building is done via template
$tpl = self::eZTemplateFactory();
/// @todo !important we could build directly html output using an html template, to reduce resource usage
//$namespace = 'webservices/wsdl/' . $service_name . '/types';
//eZURI::transformURI( $namespace , false, 'full' );
//$tpl->setVariable( 'namespace', $namespace );
/// @todo we should use different service names if, depending on permissions, user cannot see all methods...
//$tpl->setVariable( 'servicename', $service_name == '' ? 'SOAP' : ucfirst( $service_name ) );
$tpl->setVariable( 'functions', $wsdl_functions );
$wsdl = $tpl->fetch( "design:webservices/xsd.tpl" );
if ( strlen( $wsdl ) )
{
$cachefile->storeContents( $wsdl );
}
else
{
$cachefilename = null; // used below as return value
}
}
return $return_url ? $cachefilename : $wsdl;
}
|
php
|
static function methodsXSD( $server, $methods, $service_name='', $return_url=false )
{
$cachedir = eZSys::cacheDirectory() . '/webservices';
// make sure our cache file names do not collide with wsdl ones (see methodsWSDL)
$cachefilename = $cachedir . '/' . md5( "xsd,1," . implode( ',', $methods ) );
$cachefile = eZClusterFileHandler::instance( $cachefilename );
if ( $cachefile->exists() )
{
if ( $return_url )
{
$cachefile->fetch();
return $cachefilename;
}
$wsdl = $cachefile->fetchContents();
}
else
{
//$wsdl_strings = array();
$wsdl_functions = array();
foreach ( $methods as $method )
{
$wsdl = $server->userWsdl( $method );
if ( $wsdl == null )
{
$sigs = $server->methodSignatures( $method );
$wsdl_functions[$method] = array(
//'name' => $function,
'params' => $sigs[0]['in'],
'returntype' => $sigs[0]['out'],
//'documentation' => $server->methodDescription( $method )
);
}
}
// wsdl building is done via template
$tpl = self::eZTemplateFactory();
/// @todo !important we could build directly html output using an html template, to reduce resource usage
//$namespace = 'webservices/wsdl/' . $service_name . '/types';
//eZURI::transformURI( $namespace , false, 'full' );
//$tpl->setVariable( 'namespace', $namespace );
/// @todo we should use different service names if, depending on permissions, user cannot see all methods...
//$tpl->setVariable( 'servicename', $service_name == '' ? 'SOAP' : ucfirst( $service_name ) );
$tpl->setVariable( 'functions', $wsdl_functions );
$wsdl = $tpl->fetch( "design:webservices/xsd.tpl" );
if ( strlen( $wsdl ) )
{
$cachefile->storeContents( $wsdl );
}
else
{
$cachefilename = null; // used below as return value
}
}
return $return_url ? $cachefilename : $wsdl;
}
|
[
"static",
"function",
"methodsXSD",
"(",
"$",
"server",
",",
"$",
"methods",
",",
"$",
"service_name",
"=",
"''",
",",
"$",
"return_url",
"=",
"false",
")",
"{",
"$",
"cachedir",
"=",
"eZSys",
"::",
"cacheDirectory",
"(",
")",
".",
"'/webservices'",
";",
"// make sure our cache file names do not collide with wsdl ones (see methodsWSDL)",
"$",
"cachefilename",
"=",
"$",
"cachedir",
".",
"'/'",
".",
"md5",
"(",
"\"xsd,1,\"",
".",
"implode",
"(",
"','",
",",
"$",
"methods",
")",
")",
";",
"$",
"cachefile",
"=",
"eZClusterFileHandler",
"::",
"instance",
"(",
"$",
"cachefilename",
")",
";",
"if",
"(",
"$",
"cachefile",
"->",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"$",
"return_url",
")",
"{",
"$",
"cachefile",
"->",
"fetch",
"(",
")",
";",
"return",
"$",
"cachefilename",
";",
"}",
"$",
"wsdl",
"=",
"$",
"cachefile",
"->",
"fetchContents",
"(",
")",
";",
"}",
"else",
"{",
"//$wsdl_strings = array();",
"$",
"wsdl_functions",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"method",
")",
"{",
"$",
"wsdl",
"=",
"$",
"server",
"->",
"userWsdl",
"(",
"$",
"method",
")",
";",
"if",
"(",
"$",
"wsdl",
"==",
"null",
")",
"{",
"$",
"sigs",
"=",
"$",
"server",
"->",
"methodSignatures",
"(",
"$",
"method",
")",
";",
"$",
"wsdl_functions",
"[",
"$",
"method",
"]",
"=",
"array",
"(",
"//'name' => $function,",
"'params'",
"=>",
"$",
"sigs",
"[",
"0",
"]",
"[",
"'in'",
"]",
",",
"'returntype'",
"=>",
"$",
"sigs",
"[",
"0",
"]",
"[",
"'out'",
"]",
",",
"//'documentation' => $server->methodDescription( $method )",
")",
";",
"}",
"}",
"// wsdl building is done via template",
"$",
"tpl",
"=",
"self",
"::",
"eZTemplateFactory",
"(",
")",
";",
"/// @todo !important we could build directly html output using an html template, to reduce resource usage",
"//$namespace = 'webservices/wsdl/' . $service_name . '/types';",
"//eZURI::transformURI( $namespace , false, 'full' );",
"//$tpl->setVariable( 'namespace', $namespace );",
"/// @todo we should use different service names if, depending on permissions, user cannot see all methods...",
"//$tpl->setVariable( 'servicename', $service_name == '' ? 'SOAP' : ucfirst( $service_name ) );",
"$",
"tpl",
"->",
"setVariable",
"(",
"'functions'",
",",
"$",
"wsdl_functions",
")",
";",
"$",
"wsdl",
"=",
"$",
"tpl",
"->",
"fetch",
"(",
"\"design:webservices/xsd.tpl\"",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"wsdl",
")",
")",
"{",
"$",
"cachefile",
"->",
"storeContents",
"(",
"$",
"wsdl",
")",
";",
"}",
"else",
"{",
"$",
"cachefilename",
"=",
"null",
";",
"// used below as return value",
"}",
"}",
"return",
"$",
"return_url",
"?",
"$",
"cachefilename",
":",
"$",
"wsdl",
";",
"}"
] |
Returns the xml schema corresponding to a list of server's method's complex types.
This is implemented here because
. it relies on the templating system
. it does its own caching
but it should really be a function of the server class itself.
Since we do not want to pollute server classes with eZ specifics, we chose
to avoid the reverse depenency by putting the code here.
|
[
"Returns",
"the",
"xml",
"schema",
"corresponding",
"to",
"a",
"list",
"of",
"server",
"s",
"method",
"s",
"complex",
"types",
".",
"This",
"is",
"implemented",
"here",
"because",
".",
"it",
"relies",
"on",
"the",
"templating",
"system",
".",
"it",
"does",
"its",
"own",
"caching",
"but",
"it",
"should",
"really",
"be",
"a",
"function",
"of",
"the",
"server",
"class",
"itself",
".",
"Since",
"we",
"do",
"not",
"want",
"to",
"pollute",
"server",
"classes",
"with",
"eZ",
"specifics",
"we",
"chose",
"to",
"avoid",
"the",
"reverse",
"depenency",
"by",
"putting",
"the",
"code",
"here",
"."
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggezwebservices.php#L326-L382
|
228,544
|
gggeek/ggwebservices
|
classes/ggezwebservices.php
|
ggeZWebservices.ezpI18ntr
|
public static function ezpI18ntr( $context, $message, $comment = null, $argument = null )
{
// eZ Publish < 4.3 => use old i18n system
if( eZPublishSDK::majorVersion() == 4 && eZPublishSDK::minorVersion() < 3 )
{
include_once( 'kernel/common/i18n.php' );
return ezi18n( $context, $message, $comment, $argument );
}
else
{
return ezpI18n::tr( $context, $message, $comment, $argument );
}
}
|
php
|
public static function ezpI18ntr( $context, $message, $comment = null, $argument = null )
{
// eZ Publish < 4.3 => use old i18n system
if( eZPublishSDK::majorVersion() == 4 && eZPublishSDK::minorVersion() < 3 )
{
include_once( 'kernel/common/i18n.php' );
return ezi18n( $context, $message, $comment, $argument );
}
else
{
return ezpI18n::tr( $context, $message, $comment, $argument );
}
}
|
[
"public",
"static",
"function",
"ezpI18ntr",
"(",
"$",
"context",
",",
"$",
"message",
",",
"$",
"comment",
"=",
"null",
",",
"$",
"argument",
"=",
"null",
")",
"{",
"// eZ Publish < 4.3 => use old i18n system",
"if",
"(",
"eZPublishSDK",
"::",
"majorVersion",
"(",
")",
"==",
"4",
"&&",
"eZPublishSDK",
"::",
"minorVersion",
"(",
")",
"<",
"3",
")",
"{",
"include_once",
"(",
"'kernel/common/i18n.php'",
")",
";",
"return",
"ezi18n",
"(",
"$",
"context",
",",
"$",
"message",
",",
"$",
"comment",
",",
"$",
"argument",
")",
";",
"}",
"else",
"{",
"return",
"ezpI18n",
"::",
"tr",
"(",
"$",
"context",
",",
"$",
"message",
",",
"$",
"comment",
",",
"$",
"argument",
")",
";",
"}",
"}"
] |
Wrapper method to translate labels and eventually takes advantage of new 4.3 i18n API
@param $context
@param $message
@param $comment
@param $argument
@return string
|
[
"Wrapper",
"method",
"to",
"translate",
"labels",
"and",
"eventually",
"takes",
"advantage",
"of",
"new",
"4",
".",
"3",
"i18n",
"API"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggezwebservices.php#L569-L581
|
228,545
|
antaresproject/core
|
src/components/memory/src/Component/ComponentHandler.php
|
ComponentHandler.update
|
public function update(array $items = [])
{
$brandId = $this->getDefaultBrandId();
$changed = $this->verify($items, $brandId);
Memory::make('component.default')->put('terminate', (int) $changed);
if ($changed) {
$this->keyMap = [];
}
if ($changed && $this->cache instanceof Repository) {
$this->cache->forget($this->cacheKey);
}
}
|
php
|
public function update(array $items = [])
{
$brandId = $this->getDefaultBrandId();
$changed = $this->verify($items, $brandId);
Memory::make('component.default')->put('terminate', (int) $changed);
if ($changed) {
$this->keyMap = [];
}
if ($changed && $this->cache instanceof Repository) {
$this->cache->forget($this->cacheKey);
}
}
|
[
"public",
"function",
"update",
"(",
"array",
"$",
"items",
"=",
"[",
"]",
")",
"{",
"$",
"brandId",
"=",
"$",
"this",
"->",
"getDefaultBrandId",
"(",
")",
";",
"$",
"changed",
"=",
"$",
"this",
"->",
"verify",
"(",
"$",
"items",
",",
"$",
"brandId",
")",
";",
"Memory",
"::",
"make",
"(",
"'component.default'",
")",
"->",
"put",
"(",
"'terminate'",
",",
"(",
"int",
")",
"$",
"changed",
")",
";",
"if",
"(",
"$",
"changed",
")",
"{",
"$",
"this",
"->",
"keyMap",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"$",
"changed",
"&&",
"$",
"this",
"->",
"cache",
"instanceof",
"Repository",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"forget",
"(",
"$",
"this",
"->",
"cacheKey",
")",
";",
"}",
"}"
] |
updates elements in container
@param array $items
|
[
"updates",
"elements",
"in",
"container"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/src/Component/ComponentHandler.php#L236-L248
|
228,546
|
antaresproject/core
|
src/components/memory/src/Component/ComponentHandler.php
|
ComponentHandler.getDefaultBrandId
|
protected function getDefaultBrandId()
{
try {
if (is_null($this->defaultBrandId)) {
$this->defaultBrandId = 1;
}
return $this->defaultBrandId;
} catch (Exception $e) {
Log::emergency($e);
return false;
}
}
|
php
|
protected function getDefaultBrandId()
{
try {
if (is_null($this->defaultBrandId)) {
$this->defaultBrandId = 1;
}
return $this->defaultBrandId;
} catch (Exception $e) {
Log::emergency($e);
return false;
}
}
|
[
"protected",
"function",
"getDefaultBrandId",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"defaultBrandId",
")",
")",
"{",
"$",
"this",
"->",
"defaultBrandId",
"=",
"1",
";",
"}",
"return",
"$",
"this",
"->",
"defaultBrandId",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Log",
"::",
"emergency",
"(",
"$",
"e",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
get default brand
@return numeric
|
[
"get",
"default",
"brand"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/src/Component/ComponentHandler.php#L255-L266
|
228,547
|
rollerworks/RouteAutowiringBundle
|
src/RouteSlotLoader.php
|
RouteSlotLoader.load
|
public function load($resource, $type = null)
{
if (!isset($this->slots[$resource])) {
$collection = new RouteCollection();
} else {
$collection = $this->container->get($this->slots[$resource])->build();
}
foreach ($this->resources as $trackedResource) {
$collection->addResource($trackedResource);
}
return $collection;
}
|
php
|
public function load($resource, $type = null)
{
if (!isset($this->slots[$resource])) {
$collection = new RouteCollection();
} else {
$collection = $this->container->get($this->slots[$resource])->build();
}
foreach ($this->resources as $trackedResource) {
$collection->addResource($trackedResource);
}
return $collection;
}
|
[
"public",
"function",
"load",
"(",
"$",
"resource",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"slots",
"[",
"$",
"resource",
"]",
")",
")",
"{",
"$",
"collection",
"=",
"new",
"RouteCollection",
"(",
")",
";",
"}",
"else",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"this",
"->",
"slots",
"[",
"$",
"resource",
"]",
")",
"->",
"build",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"resources",
"as",
"$",
"trackedResource",
")",
"{",
"$",
"collection",
"->",
"addResource",
"(",
"$",
"trackedResource",
")",
";",
"}",
"return",
"$",
"collection",
";",
"}"
] |
Loads a RouteCollection from a routing slot.
@param mixed $resource Some value that will resolve to a callable
@param string|null $type The resource type
@return RouteCollection returns an empty RouteCollection object when noå routes
are registered for the slot
|
[
"Loads",
"a",
"RouteCollection",
"from",
"a",
"routing",
"slot",
"."
] |
8b429a306ceef5e1d795359a20afaf1b0606fd60
|
https://github.com/rollerworks/RouteAutowiringBundle/blob/8b429a306ceef5e1d795359a20afaf1b0606fd60/src/RouteSlotLoader.php#L64-L77
|
228,548
|
antaresproject/core
|
src/ui/components/templates/src/Templates/Datatables.php
|
Datatables.getWidgetAttribute
|
protected static function getWidgetAttribute($name)
{
if (!empty(self::$staticAttributes)) {
return array_get(self::$staticAttributes, $name);
}
$classname = get_called_class();
if (app('request')->ajax()) {
self::setAjaxAttributes($classname);
} else {
$components = Registry::get('ui-components', []);
foreach ($components as $component) {
if ($classname !== get_class($component)) {
continue;
}
self::$staticAttributes = $component->getAttributes();
}
}
return array_get(self::$staticAttributes, $name);
}
|
php
|
protected static function getWidgetAttribute($name)
{
if (!empty(self::$staticAttributes)) {
return array_get(self::$staticAttributes, $name);
}
$classname = get_called_class();
if (app('request')->ajax()) {
self::setAjaxAttributes($classname);
} else {
$components = Registry::get('ui-components', []);
foreach ($components as $component) {
if ($classname !== get_class($component)) {
continue;
}
self::$staticAttributes = $component->getAttributes();
}
}
return array_get(self::$staticAttributes, $name);
}
|
[
"protected",
"static",
"function",
"getWidgetAttribute",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"self",
"::",
"$",
"staticAttributes",
")",
")",
"{",
"return",
"array_get",
"(",
"self",
"::",
"$",
"staticAttributes",
",",
"$",
"name",
")",
";",
"}",
"$",
"classname",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"app",
"(",
"'request'",
")",
"->",
"ajax",
"(",
")",
")",
"{",
"self",
"::",
"setAjaxAttributes",
"(",
"$",
"classname",
")",
";",
"}",
"else",
"{",
"$",
"components",
"=",
"Registry",
"::",
"get",
"(",
"'ui-components'",
",",
"[",
"]",
")",
";",
"foreach",
"(",
"$",
"components",
"as",
"$",
"component",
")",
"{",
"if",
"(",
"$",
"classname",
"!==",
"get_class",
"(",
"$",
"component",
")",
")",
"{",
"continue",
";",
"}",
"self",
"::",
"$",
"staticAttributes",
"=",
"$",
"component",
"->",
"getAttributes",
"(",
")",
";",
"}",
"}",
"return",
"array_get",
"(",
"self",
"::",
"$",
"staticAttributes",
",",
"$",
"name",
")",
";",
"}"
] |
Ui component attribute getter
@param String $name
@return mixed
|
[
"Ui",
"component",
"attribute",
"getter"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Templates/Datatables.php#L69-L88
|
228,549
|
antaresproject/core
|
src/ui/components/templates/src/Templates/Datatables.php
|
Datatables.setAjaxAttributes
|
private static function setAjaxAttributes($classname)
{
self::$staticAttributes = app($classname)->getAttributes();
$width = Input::get('width');
if ($width) {
$width = (int) (12 * $width) / 100;
array_set(self::$staticAttributes, 'width', $width);
}
$height = Input::get('height');
if ($height) {
$height = (int) (12 * $height) / 100;
array_set(self::$staticAttributes, 'height', $height);
}
return self::$staticAttributes;
}
|
php
|
private static function setAjaxAttributes($classname)
{
self::$staticAttributes = app($classname)->getAttributes();
$width = Input::get('width');
if ($width) {
$width = (int) (12 * $width) / 100;
array_set(self::$staticAttributes, 'width', $width);
}
$height = Input::get('height');
if ($height) {
$height = (int) (12 * $height) / 100;
array_set(self::$staticAttributes, 'height', $height);
}
return self::$staticAttributes;
}
|
[
"private",
"static",
"function",
"setAjaxAttributes",
"(",
"$",
"classname",
")",
"{",
"self",
"::",
"$",
"staticAttributes",
"=",
"app",
"(",
"$",
"classname",
")",
"->",
"getAttributes",
"(",
")",
";",
"$",
"width",
"=",
"Input",
"::",
"get",
"(",
"'width'",
")",
";",
"if",
"(",
"$",
"width",
")",
"{",
"$",
"width",
"=",
"(",
"int",
")",
"(",
"12",
"*",
"$",
"width",
")",
"/",
"100",
";",
"array_set",
"(",
"self",
"::",
"$",
"staticAttributes",
",",
"'width'",
",",
"$",
"width",
")",
";",
"}",
"$",
"height",
"=",
"Input",
"::",
"get",
"(",
"'height'",
")",
";",
"if",
"(",
"$",
"height",
")",
"{",
"$",
"height",
"=",
"(",
"int",
")",
"(",
"12",
"*",
"$",
"height",
")",
"/",
"100",
";",
"array_set",
"(",
"self",
"::",
"$",
"staticAttributes",
",",
"'height'",
",",
"$",
"height",
")",
";",
"}",
"return",
"self",
"::",
"$",
"staticAttributes",
";",
"}"
] |
When ajax request with changed ui component dimensions
@param String $classname
@return array
|
[
"When",
"ajax",
"request",
"with",
"changed",
"ui",
"component",
"dimensions"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Templates/Datatables.php#L96-L110
|
228,550
|
antaresproject/core
|
src/foundation/src/Http/Controllers/SecurityController.php
|
SecurityController.index
|
public function index(Processor $processor)
{
$this->breadcrumb->onSecurity();
$data = $processor->index();
return view('antares/foundation::settings.security.index', $data);
}
|
php
|
public function index(Processor $processor)
{
$this->breadcrumb->onSecurity();
$data = $processor->index();
return view('antares/foundation::settings.security.index', $data);
}
|
[
"public",
"function",
"index",
"(",
"Processor",
"$",
"processor",
")",
"{",
"$",
"this",
"->",
"breadcrumb",
"->",
"onSecurity",
"(",
")",
";",
"$",
"data",
"=",
"$",
"processor",
"->",
"index",
"(",
")",
";",
"return",
"view",
"(",
"'antares/foundation::settings.security.index'",
",",
"$",
"data",
")",
";",
"}"
] |
Shows security settings page.
@return \Illuminate\View\View
|
[
"Shows",
"security",
"settings",
"page",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Controllers/SecurityController.php#L68-L73
|
228,551
|
antaresproject/core
|
src/utils/monitor/src/ProcessMonitor.php
|
ProcessMonitor.check
|
public function check() : void {
$processesInfo = $this->getProcessesInfo();
foreach($this->processes as $process) {
foreach($processesInfo as $processInfo) {
if( Str::startsWith($processInfo->getCommand(), $process->getCommand()) ) {
$process->setInfo($processInfo);
break 2;
}
}
}
$this->checked = true;
}
|
php
|
public function check() : void {
$processesInfo = $this->getProcessesInfo();
foreach($this->processes as $process) {
foreach($processesInfo as $processInfo) {
if( Str::startsWith($processInfo->getCommand(), $process->getCommand()) ) {
$process->setInfo($processInfo);
break 2;
}
}
}
$this->checked = true;
}
|
[
"public",
"function",
"check",
"(",
")",
":",
"void",
"{",
"$",
"processesInfo",
"=",
"$",
"this",
"->",
"getProcessesInfo",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"processes",
"as",
"$",
"process",
")",
"{",
"foreach",
"(",
"$",
"processesInfo",
"as",
"$",
"processInfo",
")",
"{",
"if",
"(",
"Str",
"::",
"startsWith",
"(",
"$",
"processInfo",
"->",
"getCommand",
"(",
")",
",",
"$",
"process",
"->",
"getCommand",
"(",
")",
")",
")",
"{",
"$",
"process",
"->",
"setInfo",
"(",
"$",
"processInfo",
")",
";",
"break",
"2",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"checked",
"=",
"true",
";",
"}"
] |
Checks processes.
|
[
"Checks",
"processes",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/monitor/src/ProcessMonitor.php#L35-L48
|
228,552
|
antaresproject/core
|
src/utils/monitor/src/ProcessMonitor.php
|
ProcessMonitor.getProcessesInfo
|
public function getProcessesInfo() : array {
$processIds = [];
$processes = [];
$data = [];
exec('pgrep php', $processIds);
exec('ps ahxwwo pid:1,command:1 | grep php | grep -v grep | grep -v emacs', $processes);
foreach($processes as $process) {
$pid = explode(' ', trim($process), 2)[0];
if( in_array($pid, $processIds) ) {
$data[] = new ProcessInfo($process);
}
}
return $data;
}
|
php
|
public function getProcessesInfo() : array {
$processIds = [];
$processes = [];
$data = [];
exec('pgrep php', $processIds);
exec('ps ahxwwo pid:1,command:1 | grep php | grep -v grep | grep -v emacs', $processes);
foreach($processes as $process) {
$pid = explode(' ', trim($process), 2)[0];
if( in_array($pid, $processIds) ) {
$data[] = new ProcessInfo($process);
}
}
return $data;
}
|
[
"public",
"function",
"getProcessesInfo",
"(",
")",
":",
"array",
"{",
"$",
"processIds",
"=",
"[",
"]",
";",
"$",
"processes",
"=",
"[",
"]",
";",
"$",
"data",
"=",
"[",
"]",
";",
"exec",
"(",
"'pgrep php'",
",",
"$",
"processIds",
")",
";",
"exec",
"(",
"'ps ahxwwo pid:1,command:1 | grep php | grep -v grep | grep -v emacs'",
",",
"$",
"processes",
")",
";",
"foreach",
"(",
"$",
"processes",
"as",
"$",
"process",
")",
"{",
"$",
"pid",
"=",
"explode",
"(",
"' '",
",",
"trim",
"(",
"$",
"process",
")",
",",
"2",
")",
"[",
"0",
"]",
";",
"if",
"(",
"in_array",
"(",
"$",
"pid",
",",
"$",
"processIds",
")",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"new",
"ProcessInfo",
"(",
"$",
"process",
")",
";",
"}",
"}",
"return",
"$",
"data",
";",
"}"
] |
Returns list of running processes.
@return ProcessInfo[]
|
[
"Returns",
"list",
"of",
"running",
"processes",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/monitor/src/ProcessMonitor.php#L68-L85
|
228,553
|
antaresproject/core
|
src/utils/monitor/src/ProcessMonitor.php
|
ProcessMonitor.getProcessByCommand
|
public function getProcessByCommand(string $command) : Process {
if( ! array_key_exists($command, $this->processes) ) {
$this->watch($command);
}
foreach($this->getWatchedProcesses() as $process) {
if($process->getCommand() === $command) {
return $process;
}
}
}
|
php
|
public function getProcessByCommand(string $command) : Process {
if( ! array_key_exists($command, $this->processes) ) {
$this->watch($command);
}
foreach($this->getWatchedProcesses() as $process) {
if($process->getCommand() === $command) {
return $process;
}
}
}
|
[
"public",
"function",
"getProcessByCommand",
"(",
"string",
"$",
"command",
")",
":",
"Process",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"command",
",",
"$",
"this",
"->",
"processes",
")",
")",
"{",
"$",
"this",
"->",
"watch",
"(",
"$",
"command",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getWatchedProcesses",
"(",
")",
"as",
"$",
"process",
")",
"{",
"if",
"(",
"$",
"process",
"->",
"getCommand",
"(",
")",
"===",
"$",
"command",
")",
"{",
"return",
"$",
"process",
";",
"}",
"}",
"}"
] |
Returns process info about command.
@param string $command
@return Process
|
[
"Returns",
"process",
"info",
"about",
"command",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/monitor/src/ProcessMonitor.php#L93-L103
|
228,554
|
antaresproject/core
|
src/utils/monitor/src/ProcessMonitor.php
|
ProcessMonitor.run
|
public function run(string $command) : Process {
$mutedCommand = Str::startsWith($command, 'artisan')
? str_replace('artisan ', '', $command)
: $command;
ignore_user_abort();
$logName = explode(' -', $mutedCommand, 2)[0];
$log = storage_path('logs' . DIRECTORY_SEPARATOR . snake_case(Str::slug($logName)) . '.log');
$rootPath = base_path();
shell_exec("cd $rootPath && php artisan $mutedCommand >> " . $log . " &");
exec('pgrep php', $processIds);
exec('ps ahxwwo pid:1,command:1 | grep php | grep -v grep | grep -v emacs', $processes);
$this->check();
return $this->getProcessByCommand($command);
}
|
php
|
public function run(string $command) : Process {
$mutedCommand = Str::startsWith($command, 'artisan')
? str_replace('artisan ', '', $command)
: $command;
ignore_user_abort();
$logName = explode(' -', $mutedCommand, 2)[0];
$log = storage_path('logs' . DIRECTORY_SEPARATOR . snake_case(Str::slug($logName)) . '.log');
$rootPath = base_path();
shell_exec("cd $rootPath && php artisan $mutedCommand >> " . $log . " &");
exec('pgrep php', $processIds);
exec('ps ahxwwo pid:1,command:1 | grep php | grep -v grep | grep -v emacs', $processes);
$this->check();
return $this->getProcessByCommand($command);
}
|
[
"public",
"function",
"run",
"(",
"string",
"$",
"command",
")",
":",
"Process",
"{",
"$",
"mutedCommand",
"=",
"Str",
"::",
"startsWith",
"(",
"$",
"command",
",",
"'artisan'",
")",
"?",
"str_replace",
"(",
"'artisan '",
",",
"''",
",",
"$",
"command",
")",
":",
"$",
"command",
";",
"ignore_user_abort",
"(",
")",
";",
"$",
"logName",
"=",
"explode",
"(",
"' -'",
",",
"$",
"mutedCommand",
",",
"2",
")",
"[",
"0",
"]",
";",
"$",
"log",
"=",
"storage_path",
"(",
"'logs'",
".",
"DIRECTORY_SEPARATOR",
".",
"snake_case",
"(",
"Str",
"::",
"slug",
"(",
"$",
"logName",
")",
")",
".",
"'.log'",
")",
";",
"$",
"rootPath",
"=",
"base_path",
"(",
")",
";",
"shell_exec",
"(",
"\"cd $rootPath && php artisan $mutedCommand >> \"",
".",
"$",
"log",
".",
"\" &\"",
")",
";",
"exec",
"(",
"'pgrep php'",
",",
"$",
"processIds",
")",
";",
"exec",
"(",
"'ps ahxwwo pid:1,command:1 | grep php | grep -v grep | grep -v emacs'",
",",
"$",
"processes",
")",
";",
"$",
"this",
"->",
"check",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getProcessByCommand",
"(",
"$",
"command",
")",
";",
"}"
] |
Runs new process and return info about it.
@param string $command
@return Process
|
[
"Runs",
"new",
"process",
"and",
"return",
"info",
"about",
"it",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/monitor/src/ProcessMonitor.php#L111-L130
|
228,555
|
antaresproject/core
|
src/ui/components/templates/src/Factory.php
|
Factory.detect
|
public function detect()
{
$components = $this->finder()->detect();
if (!$this->isValidRoute()) {
return $components;
}
$this->app->make('events')->fire('antares.ui-components: detecting');
$this->app->make('events')->fire(new ComponentsDetecting());
$service = app(Service::class);
foreach ($components as $component) {
$result = $service->findOne($component, uri());
if (!empty($result)) {
continue;
}
$this->app->make('ui-components')->save(array_get($component, 'name'), $component);
}
return $components;
}
|
php
|
public function detect()
{
$components = $this->finder()->detect();
if (!$this->isValidRoute()) {
return $components;
}
$this->app->make('events')->fire('antares.ui-components: detecting');
$this->app->make('events')->fire(new ComponentsDetecting());
$service = app(Service::class);
foreach ($components as $component) {
$result = $service->findOne($component, uri());
if (!empty($result)) {
continue;
}
$this->app->make('ui-components')->save(array_get($component, 'name'), $component);
}
return $components;
}
|
[
"public",
"function",
"detect",
"(",
")",
"{",
"$",
"components",
"=",
"$",
"this",
"->",
"finder",
"(",
")",
"->",
"detect",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isValidRoute",
"(",
")",
")",
"{",
"return",
"$",
"components",
";",
"}",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'events'",
")",
"->",
"fire",
"(",
"'antares.ui-components: detecting'",
")",
";",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'events'",
")",
"->",
"fire",
"(",
"new",
"ComponentsDetecting",
"(",
")",
")",
";",
"$",
"service",
"=",
"app",
"(",
"Service",
"::",
"class",
")",
";",
"foreach",
"(",
"$",
"components",
"as",
"$",
"component",
")",
"{",
"$",
"result",
"=",
"$",
"service",
"->",
"findOne",
"(",
"$",
"component",
",",
"uri",
"(",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'ui-components'",
")",
"->",
"save",
"(",
"array_get",
"(",
"$",
"component",
",",
"'name'",
")",
",",
"$",
"component",
")",
";",
"}",
"return",
"$",
"components",
";",
"}"
] |
Detect all ui components.
@return \Illuminate\Support\Collection|array
|
[
"Detect",
"all",
"ui",
"components",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Factory.php#L87-L108
|
228,556
|
antaresproject/core
|
src/ui/components/templates/src/Factory.php
|
Factory.isValidRoute
|
protected function isValidRoute()
{
try {
$current = Route::current();
if (!$current) {
return false;
}
$action = $current->action;
$as = array_get($action, 'as');
return str_contains($as, 'show') or str_contains($as, 'dashboard');
} catch (Exception $ex) {
return false;
}
}
|
php
|
protected function isValidRoute()
{
try {
$current = Route::current();
if (!$current) {
return false;
}
$action = $current->action;
$as = array_get($action, 'as');
return str_contains($as, 'show') or str_contains($as, 'dashboard');
} catch (Exception $ex) {
return false;
}
}
|
[
"protected",
"function",
"isValidRoute",
"(",
")",
"{",
"try",
"{",
"$",
"current",
"=",
"Route",
"::",
"current",
"(",
")",
";",
"if",
"(",
"!",
"$",
"current",
")",
"{",
"return",
"false",
";",
"}",
"$",
"action",
"=",
"$",
"current",
"->",
"action",
";",
"$",
"as",
"=",
"array_get",
"(",
"$",
"action",
",",
"'as'",
")",
";",
"return",
"str_contains",
"(",
"$",
"as",
",",
"'show'",
")",
"or",
"str_contains",
"(",
"$",
"as",
",",
"'dashboard'",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"return",
"false",
";",
"}",
"}"
] |
Whether route is valid to view widgets
@return boolean
|
[
"Whether",
"route",
"is",
"valid",
"to",
"view",
"widgets"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Factory.php#L115-L129
|
228,557
|
antaresproject/core
|
src/ui/components/templates/src/Factory.php
|
Factory.detectTemplates
|
public function detectTemplates()
{
$this->app->make('events')->fire('antares.ui-components.templates: detecting');
$this->app->make('events')->fire(new ComponentTemplatesDetecting());
return $this->templateFinder()->detect()->toArray();
}
|
php
|
public function detectTemplates()
{
$this->app->make('events')->fire('antares.ui-components.templates: detecting');
$this->app->make('events')->fire(new ComponentTemplatesDetecting());
return $this->templateFinder()->detect()->toArray();
}
|
[
"public",
"function",
"detectTemplates",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'events'",
")",
"->",
"fire",
"(",
"'antares.ui-components.templates: detecting'",
")",
";",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'events'",
")",
"->",
"fire",
"(",
"new",
"ComponentTemplatesDetecting",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"templateFinder",
"(",
")",
"->",
"detect",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"}"
] |
Detects ui component templates
@return array
|
[
"Detects",
"ui",
"component",
"templates"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Factory.php#L136-L141
|
228,558
|
antaresproject/core
|
src/utils/date/src/DateFormatter.php
|
DateFormatter.formatTimeAgoForHumans
|
public function formatTimeAgoForHumans($date, $html = true)
{
$value = Carbon::createFromTimeStamp(strtotime($date))->diffForHumans();
return ($html) ? $this->decorate($value, $date) : $value;
}
|
php
|
public function formatTimeAgoForHumans($date, $html = true)
{
$value = Carbon::createFromTimeStamp(strtotime($date))->diffForHumans();
return ($html) ? $this->decorate($value, $date) : $value;
}
|
[
"public",
"function",
"formatTimeAgoForHumans",
"(",
"$",
"date",
",",
"$",
"html",
"=",
"true",
")",
"{",
"$",
"value",
"=",
"Carbon",
"::",
"createFromTimeStamp",
"(",
"strtotime",
"(",
"$",
"date",
")",
")",
"->",
"diffForHumans",
"(",
")",
";",
"return",
"(",
"$",
"html",
")",
"?",
"$",
"this",
"->",
"decorate",
"(",
"$",
"value",
",",
"$",
"date",
")",
":",
"$",
"value",
";",
"}"
] |
creates representation of human readable date in the past
@param string $date
@param bool $html
@return String
|
[
"creates",
"representation",
"of",
"human",
"readable",
"date",
"in",
"the",
"past"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/date/src/DateFormatter.php#L41-L45
|
228,559
|
antaresproject/core
|
src/ui/components/templates/src/Http/Handlers/ComponentsSelector.php
|
ComponentsSelector.getPageId
|
protected function getPageId()
{
$route = call_user_func($this->container->make('request')->getRouteResolver());
if (is_null($route)) {
return false;
}
$action = $route->getAction();
$controller = isset($action['controller']) ? $action['controller'] : null;
if (is_null($controller)) {
return false;
}
$resource = $this->container->make('config')->get('antares/ui-components::pages.resource');
if ($controller == $resource) {
return $route->parameter('id');
}
return false;
}
|
php
|
protected function getPageId()
{
$route = call_user_func($this->container->make('request')->getRouteResolver());
if (is_null($route)) {
return false;
}
$action = $route->getAction();
$controller = isset($action['controller']) ? $action['controller'] : null;
if (is_null($controller)) {
return false;
}
$resource = $this->container->make('config')->get('antares/ui-components::pages.resource');
if ($controller == $resource) {
return $route->parameter('id');
}
return false;
}
|
[
"protected",
"function",
"getPageId",
"(",
")",
"{",
"$",
"route",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"'request'",
")",
"->",
"getRouteResolver",
"(",
")",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"route",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"action",
"=",
"$",
"route",
"->",
"getAction",
"(",
")",
";",
"$",
"controller",
"=",
"isset",
"(",
"$",
"action",
"[",
"'controller'",
"]",
")",
"?",
"$",
"action",
"[",
"'controller'",
"]",
":",
"null",
";",
"if",
"(",
"is_null",
"(",
"$",
"controller",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"resource",
"=",
"$",
"this",
"->",
"container",
"->",
"make",
"(",
"'config'",
")",
"->",
"get",
"(",
"'antares/ui-components::pages.resource'",
")",
";",
"if",
"(",
"$",
"controller",
"==",
"$",
"resource",
")",
"{",
"return",
"$",
"route",
"->",
"parameter",
"(",
"'id'",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
get page id by route
@return boolean | int
|
[
"get",
"page",
"id",
"by",
"route"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Http/Handlers/ComponentsSelector.php#L74-L92
|
228,560
|
antaresproject/core
|
src/ui/components/templates/src/Http/Handlers/ComponentsSelector.php
|
ComponentsSelector.createItem
|
protected function createItem(array $component)
{
$classname = array_get($component, 'data.classname');
if (!$this->dispatchable($classname)) {
return;
}
$id = $component['id'];
$attr = array_get($component, 'data', []);
$this->handler->add($id, '^:ui-components-selector')
->title($attr['name'])
->link(handles("antares/ui-components::ui-components/view/{$id}", ['csrf' => true]))
->icon('fa fa-plus-circle')
->attributes(array_only($attr, ['x', 'y', 'width', 'height', 'disabled']) + ['rel' => $id, 'classname' => $classname]);
}
|
php
|
protected function createItem(array $component)
{
$classname = array_get($component, 'data.classname');
if (!$this->dispatchable($classname)) {
return;
}
$id = $component['id'];
$attr = array_get($component, 'data', []);
$this->handler->add($id, '^:ui-components-selector')
->title($attr['name'])
->link(handles("antares/ui-components::ui-components/view/{$id}", ['csrf' => true]))
->icon('fa fa-plus-circle')
->attributes(array_only($attr, ['x', 'y', 'width', 'height', 'disabled']) + ['rel' => $id, 'classname' => $classname]);
}
|
[
"protected",
"function",
"createItem",
"(",
"array",
"$",
"component",
")",
"{",
"$",
"classname",
"=",
"array_get",
"(",
"$",
"component",
",",
"'data.classname'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"dispatchable",
"(",
"$",
"classname",
")",
")",
"{",
"return",
";",
"}",
"$",
"id",
"=",
"$",
"component",
"[",
"'id'",
"]",
";",
"$",
"attr",
"=",
"array_get",
"(",
"$",
"component",
",",
"'data'",
",",
"[",
"]",
")",
";",
"$",
"this",
"->",
"handler",
"->",
"add",
"(",
"$",
"id",
",",
"'^:ui-components-selector'",
")",
"->",
"title",
"(",
"$",
"attr",
"[",
"'name'",
"]",
")",
"->",
"link",
"(",
"handles",
"(",
"\"antares/ui-components::ui-components/view/{$id}\"",
",",
"[",
"'csrf'",
"=>",
"true",
"]",
")",
")",
"->",
"icon",
"(",
"'fa fa-plus-circle'",
")",
"->",
"attributes",
"(",
"array_only",
"(",
"$",
"attr",
",",
"[",
"'x'",
",",
"'y'",
",",
"'width'",
",",
"'height'",
",",
"'disabled'",
"]",
")",
"+",
"[",
"'rel'",
"=>",
"$",
"id",
",",
"'classname'",
"=>",
"$",
"classname",
"]",
")",
";",
"}"
] |
create menu item by ui component attributes
@param array $component
@return null
|
[
"create",
"menu",
"item",
"by",
"ui",
"component",
"attributes"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Http/Handlers/ComponentsSelector.php#L128-L144
|
228,561
|
antaresproject/core
|
src/foundation/src/Http/Handlers/SecurityMenu.php
|
SecurityMenu.authorize
|
public function authorize(Authorization $acl)
{
$active = (extension_active('ban_management') or extension_active('two_factor_auth'));
if (!$active) {
return false;
}
return $acl->can('manage-antares');
}
|
php
|
public function authorize(Authorization $acl)
{
$active = (extension_active('ban_management') or extension_active('two_factor_auth'));
if (!$active) {
return false;
}
return $acl->can('manage-antares');
}
|
[
"public",
"function",
"authorize",
"(",
"Authorization",
"$",
"acl",
")",
"{",
"$",
"active",
"=",
"(",
"extension_active",
"(",
"'ban_management'",
")",
"or",
"extension_active",
"(",
"'two_factor_auth'",
")",
")",
";",
"if",
"(",
"!",
"$",
"active",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"acl",
"->",
"can",
"(",
"'manage-antares'",
")",
";",
"}"
] |
Check authorization to display the menu.
@param \Antares\Contracts\Authorization\Authorization $acl
@return bool
|
[
"Check",
"authorization",
"to",
"display",
"the",
"menu",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Handlers/SecurityMenu.php#L50-L58
|
228,562
|
antaresproject/core
|
src/foundation/src/Processor/FilterProcessor.php
|
FilterProcessor.store
|
public function store()
{
$inputs = Input::all();
$params = array_get($inputs, 'params');
$column = $params['column'];
$route = uri();
$session = $this->request->session();
$classname = array_get($inputs, 'classname');
$data = $this->prepareToSave($classname, $params, $session->get($route));
$session->put($route, $data);
$session->save();
$data = $this->prepareToSave($classname, $params, $session->get($route));
$string = app($classname)->sidebar($data);
if (strlen($string) > 0) {
return response($string, 200);
}
$sidebar = $this->adapter->sidebar($column, $data[$column], $params['value']);
return response($sidebar, 200);
}
|
php
|
public function store()
{
$inputs = Input::all();
$params = array_get($inputs, 'params');
$column = $params['column'];
$route = uri();
$session = $this->request->session();
$classname = array_get($inputs, 'classname');
$data = $this->prepareToSave($classname, $params, $session->get($route));
$session->put($route, $data);
$session->save();
$data = $this->prepareToSave($classname, $params, $session->get($route));
$string = app($classname)->sidebar($data);
if (strlen($string) > 0) {
return response($string, 200);
}
$sidebar = $this->adapter->sidebar($column, $data[$column], $params['value']);
return response($sidebar, 200);
}
|
[
"public",
"function",
"store",
"(",
")",
"{",
"$",
"inputs",
"=",
"Input",
"::",
"all",
"(",
")",
";",
"$",
"params",
"=",
"array_get",
"(",
"$",
"inputs",
",",
"'params'",
")",
";",
"$",
"column",
"=",
"$",
"params",
"[",
"'column'",
"]",
";",
"$",
"route",
"=",
"uri",
"(",
")",
";",
"$",
"session",
"=",
"$",
"this",
"->",
"request",
"->",
"session",
"(",
")",
";",
"$",
"classname",
"=",
"array_get",
"(",
"$",
"inputs",
",",
"'classname'",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"prepareToSave",
"(",
"$",
"classname",
",",
"$",
"params",
",",
"$",
"session",
"->",
"get",
"(",
"$",
"route",
")",
")",
";",
"$",
"session",
"->",
"put",
"(",
"$",
"route",
",",
"$",
"data",
")",
";",
"$",
"session",
"->",
"save",
"(",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"prepareToSave",
"(",
"$",
"classname",
",",
"$",
"params",
",",
"$",
"session",
"->",
"get",
"(",
"$",
"route",
")",
")",
";",
"$",
"string",
"=",
"app",
"(",
"$",
"classname",
")",
"->",
"sidebar",
"(",
"$",
"data",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"string",
")",
">",
"0",
")",
"{",
"return",
"response",
"(",
"$",
"string",
",",
"200",
")",
";",
"}",
"$",
"sidebar",
"=",
"$",
"this",
"->",
"adapter",
"->",
"sidebar",
"(",
"$",
"column",
",",
"$",
"data",
"[",
"$",
"column",
"]",
",",
"$",
"params",
"[",
"'value'",
"]",
")",
";",
"return",
"response",
"(",
"$",
"sidebar",
",",
"200",
")",
";",
"}"
] |
stores filter data in session
@return type
|
[
"stores",
"filter",
"data",
"in",
"session"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Processor/FilterProcessor.php#L63-L83
|
228,563
|
antaresproject/core
|
src/foundation/src/Processor/FilterProcessor.php
|
FilterProcessor.prepareToSave
|
protected function prepareToSave($classname, array $params = [], array $paramsFromSession = null)
{
$column = $params['column'];
$return = [];
if (is_null($paramsFromSession)) {
$return[$column]['classname'] = $classname;
$return[$column]['values'] = [$params['value']];
//this chunk of code will automatically add custom $params values
//everything else then 'value' will be saved in session
//this allow developer to send custom parameters through request
foreach ($params as $key => $value) {
if ($key == 'value') {
continue;
}
$return[$column][$key . 's'] = [$params[$key]];
}
} elseif (isset($paramsFromSession[$column])) {
$paramsFromSession[$column]['values'][] = $params['value'];
//this chunk of code will automatically add custom $params values
//everything else then 'value' will be add to already existing key in session and saved
//this allow developer to send custom parameters through request
foreach ($params as $key => $value) {
if ($key == 'value') {
continue;
}
$paramsFromSession[$column][$key . 's'][] = $params[$key];
$return[$column][$key . 's'] = $paramsFromSession[$column][$key . 's'];
}
$return[$column]['values'] = $paramsFromSession[$column]['values'];
$return[$column]['classname'] = $classname;
} else {
$return = $paramsFromSession;
$return[$column]['classname'] = $classname;
$return[$column]['values'] = [$params['value']];
//this chunk of code will automatically add custom $params values
//everything else then 'value' will be saved in session
//this allows developer to send custom parameters through request
foreach ($params as $key => $value) {
if ($key == 'value') {
continue;
}
$return[$column][$key . 's'] = [$params[$key]];
}
}
if (!empty($paramsFromSession)) {
foreach ($paramsFromSession as $storedColumn => $config) {
if ($storedColumn == $column) {
continue;
}
$return[$storedColumn] = $config;
}
}
return $return;
}
|
php
|
protected function prepareToSave($classname, array $params = [], array $paramsFromSession = null)
{
$column = $params['column'];
$return = [];
if (is_null($paramsFromSession)) {
$return[$column]['classname'] = $classname;
$return[$column]['values'] = [$params['value']];
//this chunk of code will automatically add custom $params values
//everything else then 'value' will be saved in session
//this allow developer to send custom parameters through request
foreach ($params as $key => $value) {
if ($key == 'value') {
continue;
}
$return[$column][$key . 's'] = [$params[$key]];
}
} elseif (isset($paramsFromSession[$column])) {
$paramsFromSession[$column]['values'][] = $params['value'];
//this chunk of code will automatically add custom $params values
//everything else then 'value' will be add to already existing key in session and saved
//this allow developer to send custom parameters through request
foreach ($params as $key => $value) {
if ($key == 'value') {
continue;
}
$paramsFromSession[$column][$key . 's'][] = $params[$key];
$return[$column][$key . 's'] = $paramsFromSession[$column][$key . 's'];
}
$return[$column]['values'] = $paramsFromSession[$column]['values'];
$return[$column]['classname'] = $classname;
} else {
$return = $paramsFromSession;
$return[$column]['classname'] = $classname;
$return[$column]['values'] = [$params['value']];
//this chunk of code will automatically add custom $params values
//everything else then 'value' will be saved in session
//this allows developer to send custom parameters through request
foreach ($params as $key => $value) {
if ($key == 'value') {
continue;
}
$return[$column][$key . 's'] = [$params[$key]];
}
}
if (!empty($paramsFromSession)) {
foreach ($paramsFromSession as $storedColumn => $config) {
if ($storedColumn == $column) {
continue;
}
$return[$storedColumn] = $config;
}
}
return $return;
}
|
[
"protected",
"function",
"prepareToSave",
"(",
"$",
"classname",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"array",
"$",
"paramsFromSession",
"=",
"null",
")",
"{",
"$",
"column",
"=",
"$",
"params",
"[",
"'column'",
"]",
";",
"$",
"return",
"=",
"[",
"]",
";",
"if",
"(",
"is_null",
"(",
"$",
"paramsFromSession",
")",
")",
"{",
"$",
"return",
"[",
"$",
"column",
"]",
"[",
"'classname'",
"]",
"=",
"$",
"classname",
";",
"$",
"return",
"[",
"$",
"column",
"]",
"[",
"'values'",
"]",
"=",
"[",
"$",
"params",
"[",
"'value'",
"]",
"]",
";",
"//this chunk of code will automatically add custom $params values",
"//everything else then 'value' will be saved in session",
"//this allow developer to send custom parameters through request",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"'value'",
")",
"{",
"continue",
";",
"}",
"$",
"return",
"[",
"$",
"column",
"]",
"[",
"$",
"key",
".",
"'s'",
"]",
"=",
"[",
"$",
"params",
"[",
"$",
"key",
"]",
"]",
";",
"}",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"paramsFromSession",
"[",
"$",
"column",
"]",
")",
")",
"{",
"$",
"paramsFromSession",
"[",
"$",
"column",
"]",
"[",
"'values'",
"]",
"[",
"]",
"=",
"$",
"params",
"[",
"'value'",
"]",
";",
"//this chunk of code will automatically add custom $params values",
"//everything else then 'value' will be add to already existing key in session and saved",
"//this allow developer to send custom parameters through request",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"'value'",
")",
"{",
"continue",
";",
"}",
"$",
"paramsFromSession",
"[",
"$",
"column",
"]",
"[",
"$",
"key",
".",
"'s'",
"]",
"[",
"]",
"=",
"$",
"params",
"[",
"$",
"key",
"]",
";",
"$",
"return",
"[",
"$",
"column",
"]",
"[",
"$",
"key",
".",
"'s'",
"]",
"=",
"$",
"paramsFromSession",
"[",
"$",
"column",
"]",
"[",
"$",
"key",
".",
"'s'",
"]",
";",
"}",
"$",
"return",
"[",
"$",
"column",
"]",
"[",
"'values'",
"]",
"=",
"$",
"paramsFromSession",
"[",
"$",
"column",
"]",
"[",
"'values'",
"]",
";",
"$",
"return",
"[",
"$",
"column",
"]",
"[",
"'classname'",
"]",
"=",
"$",
"classname",
";",
"}",
"else",
"{",
"$",
"return",
"=",
"$",
"paramsFromSession",
";",
"$",
"return",
"[",
"$",
"column",
"]",
"[",
"'classname'",
"]",
"=",
"$",
"classname",
";",
"$",
"return",
"[",
"$",
"column",
"]",
"[",
"'values'",
"]",
"=",
"[",
"$",
"params",
"[",
"'value'",
"]",
"]",
";",
"//this chunk of code will automatically add custom $params values",
"//everything else then 'value' will be saved in session",
"//this allows developer to send custom parameters through request ",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"'value'",
")",
"{",
"continue",
";",
"}",
"$",
"return",
"[",
"$",
"column",
"]",
"[",
"$",
"key",
".",
"'s'",
"]",
"=",
"[",
"$",
"params",
"[",
"$",
"key",
"]",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"paramsFromSession",
")",
")",
"{",
"foreach",
"(",
"$",
"paramsFromSession",
"as",
"$",
"storedColumn",
"=>",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"storedColumn",
"==",
"$",
"column",
")",
"{",
"continue",
";",
"}",
"$",
"return",
"[",
"$",
"storedColumn",
"]",
"=",
"$",
"config",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] |
prepares data to store in session
@param String $classname
@param array $params
@param array $paramsFromSession
@return array
|
[
"prepares",
"data",
"to",
"store",
"in",
"session"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Processor/FilterProcessor.php#L93-L148
|
228,564
|
antaresproject/core
|
src/foundation/src/Processor/FilterProcessor.php
|
FilterProcessor.destroy
|
public function destroy()
{
$inputs = Input::all();
$params = array_get($inputs, 'params');
if (($unserialized = $this->unserialize($params['value'])) !== false) {
$params['value'] = $unserialized;
}
$route = uri();
$session = $this->request->session();
if (!$session->has($route)) {
return response('', 200);
}
$paramsFromSession = $session->get($route);
$data = $this->prepareToDestroy($params, $paramsFromSession);
$session->put($route, $data);
$session->save();
return response('', 200);
}
|
php
|
public function destroy()
{
$inputs = Input::all();
$params = array_get($inputs, 'params');
if (($unserialized = $this->unserialize($params['value'])) !== false) {
$params['value'] = $unserialized;
}
$route = uri();
$session = $this->request->session();
if (!$session->has($route)) {
return response('', 200);
}
$paramsFromSession = $session->get($route);
$data = $this->prepareToDestroy($params, $paramsFromSession);
$session->put($route, $data);
$session->save();
return response('', 200);
}
|
[
"public",
"function",
"destroy",
"(",
")",
"{",
"$",
"inputs",
"=",
"Input",
"::",
"all",
"(",
")",
";",
"$",
"params",
"=",
"array_get",
"(",
"$",
"inputs",
",",
"'params'",
")",
";",
"if",
"(",
"(",
"$",
"unserialized",
"=",
"$",
"this",
"->",
"unserialize",
"(",
"$",
"params",
"[",
"'value'",
"]",
")",
")",
"!==",
"false",
")",
"{",
"$",
"params",
"[",
"'value'",
"]",
"=",
"$",
"unserialized",
";",
"}",
"$",
"route",
"=",
"uri",
"(",
")",
";",
"$",
"session",
"=",
"$",
"this",
"->",
"request",
"->",
"session",
"(",
")",
";",
"if",
"(",
"!",
"$",
"session",
"->",
"has",
"(",
"$",
"route",
")",
")",
"{",
"return",
"response",
"(",
"''",
",",
"200",
")",
";",
"}",
"$",
"paramsFromSession",
"=",
"$",
"session",
"->",
"get",
"(",
"$",
"route",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"prepareToDestroy",
"(",
"$",
"params",
",",
"$",
"paramsFromSession",
")",
";",
"$",
"session",
"->",
"put",
"(",
"$",
"route",
",",
"$",
"data",
")",
";",
"$",
"session",
"->",
"save",
"(",
")",
";",
"return",
"response",
"(",
"''",
",",
"200",
")",
";",
"}"
] |
deletes filter settings from session
@return type
|
[
"deletes",
"filter",
"settings",
"from",
"session"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Processor/FilterProcessor.php#L155-L173
|
228,565
|
antaresproject/core
|
src/foundation/src/Processor/FilterProcessor.php
|
FilterProcessor.prepareToDestroy
|
protected function prepareToDestroy(array $params = [], array $paramsFromSession = null)
{
$return = [];
foreach ($paramsFromSession as $name => $values) {
if ($params['column'] == $name) {
$return[$name] = [];
}
// if (!empty($values['values'])) {
// $return[$name]['values'] = $values['values'];
// }
// if (!isset($return[$name]['classname'])) {
// $return[$name]['classname'] = $paramsFromSession[$name]['classname'];
// }
}
return $return;
}
|
php
|
protected function prepareToDestroy(array $params = [], array $paramsFromSession = null)
{
$return = [];
foreach ($paramsFromSession as $name => $values) {
if ($params['column'] == $name) {
$return[$name] = [];
}
// if (!empty($values['values'])) {
// $return[$name]['values'] = $values['values'];
// }
// if (!isset($return[$name]['classname'])) {
// $return[$name]['classname'] = $paramsFromSession[$name]['classname'];
// }
}
return $return;
}
|
[
"protected",
"function",
"prepareToDestroy",
"(",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"array",
"$",
"paramsFromSession",
"=",
"null",
")",
"{",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"paramsFromSession",
"as",
"$",
"name",
"=>",
"$",
"values",
")",
"{",
"if",
"(",
"$",
"params",
"[",
"'column'",
"]",
"==",
"$",
"name",
")",
"{",
"$",
"return",
"[",
"$",
"name",
"]",
"=",
"[",
"]",
";",
"}",
"// if (!empty($values['values'])) {",
"// $return[$name]['values'] = $values['values'];",
"// }",
"// if (!isset($return[$name]['classname'])) {",
"// $return[$name]['classname'] = $paramsFromSession[$name]['classname'];",
"// }",
"}",
"return",
"$",
"return",
";",
"}"
] |
prepare data to remove from session
@param array $params
@param array $paramsFromSession
@return array
|
[
"prepare",
"data",
"to",
"remove",
"from",
"session"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Processor/FilterProcessor.php#L182-L197
|
228,566
|
antaresproject/core
|
src/foundation/src/Processor/FilterProcessor.php
|
FilterProcessor.unserialize
|
protected function unserialize($str)
{
$str = str_replace("'", '"', $str);
$data = @unserialize($str);
if ($str === 'b:0;' || $data !== false) {
return $data;
}
return false;
}
|
php
|
protected function unserialize($str)
{
$str = str_replace("'", '"', $str);
$data = @unserialize($str);
if ($str === 'b:0;' || $data !== false) {
return $data;
}
return false;
}
|
[
"protected",
"function",
"unserialize",
"(",
"$",
"str",
")",
"{",
"$",
"str",
"=",
"str_replace",
"(",
"\"'\"",
",",
"'\"'",
",",
"$",
"str",
")",
";",
"$",
"data",
"=",
"@",
"unserialize",
"(",
"$",
"str",
")",
";",
"if",
"(",
"$",
"str",
"===",
"'b:0;'",
"||",
"$",
"data",
"!==",
"false",
")",
"{",
"return",
"$",
"data",
";",
"}",
"return",
"false",
";",
"}"
] |
custom string unserializator
@param String $str
@return boolean
|
[
"custom",
"string",
"unserializator"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Processor/FilterProcessor.php#L205-L213
|
228,567
|
antaresproject/core
|
src/foundation/src/Processor/FilterProcessor.php
|
FilterProcessor.update
|
public function update()
{
$inputs = Input::all();
$s = $this->request->session();
$route = uri();
$session = $s->get($route, []);
if (empty($session)) {
return false;
}
if (is_null($column = array_get($inputs, 'column'))) {
return false;
}
if (!isset($session[$column]['values'])) {
return false;
}
$old = !is_null($serialized = array_get($inputs, 'serialized')) ? unserialize($serialized) : array_get($inputs, 'old');
$new = array_get($inputs, 'new');
$index = array_search($old, $session[$column]['values']);
if ($index !== false) {
unset($session[$column]['values'][$index]);
}
$session[$column]['values'][] = $new;
$sidebars = $this->adapter->getDeleteSidebarItem($column, $session[$column], $new);
if (!empty($sidebars)) {
$s->put($route, [$column => $session[$column]]);
$s->save();
return response(implode('', $sidebars), 200);
}
}
|
php
|
public function update()
{
$inputs = Input::all();
$s = $this->request->session();
$route = uri();
$session = $s->get($route, []);
if (empty($session)) {
return false;
}
if (is_null($column = array_get($inputs, 'column'))) {
return false;
}
if (!isset($session[$column]['values'])) {
return false;
}
$old = !is_null($serialized = array_get($inputs, 'serialized')) ? unserialize($serialized) : array_get($inputs, 'old');
$new = array_get($inputs, 'new');
$index = array_search($old, $session[$column]['values']);
if ($index !== false) {
unset($session[$column]['values'][$index]);
}
$session[$column]['values'][] = $new;
$sidebars = $this->adapter->getDeleteSidebarItem($column, $session[$column], $new);
if (!empty($sidebars)) {
$s->put($route, [$column => $session[$column]]);
$s->save();
return response(implode('', $sidebars), 200);
}
}
|
[
"public",
"function",
"update",
"(",
")",
"{",
"$",
"inputs",
"=",
"Input",
"::",
"all",
"(",
")",
";",
"$",
"s",
"=",
"$",
"this",
"->",
"request",
"->",
"session",
"(",
")",
";",
"$",
"route",
"=",
"uri",
"(",
")",
";",
"$",
"session",
"=",
"$",
"s",
"->",
"get",
"(",
"$",
"route",
",",
"[",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"session",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"column",
"=",
"array_get",
"(",
"$",
"inputs",
",",
"'column'",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"session",
"[",
"$",
"column",
"]",
"[",
"'values'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"old",
"=",
"!",
"is_null",
"(",
"$",
"serialized",
"=",
"array_get",
"(",
"$",
"inputs",
",",
"'serialized'",
")",
")",
"?",
"unserialize",
"(",
"$",
"serialized",
")",
":",
"array_get",
"(",
"$",
"inputs",
",",
"'old'",
")",
";",
"$",
"new",
"=",
"array_get",
"(",
"$",
"inputs",
",",
"'new'",
")",
";",
"$",
"index",
"=",
"array_search",
"(",
"$",
"old",
",",
"$",
"session",
"[",
"$",
"column",
"]",
"[",
"'values'",
"]",
")",
";",
"if",
"(",
"$",
"index",
"!==",
"false",
")",
"{",
"unset",
"(",
"$",
"session",
"[",
"$",
"column",
"]",
"[",
"'values'",
"]",
"[",
"$",
"index",
"]",
")",
";",
"}",
"$",
"session",
"[",
"$",
"column",
"]",
"[",
"'values'",
"]",
"[",
"]",
"=",
"$",
"new",
";",
"$",
"sidebars",
"=",
"$",
"this",
"->",
"adapter",
"->",
"getDeleteSidebarItem",
"(",
"$",
"column",
",",
"$",
"session",
"[",
"$",
"column",
"]",
",",
"$",
"new",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"sidebars",
")",
")",
"{",
"$",
"s",
"->",
"put",
"(",
"$",
"route",
",",
"[",
"$",
"column",
"=>",
"$",
"session",
"[",
"$",
"column",
"]",
"]",
")",
";",
"$",
"s",
"->",
"save",
"(",
")",
";",
"return",
"response",
"(",
"implode",
"(",
"''",
",",
"$",
"sidebars",
")",
",",
"200",
")",
";",
"}",
"}"
] |
updates filter paramateres in session
|
[
"updates",
"filter",
"paramateres",
"in",
"session"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Processor/FilterProcessor.php#L218-L249
|
228,568
|
antaresproject/core
|
src/foundation/src/Processor/FilterProcessor.php
|
FilterProcessor.save
|
public function save()
{
$input = Input::all();
$session = app('request')->session();
$classname = array_get($input, 'classname');
$key = uri();
$params = $session->get($key);
$params[$classname] = array_get($input, 'params');
$session->put($key, $params);
$session->save();
return response(app($classname)->sidebar($params[$classname]), 200);
}
|
php
|
public function save()
{
$input = Input::all();
$session = app('request')->session();
$classname = array_get($input, 'classname');
$key = uri();
$params = $session->get($key);
$params[$classname] = array_get($input, 'params');
$session->put($key, $params);
$session->save();
return response(app($classname)->sidebar($params[$classname]), 200);
}
|
[
"public",
"function",
"save",
"(",
")",
"{",
"$",
"input",
"=",
"Input",
"::",
"all",
"(",
")",
";",
"$",
"session",
"=",
"app",
"(",
"'request'",
")",
"->",
"session",
"(",
")",
";",
"$",
"classname",
"=",
"array_get",
"(",
"$",
"input",
",",
"'classname'",
")",
";",
"$",
"key",
"=",
"uri",
"(",
")",
";",
"$",
"params",
"=",
"$",
"session",
"->",
"get",
"(",
"$",
"key",
")",
";",
"$",
"params",
"[",
"$",
"classname",
"]",
"=",
"array_get",
"(",
"$",
"input",
",",
"'params'",
")",
";",
"$",
"session",
"->",
"put",
"(",
"$",
"key",
",",
"$",
"params",
")",
";",
"$",
"session",
"->",
"save",
"(",
")",
";",
"return",
"response",
"(",
"app",
"(",
"$",
"classname",
")",
"->",
"sidebar",
"(",
"$",
"params",
"[",
"$",
"classname",
"]",
")",
",",
"200",
")",
";",
"}"
] |
Additional save filter params
@return \Illuminate\Http\Response
|
[
"Additional",
"save",
"filter",
"params"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Processor/FilterProcessor.php#L256-L267
|
228,569
|
antaresproject/core
|
src/foundation/src/Processor/FilterProcessor.php
|
FilterProcessor.delete
|
public function delete()
{
$column = Input::get('params.column');
$session = app('request')->session();
$key = uri();
$params = $session->get($key);
$data = [];
foreach ($params as $name => $values) {
if (isset($values['column']) && $values['column'] == $column) {
continue;
}
$data[$name] = $values;
}
$session->put($key, $data);
$session->save();
return response('', 200);
}
|
php
|
public function delete()
{
$column = Input::get('params.column');
$session = app('request')->session();
$key = uri();
$params = $session->get($key);
$data = [];
foreach ($params as $name => $values) {
if (isset($values['column']) && $values['column'] == $column) {
continue;
}
$data[$name] = $values;
}
$session->put($key, $data);
$session->save();
return response('', 200);
}
|
[
"public",
"function",
"delete",
"(",
")",
"{",
"$",
"column",
"=",
"Input",
"::",
"get",
"(",
"'params.column'",
")",
";",
"$",
"session",
"=",
"app",
"(",
"'request'",
")",
"->",
"session",
"(",
")",
";",
"$",
"key",
"=",
"uri",
"(",
")",
";",
"$",
"params",
"=",
"$",
"session",
"->",
"get",
"(",
"$",
"key",
")",
";",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"name",
"=>",
"$",
"values",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"values",
"[",
"'column'",
"]",
")",
"&&",
"$",
"values",
"[",
"'column'",
"]",
"==",
"$",
"column",
")",
"{",
"continue",
";",
"}",
"$",
"data",
"[",
"$",
"name",
"]",
"=",
"$",
"values",
";",
"}",
"$",
"session",
"->",
"put",
"(",
"$",
"key",
",",
"$",
"data",
")",
";",
"$",
"session",
"->",
"save",
"(",
")",
";",
"return",
"response",
"(",
"''",
",",
"200",
")",
";",
"}"
] |
Additional delete filter params
@return \Illuminate\Http\Response
|
[
"Additional",
"delete",
"filter",
"params"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Processor/FilterProcessor.php#L274-L290
|
228,570
|
24aitor/Localizer
|
src/Middlewares/LocalizerMiddleware.php
|
LocalizerMiddleware.setIfAllowed
|
private function setIfAllowed($lang)
{
$allowedLangs = array_keys(Localizer::allowedLanguages());
if (config('localizer.block_unallowed_langs') && !in_array($lang, $allowedLangs)) {
$lang = $allowedLangs[0];
}
App::setLocale($lang);
if (config('localizer.carbon')) {
Carbon::setLocale($lang);
}
}
|
php
|
private function setIfAllowed($lang)
{
$allowedLangs = array_keys(Localizer::allowedLanguages());
if (config('localizer.block_unallowed_langs') && !in_array($lang, $allowedLangs)) {
$lang = $allowedLangs[0];
}
App::setLocale($lang);
if (config('localizer.carbon')) {
Carbon::setLocale($lang);
}
}
|
[
"private",
"function",
"setIfAllowed",
"(",
"$",
"lang",
")",
"{",
"$",
"allowedLangs",
"=",
"array_keys",
"(",
"Localizer",
"::",
"allowedLanguages",
"(",
")",
")",
";",
"if",
"(",
"config",
"(",
"'localizer.block_unallowed_langs'",
")",
"&&",
"!",
"in_array",
"(",
"$",
"lang",
",",
"$",
"allowedLangs",
")",
")",
"{",
"$",
"lang",
"=",
"$",
"allowedLangs",
"[",
"0",
"]",
";",
"}",
"App",
"::",
"setLocale",
"(",
"$",
"lang",
")",
";",
"if",
"(",
"config",
"(",
"'localizer.carbon'",
")",
")",
"{",
"Carbon",
"::",
"setLocale",
"(",
"$",
"lang",
")",
";",
"}",
"}"
] |
This function checks if language to set is an allowed lang of config.
@param string $lang
|
[
"This",
"function",
"checks",
"if",
"language",
"to",
"set",
"is",
"an",
"allowed",
"lang",
"of",
"config",
"."
] |
3f234dfeab1030119148ece01f61d79dba27ac67
|
https://github.com/24aitor/Localizer/blob/3f234dfeab1030119148ece01f61d79dba27ac67/src/Middlewares/LocalizerMiddleware.php#L19-L30
|
228,571
|
24aitor/Localizer
|
src/Middlewares/LocalizerMiddleware.php
|
LocalizerMiddleware.setLang
|
public function setLang($request)
{
if (Auth::check()) {
$user = Auth::user();
// Set user locale
if ($user->locale) {
$this->setIfAllowed($user->locale);
} else {
if (config('localizer.set_auto_lang')) {
$this->setIfAllowed(Identify::lang()->getLanguage());
} else {
$this->setIfAllowed(config('localizer.default_lang'));
}
}
} else {
if ($request->session()->has('locale')) {
$this->setIfAllowed(session('locale'));
} else {
if (config('localizer.set_auto_lang')) {
$this->setIfAllowed(Identify::lang()->getLanguage());
} else {
$this->setIfAllowed(config('localizer.default_lang'));
}
}
}
}
|
php
|
public function setLang($request)
{
if (Auth::check()) {
$user = Auth::user();
// Set user locale
if ($user->locale) {
$this->setIfAllowed($user->locale);
} else {
if (config('localizer.set_auto_lang')) {
$this->setIfAllowed(Identify::lang()->getLanguage());
} else {
$this->setIfAllowed(config('localizer.default_lang'));
}
}
} else {
if ($request->session()->has('locale')) {
$this->setIfAllowed(session('locale'));
} else {
if (config('localizer.set_auto_lang')) {
$this->setIfAllowed(Identify::lang()->getLanguage());
} else {
$this->setIfAllowed(config('localizer.default_lang'));
}
}
}
}
|
[
"public",
"function",
"setLang",
"(",
"$",
"request",
")",
"{",
"if",
"(",
"Auth",
"::",
"check",
"(",
")",
")",
"{",
"$",
"user",
"=",
"Auth",
"::",
"user",
"(",
")",
";",
"// Set user locale",
"if",
"(",
"$",
"user",
"->",
"locale",
")",
"{",
"$",
"this",
"->",
"setIfAllowed",
"(",
"$",
"user",
"->",
"locale",
")",
";",
"}",
"else",
"{",
"if",
"(",
"config",
"(",
"'localizer.set_auto_lang'",
")",
")",
"{",
"$",
"this",
"->",
"setIfAllowed",
"(",
"Identify",
"::",
"lang",
"(",
")",
"->",
"getLanguage",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setIfAllowed",
"(",
"config",
"(",
"'localizer.default_lang'",
")",
")",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"request",
"->",
"session",
"(",
")",
"->",
"has",
"(",
"'locale'",
")",
")",
"{",
"$",
"this",
"->",
"setIfAllowed",
"(",
"session",
"(",
"'locale'",
")",
")",
";",
"}",
"else",
"{",
"if",
"(",
"config",
"(",
"'localizer.set_auto_lang'",
")",
")",
"{",
"$",
"this",
"->",
"setIfAllowed",
"(",
"Identify",
"::",
"lang",
"(",
")",
"->",
"getLanguage",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"setIfAllowed",
"(",
"config",
"(",
"'localizer.default_lang'",
")",
")",
";",
"}",
"}",
"}",
"}"
] |
This function checks if user is logged in, and loads the prefered language.
@param string $lang
|
[
"This",
"function",
"checks",
"if",
"user",
"is",
"logged",
"in",
"and",
"loads",
"the",
"prefered",
"language",
"."
] |
3f234dfeab1030119148ece01f61d79dba27ac67
|
https://github.com/24aitor/Localizer/blob/3f234dfeab1030119148ece01f61d79dba27ac67/src/Middlewares/LocalizerMiddleware.php#L37-L63
|
228,572
|
antaresproject/core
|
src/components/auth/src/Auth/AuthServiceProvider.php
|
AuthServiceProvider.registerAuthenticator
|
protected function registerAuthenticator()
{
$this->app->singleton('auth', function (Application $app) {
// Once the authentication service has actually been requested by the developer
// we will set a variable in the application indicating such. This helps us
// know that we need to set any queued cookies in the after event later.
$app['auth.loaded'] = true;
return new AuthManager($app);
});
$this->app->singleton('auth.driver', function (Application $app) {
return $app->make('auth')->guard();
});
$this->app->singleton('multiuser', function (Application $app) {
return new Multiuser();
});
}
|
php
|
protected function registerAuthenticator()
{
$this->app->singleton('auth', function (Application $app) {
// Once the authentication service has actually been requested by the developer
// we will set a variable in the application indicating such. This helps us
// know that we need to set any queued cookies in the after event later.
$app['auth.loaded'] = true;
return new AuthManager($app);
});
$this->app->singleton('auth.driver', function (Application $app) {
return $app->make('auth')->guard();
});
$this->app->singleton('multiuser', function (Application $app) {
return new Multiuser();
});
}
|
[
"protected",
"function",
"registerAuthenticator",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'auth'",
",",
"function",
"(",
"Application",
"$",
"app",
")",
"{",
"// Once the authentication service has actually been requested by the developer",
"// we will set a variable in the application indicating such. This helps us",
"// know that we need to set any queued cookies in the after event later.",
"$",
"app",
"[",
"'auth.loaded'",
"]",
"=",
"true",
";",
"return",
"new",
"AuthManager",
"(",
"$",
"app",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'auth.driver'",
",",
"function",
"(",
"Application",
"$",
"app",
")",
"{",
"return",
"$",
"app",
"->",
"make",
"(",
"'auth'",
")",
"->",
"guard",
"(",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'multiuser'",
",",
"function",
"(",
"Application",
"$",
"app",
")",
"{",
"return",
"new",
"Multiuser",
"(",
")",
";",
"}",
")",
";",
"}"
] |
Register the service provider for Auth.
@return void
|
[
"Register",
"the",
"service",
"provider",
"for",
"Auth",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/auth/src/Auth/AuthServiceProvider.php#L51-L67
|
228,573
|
antaresproject/core
|
src/components/auth/src/Auth/AuthServiceProvider.php
|
AuthServiceProvider.registerPolicyAfterResolvingHandler
|
protected function registerPolicyAfterResolvingHandler()
{
$this->app->afterResolving(Policy::class, function (Policy $policy) {
return $policy->setAuthorization($this->app->make(FactoryContract::class));
});
}
|
php
|
protected function registerPolicyAfterResolvingHandler()
{
$this->app->afterResolving(Policy::class, function (Policy $policy) {
return $policy->setAuthorization($this->app->make(FactoryContract::class));
});
}
|
[
"protected",
"function",
"registerPolicyAfterResolvingHandler",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"afterResolving",
"(",
"Policy",
"::",
"class",
",",
"function",
"(",
"Policy",
"$",
"policy",
")",
"{",
"return",
"$",
"policy",
"->",
"setAuthorization",
"(",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"FactoryContract",
"::",
"class",
")",
")",
";",
"}",
")",
";",
"}"
] |
Register the Policy after resolving handler.
@return void
|
[
"Register",
"the",
"Policy",
"after",
"resolving",
"handler",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/auth/src/Auth/AuthServiceProvider.php#L74-L79
|
228,574
|
antaresproject/core
|
src/utils/security/src/Traits/DbCryptTrait.php
|
DbCryptTrait.getPackage
|
private function getPackage()
{
$reflection = new ReflectionClass(get_called_class());
return app(FilesystemFinder::class)->resolveNamespace($reflection->getFileName(), true);
}
|
php
|
private function getPackage()
{
$reflection = new ReflectionClass(get_called_class());
return app(FilesystemFinder::class)->resolveNamespace($reflection->getFileName(), true);
}
|
[
"private",
"function",
"getPackage",
"(",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"get_called_class",
"(",
")",
")",
";",
"return",
"app",
"(",
"FilesystemFinder",
"::",
"class",
")",
"->",
"resolveNamespace",
"(",
"$",
"reflection",
"->",
"getFileName",
"(",
")",
",",
"true",
")",
";",
"}"
] |
package name getter
@return String
|
[
"package",
"name",
"getter"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/security/src/Traits/DbCryptTrait.php#L74-L78
|
228,575
|
antaresproject/core
|
src/utils/security/src/Traits/DbCryptTrait.php
|
DbCryptTrait.setCasting
|
private function setCasting()
{
return false;
$package = $this->getPackage();
$tablename = $this->getTable();
$config = config("db_cryptor", []);
if (!array_get($config, 'enabled')) {
return false;
}
if (is_null($castName = array_get($config, 'cast_name'))) {
return false;
}
$this->castName = $castName;
if (is_null($columnTypes = array_get($config, 'column_types'))) {
return false;
}
$this->columnTypes = $columnTypes;
$this->enabled = true;
$casts = config($package . "::cast.{$tablename}", []);
$this->setCast($casts);
}
|
php
|
private function setCasting()
{
return false;
$package = $this->getPackage();
$tablename = $this->getTable();
$config = config("db_cryptor", []);
if (!array_get($config, 'enabled')) {
return false;
}
if (is_null($castName = array_get($config, 'cast_name'))) {
return false;
}
$this->castName = $castName;
if (is_null($columnTypes = array_get($config, 'column_types'))) {
return false;
}
$this->columnTypes = $columnTypes;
$this->enabled = true;
$casts = config($package . "::cast.{$tablename}", []);
$this->setCast($casts);
}
|
[
"private",
"function",
"setCasting",
"(",
")",
"{",
"return",
"false",
";",
"$",
"package",
"=",
"$",
"this",
"->",
"getPackage",
"(",
")",
";",
"$",
"tablename",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"$",
"config",
"=",
"config",
"(",
"\"db_cryptor\"",
",",
"[",
"]",
")",
";",
"if",
"(",
"!",
"array_get",
"(",
"$",
"config",
",",
"'enabled'",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"castName",
"=",
"array_get",
"(",
"$",
"config",
",",
"'cast_name'",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"castName",
"=",
"$",
"castName",
";",
"if",
"(",
"is_null",
"(",
"$",
"columnTypes",
"=",
"array_get",
"(",
"$",
"config",
",",
"'column_types'",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"columnTypes",
"=",
"$",
"columnTypes",
";",
"$",
"this",
"->",
"enabled",
"=",
"true",
";",
"$",
"casts",
"=",
"config",
"(",
"$",
"package",
".",
"\"::cast.{$tablename}\"",
",",
"[",
"]",
")",
";",
"$",
"this",
"->",
"setCast",
"(",
"$",
"casts",
")",
";",
"}"
] |
fills configuration options
@return boolean
|
[
"fills",
"configuration",
"options"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/security/src/Traits/DbCryptTrait.php#L85-L107
|
228,576
|
antaresproject/core
|
src/components/html/src/Support/FormBuilder.php
|
FormBuilder.token
|
public function token()
{
if (empty($this->csrfToken) && !is_null($this->session)) {
$this->csrfToken = $this->session->token();
}
return $this->hidden('_token', $this->csrfToken);
}
|
php
|
public function token()
{
if (empty($this->csrfToken) && !is_null($this->session)) {
$this->csrfToken = $this->session->token();
}
return $this->hidden('_token', $this->csrfToken);
}
|
[
"public",
"function",
"token",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"csrfToken",
")",
"&&",
"!",
"is_null",
"(",
"$",
"this",
"->",
"session",
")",
")",
"{",
"$",
"this",
"->",
"csrfToken",
"=",
"$",
"this",
"->",
"session",
"->",
"token",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"hidden",
"(",
"'_token'",
",",
"$",
"this",
"->",
"csrfToken",
")",
";",
"}"
] |
Generate a hidden field with the current CSRF token.
@return string
|
[
"Generate",
"a",
"hidden",
"field",
"with",
"the",
"current",
"CSRF",
"token",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Support/FormBuilder.php#L68-L75
|
228,577
|
antaresproject/core
|
src/components/html/src/Support/FormBuilder.php
|
FormBuilder.htmlLabel
|
public function htmlLabel($control, $options = ['class' => 'form-block__name'])
{
$this->labels[] = $control->name;
$value = e($this->formatLabel($control->name, $control->label));
$tip = isset($control->tip) ? tooltip($control->name, $control->tip) : '';
return '<label for="' . $control->name . '"' . $this->html->attributes($options) . '>' . $value . $tip . '</label>';
}
|
php
|
public function htmlLabel($control, $options = ['class' => 'form-block__name'])
{
$this->labels[] = $control->name;
$value = e($this->formatLabel($control->name, $control->label));
$tip = isset($control->tip) ? tooltip($control->name, $control->tip) : '';
return '<label for="' . $control->name . '"' . $this->html->attributes($options) . '>' . $value . $tip . '</label>';
}
|
[
"public",
"function",
"htmlLabel",
"(",
"$",
"control",
",",
"$",
"options",
"=",
"[",
"'class'",
"=>",
"'form-block__name'",
"]",
")",
"{",
"$",
"this",
"->",
"labels",
"[",
"]",
"=",
"$",
"control",
"->",
"name",
";",
"$",
"value",
"=",
"e",
"(",
"$",
"this",
"->",
"formatLabel",
"(",
"$",
"control",
"->",
"name",
",",
"$",
"control",
"->",
"label",
")",
")",
";",
"$",
"tip",
"=",
"isset",
"(",
"$",
"control",
"->",
"tip",
")",
"?",
"tooltip",
"(",
"$",
"control",
"->",
"name",
",",
"$",
"control",
"->",
"tip",
")",
":",
"''",
";",
"return",
"'<label for=\"'",
".",
"$",
"control",
"->",
"name",
".",
"'\"'",
".",
"$",
"this",
"->",
"html",
"->",
"attributes",
"(",
"$",
"options",
")",
".",
"'>'",
".",
"$",
"value",
".",
"$",
"tip",
".",
"'</label>'",
";",
"}"
] |
Creates form html label element
@param \Antares\Html\Form\Field $control
@param array $options
@return String
|
[
"Creates",
"form",
"html",
"label",
"element"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Support/FormBuilder.php#L131-L137
|
228,578
|
antaresproject/core
|
src/components/model/src/Memory/UserMetaProvider.php
|
UserMetaProvider.all
|
public function all($userId = null)
{
if (empty($this->items)) {
return (is_null($userId)) ? parent::all() : $this->handler->retrieveAll($userId);
}
return $this->items;
}
|
php
|
public function all($userId = null)
{
if (empty($this->items)) {
return (is_null($userId)) ? parent::all() : $this->handler->retrieveAll($userId);
}
return $this->items;
}
|
[
"public",
"function",
"all",
"(",
"$",
"userId",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"items",
")",
")",
"{",
"return",
"(",
"is_null",
"(",
"$",
"userId",
")",
")",
"?",
"parent",
"::",
"all",
"(",
")",
":",
"$",
"this",
"->",
"handler",
"->",
"retrieveAll",
"(",
"$",
"userId",
")",
";",
"}",
"return",
"$",
"this",
"->",
"items",
";",
"}"
] |
all meta fields for user
@param numeric $userId
@return type
|
[
"all",
"meta",
"fields",
"for",
"user"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/model/src/Memory/UserMetaProvider.php#L101-L107
|
228,579
|
lawoole/framework
|
src/Homer/Serialize/Maker.php
|
Maker.make
|
public static function make($value)
{
if (is_resource($value)) {
$value = null;
} elseif (Arr::accessible($value)) {
$value = new ArraySerialization($value);
} elseif ($value instanceof stdClass) {
$value = new ObjectSerialization($value);
} elseif ($value instanceof Container) {
$value = new ContainerSerialization($value);
} elseif ($value instanceof DateTime) {
$value = new DateTimeSerialization($value);
} elseif ($value instanceof Validator) {
$value = new ValidatorSerialization($value);
} elseif ($value instanceof Throwable) {
$value = new ThrowableSerialization($value);
} elseif ($value instanceof Closure) {
$value = null;
}
return $value;
}
|
php
|
public static function make($value)
{
if (is_resource($value)) {
$value = null;
} elseif (Arr::accessible($value)) {
$value = new ArraySerialization($value);
} elseif ($value instanceof stdClass) {
$value = new ObjectSerialization($value);
} elseif ($value instanceof Container) {
$value = new ContainerSerialization($value);
} elseif ($value instanceof DateTime) {
$value = new DateTimeSerialization($value);
} elseif ($value instanceof Validator) {
$value = new ValidatorSerialization($value);
} elseif ($value instanceof Throwable) {
$value = new ThrowableSerialization($value);
} elseif ($value instanceof Closure) {
$value = null;
}
return $value;
}
|
[
"public",
"static",
"function",
"make",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"null",
";",
"}",
"elseif",
"(",
"Arr",
"::",
"accessible",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"new",
"ArraySerialization",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"stdClass",
")",
"{",
"$",
"value",
"=",
"new",
"ObjectSerialization",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"Container",
")",
"{",
"$",
"value",
"=",
"new",
"ContainerSerialization",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"DateTime",
")",
"{",
"$",
"value",
"=",
"new",
"DateTimeSerialization",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"Validator",
")",
"{",
"$",
"value",
"=",
"new",
"ValidatorSerialization",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"Throwable",
")",
"{",
"$",
"value",
"=",
"new",
"ThrowableSerialization",
"(",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"Closure",
")",
"{",
"$",
"value",
"=",
"null",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Get the value for serialization.
@param mixed $value
@return mixed
|
[
"Get",
"the",
"value",
"for",
"serialization",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Serialize/Maker.php#L27-L48
|
228,580
|
antaresproject/core
|
src/components/publisher/src/MigrateManager.php
|
MigrateManager.getPaths
|
protected function getPaths($name, $directory = 'migrations')
{
$package = $this->manager->getAvailableExtensions()->findByName($name);
if ($package === null) {
return [];
}
$basePath = $package->getPath();
$paths = [
"{$basePath}/resources/database/{$directory}/",
"{$basePath}/resources/{$directory}/",
"{$basePath}/src/{$directory}/",
];
return $paths;
}
|
php
|
protected function getPaths($name, $directory = 'migrations')
{
$package = $this->manager->getAvailableExtensions()->findByName($name);
if ($package === null) {
return [];
}
$basePath = $package->getPath();
$paths = [
"{$basePath}/resources/database/{$directory}/",
"{$basePath}/resources/{$directory}/",
"{$basePath}/src/{$directory}/",
];
return $paths;
}
|
[
"protected",
"function",
"getPaths",
"(",
"$",
"name",
",",
"$",
"directory",
"=",
"'migrations'",
")",
"{",
"$",
"package",
"=",
"$",
"this",
"->",
"manager",
"->",
"getAvailableExtensions",
"(",
")",
"->",
"findByName",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"package",
"===",
"null",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"basePath",
"=",
"$",
"package",
"->",
"getPath",
"(",
")",
";",
"$",
"paths",
"=",
"[",
"\"{$basePath}/resources/database/{$directory}/\"",
",",
"\"{$basePath}/resources/{$directory}/\"",
",",
"\"{$basePath}/src/{$directory}/\"",
",",
"]",
";",
"return",
"$",
"paths",
";",
"}"
] |
resolve paths of migrations & seeds
@param String $name
@param String $directory
@return array
|
[
"resolve",
"paths",
"of",
"migrations",
"&",
"seeds"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/publisher/src/MigrateManager.php#L161-L178
|
228,581
|
antaresproject/core
|
src/components/publisher/src/MigrateManager.php
|
MigrateManager.seed
|
public function seed($name, $paths = null)
{
$directories = is_null($paths) ? $this->getPaths($name, 'seeds') : $paths;
$files = $this->app->make('files');
foreach ($directories as $path) {
if ($files->isDirectory($path)) {
$allFiles = $files->allFiles($path);
foreach ($allFiles as $file) {
$class = $this->prepareSeedClass($file);
if (!is_null($class)) {
$this->seeder->call($this->prepareSeedClass($file));
}
}
}
}
}
|
php
|
public function seed($name, $paths = null)
{
$directories = is_null($paths) ? $this->getPaths($name, 'seeds') : $paths;
$files = $this->app->make('files');
foreach ($directories as $path) {
if ($files->isDirectory($path)) {
$allFiles = $files->allFiles($path);
foreach ($allFiles as $file) {
$class = $this->prepareSeedClass($file);
if (!is_null($class)) {
$this->seeder->call($this->prepareSeedClass($file));
}
}
}
}
}
|
[
"public",
"function",
"seed",
"(",
"$",
"name",
",",
"$",
"paths",
"=",
"null",
")",
"{",
"$",
"directories",
"=",
"is_null",
"(",
"$",
"paths",
")",
"?",
"$",
"this",
"->",
"getPaths",
"(",
"$",
"name",
",",
"'seeds'",
")",
":",
"$",
"paths",
";",
"$",
"files",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'files'",
")",
";",
"foreach",
"(",
"$",
"directories",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"files",
"->",
"isDirectory",
"(",
"$",
"path",
")",
")",
"{",
"$",
"allFiles",
"=",
"$",
"files",
"->",
"allFiles",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"allFiles",
"as",
"$",
"file",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"prepareSeedClass",
"(",
"$",
"file",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"class",
")",
")",
"{",
"$",
"this",
"->",
"seeder",
"->",
"call",
"(",
"$",
"this",
"->",
"prepareSeedClass",
"(",
"$",
"file",
")",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
run seeds from all files in seeds directory
@param type $name
|
[
"run",
"seeds",
"from",
"all",
"files",
"in",
"seeds",
"directory"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/publisher/src/MigrateManager.php#L203-L225
|
228,582
|
antaresproject/core
|
src/components/publisher/src/MigrateManager.php
|
MigrateManager.uninstallPathes
|
protected function uninstallPathes($name, $directory = 'migrations')
{
$package = $this->manager->getAvailableExtensions()->findByName($name);
if ($package === null) {
return [];
}
$basePath = $package->getPath();
return [
"{$basePath}/resources/database/{$directory}/",
"{$basePath}/resources/{$directory}/",
"{$basePath}/src/{$directory}/",
];
}
|
php
|
protected function uninstallPathes($name, $directory = 'migrations')
{
$package = $this->manager->getAvailableExtensions()->findByName($name);
if ($package === null) {
return [];
}
$basePath = $package->getPath();
return [
"{$basePath}/resources/database/{$directory}/",
"{$basePath}/resources/{$directory}/",
"{$basePath}/src/{$directory}/",
];
}
|
[
"protected",
"function",
"uninstallPathes",
"(",
"$",
"name",
",",
"$",
"directory",
"=",
"'migrations'",
")",
"{",
"$",
"package",
"=",
"$",
"this",
"->",
"manager",
"->",
"getAvailableExtensions",
"(",
")",
"->",
"findByName",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"package",
"===",
"null",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"basePath",
"=",
"$",
"package",
"->",
"getPath",
"(",
")",
";",
"return",
"[",
"\"{$basePath}/resources/database/{$directory}/\"",
",",
"\"{$basePath}/resources/{$directory}/\"",
",",
"\"{$basePath}/src/{$directory}/\"",
",",
"]",
";",
"}"
] |
get uninstall pathes
@param String $name
@param String $directory
@return array
|
[
"get",
"uninstall",
"pathes"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/publisher/src/MigrateManager.php#L234-L249
|
228,583
|
antaresproject/core
|
src/components/publisher/src/MigrateManager.php
|
MigrateManager.prepareSeedClass
|
protected function prepareSeedClass($file)
{
$extension = $file->getExtension();
if ($extension !== 'php') {
return null;
}
return '\\' . str_replace('.' . $extension, '', $file->getFilename());
}
|
php
|
protected function prepareSeedClass($file)
{
$extension = $file->getExtension();
if ($extension !== 'php') {
return null;
}
return '\\' . str_replace('.' . $extension, '', $file->getFilename());
}
|
[
"protected",
"function",
"prepareSeedClass",
"(",
"$",
"file",
")",
"{",
"$",
"extension",
"=",
"$",
"file",
"->",
"getExtension",
"(",
")",
";",
"if",
"(",
"$",
"extension",
"!==",
"'php'",
")",
"{",
"return",
"null",
";",
"}",
"return",
"'\\\\'",
".",
"str_replace",
"(",
"'.'",
".",
"$",
"extension",
",",
"''",
",",
"$",
"file",
"->",
"getFilename",
"(",
")",
")",
";",
"}"
] |
prepare seed classname
@param \Symfony\Component\Finder\SplFileInfo $file
@return String
|
[
"prepare",
"seed",
"classname"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/publisher/src/MigrateManager.php#L257-L264
|
228,584
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/CharUtils.php
|
CharUtils.charAsciiArray
|
public static function charAsciiArray()
{
static $result = array();
if (!$result) {
$result = \array_merge(
self::charAsciiControlArray(),
self::charAsciiPrintableArray()
);
}
return $result;
}
|
php
|
public static function charAsciiArray()
{
static $result = array();
if (!$result) {
$result = \array_merge(
self::charAsciiControlArray(),
self::charAsciiPrintableArray()
);
}
return $result;
}
|
[
"public",
"static",
"function",
"charAsciiArray",
"(",
")",
"{",
"static",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"$",
"result",
"=",
"\\",
"array_merge",
"(",
"self",
"::",
"charAsciiControlArray",
"(",
")",
",",
"self",
"::",
"charAsciiPrintableArray",
"(",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns all ASCII 7 bit characters in an array.
@return string[] All ASCII 7 bit characters.
|
[
"Returns",
"all",
"ASCII",
"7",
"bit",
"characters",
"in",
"an",
"array",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/CharUtils.php#L66-L78
|
228,585
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/CharUtils.php
|
CharUtils.charAsciiAlphaArray
|
public static function charAsciiAlphaArray()
{
static $result = array();
if (!$result) {
$result = \array_merge(
self::charAsciiAlphaLowerArray(),
self::charAsciiAlphaUpperArray()
);
}
return $result;
}
|
php
|
public static function charAsciiAlphaArray()
{
static $result = array();
if (!$result) {
$result = \array_merge(
self::charAsciiAlphaLowerArray(),
self::charAsciiAlphaUpperArray()
);
}
return $result;
}
|
[
"public",
"static",
"function",
"charAsciiAlphaArray",
"(",
")",
"{",
"static",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"$",
"result",
"=",
"\\",
"array_merge",
"(",
"self",
"::",
"charAsciiAlphaLowerArray",
"(",
")",
",",
"self",
"::",
"charAsciiAlphaUpperArray",
"(",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns all ASCII 7 bit alphabetic characters in an array.
@return string[] All ASCII 7 bit alphabetic characters.
|
[
"Returns",
"all",
"ASCII",
"7",
"bit",
"alphabetic",
"characters",
"in",
"an",
"array",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/CharUtils.php#L85-L97
|
228,586
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/CharUtils.php
|
CharUtils.charAsciiAlphaLowerArray
|
public static function charAsciiAlphaLowerArray()
{
static $result = array();
if (!$result) {
for ($i = 97; $i < 123; ++$i) {
$result[] = \chr($i);
}
}
return $result;
}
|
php
|
public static function charAsciiAlphaLowerArray()
{
static $result = array();
if (!$result) {
for ($i = 97; $i < 123; ++$i) {
$result[] = \chr($i);
}
}
return $result;
}
|
[
"public",
"static",
"function",
"charAsciiAlphaLowerArray",
"(",
")",
"{",
"static",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"97",
";",
"$",
"i",
"<",
"123",
";",
"++",
"$",
"i",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"\\",
"chr",
"(",
"$",
"i",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns all ASCII 7 bit alphabetic lowercase characters in an array.
@return string[] All ASCII 7 bit alphabetic lowercase characters.
|
[
"Returns",
"all",
"ASCII",
"7",
"bit",
"alphabetic",
"lowercase",
"characters",
"in",
"an",
"array",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/CharUtils.php#L104-L115
|
228,587
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/CharUtils.php
|
CharUtils.charAsciiAlphaUpperArray
|
public static function charAsciiAlphaUpperArray()
{
static $result = array();
if (!$result) {
for ($i = 65; $i < 91; ++$i) {
$result[] = \chr($i);
}
}
return $result;
}
|
php
|
public static function charAsciiAlphaUpperArray()
{
static $result = array();
if (!$result) {
for ($i = 65; $i < 91; ++$i) {
$result[] = \chr($i);
}
}
return $result;
}
|
[
"public",
"static",
"function",
"charAsciiAlphaUpperArray",
"(",
")",
"{",
"static",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"65",
";",
"$",
"i",
"<",
"91",
";",
"++",
"$",
"i",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"\\",
"chr",
"(",
"$",
"i",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns all ASCII 7 bit alphabetic uppercase characters in an array.
@return string[] All ASCII 7 bit alphabetic uppercase characters.
|
[
"Returns",
"all",
"ASCII",
"7",
"bit",
"alphabetic",
"uppercase",
"characters",
"in",
"an",
"array",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/CharUtils.php#L122-L133
|
228,588
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/CharUtils.php
|
CharUtils.charAsciiAlphanumericArray
|
public static function charAsciiAlphanumericArray()
{
static $result = array();
if (null === $result) {
$result = \array_merge(
self::charAsciiNumericArray(),
self::charAsciiAlphaArray()
);
}
return $result;
}
|
php
|
public static function charAsciiAlphanumericArray()
{
static $result = array();
if (null === $result) {
$result = \array_merge(
self::charAsciiNumericArray(),
self::charAsciiAlphaArray()
);
}
return $result;
}
|
[
"public",
"static",
"function",
"charAsciiAlphanumericArray",
"(",
")",
"{",
"static",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"result",
")",
"{",
"$",
"result",
"=",
"\\",
"array_merge",
"(",
"self",
"::",
"charAsciiNumericArray",
"(",
")",
",",
"self",
"::",
"charAsciiAlphaArray",
"(",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns all ASCII 7 bit alphanumeric characters in an array.
@return string[] All ASCII 7 bit alphanumeric characters.
|
[
"Returns",
"all",
"ASCII",
"7",
"bit",
"alphanumeric",
"characters",
"in",
"an",
"array",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/CharUtils.php#L140-L152
|
228,589
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/CharUtils.php
|
CharUtils.charAsciiControlArray
|
public static function charAsciiControlArray()
{
static $result = array();
if (!$result) {
for ($i = 0; $i < 32; ++$i) {
$result[] = \chr($i);
}
$result[] = \chr(127);
}
return $result;
}
|
php
|
public static function charAsciiControlArray()
{
static $result = array();
if (!$result) {
for ($i = 0; $i < 32; ++$i) {
$result[] = \chr($i);
}
$result[] = \chr(127);
}
return $result;
}
|
[
"public",
"static",
"function",
"charAsciiControlArray",
"(",
")",
"{",
"static",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"32",
";",
"++",
"$",
"i",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"\\",
"chr",
"(",
"$",
"i",
")",
";",
"}",
"$",
"result",
"[",
"]",
"=",
"\\",
"chr",
"(",
"127",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns all ASCII 7 bit control characters in an array.
@return string[] All ASCII 7 bit control characters.
|
[
"Returns",
"all",
"ASCII",
"7",
"bit",
"control",
"characters",
"in",
"an",
"array",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/CharUtils.php#L159-L171
|
228,590
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/CharUtils.php
|
CharUtils.charAsciiPrintableArray
|
public static function charAsciiPrintableArray()
{
static $result = array();
if (!$result) {
for ($i = 32; $i < 127; ++$i) {
$result[] = \chr($i);
}
}
return $result;
}
|
php
|
public static function charAsciiPrintableArray()
{
static $result = array();
if (!$result) {
for ($i = 32; $i < 127; ++$i) {
$result[] = \chr($i);
}
}
return $result;
}
|
[
"public",
"static",
"function",
"charAsciiPrintableArray",
"(",
")",
"{",
"static",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"32",
";",
"$",
"i",
"<",
"127",
";",
"++",
"$",
"i",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"\\",
"chr",
"(",
"$",
"i",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns all ASCII 7 bit printable characters in an array.
@return string[] All ASCII 7 bit printable characters.
|
[
"Returns",
"all",
"ASCII",
"7",
"bit",
"printable",
"characters",
"in",
"an",
"array",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/CharUtils.php#L178-L189
|
228,591
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/CharUtils.php
|
CharUtils.charAsciiNumericArray
|
public static function charAsciiNumericArray()
{
static $result = array();
if (!$result) {
for ($i = 48; $i < 58; ++$i) {
$result[] = (string) ($i - 48);
}
}
return $result;
}
|
php
|
public static function charAsciiNumericArray()
{
static $result = array();
if (!$result) {
for ($i = 48; $i < 58; ++$i) {
$result[] = (string) ($i - 48);
}
}
return $result;
}
|
[
"public",
"static",
"function",
"charAsciiNumericArray",
"(",
")",
"{",
"static",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"48",
";",
"$",
"i",
"<",
"58",
";",
"++",
"$",
"i",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"(",
"string",
")",
"(",
"$",
"i",
"-",
"48",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns all ASCII 7 bit numeric characters in an array.
@return string[] All ASCII 7 bit numeric characters.
|
[
"Returns",
"all",
"ASCII",
"7",
"bit",
"numeric",
"characters",
"in",
"an",
"array",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/CharUtils.php#L196-L207
|
228,592
|
FlorianWolters/PHP-Component-Core-StringUtils
|
src/main/php/CharUtils.php
|
CharUtils.isAsciiPrintable
|
public static function isAsciiPrintable($char)
{
return (true === self::isAscii($char))
&& (false === self::isAsciiControl($char));
}
|
php
|
public static function isAsciiPrintable($char)
{
return (true === self::isAscii($char))
&& (false === self::isAsciiControl($char));
}
|
[
"public",
"static",
"function",
"isAsciiPrintable",
"(",
"$",
"char",
")",
"{",
"return",
"(",
"true",
"===",
"self",
"::",
"isAscii",
"(",
"$",
"char",
")",
")",
"&&",
"(",
"false",
"===",
"self",
"::",
"isAsciiControl",
"(",
"$",
"char",
")",
")",
";",
"}"
] |
Checks whether the character is ASCII 7 bit printable.
CharUtils::isAsciiPrintable('a'); // true
CharUtils::isAsciiPrintable('A'); // true
CharUtils::isAsciiPrintable('3'); // true
CharUtils::isAsciiPrintable('-'); // true
CharUtils::isAsciiPrintable('\n'); // false
CharUtils::isAsciiPrintable('©'); // false
@param string $char The character to check.
@return true if between 32 and 126 inclusive
|
[
"Checks",
"whether",
"the",
"character",
"is",
"ASCII",
"7",
"bit",
"printable",
"."
] |
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
|
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/CharUtils.php#L370-L374
|
228,593
|
antaresproject/core
|
src/components/acl/src/Migration.php
|
Migration.getNormalizedName
|
protected function getNormalizedName(string $name): string
{
$name = str_replace('antaresproject/component-', 'antares/', $name);
$name = str_replace('antaresproject/module-', 'antares/', $name);
return str_replace('-', '_', $name);
}
|
php
|
protected function getNormalizedName(string $name): string
{
$name = str_replace('antaresproject/component-', 'antares/', $name);
$name = str_replace('antaresproject/module-', 'antares/', $name);
return str_replace('-', '_', $name);
}
|
[
"protected",
"function",
"getNormalizedName",
"(",
"string",
"$",
"name",
")",
":",
"string",
"{",
"$",
"name",
"=",
"str_replace",
"(",
"'antaresproject/component-'",
",",
"'antares/'",
",",
"$",
"name",
")",
";",
"$",
"name",
"=",
"str_replace",
"(",
"'antaresproject/module-'",
",",
"'antares/'",
",",
"$",
"name",
")",
";",
"return",
"str_replace",
"(",
"'-'",
",",
"'_'",
",",
"$",
"name",
")",
";",
"}"
] |
Returns normalized component name. It is used for backward compatibility.
@param string $name
@return string
|
[
"Returns",
"normalized",
"component",
"name",
".",
"It",
"is",
"used",
"for",
"backward",
"compatibility",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/acl/src/Migration.php#L61-L67
|
228,594
|
antaresproject/core
|
src/components/acl/src/Migration.php
|
Migration.up
|
public function up(string $componentFullName, RoleActionList $roleActionList)
{
$componentFullName = $this->getNormalizedName($componentFullName);
$memory = $this->getMemoryProvider();
$acl = $this->getComponentAcl($componentFullName);
$roles = $roleActionList->getRoles();
$actions = $roleActionList->getActions();
$acl->attach($memory);
$acl->roles()->attach($roles);
$acl->actions()->attach(self::getFlatActions($actions));
foreach ($roles as $role) {
$roleActions = self::getFlatActions($roleActionList->getActionsByRole($role));
$acl->allow($role, $roleActions, true, $roleActionList->getDescriptions(), $roleActionList->getCategories());
}
$memory->finish();
}
|
php
|
public function up(string $componentFullName, RoleActionList $roleActionList)
{
$componentFullName = $this->getNormalizedName($componentFullName);
$memory = $this->getMemoryProvider();
$acl = $this->getComponentAcl($componentFullName);
$roles = $roleActionList->getRoles();
$actions = $roleActionList->getActions();
$acl->attach($memory);
$acl->roles()->attach($roles);
$acl->actions()->attach(self::getFlatActions($actions));
foreach ($roles as $role) {
$roleActions = self::getFlatActions($roleActionList->getActionsByRole($role));
$acl->allow($role, $roleActions, true, $roleActionList->getDescriptions(), $roleActionList->getCategories());
}
$memory->finish();
}
|
[
"public",
"function",
"up",
"(",
"string",
"$",
"componentFullName",
",",
"RoleActionList",
"$",
"roleActionList",
")",
"{",
"$",
"componentFullName",
"=",
"$",
"this",
"->",
"getNormalizedName",
"(",
"$",
"componentFullName",
")",
";",
"$",
"memory",
"=",
"$",
"this",
"->",
"getMemoryProvider",
"(",
")",
";",
"$",
"acl",
"=",
"$",
"this",
"->",
"getComponentAcl",
"(",
"$",
"componentFullName",
")",
";",
"$",
"roles",
"=",
"$",
"roleActionList",
"->",
"getRoles",
"(",
")",
";",
"$",
"actions",
"=",
"$",
"roleActionList",
"->",
"getActions",
"(",
")",
";",
"$",
"acl",
"->",
"attach",
"(",
"$",
"memory",
")",
";",
"$",
"acl",
"->",
"roles",
"(",
")",
"->",
"attach",
"(",
"$",
"roles",
")",
";",
"$",
"acl",
"->",
"actions",
"(",
")",
"->",
"attach",
"(",
"self",
"::",
"getFlatActions",
"(",
"$",
"actions",
")",
")",
";",
"foreach",
"(",
"$",
"roles",
"as",
"$",
"role",
")",
"{",
"$",
"roleActions",
"=",
"self",
"::",
"getFlatActions",
"(",
"$",
"roleActionList",
"->",
"getActionsByRole",
"(",
"$",
"role",
")",
")",
";",
"$",
"acl",
"->",
"allow",
"(",
"$",
"role",
",",
"$",
"roleActions",
",",
"true",
",",
"$",
"roleActionList",
"->",
"getDescriptions",
"(",
")",
",",
"$",
"roleActionList",
"->",
"getCategories",
"(",
")",
")",
";",
"}",
"$",
"memory",
"->",
"finish",
"(",
")",
";",
"}"
] |
Set up permissions to the component ACL.
@param string $componentFullName
@param RoleActionList $roleActionList
@throws \InvalidArgumentException
@throws \RuntimeException
|
[
"Set",
"up",
"permissions",
"to",
"the",
"component",
"ACL",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/acl/src/Migration.php#L87-L107
|
228,595
|
antaresproject/core
|
src/components/acl/src/Migration.php
|
Migration.down
|
public function down(string $componentFullName)
{
$componentFullName = $this->getNormalizedName($componentFullName);
$memory = $this->getMemoryProvider();
$memory->forget('acl_' . $componentFullName);
$memory->finish();
}
|
php
|
public function down(string $componentFullName)
{
$componentFullName = $this->getNormalizedName($componentFullName);
$memory = $this->getMemoryProvider();
$memory->forget('acl_' . $componentFullName);
$memory->finish();
}
|
[
"public",
"function",
"down",
"(",
"string",
"$",
"componentFullName",
")",
"{",
"$",
"componentFullName",
"=",
"$",
"this",
"->",
"getNormalizedName",
"(",
"$",
"componentFullName",
")",
";",
"$",
"memory",
"=",
"$",
"this",
"->",
"getMemoryProvider",
"(",
")",
";",
"$",
"memory",
"->",
"forget",
"(",
"'acl_'",
".",
"$",
"componentFullName",
")",
";",
"$",
"memory",
"->",
"finish",
"(",
")",
";",
"}"
] |
Tear down permissions from the component ACL.
@param string $componentFullName
@throws \RuntimeException
|
[
"Tear",
"down",
"permissions",
"from",
"the",
"component",
"ACL",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/acl/src/Migration.php#L115-L122
|
228,596
|
antaresproject/core
|
src/components/acl/src/Migration.php
|
Migration.getFlatActions
|
protected static function getFlatActions(array $actions)
{
$actions = array_map(function(Action $action) {
return $action->getAction();
}, $actions);
return array_unique($actions);
}
|
php
|
protected static function getFlatActions(array $actions)
{
$actions = array_map(function(Action $action) {
return $action->getAction();
}, $actions);
return array_unique($actions);
}
|
[
"protected",
"static",
"function",
"getFlatActions",
"(",
"array",
"$",
"actions",
")",
"{",
"$",
"actions",
"=",
"array_map",
"(",
"function",
"(",
"Action",
"$",
"action",
")",
"{",
"return",
"$",
"action",
"->",
"getAction",
"(",
")",
";",
"}",
",",
"$",
"actions",
")",
";",
"return",
"array_unique",
"(",
"$",
"actions",
")",
";",
"}"
] |
Returns a flatten array of actions which only contains friendly action names.
@param array $actions
@return array
|
[
"Returns",
"a",
"flatten",
"array",
"of",
"actions",
"which",
"only",
"contains",
"friendly",
"action",
"names",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/acl/src/Migration.php#L130-L137
|
228,597
|
lawoole/framework
|
src/Server/Console/StartCommand.php
|
StartCommand.processRuntime
|
protected function processRuntime($server)
{
$filename = $this->option('filename') ?? storage_path('framework/server.runtime');
$server->registerEventCallback('Launching', function () use ($filename) {
$this->saveRuntime($filename);
});
$server->registerEventCallback('Start', function () {
$this->info("{$this->laravel->name()} server is running.");
});
$server->registerEventCallback('Shutdown', function () use ($filename) {
$this->removeRuntime($filename);
$this->info("{$this->laravel->name()} server is stopped.");
});
}
|
php
|
protected function processRuntime($server)
{
$filename = $this->option('filename') ?? storage_path('framework/server.runtime');
$server->registerEventCallback('Launching', function () use ($filename) {
$this->saveRuntime($filename);
});
$server->registerEventCallback('Start', function () {
$this->info("{$this->laravel->name()} server is running.");
});
$server->registerEventCallback('Shutdown', function () use ($filename) {
$this->removeRuntime($filename);
$this->info("{$this->laravel->name()} server is stopped.");
});
}
|
[
"protected",
"function",
"processRuntime",
"(",
"$",
"server",
")",
"{",
"$",
"filename",
"=",
"$",
"this",
"->",
"option",
"(",
"'filename'",
")",
"??",
"storage_path",
"(",
"'framework/server.runtime'",
")",
";",
"$",
"server",
"->",
"registerEventCallback",
"(",
"'Launching'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"filename",
")",
"{",
"$",
"this",
"->",
"saveRuntime",
"(",
"$",
"filename",
")",
";",
"}",
")",
";",
"$",
"server",
"->",
"registerEventCallback",
"(",
"'Start'",
",",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"info",
"(",
"\"{$this->laravel->name()} server is running.\"",
")",
";",
"}",
")",
";",
"$",
"server",
"->",
"registerEventCallback",
"(",
"'Shutdown'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"filename",
")",
"{",
"$",
"this",
"->",
"removeRuntime",
"(",
"$",
"filename",
")",
";",
"$",
"this",
"->",
"info",
"(",
"\"{$this->laravel->name()} server is stopped.\"",
")",
";",
"}",
")",
";",
"}"
] |
Process the server runtime info.
@param \Lawoole\Contracts\Server\Server $server
|
[
"Process",
"the",
"server",
"runtime",
"info",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/Console/StartCommand.php#L43-L60
|
228,598
|
lawoole/framework
|
src/Server/Console/StartCommand.php
|
StartCommand.saveRuntime
|
protected function saveRuntime($filename)
{
$payload = [
'name' => $this->laravel->name(),
'pid' => getmypid(),
'time' => (string) Carbon::now(),
];
file_put_contents($filename, json_encode($payload, JSON_PRETTY_PRINT));
}
|
php
|
protected function saveRuntime($filename)
{
$payload = [
'name' => $this->laravel->name(),
'pid' => getmypid(),
'time' => (string) Carbon::now(),
];
file_put_contents($filename, json_encode($payload, JSON_PRETTY_PRINT));
}
|
[
"protected",
"function",
"saveRuntime",
"(",
"$",
"filename",
")",
"{",
"$",
"payload",
"=",
"[",
"'name'",
"=>",
"$",
"this",
"->",
"laravel",
"->",
"name",
"(",
")",
",",
"'pid'",
"=>",
"getmypid",
"(",
")",
",",
"'time'",
"=>",
"(",
"string",
")",
"Carbon",
"::",
"now",
"(",
")",
",",
"]",
";",
"file_put_contents",
"(",
"$",
"filename",
",",
"json_encode",
"(",
"$",
"payload",
",",
"JSON_PRETTY_PRINT",
")",
")",
";",
"}"
] |
Record server runtime info.
@param string $filename
|
[
"Record",
"server",
"runtime",
"info",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/Console/StartCommand.php#L67-L76
|
228,599
|
gurukami/php-array
|
src/Arrays.php
|
Arrays.exists
|
public static function exists($key, $array)
{
if (!is_array($array)) {
return false;
}
if ($key == '') {
return is_array($array) && array_key_exists((string)$key, $array);
}
return self::parseAndValidateKeys($key, $array)['isExists'];
}
|
php
|
public static function exists($key, $array)
{
if (!is_array($array)) {
return false;
}
if ($key == '') {
return is_array($array) && array_key_exists((string)$key, $array);
}
return self::parseAndValidateKeys($key, $array)['isExists'];
}
|
[
"public",
"static",
"function",
"exists",
"(",
"$",
"key",
",",
"$",
"array",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"array",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"key",
"==",
"''",
")",
"{",
"return",
"is_array",
"(",
"$",
"array",
")",
"&&",
"array_key_exists",
"(",
"(",
"string",
")",
"$",
"key",
",",
"$",
"array",
")",
";",
"}",
"return",
"self",
"::",
"parseAndValidateKeys",
"(",
"$",
"key",
",",
"$",
"array",
")",
"[",
"'isExists'",
"]",
";",
"}"
] |
Checks if the given key exists in the array by a string representation
@param string $key <p>Name key in the array. Example: key[sub_key][sub_sub_key]</p>
@param array $array <p>The array</p>
@return bool returns true if key is exists, false otherwise
|
[
"Checks",
"if",
"the",
"given",
"key",
"exists",
"in",
"the",
"array",
"by",
"a",
"string",
"representation"
] |
634715e70efd67edfb99d2a74e09cec809280abd
|
https://github.com/gurukami/php-array/blob/634715e70efd67edfb99d2a74e09cec809280abd/src/Arrays.php#L23-L32
|
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.