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,200
|
tomwalder/php-appengine-search
|
src/Search/Query.php
|
Query.sort
|
public function sort($str_field, $str_direction = self::DESC)
{
$this->arr_sorts[] = [$str_field, $str_direction];
return $this;
}
|
php
|
public function sort($str_field, $str_direction = self::DESC)
{
$this->arr_sorts[] = [$str_field, $str_direction];
return $this;
}
|
[
"public",
"function",
"sort",
"(",
"$",
"str_field",
",",
"$",
"str_direction",
"=",
"self",
"::",
"DESC",
")",
"{",
"$",
"this",
"->",
"arr_sorts",
"[",
"]",
"=",
"[",
"$",
"str_field",
",",
"$",
"str_direction",
"]",
";",
"return",
"$",
"this",
";",
"}"
] |
Sort results by a field in ASCending order
@param $str_field
@param string $str_direction
@return $this
|
[
"Sort",
"results",
"by",
"a",
"field",
"in",
"ASCending",
"order"
] |
e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba
|
https://github.com/tomwalder/php-appengine-search/blob/e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba/src/Search/Query.php#L167-L171
|
228,201
|
antaresproject/core
|
src/ui/components/templates/src/Traits/DispatchableTrait.php
|
DispatchableTrait.finish
|
public function finish()
{
if (isset($this->components)) {
foreach ($this->components as $name => $options) {
$this->dispatcher->finish($name, $options);
}
}
$this->components = new Collection();
return $this;
}
|
php
|
public function finish()
{
if (isset($this->components)) {
foreach ($this->components as $name => $options) {
$this->dispatcher->finish($name, $options);
}
}
$this->components = new Collection();
return $this;
}
|
[
"public",
"function",
"finish",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"components",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"components",
"as",
"$",
"name",
"=>",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"dispatcher",
"->",
"finish",
"(",
"$",
"name",
",",
"$",
"options",
")",
";",
"}",
"}",
"$",
"this",
"->",
"components",
"=",
"new",
"Collection",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Shutdown all extensions.
@return $this
|
[
"Shutdown",
"all",
"extensions",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Traits/DispatchableTrait.php#L50-L61
|
228,202
|
antaresproject/core
|
src/utils/form/src/Controls/AbstractType.php
|
AbstractType.findErrors
|
protected function findErrors()
{
$session = session();
if (!$session->has('errors') || !$session->get('errors')->hasBag('default')) {
return;
}
/** @var MessageBag $messageBag */
$messageBag = session()->get('errors')->getBag('default');
if (isset($messageBag->messages()[$this->name])) {
foreach ($messageBag->messages()[$this->name] as $error) {
$this->addError($error);
}
}
}
|
php
|
protected function findErrors()
{
$session = session();
if (!$session->has('errors') || !$session->get('errors')->hasBag('default')) {
return;
}
/** @var MessageBag $messageBag */
$messageBag = session()->get('errors')->getBag('default');
if (isset($messageBag->messages()[$this->name])) {
foreach ($messageBag->messages()[$this->name] as $error) {
$this->addError($error);
}
}
}
|
[
"protected",
"function",
"findErrors",
"(",
")",
"{",
"$",
"session",
"=",
"session",
"(",
")",
";",
"if",
"(",
"!",
"$",
"session",
"->",
"has",
"(",
"'errors'",
")",
"||",
"!",
"$",
"session",
"->",
"get",
"(",
"'errors'",
")",
"->",
"hasBag",
"(",
"'default'",
")",
")",
"{",
"return",
";",
"}",
"/** @var MessageBag $messageBag */",
"$",
"messageBag",
"=",
"session",
"(",
")",
"->",
"get",
"(",
"'errors'",
")",
"->",
"getBag",
"(",
"'default'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"messageBag",
"->",
"messages",
"(",
")",
"[",
"$",
"this",
"->",
"name",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"messageBag",
"->",
"messages",
"(",
")",
"[",
"$",
"this",
"->",
"name",
"]",
"as",
"$",
"error",
")",
"{",
"$",
"this",
"->",
"addError",
"(",
"$",
"error",
")",
";",
"}",
"}",
"}"
] |
lookup for validation errors for this control
|
[
"lookup",
"for",
"validation",
"errors",
"for",
"this",
"control"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/form/src/Controls/AbstractType.php#L296-L309
|
228,203
|
antaresproject/core
|
src/utils/form/src/Controls/AbstractType.php
|
AbstractType.render
|
protected function render()
{
$this->findErrors();
if (!$this->label instanceof AbstractLabel) {
$this->setLabel(new Label(ucfirst(str_replace('_', ' ', $this->name))));
}
if (!$this->decorator instanceof AbstractDecorator) {
$this->setDecorator((new HorizontalDecorator()));
}
return $this->decorator->render($this);
}
|
php
|
protected function render()
{
$this->findErrors();
if (!$this->label instanceof AbstractLabel) {
$this->setLabel(new Label(ucfirst(str_replace('_', ' ', $this->name))));
}
if (!$this->decorator instanceof AbstractDecorator) {
$this->setDecorator((new HorizontalDecorator()));
}
return $this->decorator->render($this);
}
|
[
"protected",
"function",
"render",
"(",
")",
"{",
"$",
"this",
"->",
"findErrors",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"label",
"instanceof",
"AbstractLabel",
")",
"{",
"$",
"this",
"->",
"setLabel",
"(",
"new",
"Label",
"(",
"ucfirst",
"(",
"str_replace",
"(",
"'_'",
",",
"' '",
",",
"$",
"this",
"->",
"name",
")",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"decorator",
"instanceof",
"AbstractDecorator",
")",
"{",
"$",
"this",
"->",
"setDecorator",
"(",
"(",
"new",
"HorizontalDecorator",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"decorator",
"->",
"render",
"(",
"$",
"this",
")",
";",
"}"
] |
Render control to html
@return string
|
[
"Render",
"control",
"to",
"html"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/form/src/Controls/AbstractType.php#L350-L362
|
228,204
|
lawoole/framework
|
src/Homer/Transport/Whisper/WhisperServerSocketHandler.php
|
WhisperServerSocketHandler.checkReceivedDataMagic
|
protected function checkReceivedDataMagic($data)
{
if (! Str::startsWith($data, self::MAGIC_HEADER)) {
throw new TransportException('Receive data with error bytes.', TransportException::REMOTE);
}
}
|
php
|
protected function checkReceivedDataMagic($data)
{
if (! Str::startsWith($data, self::MAGIC_HEADER)) {
throw new TransportException('Receive data with error bytes.', TransportException::REMOTE);
}
}
|
[
"protected",
"function",
"checkReceivedDataMagic",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"Str",
"::",
"startsWith",
"(",
"$",
"data",
",",
"self",
"::",
"MAGIC_HEADER",
")",
")",
"{",
"throw",
"new",
"TransportException",
"(",
"'Receive data with error bytes.'",
",",
"TransportException",
"::",
"REMOTE",
")",
";",
"}",
"}"
] |
Check the data just received.
@param string $data
|
[
"Check",
"the",
"data",
"just",
"received",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Transport/Whisper/WhisperServerSocketHandler.php#L65-L70
|
228,205
|
antaresproject/core
|
src/ui/components/templates/src/Service/Service.php
|
Service.findOne
|
public function findOne($attributes, $uri)
{
$where = [
'resource' => $uri,
'name' => snake_case(array_get($attributes, 'name'))
];
$components = $this->components->filter(function($item) use($where) {
return $item->resource == array_get($where, 'resource') && $item->name == array_get($where, 'name');
});
$component = $components->count() ? $components->first() : null;
if (!is_null($component)) {
return array_merge($component->data, ['id' => $component->id]);
}
return [];
}
|
php
|
public function findOne($attributes, $uri)
{
$where = [
'resource' => $uri,
'name' => snake_case(array_get($attributes, 'name'))
];
$components = $this->components->filter(function($item) use($where) {
return $item->resource == array_get($where, 'resource') && $item->name == array_get($where, 'name');
});
$component = $components->count() ? $components->first() : null;
if (!is_null($component)) {
return array_merge($component->data, ['id' => $component->id]);
}
return [];
}
|
[
"public",
"function",
"findOne",
"(",
"$",
"attributes",
",",
"$",
"uri",
")",
"{",
"$",
"where",
"=",
"[",
"'resource'",
"=>",
"$",
"uri",
",",
"'name'",
"=>",
"snake_case",
"(",
"array_get",
"(",
"$",
"attributes",
",",
"'name'",
")",
")",
"]",
";",
"$",
"components",
"=",
"$",
"this",
"->",
"components",
"->",
"filter",
"(",
"function",
"(",
"$",
"item",
")",
"use",
"(",
"$",
"where",
")",
"{",
"return",
"$",
"item",
"->",
"resource",
"==",
"array_get",
"(",
"$",
"where",
",",
"'resource'",
")",
"&&",
"$",
"item",
"->",
"name",
"==",
"array_get",
"(",
"$",
"where",
",",
"'name'",
")",
";",
"}",
")",
";",
"$",
"component",
"=",
"$",
"components",
"->",
"count",
"(",
")",
"?",
"$",
"components",
"->",
"first",
"(",
")",
":",
"null",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"component",
")",
")",
"{",
"return",
"array_merge",
"(",
"$",
"component",
"->",
"data",
",",
"[",
"'id'",
"=>",
"$",
"component",
"->",
"id",
"]",
")",
";",
"}",
"return",
"[",
"]",
";",
"}"
] |
Finds ui component details
@param array $attributes
@param String $uri
@return array
|
[
"Finds",
"ui",
"component",
"details"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Service/Service.php#L52-L66
|
228,206
|
robgridley/flysystem-smb
|
src/SmbAdapter.php
|
SmbAdapter.recursiveCreateDir
|
protected function recursiveCreateDir($path)
{
if ($this->isDirectory($path)) {
return;
}
$directories = explode($this->pathSeparator, $path);
if (count($directories) > 1) {
$parentDirectories = array_splice($directories, 0, count($directories) - 1);
$this->recursiveCreateDir(implode($this->pathSeparator, $parentDirectories));
}
$location = $this->applyPathPrefix($path);
$this->share->mkdir($location);
}
|
php
|
protected function recursiveCreateDir($path)
{
if ($this->isDirectory($path)) {
return;
}
$directories = explode($this->pathSeparator, $path);
if (count($directories) > 1) {
$parentDirectories = array_splice($directories, 0, count($directories) - 1);
$this->recursiveCreateDir(implode($this->pathSeparator, $parentDirectories));
}
$location = $this->applyPathPrefix($path);
$this->share->mkdir($location);
}
|
[
"protected",
"function",
"recursiveCreateDir",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isDirectory",
"(",
"$",
"path",
")",
")",
"{",
"return",
";",
"}",
"$",
"directories",
"=",
"explode",
"(",
"$",
"this",
"->",
"pathSeparator",
",",
"$",
"path",
")",
";",
"if",
"(",
"count",
"(",
"$",
"directories",
")",
">",
"1",
")",
"{",
"$",
"parentDirectories",
"=",
"array_splice",
"(",
"$",
"directories",
",",
"0",
",",
"count",
"(",
"$",
"directories",
")",
"-",
"1",
")",
";",
"$",
"this",
"->",
"recursiveCreateDir",
"(",
"implode",
"(",
"$",
"this",
"->",
"pathSeparator",
",",
"$",
"parentDirectories",
")",
")",
";",
"}",
"$",
"location",
"=",
"$",
"this",
"->",
"applyPathPrefix",
"(",
"$",
"path",
")",
";",
"$",
"this",
"->",
"share",
"->",
"mkdir",
"(",
"$",
"location",
")",
";",
"}"
] |
Recursively create directories.
@param $path
|
[
"Recursively",
"create",
"directories",
"."
] |
91927ceb5ace080973bc2df226c18a8d2086de20
|
https://github.com/robgridley/flysystem-smb/blob/91927ceb5ace080973bc2df226c18a8d2086de20/src/SmbAdapter.php#L202-L217
|
228,207
|
robgridley/flysystem-smb
|
src/SmbAdapter.php
|
SmbAdapter.has
|
public function has($path)
{
$location = $this->applyPathPrefix($path);
try {
$this->share->stat($location);
} catch (NotFoundException $e) {
return false;
}
return true;
}
|
php
|
public function has($path)
{
$location = $this->applyPathPrefix($path);
try {
$this->share->stat($location);
} catch (NotFoundException $e) {
return false;
}
return true;
}
|
[
"public",
"function",
"has",
"(",
"$",
"path",
")",
"{",
"$",
"location",
"=",
"$",
"this",
"->",
"applyPathPrefix",
"(",
"$",
"path",
")",
";",
"try",
"{",
"$",
"this",
"->",
"share",
"->",
"stat",
"(",
"$",
"location",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Determine if a file or directory exists.
@param string $path
@return bool
|
[
"Determine",
"if",
"a",
"file",
"or",
"directory",
"exists",
"."
] |
91927ceb5ace080973bc2df226c18a8d2086de20
|
https://github.com/robgridley/flysystem-smb/blob/91927ceb5ace080973bc2df226c18a8d2086de20/src/SmbAdapter.php#L225-L236
|
228,208
|
robgridley/flysystem-smb
|
src/SmbAdapter.php
|
SmbAdapter.getMetadata
|
public function getMetadata($path)
{
$location = $this->applyPathPrefix($path);
try {
$file = $this->share->stat($location);
} catch (NotFoundException $e) {
return false;
}
return $this->normalizeFileInfo($file);
}
|
php
|
public function getMetadata($path)
{
$location = $this->applyPathPrefix($path);
try {
$file = $this->share->stat($location);
} catch (NotFoundException $e) {
return false;
}
return $this->normalizeFileInfo($file);
}
|
[
"public",
"function",
"getMetadata",
"(",
"$",
"path",
")",
"{",
"$",
"location",
"=",
"$",
"this",
"->",
"applyPathPrefix",
"(",
"$",
"path",
")",
";",
"try",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"share",
"->",
"stat",
"(",
"$",
"location",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"normalizeFileInfo",
"(",
"$",
"file",
")",
";",
"}"
] |
Get all of the metadata for a file or directory.
@param string $path
@return array|false
|
[
"Get",
"all",
"of",
"the",
"metadata",
"for",
"a",
"file",
"or",
"directory",
"."
] |
91927ceb5ace080973bc2df226c18a8d2086de20
|
https://github.com/robgridley/flysystem-smb/blob/91927ceb5ace080973bc2df226c18a8d2086de20/src/SmbAdapter.php#L322-L333
|
228,209
|
robgridley/flysystem-smb
|
src/SmbAdapter.php
|
SmbAdapter.getMimetype
|
public function getMimetype($path)
{
$metadata = $this->read($path);
if ($metadata === false) {
return false;
}
$metadata['mimetype'] = Util::guessMimeType($path, $metadata['contents']);
return $metadata;
}
|
php
|
public function getMimetype($path)
{
$metadata = $this->read($path);
if ($metadata === false) {
return false;
}
$metadata['mimetype'] = Util::guessMimeType($path, $metadata['contents']);
return $metadata;
}
|
[
"public",
"function",
"getMimetype",
"(",
"$",
"path",
")",
"{",
"$",
"metadata",
"=",
"$",
"this",
"->",
"read",
"(",
"$",
"path",
")",
";",
"if",
"(",
"$",
"metadata",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"metadata",
"[",
"'mimetype'",
"]",
"=",
"Util",
"::",
"guessMimeType",
"(",
"$",
"path",
",",
"$",
"metadata",
"[",
"'contents'",
"]",
")",
";",
"return",
"$",
"metadata",
";",
"}"
] |
Get the MIME type of a file.
@param string $path
@return array|false
|
[
"Get",
"the",
"MIME",
"type",
"of",
"a",
"file",
"."
] |
91927ceb5ace080973bc2df226c18a8d2086de20
|
https://github.com/robgridley/flysystem-smb/blob/91927ceb5ace080973bc2df226c18a8d2086de20/src/SmbAdapter.php#L352-L363
|
228,210
|
robgridley/flysystem-smb
|
src/SmbAdapter.php
|
SmbAdapter.deleteContents
|
protected function deleteContents($path)
{
$contents = $this->listContents($path, true);
foreach (array_reverse($contents) as $object) {
$location = $this->applyPathPrefix($object['path']);
if ($object['type'] === 'dir') {
$this->share->rmdir($location);
} else {
$this->share->del($location);
}
}
}
|
php
|
protected function deleteContents($path)
{
$contents = $this->listContents($path, true);
foreach (array_reverse($contents) as $object) {
$location = $this->applyPathPrefix($object['path']);
if ($object['type'] === 'dir') {
$this->share->rmdir($location);
} else {
$this->share->del($location);
}
}
}
|
[
"protected",
"function",
"deleteContents",
"(",
"$",
"path",
")",
"{",
"$",
"contents",
"=",
"$",
"this",
"->",
"listContents",
"(",
"$",
"path",
",",
"true",
")",
";",
"foreach",
"(",
"array_reverse",
"(",
"$",
"contents",
")",
"as",
"$",
"object",
")",
"{",
"$",
"location",
"=",
"$",
"this",
"->",
"applyPathPrefix",
"(",
"$",
"object",
"[",
"'path'",
"]",
")",
";",
"if",
"(",
"$",
"object",
"[",
"'type'",
"]",
"===",
"'dir'",
")",
"{",
"$",
"this",
"->",
"share",
"->",
"rmdir",
"(",
"$",
"location",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"share",
"->",
"del",
"(",
"$",
"location",
")",
";",
"}",
"}",
"}"
] |
Delete the contents of a directory.
@param string $path
|
[
"Delete",
"the",
"contents",
"of",
"a",
"directory",
"."
] |
91927ceb5ace080973bc2df226c18a8d2086de20
|
https://github.com/robgridley/flysystem-smb/blob/91927ceb5ace080973bc2df226c18a8d2086de20/src/SmbAdapter.php#L415-L428
|
228,211
|
robgridley/flysystem-smb
|
src/SmbAdapter.php
|
SmbAdapter.isDirectory
|
protected function isDirectory($path)
{
$location = $this->applyPathPrefix($path);
if (empty($location)) {
return true;
}
try {
$file = $this->share->stat($location);
} catch (NotFoundException $e) {
return false;
}
return $file->isDirectory();
}
|
php
|
protected function isDirectory($path)
{
$location = $this->applyPathPrefix($path);
if (empty($location)) {
return true;
}
try {
$file = $this->share->stat($location);
} catch (NotFoundException $e) {
return false;
}
return $file->isDirectory();
}
|
[
"protected",
"function",
"isDirectory",
"(",
"$",
"path",
")",
"{",
"$",
"location",
"=",
"$",
"this",
"->",
"applyPathPrefix",
"(",
"$",
"path",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"location",
")",
")",
"{",
"return",
"true",
";",
"}",
"try",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"share",
"->",
"stat",
"(",
"$",
"location",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"file",
"->",
"isDirectory",
"(",
")",
";",
"}"
] |
Determine if the specified path is a directory.
@param string $path
@return bool
|
[
"Determine",
"if",
"the",
"specified",
"path",
"is",
"a",
"directory",
"."
] |
91927ceb5ace080973bc2df226c18a8d2086de20
|
https://github.com/robgridley/flysystem-smb/blob/91927ceb5ace080973bc2df226c18a8d2086de20/src/SmbAdapter.php#L436-L451
|
228,212
|
antaresproject/core
|
src/components/html/src/Control/RemoteSelect.php
|
RemoteSelect.render
|
public function render()
{
$params = isset($this->params['attributes']) ? $this->params['attributes'] : $this->params;
$id = !isset($params['id']) ? $params['name'] . '-' . str_random(4) : $params['id'];
$script = $this->script($id, $params);
$attributes = app('html')->decorate(array_except($params + ['id' => $id], ['pluginOptions', 'options']));
$optionsData = array_get($this->params, 'optionsData', []);
$control = app('form')->select(
array_get($this->params, 'name'), array_get($this->params, 'options', []), array_get($this->params, 'value'), $attributes, $optionsData
);
echo view('antares/html::controls.remote_select', ['control' => $control])->render();
if (app('request')->ajax()) {
echo '<script type="text/javascript">' . $script . '</script>';
} else {
app('antares.asset')->container('antares/foundation::scripts')->inlineScript('remote-select-' . $id, $script);
}
return '';
}
|
php
|
public function render()
{
$params = isset($this->params['attributes']) ? $this->params['attributes'] : $this->params;
$id = !isset($params['id']) ? $params['name'] . '-' . str_random(4) : $params['id'];
$script = $this->script($id, $params);
$attributes = app('html')->decorate(array_except($params + ['id' => $id], ['pluginOptions', 'options']));
$optionsData = array_get($this->params, 'optionsData', []);
$control = app('form')->select(
array_get($this->params, 'name'), array_get($this->params, 'options', []), array_get($this->params, 'value'), $attributes, $optionsData
);
echo view('antares/html::controls.remote_select', ['control' => $control])->render();
if (app('request')->ajax()) {
echo '<script type="text/javascript">' . $script . '</script>';
} else {
app('antares.asset')->container('antares/foundation::scripts')->inlineScript('remote-select-' . $id, $script);
}
return '';
}
|
[
"public",
"function",
"render",
"(",
")",
"{",
"$",
"params",
"=",
"isset",
"(",
"$",
"this",
"->",
"params",
"[",
"'attributes'",
"]",
")",
"?",
"$",
"this",
"->",
"params",
"[",
"'attributes'",
"]",
":",
"$",
"this",
"->",
"params",
";",
"$",
"id",
"=",
"!",
"isset",
"(",
"$",
"params",
"[",
"'id'",
"]",
")",
"?",
"$",
"params",
"[",
"'name'",
"]",
".",
"'-'",
".",
"str_random",
"(",
"4",
")",
":",
"$",
"params",
"[",
"'id'",
"]",
";",
"$",
"script",
"=",
"$",
"this",
"->",
"script",
"(",
"$",
"id",
",",
"$",
"params",
")",
";",
"$",
"attributes",
"=",
"app",
"(",
"'html'",
")",
"->",
"decorate",
"(",
"array_except",
"(",
"$",
"params",
"+",
"[",
"'id'",
"=>",
"$",
"id",
"]",
",",
"[",
"'pluginOptions'",
",",
"'options'",
"]",
")",
")",
";",
"$",
"optionsData",
"=",
"array_get",
"(",
"$",
"this",
"->",
"params",
",",
"'optionsData'",
",",
"[",
"]",
")",
";",
"$",
"control",
"=",
"app",
"(",
"'form'",
")",
"->",
"select",
"(",
"array_get",
"(",
"$",
"this",
"->",
"params",
",",
"'name'",
")",
",",
"array_get",
"(",
"$",
"this",
"->",
"params",
",",
"'options'",
",",
"[",
"]",
")",
",",
"array_get",
"(",
"$",
"this",
"->",
"params",
",",
"'value'",
")",
",",
"$",
"attributes",
",",
"$",
"optionsData",
")",
";",
"echo",
"view",
"(",
"'antares/html::controls.remote_select'",
",",
"[",
"'control'",
"=>",
"$",
"control",
"]",
")",
"->",
"render",
"(",
")",
";",
"if",
"(",
"app",
"(",
"'request'",
")",
"->",
"ajax",
"(",
")",
")",
"{",
"echo",
"'<script type=\"text/javascript\">'",
".",
"$",
"script",
".",
"'</script>'",
";",
"}",
"else",
"{",
"app",
"(",
"'antares.asset'",
")",
"->",
"container",
"(",
"'antares/foundation::scripts'",
")",
"->",
"inlineScript",
"(",
"'remote-select-'",
".",
"$",
"id",
",",
"$",
"script",
")",
";",
"}",
"return",
"''",
";",
"}"
] |
renders infinity select control
@return \Illuminate\View\View
|
[
"renders",
"infinity",
"select",
"control"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Control/RemoteSelect.php#L48-L67
|
228,213
|
antaresproject/core
|
src/components/html/src/Control/RemoteSelect.php
|
RemoteSelect.script
|
protected function script($id, $params)
{
$handler = $this->handler = 'handler' . str_random(4);
$options = array_replace_recursive($this->defaults()['pluginOptions'], $params['pluginOptions']);
$decorated = JavaScriptDecorator::decorate($options);
return $this->init($id) . $handler . '.' . $this->pluginName . '(' . $decorated . ')';
}
|
php
|
protected function script($id, $params)
{
$handler = $this->handler = 'handler' . str_random(4);
$options = array_replace_recursive($this->defaults()['pluginOptions'], $params['pluginOptions']);
$decorated = JavaScriptDecorator::decorate($options);
return $this->init($id) . $handler . '.' . $this->pluginName . '(' . $decorated . ')';
}
|
[
"protected",
"function",
"script",
"(",
"$",
"id",
",",
"$",
"params",
")",
"{",
"$",
"handler",
"=",
"$",
"this",
"->",
"handler",
"=",
"'handler'",
".",
"str_random",
"(",
"4",
")",
";",
"$",
"options",
"=",
"array_replace_recursive",
"(",
"$",
"this",
"->",
"defaults",
"(",
")",
"[",
"'pluginOptions'",
"]",
",",
"$",
"params",
"[",
"'pluginOptions'",
"]",
")",
";",
"$",
"decorated",
"=",
"JavaScriptDecorator",
"::",
"decorate",
"(",
"$",
"options",
")",
";",
"return",
"$",
"this",
"->",
"init",
"(",
"$",
"id",
")",
".",
"$",
"handler",
".",
"'.'",
".",
"$",
"this",
"->",
"pluginName",
".",
"'('",
".",
"$",
"decorated",
".",
"')'",
";",
"}"
] |
creates javascript select scripts
@param type $id
@return type
|
[
"creates",
"javascript",
"select",
"scripts"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Control/RemoteSelect.php#L75-L81
|
228,214
|
antaresproject/core
|
src/components/html/src/Control/RemoteSelect.php
|
RemoteSelect.defaults
|
protected function defaults()
{
return [
'options' => ['placeholder' => 'Search for a repo ...'],
'pluginOptions' => [
'allowClear' => true,
'minimumInputLength' => 0,
'minimumResultsForSearch' => 'Infinity',
'ajax' => [
'dataType' => 'json',
'delay' => 250,
'data' => new JavaScriptExpression($this->ajaxData()),
'processResults' => new JavaScriptExpression($this->processResults()),
'cache' => true
],
'escapeMarkup' => new JavaScriptExpression($this->escapeMarkup()),
'templateResult' => new JavaScriptExpression($this->templateResult()),
'templateSelection' => new JavaScriptExpression($this->templateSelection()),
],
];
}
|
php
|
protected function defaults()
{
return [
'options' => ['placeholder' => 'Search for a repo ...'],
'pluginOptions' => [
'allowClear' => true,
'minimumInputLength' => 0,
'minimumResultsForSearch' => 'Infinity',
'ajax' => [
'dataType' => 'json',
'delay' => 250,
'data' => new JavaScriptExpression($this->ajaxData()),
'processResults' => new JavaScriptExpression($this->processResults()),
'cache' => true
],
'escapeMarkup' => new JavaScriptExpression($this->escapeMarkup()),
'templateResult' => new JavaScriptExpression($this->templateResult()),
'templateSelection' => new JavaScriptExpression($this->templateSelection()),
],
];
}
|
[
"protected",
"function",
"defaults",
"(",
")",
"{",
"return",
"[",
"'options'",
"=>",
"[",
"'placeholder'",
"=>",
"'Search for a repo ...'",
"]",
",",
"'pluginOptions'",
"=>",
"[",
"'allowClear'",
"=>",
"true",
",",
"'minimumInputLength'",
"=>",
"0",
",",
"'minimumResultsForSearch'",
"=>",
"'Infinity'",
",",
"'ajax'",
"=>",
"[",
"'dataType'",
"=>",
"'json'",
",",
"'delay'",
"=>",
"250",
",",
"'data'",
"=>",
"new",
"JavaScriptExpression",
"(",
"$",
"this",
"->",
"ajaxData",
"(",
")",
")",
",",
"'processResults'",
"=>",
"new",
"JavaScriptExpression",
"(",
"$",
"this",
"->",
"processResults",
"(",
")",
")",
",",
"'cache'",
"=>",
"true",
"]",
",",
"'escapeMarkup'",
"=>",
"new",
"JavaScriptExpression",
"(",
"$",
"this",
"->",
"escapeMarkup",
"(",
")",
")",
",",
"'templateResult'",
"=>",
"new",
"JavaScriptExpression",
"(",
"$",
"this",
"->",
"templateResult",
"(",
")",
")",
",",
"'templateSelection'",
"=>",
"new",
"JavaScriptExpression",
"(",
"$",
"this",
"->",
"templateSelection",
"(",
")",
")",
",",
"]",
",",
"]",
";",
"}"
] |
default plugin properties
@return array
|
[
"default",
"plugin",
"properties"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Control/RemoteSelect.php#L88-L108
|
228,215
|
antaresproject/core
|
src/foundation/src/Http/Datatables/Extensions.php
|
Extensions.getButtonLink
|
protected function getButtonLink(ExtensionContract $extension, string $action, string $icon): string
{
$actionUrl = URL::route(area() . '.modules.' . $action, [
'vendor' => $extension->getVendorName(),
'name' => $extension->getPackageName(),
'csrf' => true,
]);
$notWritablePaths = $this->getNotWritablePaths();
$label = trans('antares/foundation::label.extensions.actions.' . $action);
if (count($notWritablePaths)) {
$url = '#';
$params = [
'class' => 'bindable component-error-modal',
'data-title' => trans('Not writable permissions for:'),
'data-icon' => $icon,
'data-errors' => json_encode($notWritablePaths),
];
} else {
$name = $extension->getFriendlyName();
$url = URL::route(area() . '.modules.progress.index');
$params = [
'class' => 'bindable component-prompt-modal',
'data-title' => trans('antares/foundation::messages.extensions.modal_title.' . $action),
'data-icon' => $icon,
'data-action-url' => $actionUrl,
'data-description' => trans('antares/foundation::messages.extensions.modal_content.' . $action, compact('name')),
];
}
return (string) HTML::link($url, $label, $params);
}
|
php
|
protected function getButtonLink(ExtensionContract $extension, string $action, string $icon): string
{
$actionUrl = URL::route(area() . '.modules.' . $action, [
'vendor' => $extension->getVendorName(),
'name' => $extension->getPackageName(),
'csrf' => true,
]);
$notWritablePaths = $this->getNotWritablePaths();
$label = trans('antares/foundation::label.extensions.actions.' . $action);
if (count($notWritablePaths)) {
$url = '#';
$params = [
'class' => 'bindable component-error-modal',
'data-title' => trans('Not writable permissions for:'),
'data-icon' => $icon,
'data-errors' => json_encode($notWritablePaths),
];
} else {
$name = $extension->getFriendlyName();
$url = URL::route(area() . '.modules.progress.index');
$params = [
'class' => 'bindable component-prompt-modal',
'data-title' => trans('antares/foundation::messages.extensions.modal_title.' . $action),
'data-icon' => $icon,
'data-action-url' => $actionUrl,
'data-description' => trans('antares/foundation::messages.extensions.modal_content.' . $action, compact('name')),
];
}
return (string) HTML::link($url, $label, $params);
}
|
[
"protected",
"function",
"getButtonLink",
"(",
"ExtensionContract",
"$",
"extension",
",",
"string",
"$",
"action",
",",
"string",
"$",
"icon",
")",
":",
"string",
"{",
"$",
"actionUrl",
"=",
"URL",
"::",
"route",
"(",
"area",
"(",
")",
".",
"'.modules.'",
".",
"$",
"action",
",",
"[",
"'vendor'",
"=>",
"$",
"extension",
"->",
"getVendorName",
"(",
")",
",",
"'name'",
"=>",
"$",
"extension",
"->",
"getPackageName",
"(",
")",
",",
"'csrf'",
"=>",
"true",
",",
"]",
")",
";",
"$",
"notWritablePaths",
"=",
"$",
"this",
"->",
"getNotWritablePaths",
"(",
")",
";",
"$",
"label",
"=",
"trans",
"(",
"'antares/foundation::label.extensions.actions.'",
".",
"$",
"action",
")",
";",
"if",
"(",
"count",
"(",
"$",
"notWritablePaths",
")",
")",
"{",
"$",
"url",
"=",
"'#'",
";",
"$",
"params",
"=",
"[",
"'class'",
"=>",
"'bindable component-error-modal'",
",",
"'data-title'",
"=>",
"trans",
"(",
"'Not writable permissions for:'",
")",
",",
"'data-icon'",
"=>",
"$",
"icon",
",",
"'data-errors'",
"=>",
"json_encode",
"(",
"$",
"notWritablePaths",
")",
",",
"]",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"$",
"extension",
"->",
"getFriendlyName",
"(",
")",
";",
"$",
"url",
"=",
"URL",
"::",
"route",
"(",
"area",
"(",
")",
".",
"'.modules.progress.index'",
")",
";",
"$",
"params",
"=",
"[",
"'class'",
"=>",
"'bindable component-prompt-modal'",
",",
"'data-title'",
"=>",
"trans",
"(",
"'antares/foundation::messages.extensions.modal_title.'",
".",
"$",
"action",
")",
",",
"'data-icon'",
"=>",
"$",
"icon",
",",
"'data-action-url'",
"=>",
"$",
"actionUrl",
",",
"'data-description'",
"=>",
"trans",
"(",
"'antares/foundation::messages.extensions.modal_content.'",
".",
"$",
"action",
",",
"compact",
"(",
"'name'",
")",
")",
",",
"]",
";",
"}",
"return",
"(",
"string",
")",
"HTML",
"::",
"link",
"(",
"$",
"url",
",",
"$",
"label",
",",
"$",
"params",
")",
";",
"}"
] |
Returns buttons for each row.
@param ExtensionContract $extension
@param string $action
@param string $icon
@return string
|
[
"Returns",
"buttons",
"for",
"each",
"row",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Datatables/Extensions.php#L239-L274
|
228,216
|
antaresproject/core
|
src/foundation/src/Http/Datatables/Extensions.php
|
Extensions.getStatusColumn
|
protected function getStatusColumn(): Closure
{
return function(ExtensionContract $extension) {
switch ($extension->getStatus()) {
case ExtensionContract::STATUS_ACTIVATED:
return '<span class="label-basic label-basic--success">' . trans('antares/foundation::label.extensions.statuses.active') . '</span>';
case ExtensionContract::STATUS_INSTALLED:
return '<span class="label-basic label-basic--danger">' . trans('antares/foundation::label.extensions.statuses.inactive') . '</span>';
case ExtensionContract::STATUS_AVAILABLE:
default:
return '<span class="label-basic label-basic--info">' . trans('antares/foundation::label.extensions.statuses.available') . '</span>';
}
};
}
|
php
|
protected function getStatusColumn(): Closure
{
return function(ExtensionContract $extension) {
switch ($extension->getStatus()) {
case ExtensionContract::STATUS_ACTIVATED:
return '<span class="label-basic label-basic--success">' . trans('antares/foundation::label.extensions.statuses.active') . '</span>';
case ExtensionContract::STATUS_INSTALLED:
return '<span class="label-basic label-basic--danger">' . trans('antares/foundation::label.extensions.statuses.inactive') . '</span>';
case ExtensionContract::STATUS_AVAILABLE:
default:
return '<span class="label-basic label-basic--info">' . trans('antares/foundation::label.extensions.statuses.available') . '</span>';
}
};
}
|
[
"protected",
"function",
"getStatusColumn",
"(",
")",
":",
"Closure",
"{",
"return",
"function",
"(",
"ExtensionContract",
"$",
"extension",
")",
"{",
"switch",
"(",
"$",
"extension",
"->",
"getStatus",
"(",
")",
")",
"{",
"case",
"ExtensionContract",
"::",
"STATUS_ACTIVATED",
":",
"return",
"'<span class=\"label-basic label-basic--success\">'",
".",
"trans",
"(",
"'antares/foundation::label.extensions.statuses.active'",
")",
".",
"'</span>'",
";",
"case",
"ExtensionContract",
"::",
"STATUS_INSTALLED",
":",
"return",
"'<span class=\"label-basic label-basic--danger\">'",
".",
"trans",
"(",
"'antares/foundation::label.extensions.statuses.inactive'",
")",
".",
"'</span>'",
";",
"case",
"ExtensionContract",
"::",
"STATUS_AVAILABLE",
":",
"default",
":",
"return",
"'<span class=\"label-basic label-basic--info\">'",
".",
"trans",
"(",
"'antares/foundation::label.extensions.statuses.available'",
")",
".",
"'</span>'",
";",
"}",
"}",
";",
"}"
] |
Returns status column.
@return Closure
|
[
"Returns",
"status",
"column",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Datatables/Extensions.php#L313-L328
|
228,217
|
antaresproject/core
|
src/foundation/src/Http/Datatables/Extensions.php
|
Extensions.getNameColumn
|
protected function getNameColumn(): Closure
{
return function(ExtensionContract $package) {
$name = $package->getFriendlyName();
$url = $package->getPackage()->getHomepage();
if ($url) {
return (string) HTML::link($url, $name, [
'target' => '_blank',
]);
}
return $name;
};
}
|
php
|
protected function getNameColumn(): Closure
{
return function(ExtensionContract $package) {
$name = $package->getFriendlyName();
$url = $package->getPackage()->getHomepage();
if ($url) {
return (string) HTML::link($url, $name, [
'target' => '_blank',
]);
}
return $name;
};
}
|
[
"protected",
"function",
"getNameColumn",
"(",
")",
":",
"Closure",
"{",
"return",
"function",
"(",
"ExtensionContract",
"$",
"package",
")",
"{",
"$",
"name",
"=",
"$",
"package",
"->",
"getFriendlyName",
"(",
")",
";",
"$",
"url",
"=",
"$",
"package",
"->",
"getPackage",
"(",
")",
"->",
"getHomepage",
"(",
")",
";",
"if",
"(",
"$",
"url",
")",
"{",
"return",
"(",
"string",
")",
"HTML",
"::",
"link",
"(",
"$",
"url",
",",
"$",
"name",
",",
"[",
"'target'",
"=>",
"'_blank'",
",",
"]",
")",
";",
"}",
"return",
"$",
"name",
";",
"}",
";",
"}"
] |
Returns name column.
@return Closure
|
[
"Returns",
"name",
"column",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Datatables/Extensions.php#L347-L361
|
228,218
|
antaresproject/core
|
src/foundation/src/Http/Datatables/Extensions.php
|
Extensions.getAuthorsColumn
|
protected function getAuthorsColumn(): Closure
{
return function(ExtensionContract $extension) {
$authors = array_map(function(array $author) {
if (array_key_exists('email', $author)) {
return (string) HTML::mailto($author['email'], $author['name']);
}
return $author['name'];
}, $extension->getPackage()->getAuthors());
$prefix = '';
if ($extension->getVendorName() === 'antaresproject') {
$prefix = trans('antares/foundation::title.antares_team');
}
return $prefix . ' - ' . implode(', ', $authors);
};
}
|
php
|
protected function getAuthorsColumn(): Closure
{
return function(ExtensionContract $extension) {
$authors = array_map(function(array $author) {
if (array_key_exists('email', $author)) {
return (string) HTML::mailto($author['email'], $author['name']);
}
return $author['name'];
}, $extension->getPackage()->getAuthors());
$prefix = '';
if ($extension->getVendorName() === 'antaresproject') {
$prefix = trans('antares/foundation::title.antares_team');
}
return $prefix . ' - ' . implode(', ', $authors);
};
}
|
[
"protected",
"function",
"getAuthorsColumn",
"(",
")",
":",
"Closure",
"{",
"return",
"function",
"(",
"ExtensionContract",
"$",
"extension",
")",
"{",
"$",
"authors",
"=",
"array_map",
"(",
"function",
"(",
"array",
"$",
"author",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'email'",
",",
"$",
"author",
")",
")",
"{",
"return",
"(",
"string",
")",
"HTML",
"::",
"mailto",
"(",
"$",
"author",
"[",
"'email'",
"]",
",",
"$",
"author",
"[",
"'name'",
"]",
")",
";",
"}",
"return",
"$",
"author",
"[",
"'name'",
"]",
";",
"}",
",",
"$",
"extension",
"->",
"getPackage",
"(",
")",
"->",
"getAuthors",
"(",
")",
")",
";",
"$",
"prefix",
"=",
"''",
";",
"if",
"(",
"$",
"extension",
"->",
"getVendorName",
"(",
")",
"===",
"'antaresproject'",
")",
"{",
"$",
"prefix",
"=",
"trans",
"(",
"'antares/foundation::title.antares_team'",
")",
";",
"}",
"return",
"$",
"prefix",
".",
"' - '",
".",
"implode",
"(",
"', '",
",",
"$",
"authors",
")",
";",
"}",
";",
"}"
] |
Returns authors column.
@return Closure
|
[
"Returns",
"authors",
"column",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Datatables/Extensions.php#L392-L411
|
228,219
|
lawoole/framework
|
src/WebSocket/WebSocketConnection.php
|
WebSocketConnection.push
|
public function push($data, $finish = true, $binary = false)
{
return $this->server->push(
$this->id, $data, $binary ? WEBSOCKET_OPCODE_BINARY : WEBSOCKET_OPCODE_TEXT, $finish
);
}
|
php
|
public function push($data, $finish = true, $binary = false)
{
return $this->server->push(
$this->id, $data, $binary ? WEBSOCKET_OPCODE_BINARY : WEBSOCKET_OPCODE_TEXT, $finish
);
}
|
[
"public",
"function",
"push",
"(",
"$",
"data",
",",
"$",
"finish",
"=",
"true",
",",
"$",
"binary",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"server",
"->",
"push",
"(",
"$",
"this",
"->",
"id",
",",
"$",
"data",
",",
"$",
"binary",
"?",
"WEBSOCKET_OPCODE_BINARY",
":",
"WEBSOCKET_OPCODE_TEXT",
",",
"$",
"finish",
")",
";",
"}"
] |
Push data to the client.
@param string $data
@param bool $finish
@param bool $binary
@return bool
|
[
"Push",
"data",
"to",
"the",
"client",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/WebSocket/WebSocketConnection.php#L63-L68
|
228,220
|
lawoole/framework
|
src/WebSocket/WebSocketConnection.php
|
WebSocketConnection.close
|
public function close($code = 1000, $reason = '')
{
return $this->server->disconnect($this->id, $code, $reason);
}
|
php
|
public function close($code = 1000, $reason = '')
{
return $this->server->disconnect($this->id, $code, $reason);
}
|
[
"public",
"function",
"close",
"(",
"$",
"code",
"=",
"1000",
",",
"$",
"reason",
"=",
"''",
")",
"{",
"return",
"$",
"this",
"->",
"server",
"->",
"disconnect",
"(",
"$",
"this",
"->",
"id",
",",
"$",
"code",
",",
"$",
"reason",
")",
";",
"}"
] |
Close to the connection.
@param int $code
@param string $reason
@return bool
|
[
"Close",
"to",
"the",
"connection",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/WebSocket/WebSocketConnection.php#L91-L94
|
228,221
|
antaresproject/core
|
src/components/extension/src/Factories/SettingsFactory.php
|
SettingsFactory.createFromConfig
|
public function createFromConfig(string $path) : SettingsContract {
$configData = (array) $this->filesystem->getRequire($path);
return $this->createFromData($configData);
}
|
php
|
public function createFromConfig(string $path) : SettingsContract {
$configData = (array) $this->filesystem->getRequire($path);
return $this->createFromData($configData);
}
|
[
"public",
"function",
"createFromConfig",
"(",
"string",
"$",
"path",
")",
":",
"SettingsContract",
"{",
"$",
"configData",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"filesystem",
"->",
"getRequire",
"(",
"$",
"path",
")",
";",
"return",
"$",
"this",
"->",
"createFromData",
"(",
"$",
"configData",
")",
";",
"}"
] |
Returns the settings by the given configuration file.
@param string $path
@return SettingsContract
@throws FileNotFoundException
|
[
"Returns",
"the",
"settings",
"by",
"the",
"given",
"configuration",
"file",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Factories/SettingsFactory.php#L37-L41
|
228,222
|
antaresproject/core
|
src/components/extension/src/Factories/SettingsFactory.php
|
SettingsFactory.createFromData
|
public function createFromData(array $configData) : SettingsContract {
$data = (array) Arr::get($configData, 'data', []);
$rules = (array) Arr::get($configData, 'rules', []);
$phrases = (array) Arr::get($configData, 'phrases', []);
$customUrl = (string) Arr::get($configData, 'custom_url', '');
return new Settings($data, $rules, $phrases, $customUrl);
}
|
php
|
public function createFromData(array $configData) : SettingsContract {
$data = (array) Arr::get($configData, 'data', []);
$rules = (array) Arr::get($configData, 'rules', []);
$phrases = (array) Arr::get($configData, 'phrases', []);
$customUrl = (string) Arr::get($configData, 'custom_url', '');
return new Settings($data, $rules, $phrases, $customUrl);
}
|
[
"public",
"function",
"createFromData",
"(",
"array",
"$",
"configData",
")",
":",
"SettingsContract",
"{",
"$",
"data",
"=",
"(",
"array",
")",
"Arr",
"::",
"get",
"(",
"$",
"configData",
",",
"'data'",
",",
"[",
"]",
")",
";",
"$",
"rules",
"=",
"(",
"array",
")",
"Arr",
"::",
"get",
"(",
"$",
"configData",
",",
"'rules'",
",",
"[",
"]",
")",
";",
"$",
"phrases",
"=",
"(",
"array",
")",
"Arr",
"::",
"get",
"(",
"$",
"configData",
",",
"'phrases'",
",",
"[",
"]",
")",
";",
"$",
"customUrl",
"=",
"(",
"string",
")",
"Arr",
"::",
"get",
"(",
"$",
"configData",
",",
"'custom_url'",
",",
"''",
")",
";",
"return",
"new",
"Settings",
"(",
"$",
"data",
",",
"$",
"rules",
",",
"$",
"phrases",
",",
"$",
"customUrl",
")",
";",
"}"
] |
Returns the settings by the given configuration array.
@param array $configData
@return SettingsContract
@throws FileNotFoundException
|
[
"Returns",
"the",
"settings",
"by",
"the",
"given",
"configuration",
"array",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Factories/SettingsFactory.php#L50-L57
|
228,223
|
antaresproject/core
|
src/components/view/src/Decorator.php
|
Decorator.render
|
public function render($name, $data = null)
{
if (! isset($this->macros[$name])) {
throw new BadMethodCallException("Method [$name] does not exist.");
}
return call_user_func($this->macros[$name], $data);
}
|
php
|
public function render($name, $data = null)
{
if (! isset($this->macros[$name])) {
throw new BadMethodCallException("Method [$name] does not exist.");
}
return call_user_func($this->macros[$name], $data);
}
|
[
"public",
"function",
"render",
"(",
"$",
"name",
",",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"macros",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"\"Method [$name] does not exist.\"",
")",
";",
"}",
"return",
"call_user_func",
"(",
"$",
"this",
"->",
"macros",
"[",
"$",
"name",
"]",
",",
"$",
"data",
")",
";",
"}"
] |
Render the macro.
@param string $name
@param array $data
@return string
@throws \BadMethodCallException
|
[
"Render",
"the",
"macro",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Decorator.php#L57-L64
|
228,224
|
antaresproject/core
|
src/components/translations/src/Repository/LanguageRepository.php
|
LanguageRepository.insert
|
public function insert($data)
{
DB::transaction(function() use($data) {
$data['code'] = strtolower($data['code']);
$model = new Languages($data);
$model->save();
$inserts = $this->prepareMultiInsert($data['code']);
DB::table('tbl_translations')->insert($inserts);
});
}
|
php
|
public function insert($data)
{
DB::transaction(function() use($data) {
$data['code'] = strtolower($data['code']);
$model = new Languages($data);
$model->save();
$inserts = $this->prepareMultiInsert($data['code']);
DB::table('tbl_translations')->insert($inserts);
});
}
|
[
"public",
"function",
"insert",
"(",
"$",
"data",
")",
"{",
"DB",
"::",
"transaction",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"data",
")",
"{",
"$",
"data",
"[",
"'code'",
"]",
"=",
"strtolower",
"(",
"$",
"data",
"[",
"'code'",
"]",
")",
";",
"$",
"model",
"=",
"new",
"Languages",
"(",
"$",
"data",
")",
";",
"$",
"model",
"->",
"save",
"(",
")",
";",
"$",
"inserts",
"=",
"$",
"this",
"->",
"prepareMultiInsert",
"(",
"$",
"data",
"[",
"'code'",
"]",
")",
";",
"DB",
"::",
"table",
"(",
"'tbl_translations'",
")",
"->",
"insert",
"(",
"$",
"inserts",
")",
";",
"}",
")",
";",
"}"
] |
store new language in database
@param array $data
|
[
"store",
"new",
"language",
"in",
"database"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/translations/src/Repository/LanguageRepository.php#L58-L67
|
228,225
|
antaresproject/core
|
src/components/translations/src/Repository/LanguageRepository.php
|
LanguageRepository.prepareMultiInsert
|
protected function prepareMultiInsert($code)
{
$default = Languages::where('is_default', 1)->first()->code;
$translations = Translation::where('locale', $default)->get()->toArray();
$translation = new Translation();
$guarded = $translation->getGuarded();
$langId = Languages::where('code', $code)->first()->id;
$inserts = array_map(function($current) use($code, $langId, $guarded) {
$current['locale'] = $code;
$current['lang_id'] = $langId;
return array_except($current, $guarded);
}, $translations);
return $inserts;
}
|
php
|
protected function prepareMultiInsert($code)
{
$default = Languages::where('is_default', 1)->first()->code;
$translations = Translation::where('locale', $default)->get()->toArray();
$translation = new Translation();
$guarded = $translation->getGuarded();
$langId = Languages::where('code', $code)->first()->id;
$inserts = array_map(function($current) use($code, $langId, $guarded) {
$current['locale'] = $code;
$current['lang_id'] = $langId;
return array_except($current, $guarded);
}, $translations);
return $inserts;
}
|
[
"protected",
"function",
"prepareMultiInsert",
"(",
"$",
"code",
")",
"{",
"$",
"default",
"=",
"Languages",
"::",
"where",
"(",
"'is_default'",
",",
"1",
")",
"->",
"first",
"(",
")",
"->",
"code",
";",
"$",
"translations",
"=",
"Translation",
"::",
"where",
"(",
"'locale'",
",",
"$",
"default",
")",
"->",
"get",
"(",
")",
"->",
"toArray",
"(",
")",
";",
"$",
"translation",
"=",
"new",
"Translation",
"(",
")",
";",
"$",
"guarded",
"=",
"$",
"translation",
"->",
"getGuarded",
"(",
")",
";",
"$",
"langId",
"=",
"Languages",
"::",
"where",
"(",
"'code'",
",",
"$",
"code",
")",
"->",
"first",
"(",
")",
"->",
"id",
";",
"$",
"inserts",
"=",
"array_map",
"(",
"function",
"(",
"$",
"current",
")",
"use",
"(",
"$",
"code",
",",
"$",
"langId",
",",
"$",
"guarded",
")",
"{",
"$",
"current",
"[",
"'locale'",
"]",
"=",
"$",
"code",
";",
"$",
"current",
"[",
"'lang_id'",
"]",
"=",
"$",
"langId",
";",
"return",
"array_except",
"(",
"$",
"current",
",",
"$",
"guarded",
")",
";",
"}",
",",
"$",
"translations",
")",
";",
"return",
"$",
"inserts",
";",
"}"
] |
prepare data before multiinsert translations from default
@param String $code
@return array
|
[
"prepare",
"data",
"before",
"multiinsert",
"translations",
"from",
"default"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/translations/src/Repository/LanguageRepository.php#L75-L89
|
228,226
|
antaresproject/core
|
src/components/translations/src/Repository/LanguageRepository.php
|
LanguageRepository.findByLocale
|
public function findByLocale(array $params = [])
{
return (empty($params)) ? $this->fetchAll() : $this->makeModel()->whereIn('code', array_values($params))->get();
}
|
php
|
public function findByLocale(array $params = [])
{
return (empty($params)) ? $this->fetchAll() : $this->makeModel()->whereIn('code', array_values($params))->get();
}
|
[
"public",
"function",
"findByLocale",
"(",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"return",
"(",
"empty",
"(",
"$",
"params",
")",
")",
"?",
"$",
"this",
"->",
"fetchAll",
"(",
")",
":",
"$",
"this",
"->",
"makeModel",
"(",
")",
"->",
"whereIn",
"(",
"'code'",
",",
"array_values",
"(",
"$",
"params",
")",
")",
"->",
"get",
"(",
")",
";",
"}"
] |
Finds languages by specified locale
@param array $params
@return \Illuminate\Database\Eloquent\Collection
|
[
"Finds",
"languages",
"by",
"specified",
"locale"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/translations/src/Repository/LanguageRepository.php#L97-L100
|
228,227
|
antaresproject/core
|
src/components/extension/src/Repositories/ExtensionsRepository.php
|
ExtensionsRepository.save
|
public function save(ExtensionContract $extension, array $attributes = []) : ExtensionModel {
$identity = [
'vendor' => $extension->getVendorName(),
'name' => $extension->getPackageName(),
];
/* @var $model ExtensionModel */
$model = ExtensionModel::query()->updateOrCreate($identity, $attributes);
return $model;
}
|
php
|
public function save(ExtensionContract $extension, array $attributes = []) : ExtensionModel {
$identity = [
'vendor' => $extension->getVendorName(),
'name' => $extension->getPackageName(),
];
/* @var $model ExtensionModel */
$model = ExtensionModel::query()->updateOrCreate($identity, $attributes);
return $model;
}
|
[
"public",
"function",
"save",
"(",
"ExtensionContract",
"$",
"extension",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
":",
"ExtensionModel",
"{",
"$",
"identity",
"=",
"[",
"'vendor'",
"=>",
"$",
"extension",
"->",
"getVendorName",
"(",
")",
",",
"'name'",
"=>",
"$",
"extension",
"->",
"getPackageName",
"(",
")",
",",
"]",
";",
"/* @var $model ExtensionModel */",
"$",
"model",
"=",
"ExtensionModel",
"::",
"query",
"(",
")",
"->",
"updateOrCreate",
"(",
"$",
"identity",
",",
"$",
"attributes",
")",
";",
"return",
"$",
"model",
";",
"}"
] |
Create or update the package.
@param ExtensionContract $extension
@param array $attributes
@return ExtensionModel
|
[
"Create",
"or",
"update",
"the",
"package",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Repositories/ExtensionsRepository.php#L28-L38
|
228,228
|
antaresproject/core
|
src/components/html/src/Memory/Config.php
|
Config.getKeyId
|
protected function getKeyId($name)
{
return isset($this->keyMap[$name]) ? $this->keyMap[$name]['id'] : null;
}
|
php
|
protected function getKeyId($name)
{
return isset($this->keyMap[$name]) ? $this->keyMap[$name]['id'] : null;
}
|
[
"protected",
"function",
"getKeyId",
"(",
"$",
"name",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"keyMap",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"keyMap",
"[",
"$",
"name",
"]",
"[",
"'id'",
"]",
":",
"null",
";",
"}"
] |
Is given key a new content.
@param string $name
@return int
|
[
"Is",
"given",
"key",
"a",
"new",
"content",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Memory/Config.php#L195-L198
|
228,229
|
antaresproject/core
|
src/components/html/src/Memory/Config.php
|
Config.resolver
|
protected function resolver()
{
$model = Arr::get($this->config, 'model', $this->name);
return $this->repository->make($model)->newInstance();
}
|
php
|
protected function resolver()
{
$model = Arr::get($this->config, 'model', $this->name);
return $this->repository->make($model)->newInstance();
}
|
[
"protected",
"function",
"resolver",
"(",
")",
"{",
"$",
"model",
"=",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"config",
",",
"'model'",
",",
"$",
"this",
"->",
"name",
")",
";",
"return",
"$",
"this",
"->",
"repository",
"->",
"make",
"(",
"$",
"model",
")",
"->",
"newInstance",
"(",
")",
";",
"}"
] |
get handler model instance
@return Eloquent
|
[
"get",
"handler",
"model",
"instance"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Memory/Config.php#L204-L208
|
228,230
|
bpocallaghan/impersonate
|
src/ImpersonateController.php
|
ImpersonateController.login
|
protected function login(Request $request, User $user)
{
impersonate()->login($user);
// if redirect url in request
if ($request->has('redirect_to')) {
return redirect($request->get('redirect_to'));
}
return back();
}
|
php
|
protected function login(Request $request, User $user)
{
impersonate()->login($user);
// if redirect url in request
if ($request->has('redirect_to')) {
return redirect($request->get('redirect_to'));
}
return back();
}
|
[
"protected",
"function",
"login",
"(",
"Request",
"$",
"request",
",",
"User",
"$",
"user",
")",
"{",
"impersonate",
"(",
")",
"->",
"login",
"(",
"$",
"user",
")",
";",
"// if redirect url in request",
"if",
"(",
"$",
"request",
"->",
"has",
"(",
"'redirect_to'",
")",
")",
"{",
"return",
"redirect",
"(",
"$",
"request",
"->",
"get",
"(",
"'redirect_to'",
")",
")",
";",
"}",
"return",
"back",
"(",
")",
";",
"}"
] |
Impersonate the given user
@param Request $request
@param User $user
@return \Illuminate\Http\RedirectResponse
|
[
"Impersonate",
"the",
"given",
"user"
] |
e7404b94fe464782abe297ace8f1211fea7c41b0
|
https://github.com/bpocallaghan/impersonate/blob/e7404b94fe464782abe297ace8f1211fea7c41b0/src/ImpersonateController.php#L17-L27
|
228,231
|
bpocallaghan/impersonate
|
src/ImpersonateController.php
|
ImpersonateController.logout
|
protected function logout(Request $request)
{
impersonate()->logout();
// if redirect url in request
if ($request->has('redirect_to')) {
return redirect($request->get('redirect_to'));
}
return back();
}
|
php
|
protected function logout(Request $request)
{
impersonate()->logout();
// if redirect url in request
if ($request->has('redirect_to')) {
return redirect($request->get('redirect_to'));
}
return back();
}
|
[
"protected",
"function",
"logout",
"(",
"Request",
"$",
"request",
")",
"{",
"impersonate",
"(",
")",
"->",
"logout",
"(",
")",
";",
"// if redirect url in request",
"if",
"(",
"$",
"request",
"->",
"has",
"(",
"'redirect_to'",
")",
")",
"{",
"return",
"redirect",
"(",
"$",
"request",
"->",
"get",
"(",
"'redirect_to'",
")",
")",
";",
"}",
"return",
"back",
"(",
")",
";",
"}"
] |
Logout as the impersonated user
Log back in as the original user
@param Request $request
@return \Illuminate\Http\RedirectResponse
|
[
"Logout",
"as",
"the",
"impersonated",
"user",
"Log",
"back",
"in",
"as",
"the",
"original",
"user"
] |
e7404b94fe464782abe297ace8f1211fea7c41b0
|
https://github.com/bpocallaghan/impersonate/blob/e7404b94fe464782abe297ace8f1211fea7c41b0/src/ImpersonateController.php#L35-L45
|
228,232
|
24aitor/Localizer
|
src/Controllers/LocalizerController.php
|
LocalizerController.setLocale
|
private function setLocale($locale, $request)
{
$allowedLangs = array_keys(Localizer::allowedLanguages());
if (config('localizer.block_unallowed_langs') && !in_array($locale, $allowedLangs)) {
abort(404, 'Unallowed language');
}
if (Auth::check()) {
$user = Auth::User();
$user->locale = $locale;
$user->save();
} else {
$request->session()->put('locale', $locale);
}
}
|
php
|
private function setLocale($locale, $request)
{
$allowedLangs = array_keys(Localizer::allowedLanguages());
if (config('localizer.block_unallowed_langs') && !in_array($locale, $allowedLangs)) {
abort(404, 'Unallowed language');
}
if (Auth::check()) {
$user = Auth::User();
$user->locale = $locale;
$user->save();
} else {
$request->session()->put('locale', $locale);
}
}
|
[
"private",
"function",
"setLocale",
"(",
"$",
"locale",
",",
"$",
"request",
")",
"{",
"$",
"allowedLangs",
"=",
"array_keys",
"(",
"Localizer",
"::",
"allowedLanguages",
"(",
")",
")",
";",
"if",
"(",
"config",
"(",
"'localizer.block_unallowed_langs'",
")",
"&&",
"!",
"in_array",
"(",
"$",
"locale",
",",
"$",
"allowedLangs",
")",
")",
"{",
"abort",
"(",
"404",
",",
"'Unallowed language'",
")",
";",
"}",
"if",
"(",
"Auth",
"::",
"check",
"(",
")",
")",
"{",
"$",
"user",
"=",
"Auth",
"::",
"User",
"(",
")",
";",
"$",
"user",
"->",
"locale",
"=",
"$",
"locale",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"}",
"else",
"{",
"$",
"request",
"->",
"session",
"(",
")",
"->",
"put",
"(",
"'locale'",
",",
"$",
"locale",
")",
";",
"}",
"}"
] |
Set locale if it's allowed.
@param string $locale
@param \Illuminate\Http\Request $request
|
[
"Set",
"locale",
"if",
"it",
"s",
"allowed",
"."
] |
3f234dfeab1030119148ece01f61d79dba27ac67
|
https://github.com/24aitor/Localizer/blob/3f234dfeab1030119148ece01f61d79dba27ac67/src/Controllers/LocalizerController.php#L18-L32
|
228,233
|
24aitor/Localizer
|
src/Controllers/LocalizerController.php
|
LocalizerController.setHome
|
public function setHome($locale, Request $request)
{
$this->setLocale($locale, $request);
return redirect(url('/'));
}
|
php
|
public function setHome($locale, Request $request)
{
$this->setLocale($locale, $request);
return redirect(url('/'));
}
|
[
"public",
"function",
"setHome",
"(",
"$",
"locale",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"setLocale",
"(",
"$",
"locale",
",",
"$",
"request",
")",
";",
"return",
"redirect",
"(",
"url",
"(",
"'/'",
")",
")",
";",
"}"
] |
Set locale and return home url.
@param string $locale
@param \Illuminate\Http\Request $request
|
[
"Set",
"locale",
"and",
"return",
"home",
"url",
"."
] |
3f234dfeab1030119148ece01f61d79dba27ac67
|
https://github.com/24aitor/Localizer/blob/3f234dfeab1030119148ece01f61d79dba27ac67/src/Controllers/LocalizerController.php#L40-L45
|
228,234
|
24aitor/Localizer
|
src/Controllers/LocalizerController.php
|
LocalizerController.set
|
public function set($locale, Request $request)
{
$this->setLocale($locale, $request);
return redirect()->back();
}
|
php
|
public function set($locale, Request $request)
{
$this->setLocale($locale, $request);
return redirect()->back();
}
|
[
"public",
"function",
"set",
"(",
"$",
"locale",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"setLocale",
"(",
"$",
"locale",
",",
"$",
"request",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"back",
"(",
")",
";",
"}"
] |
Set locale and return back.
@param string $locale
@param \Illuminate\Http\Request $request
|
[
"Set",
"locale",
"and",
"return",
"back",
"."
] |
3f234dfeab1030119148ece01f61d79dba27ac67
|
https://github.com/24aitor/Localizer/blob/3f234dfeab1030119148ece01f61d79dba27ac67/src/Controllers/LocalizerController.php#L53-L58
|
228,235
|
antaresproject/core
|
src/foundation/src/Http/Composers/LeftPane.php
|
LeftPane.compose
|
public function compose($name = null, $options = array())
{
if ($name instanceof View) {
$name = null;
}
if (is_null($this->widget)) {
return false;
}
$this->widget
->make((is_null($name) ? 'pane.left' : $name))
->add(isset($options['name']) ? $options['name'] : $this->defaultAttributes['name'])
->attributes(isset($options['attributes']) ? $options['attributes'] : $this->defaultAttributes['attributes'])
->title(trans(isset($options['title']) ? $options['title'] : $this->defaultAttributes['title']))
->content(view(isset($options['view']) ? $options['view'] : $this->defaultAttributes['view']));
}
|
php
|
public function compose($name = null, $options = array())
{
if ($name instanceof View) {
$name = null;
}
if (is_null($this->widget)) {
return false;
}
$this->widget
->make((is_null($name) ? 'pane.left' : $name))
->add(isset($options['name']) ? $options['name'] : $this->defaultAttributes['name'])
->attributes(isset($options['attributes']) ? $options['attributes'] : $this->defaultAttributes['attributes'])
->title(trans(isset($options['title']) ? $options['title'] : $this->defaultAttributes['title']))
->content(view(isset($options['view']) ? $options['view'] : $this->defaultAttributes['view']));
}
|
[
"public",
"function",
"compose",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"name",
"instanceof",
"View",
")",
"{",
"$",
"name",
"=",
"null",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"widget",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"widget",
"->",
"make",
"(",
"(",
"is_null",
"(",
"$",
"name",
")",
"?",
"'pane.left'",
":",
"$",
"name",
")",
")",
"->",
"add",
"(",
"isset",
"(",
"$",
"options",
"[",
"'name'",
"]",
")",
"?",
"$",
"options",
"[",
"'name'",
"]",
":",
"$",
"this",
"->",
"defaultAttributes",
"[",
"'name'",
"]",
")",
"->",
"attributes",
"(",
"isset",
"(",
"$",
"options",
"[",
"'attributes'",
"]",
")",
"?",
"$",
"options",
"[",
"'attributes'",
"]",
":",
"$",
"this",
"->",
"defaultAttributes",
"[",
"'attributes'",
"]",
")",
"->",
"title",
"(",
"trans",
"(",
"isset",
"(",
"$",
"options",
"[",
"'title'",
"]",
")",
"?",
"$",
"options",
"[",
"'title'",
"]",
":",
"$",
"this",
"->",
"defaultAttributes",
"[",
"'title'",
"]",
")",
")",
"->",
"content",
"(",
"view",
"(",
"isset",
"(",
"$",
"options",
"[",
"'view'",
"]",
")",
"?",
"$",
"options",
"[",
"'view'",
"]",
":",
"$",
"this",
"->",
"defaultAttributes",
"[",
"'view'",
"]",
")",
")",
";",
"}"
] |
Handle pane for left conatiner.
@return void
|
[
"Handle",
"pane",
"for",
"left",
"conatiner",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Composers/LeftPane.php#L76-L91
|
228,236
|
lawoole/framework
|
src/Homer/Components/Component.php
|
Component.withMiddleware
|
protected function withMiddleware($invoker, $interface, $config)
{
if (empty($this->middleware)) {
return $invoker;
}
return new MiddlewareInvoker($this->container, $interface, $invoker, $this->middleware, $config);
}
|
php
|
protected function withMiddleware($invoker, $interface, $config)
{
if (empty($this->middleware)) {
return $invoker;
}
return new MiddlewareInvoker($this->container, $interface, $invoker, $this->middleware, $config);
}
|
[
"protected",
"function",
"withMiddleware",
"(",
"$",
"invoker",
",",
"$",
"interface",
",",
"$",
"config",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"middleware",
")",
")",
"{",
"return",
"$",
"invoker",
";",
"}",
"return",
"new",
"MiddlewareInvoker",
"(",
"$",
"this",
"->",
"container",
",",
"$",
"interface",
",",
"$",
"invoker",
",",
"$",
"this",
"->",
"middleware",
",",
"$",
"config",
")",
";",
"}"
] |
Add middleware to the invoker.
@param \Lawoole\Homer\Calling\Invokers\Invoker $invoker
@param string $interface
@param array $config
@return \Lawoole\Homer\Calling\Invokers\Invoker
|
[
"Add",
"middleware",
"to",
"the",
"invoker",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Components/Component.php#L65-L72
|
228,237
|
gggeek/ggwebservices
|
classes/ggrestrequest.php
|
ggRESTRequest.payload
|
function payload()
{
if ( $this->Verb == 'GET' || $this->Verb == 'HEAD' || $this->Verb == 'TRACE' )
{
return '';
}
else
{
$params = $this->Parameters;
if ( $this->NameVar != null )
{
$params[$this->NameVar] = $this->Name;
}
return $this->_payload( $params );
}
}
|
php
|
function payload()
{
if ( $this->Verb == 'GET' || $this->Verb == 'HEAD' || $this->Verb == 'TRACE' )
{
return '';
}
else
{
$params = $this->Parameters;
if ( $this->NameVar != null )
{
$params[$this->NameVar] = $this->Name;
}
return $this->_payload( $params );
}
}
|
[
"function",
"payload",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"Verb",
"==",
"'GET'",
"||",
"$",
"this",
"->",
"Verb",
"==",
"'HEAD'",
"||",
"$",
"this",
"->",
"Verb",
"==",
"'TRACE'",
")",
"{",
"return",
"''",
";",
"}",
"else",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"Parameters",
";",
"if",
"(",
"$",
"this",
"->",
"NameVar",
"!=",
"null",
")",
"{",
"$",
"params",
"[",
"$",
"this",
"->",
"NameVar",
"]",
"=",
"$",
"this",
"->",
"Name",
";",
"}",
"return",
"$",
"this",
"->",
"_payload",
"(",
"$",
"params",
")",
";",
"}",
"}"
] |
No request body for GET requests, as all params are put in the url
|
[
"No",
"request",
"body",
"for",
"GET",
"requests",
"as",
"all",
"params",
"are",
"put",
"in",
"the",
"url"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggrestrequest.php#L14-L29
|
228,238
|
gggeek/ggwebservices
|
classes/ggrestrequest.php
|
ggRESTRequest.getHttpAccept
|
function getHttpAccept()
{
if ( isset( $_GET[$this->FormatVar] ) )
{
return $_GET[$this->FormatVar];
}
else
{
if ( isset( $_POST['http_accept'] ) )
$acceptList = explode( ',', $_POST['http_accept'] );
else if ( isset( $_POST['HTTP_ACCEPT'] ) )
$acceptList = explode( ',', $_POST['HTTP_ACCEPT'] );
else if ( isset( $_GET['http_accept'] ) )
$acceptList = explode( ',', $_GET['http_accept'] );
else if ( isset( $_GET['HTTP_ACCEPT'] ) )
$acceptList = explode( ',', $_GET['HTTP_ACCEPT'] );
else if ( isset( $_SERVER['HTTP_ACCEPT'] ) )
$acceptList = explode( ',', $_SERVER['HTTP_ACCEPT'] );
else
$acceptList = false;
if ( !$acceptList ) // works for false && for empty arrays too
{
return '';
}
$weightedList = array();
foreach( $acceptList as $accept )
{
if ( preg_match( '/; *q *= *([0-9.]+) *$/', $accept, $matches ) )
{
$accept = explode( ';', $accept );
$accept = trim( $accept[0] );
$weightedList[$accept] = (float)$matches[1];
}
else
{
$weightedList[$accept] = 1.0;
}
}
arsort( $weightedList );
$weightedList = array_keys( $weightedList );
// try first we the types that responses can serialize to
/// @todo add txt, html, php, phps to the list - be loyal to other class methods
$aliasList = array( 'json' => 'application/json', 'javascript' => 'application/json', /*'xml' => 'text/xml', 'html' => 'text/xhtml', 'text' => 'text'*/ );
foreach( $weightedList as $accept )
{
if ( $accept == '*/*' )
{
return reset( $aliasList );
}
foreach( $aliasList as $alias => $returnType )
{
if ( strpos( $accept, $alias ) !== false )
{
return $returnType;
}
}
}
// request said what it wants, but we cannot give it back as it is not supported by response
return $weightedList[0];
}
}
|
php
|
function getHttpAccept()
{
if ( isset( $_GET[$this->FormatVar] ) )
{
return $_GET[$this->FormatVar];
}
else
{
if ( isset( $_POST['http_accept'] ) )
$acceptList = explode( ',', $_POST['http_accept'] );
else if ( isset( $_POST['HTTP_ACCEPT'] ) )
$acceptList = explode( ',', $_POST['HTTP_ACCEPT'] );
else if ( isset( $_GET['http_accept'] ) )
$acceptList = explode( ',', $_GET['http_accept'] );
else if ( isset( $_GET['HTTP_ACCEPT'] ) )
$acceptList = explode( ',', $_GET['HTTP_ACCEPT'] );
else if ( isset( $_SERVER['HTTP_ACCEPT'] ) )
$acceptList = explode( ',', $_SERVER['HTTP_ACCEPT'] );
else
$acceptList = false;
if ( !$acceptList ) // works for false && for empty arrays too
{
return '';
}
$weightedList = array();
foreach( $acceptList as $accept )
{
if ( preg_match( '/; *q *= *([0-9.]+) *$/', $accept, $matches ) )
{
$accept = explode( ';', $accept );
$accept = trim( $accept[0] );
$weightedList[$accept] = (float)$matches[1];
}
else
{
$weightedList[$accept] = 1.0;
}
}
arsort( $weightedList );
$weightedList = array_keys( $weightedList );
// try first we the types that responses can serialize to
/// @todo add txt, html, php, phps to the list - be loyal to other class methods
$aliasList = array( 'json' => 'application/json', 'javascript' => 'application/json', /*'xml' => 'text/xml', 'html' => 'text/xhtml', 'text' => 'text'*/ );
foreach( $weightedList as $accept )
{
if ( $accept == '*/*' )
{
return reset( $aliasList );
}
foreach( $aliasList as $alias => $returnType )
{
if ( strpos( $accept, $alias ) !== false )
{
return $returnType;
}
}
}
// request said what it wants, but we cannot give it back as it is not supported by response
return $weightedList[0];
}
}
|
[
"function",
"getHttpAccept",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"$",
"this",
"->",
"FormatVar",
"]",
")",
")",
"{",
"return",
"$",
"_GET",
"[",
"$",
"this",
"->",
"FormatVar",
"]",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'http_accept'",
"]",
")",
")",
"$",
"acceptList",
"=",
"explode",
"(",
"','",
",",
"$",
"_POST",
"[",
"'http_accept'",
"]",
")",
";",
"else",
"if",
"(",
"isset",
"(",
"$",
"_POST",
"[",
"'HTTP_ACCEPT'",
"]",
")",
")",
"$",
"acceptList",
"=",
"explode",
"(",
"','",
",",
"$",
"_POST",
"[",
"'HTTP_ACCEPT'",
"]",
")",
";",
"else",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'http_accept'",
"]",
")",
")",
"$",
"acceptList",
"=",
"explode",
"(",
"','",
",",
"$",
"_GET",
"[",
"'http_accept'",
"]",
")",
";",
"else",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'HTTP_ACCEPT'",
"]",
")",
")",
"$",
"acceptList",
"=",
"explode",
"(",
"','",
",",
"$",
"_GET",
"[",
"'HTTP_ACCEPT'",
"]",
")",
";",
"else",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_ACCEPT'",
"]",
")",
")",
"$",
"acceptList",
"=",
"explode",
"(",
"','",
",",
"$",
"_SERVER",
"[",
"'HTTP_ACCEPT'",
"]",
")",
";",
"else",
"$",
"acceptList",
"=",
"false",
";",
"if",
"(",
"!",
"$",
"acceptList",
")",
"// works for false && for empty arrays too",
"{",
"return",
"''",
";",
"}",
"$",
"weightedList",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"acceptList",
"as",
"$",
"accept",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/; *q *= *([0-9.]+) *$/'",
",",
"$",
"accept",
",",
"$",
"matches",
")",
")",
"{",
"$",
"accept",
"=",
"explode",
"(",
"';'",
",",
"$",
"accept",
")",
";",
"$",
"accept",
"=",
"trim",
"(",
"$",
"accept",
"[",
"0",
"]",
")",
";",
"$",
"weightedList",
"[",
"$",
"accept",
"]",
"=",
"(",
"float",
")",
"$",
"matches",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"weightedList",
"[",
"$",
"accept",
"]",
"=",
"1.0",
";",
"}",
"}",
"arsort",
"(",
"$",
"weightedList",
")",
";",
"$",
"weightedList",
"=",
"array_keys",
"(",
"$",
"weightedList",
")",
";",
"// try first we the types that responses can serialize to",
"/// @todo add txt, html, php, phps to the list - be loyal to other class methods",
"$",
"aliasList",
"=",
"array",
"(",
"'json'",
"=>",
"'application/json'",
",",
"'javascript'",
"=>",
"'application/json'",
",",
"/*'xml' => 'text/xml', 'html' => 'text/xhtml', 'text' => 'text'*/",
")",
";",
"foreach",
"(",
"$",
"weightedList",
"as",
"$",
"accept",
")",
"{",
"if",
"(",
"$",
"accept",
"==",
"'*/*'",
")",
"{",
"return",
"reset",
"(",
"$",
"aliasList",
")",
";",
"}",
"foreach",
"(",
"$",
"aliasList",
"as",
"$",
"alias",
"=>",
"$",
"returnType",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"accept",
",",
"$",
"alias",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"returnType",
";",
"}",
"}",
"}",
"// request said what it wants, but we cannot give it back as it is not supported by response",
"return",
"$",
"weightedList",
"[",
"0",
"]",
";",
"}",
"}"
] |
Method used server-side to retrieve the accepted value from HTTP.
Same logic as used by ezjscore for the 'call' view, but tries to respect
weights in http Accept header
@todo (!important) recover $aliasList form the response class
|
[
"Method",
"used",
"server",
"-",
"side",
"to",
"retrieve",
"the",
"accepted",
"value",
"from",
"HTTP",
".",
"Same",
"logic",
"as",
"used",
"by",
"ezjscore",
"for",
"the",
"call",
"view",
"but",
"tries",
"to",
"respect",
"weights",
"in",
"http",
"Accept",
"header"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggrestrequest.php#L172-L236
|
228,239
|
gggeek/ggwebservices
|
classes/ggrestrequest.php
|
ggRESTRequest.setContentType
|
function setContentType( $typeAlias )
{
// expand short-hand notation for "php", json" etc
if ( isset( self::$KnownContentTypes[$typeAlias] ) )
{
$this->ContentType = self::$KnownContentTypes[$typeAlias];
return true;
}
// accept as well other mimetypes, as long as we later know how to encode them
$decodableType = $this->mimeTypeToEncodeType( $typeAlias );
if ( isset( self::$KnownContentTypes[$decodableType] ) )
{
$this->ContentType = $typeAlias;
return true;
}
return false;
}
|
php
|
function setContentType( $typeAlias )
{
// expand short-hand notation for "php", json" etc
if ( isset( self::$KnownContentTypes[$typeAlias] ) )
{
$this->ContentType = self::$KnownContentTypes[$typeAlias];
return true;
}
// accept as well other mimetypes, as long as we later know how to encode them
$decodableType = $this->mimeTypeToEncodeType( $typeAlias );
if ( isset( self::$KnownContentTypes[$decodableType] ) )
{
$this->ContentType = $typeAlias;
return true;
}
return false;
}
|
[
"function",
"setContentType",
"(",
"$",
"typeAlias",
")",
"{",
"// expand short-hand notation for \"php\", json\" etc",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"KnownContentTypes",
"[",
"$",
"typeAlias",
"]",
")",
")",
"{",
"$",
"this",
"->",
"ContentType",
"=",
"self",
"::",
"$",
"KnownContentTypes",
"[",
"$",
"typeAlias",
"]",
";",
"return",
"true",
";",
"}",
"// accept as well other mimetypes, as long as we later know how to encode them",
"$",
"decodableType",
"=",
"$",
"this",
"->",
"mimeTypeToEncodeType",
"(",
"$",
"typeAlias",
")",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"KnownContentTypes",
"[",
"$",
"decodableType",
"]",
")",
")",
"{",
"$",
"this",
"->",
"ContentType",
"=",
"$",
"typeAlias",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Only sets content-type header if we know how to serialize it later
@param string $typeAlias
@return bool
@todo should we allow more freedom to caller, and only map very obviously wrong things like "php", json" etc
|
[
"Only",
"sets",
"content",
"-",
"type",
"header",
"if",
"we",
"know",
"how",
"to",
"serialize",
"it",
"later"
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggrestrequest.php#L304-L320
|
228,240
|
antaresproject/core
|
src/utils/asset/src/AssetServiceProvider.php
|
AssetServiceProvider.registerAssetSymlinker
|
protected function registerAssetSymlinker()
{
// $this->app->singleton('asset.symlinker', function() {
// $publicPath = sandbox_path('packages/antares');
//
// return new AssetSymlinker(new Filesystem, $publicPath);
// });
$this->app->singleton(AssetSymlinker::class, function() {
$publicPath = sandbox_path('packages/antares');
return new AssetSymlinker(new Filesystem, $publicPath);
});
$this->app->alias(AssetSymlinker::class, 'asset.symlinker');
}
|
php
|
protected function registerAssetSymlinker()
{
// $this->app->singleton('asset.symlinker', function() {
// $publicPath = sandbox_path('packages/antares');
//
// return new AssetSymlinker(new Filesystem, $publicPath);
// });
$this->app->singleton(AssetSymlinker::class, function() {
$publicPath = sandbox_path('packages/antares');
return new AssetSymlinker(new Filesystem, $publicPath);
});
$this->app->alias(AssetSymlinker::class, 'asset.symlinker');
}
|
[
"protected",
"function",
"registerAssetSymlinker",
"(",
")",
"{",
"// $this->app->singleton('asset.symlinker', function() {",
"// $publicPath = sandbox_path('packages/antares');",
"//",
"// return new AssetSymlinker(new Filesystem, $publicPath);",
"// });",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"AssetSymlinker",
"::",
"class",
",",
"function",
"(",
")",
"{",
"$",
"publicPath",
"=",
"sandbox_path",
"(",
"'packages/antares'",
")",
";",
"return",
"new",
"AssetSymlinker",
"(",
"new",
"Filesystem",
",",
"$",
"publicPath",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"alias",
"(",
"AssetSymlinker",
"::",
"class",
",",
"'asset.symlinker'",
")",
";",
"}"
] |
registering asset symlinker
|
[
"registering",
"asset",
"symlinker"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/asset/src/AssetServiceProvider.php#L68-L83
|
228,241
|
bpocallaghan/impersonate
|
src/Impersonate.php
|
Impersonate.login
|
public function login(User $user)
{
// if not impersonated, save current logged in user
// otherwise do not update (leave first original user in session)
if (!$this->isActive()) {
session()->put($this->originalUserKey, auth()->user()->id);
}
auth()->loginUsingId($user->id);
session()->put($this->isActiveKey, true);
}
|
php
|
public function login(User $user)
{
// if not impersonated, save current logged in user
// otherwise do not update (leave first original user in session)
if (!$this->isActive()) {
session()->put($this->originalUserKey, auth()->user()->id);
}
auth()->loginUsingId($user->id);
session()->put($this->isActiveKey, true);
}
|
[
"public",
"function",
"login",
"(",
"User",
"$",
"user",
")",
"{",
"// if not impersonated, save current logged in user",
"// otherwise do not update (leave first original user in session)",
"if",
"(",
"!",
"$",
"this",
"->",
"isActive",
"(",
")",
")",
"{",
"session",
"(",
")",
"->",
"put",
"(",
"$",
"this",
"->",
"originalUserKey",
",",
"auth",
"(",
")",
"->",
"user",
"(",
")",
"->",
"id",
")",
";",
"}",
"auth",
"(",
")",
"->",
"loginUsingId",
"(",
"$",
"user",
"->",
"id",
")",
";",
"session",
"(",
")",
"->",
"put",
"(",
"$",
"this",
"->",
"isActiveKey",
",",
"true",
")",
";",
"}"
] |
Impersonate the given user
Store the currently logged in user's id in session.
Log the new user in
@param User $user
|
[
"Impersonate",
"the",
"given",
"user",
"Store",
"the",
"currently",
"logged",
"in",
"user",
"s",
"id",
"in",
"session",
".",
"Log",
"the",
"new",
"user",
"in"
] |
e7404b94fe464782abe297ace8f1211fea7c41b0
|
https://github.com/bpocallaghan/impersonate/blob/e7404b94fe464782abe297ace8f1211fea7c41b0/src/Impersonate.php#L28-L39
|
228,242
|
bpocallaghan/impersonate
|
src/Impersonate.php
|
Impersonate.logout
|
public function logout()
{
if (!$this->isActive()) {
return false;
}
auth()->logout();
// log back in as the original user
$originalUserId = session()->get($this->originalUserKey);
if ($originalUserId) {
auth()->loginUsingId($originalUserId);
}
session()->forget($this->originalUserKey);
session()->forget($this->isActiveKey);
return true;
}
|
php
|
public function logout()
{
if (!$this->isActive()) {
return false;
}
auth()->logout();
// log back in as the original user
$originalUserId = session()->get($this->originalUserKey);
if ($originalUserId) {
auth()->loginUsingId($originalUserId);
}
session()->forget($this->originalUserKey);
session()->forget($this->isActiveKey);
return true;
}
|
[
"public",
"function",
"logout",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isActive",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"auth",
"(",
")",
"->",
"logout",
"(",
")",
";",
"// log back in as the original user",
"$",
"originalUserId",
"=",
"session",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"originalUserKey",
")",
";",
"if",
"(",
"$",
"originalUserId",
")",
"{",
"auth",
"(",
")",
"->",
"loginUsingId",
"(",
"$",
"originalUserId",
")",
";",
"}",
"session",
"(",
")",
"->",
"forget",
"(",
"$",
"this",
"->",
"originalUserKey",
")",
";",
"session",
"(",
")",
"->",
"forget",
"(",
"$",
"this",
"->",
"isActiveKey",
")",
";",
"return",
"true",
";",
"}"
] |
Logout the impersonated user
Log back in as the orignal user
Delete the impersonation session
@return bool
|
[
"Logout",
"the",
"impersonated",
"user",
"Log",
"back",
"in",
"as",
"the",
"orignal",
"user",
"Delete",
"the",
"impersonation",
"session"
] |
e7404b94fe464782abe297ace8f1211fea7c41b0
|
https://github.com/bpocallaghan/impersonate/blob/e7404b94fe464782abe297ace8f1211fea7c41b0/src/Impersonate.php#L47-L66
|
228,243
|
antaresproject/core
|
src/components/support/src/Support/Nesty.php
|
Nesty.lookForChild
|
protected function lookForChild($item, $after)
{
if (str_contains($after, '.')) {
$found = [];
$this->lookInDeep($this->items, $after, $item, $found);
if (!empty($found)) {
$this->items[key($found)]->childs = current($found);
return $item;
}
}
return false;
}
|
php
|
protected function lookForChild($item, $after)
{
if (str_contains($after, '.')) {
$found = [];
$this->lookInDeep($this->items, $after, $item, $found);
if (!empty($found)) {
$this->items[key($found)]->childs = current($found);
return $item;
}
}
return false;
}
|
[
"protected",
"function",
"lookForChild",
"(",
"$",
"item",
",",
"$",
"after",
")",
"{",
"if",
"(",
"str_contains",
"(",
"$",
"after",
",",
"'.'",
")",
")",
"{",
"$",
"found",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"lookInDeep",
"(",
"$",
"this",
"->",
"items",
",",
"$",
"after",
",",
"$",
"item",
",",
"$",
"found",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"found",
")",
")",
"{",
"$",
"this",
"->",
"items",
"[",
"key",
"(",
"$",
"found",
")",
"]",
"->",
"childs",
"=",
"current",
"(",
"$",
"found",
")",
";",
"return",
"$",
"item",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
does menu item should be placed before or after child item
@param Fluent $item
@param String $after
@return boolean
|
[
"does",
"menu",
"item",
"should",
"be",
"placed",
"before",
"or",
"after",
"child",
"item"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Support/Nesty.php#L148-L159
|
228,244
|
antaresproject/core
|
src/components/support/src/Support/Nesty.php
|
Nesty.lookInDeep
|
protected function lookInDeep(array $elements, $after, $item, &$buffer = [], &$return = '', $current = null)
{
$branch = array();
foreach ($elements as $key => $element) {
$return = strlen($return) <= 0 ? $current : $return . '.' . $current;
if ($return . '.' . $key == $after) {
$this->buffer($buffer, $elements, $item, $after, $current);
}
if ($element instanceof Fluent) {
$element = $element->toArray();
}
if (!empty($element['childs'])) {
$children = $this->lookInDeep($element['childs'], $after, $item, $buffer, $return, $key);
if ($children) {
$element[$key]['childs'] = $children;
}
} else {
$return = '';
}
$branch[$key] = $element;
}
return $branch;
}
|
php
|
protected function lookInDeep(array $elements, $after, $item, &$buffer = [], &$return = '', $current = null)
{
$branch = array();
foreach ($elements as $key => $element) {
$return = strlen($return) <= 0 ? $current : $return . '.' . $current;
if ($return . '.' . $key == $after) {
$this->buffer($buffer, $elements, $item, $after, $current);
}
if ($element instanceof Fluent) {
$element = $element->toArray();
}
if (!empty($element['childs'])) {
$children = $this->lookInDeep($element['childs'], $after, $item, $buffer, $return, $key);
if ($children) {
$element[$key]['childs'] = $children;
}
} else {
$return = '';
}
$branch[$key] = $element;
}
return $branch;
}
|
[
"protected",
"function",
"lookInDeep",
"(",
"array",
"$",
"elements",
",",
"$",
"after",
",",
"$",
"item",
",",
"&",
"$",
"buffer",
"=",
"[",
"]",
",",
"&",
"$",
"return",
"=",
"''",
",",
"$",
"current",
"=",
"null",
")",
"{",
"$",
"branch",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"elements",
"as",
"$",
"key",
"=>",
"$",
"element",
")",
"{",
"$",
"return",
"=",
"strlen",
"(",
"$",
"return",
")",
"<=",
"0",
"?",
"$",
"current",
":",
"$",
"return",
".",
"'.'",
".",
"$",
"current",
";",
"if",
"(",
"$",
"return",
".",
"'.'",
".",
"$",
"key",
"==",
"$",
"after",
")",
"{",
"$",
"this",
"->",
"buffer",
"(",
"$",
"buffer",
",",
"$",
"elements",
",",
"$",
"item",
",",
"$",
"after",
",",
"$",
"current",
")",
";",
"}",
"if",
"(",
"$",
"element",
"instanceof",
"Fluent",
")",
"{",
"$",
"element",
"=",
"$",
"element",
"->",
"toArray",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"element",
"[",
"'childs'",
"]",
")",
")",
"{",
"$",
"children",
"=",
"$",
"this",
"->",
"lookInDeep",
"(",
"$",
"element",
"[",
"'childs'",
"]",
",",
"$",
"after",
",",
"$",
"item",
",",
"$",
"buffer",
",",
"$",
"return",
",",
"$",
"key",
")",
";",
"if",
"(",
"$",
"children",
")",
"{",
"$",
"element",
"[",
"$",
"key",
"]",
"[",
"'childs'",
"]",
"=",
"$",
"children",
";",
"}",
"}",
"else",
"{",
"$",
"return",
"=",
"''",
";",
"}",
"$",
"branch",
"[",
"$",
"key",
"]",
"=",
"$",
"element",
";",
"}",
"return",
"$",
"branch",
";",
"}"
] |
looking for matched item in nesty array configuration
@param array $elements
@param Strng $after
@param Fluent $item
@param array $buffer
@param array $return
@param String $current
@return array
|
[
"looking",
"for",
"matched",
"item",
"in",
"nesty",
"array",
"configuration"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Support/Nesty.php#L172-L197
|
228,245
|
antaresproject/core
|
src/components/support/src/Support/Nesty.php
|
Nesty.buffer
|
protected function buffer(&$buffer, $elements, $item, $after, $current)
{
foreach ($elements as $keyname => $element) {
$found = last(explode('.', $after));
if ($keyname == $found) {
$buffer[$current][$keyname] = $element;
$buffer[$current][$item->id] = $item;
} else {
$buffer[$current][$keyname] = $element;
}
}
return $buffer;
}
|
php
|
protected function buffer(&$buffer, $elements, $item, $after, $current)
{
foreach ($elements as $keyname => $element) {
$found = last(explode('.', $after));
if ($keyname == $found) {
$buffer[$current][$keyname] = $element;
$buffer[$current][$item->id] = $item;
} else {
$buffer[$current][$keyname] = $element;
}
}
return $buffer;
}
|
[
"protected",
"function",
"buffer",
"(",
"&",
"$",
"buffer",
",",
"$",
"elements",
",",
"$",
"item",
",",
"$",
"after",
",",
"$",
"current",
")",
"{",
"foreach",
"(",
"$",
"elements",
"as",
"$",
"keyname",
"=>",
"$",
"element",
")",
"{",
"$",
"found",
"=",
"last",
"(",
"explode",
"(",
"'.'",
",",
"$",
"after",
")",
")",
";",
"if",
"(",
"$",
"keyname",
"==",
"$",
"found",
")",
"{",
"$",
"buffer",
"[",
"$",
"current",
"]",
"[",
"$",
"keyname",
"]",
"=",
"$",
"element",
";",
"$",
"buffer",
"[",
"$",
"current",
"]",
"[",
"$",
"item",
"->",
"id",
"]",
"=",
"$",
"item",
";",
"}",
"else",
"{",
"$",
"buffer",
"[",
"$",
"current",
"]",
"[",
"$",
"keyname",
"]",
"=",
"$",
"element",
";",
"}",
"}",
"return",
"$",
"buffer",
";",
"}"
] |
buffer item into container
@param array $buffer
@param array $elements
@param Fluent $item
@param String $after
@param String $current
@return array
|
[
"buffer",
"item",
"into",
"container"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Support/Nesty.php#L209-L221
|
228,246
|
antaresproject/core
|
src/components/support/src/Support/Nesty.php
|
Nesty.add
|
public function add($id, $location = '#')
{
if ($location === '<' && count($keys = array_keys($this->items)) > 0) {
return $this->addBefore($id, $keys[0]);
} elseif (preg_match('/^(<|>|\^):(.+)$/', $location, $matches) && count($matches) >= 3) {
return $this->pickTraverseFromMatchedExpression($id, $matches[1], $matches[2]);
}
return $this->addParent($id);
}
|
php
|
public function add($id, $location = '#')
{
if ($location === '<' && count($keys = array_keys($this->items)) > 0) {
return $this->addBefore($id, $keys[0]);
} elseif (preg_match('/^(<|>|\^):(.+)$/', $location, $matches) && count($matches) >= 3) {
return $this->pickTraverseFromMatchedExpression($id, $matches[1], $matches[2]);
}
return $this->addParent($id);
}
|
[
"public",
"function",
"add",
"(",
"$",
"id",
",",
"$",
"location",
"=",
"'#'",
")",
"{",
"if",
"(",
"$",
"location",
"===",
"'<'",
"&&",
"count",
"(",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"items",
")",
")",
">",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"addBefore",
"(",
"$",
"id",
",",
"$",
"keys",
"[",
"0",
"]",
")",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/^(<|>|\\^):(.+)$/'",
",",
"$",
"location",
",",
"$",
"matches",
")",
"&&",
"count",
"(",
"$",
"matches",
")",
">=",
"3",
")",
"{",
"return",
"$",
"this",
"->",
"pickTraverseFromMatchedExpression",
"(",
"$",
"id",
",",
"$",
"matches",
"[",
"1",
"]",
",",
"$",
"matches",
"[",
"2",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"addParent",
"(",
"$",
"id",
")",
";",
"}"
] |
Add a new item, by prepend or append.
@param string $id
@param string $location
@return \Illuminate\Support\Fluent
|
[
"Add",
"a",
"new",
"item",
"by",
"prepend",
"or",
"append",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Support/Nesty.php#L267-L275
|
228,247
|
antaresproject/core
|
src/components/support/src/Support/Nesty.php
|
Nesty.has
|
public function has($key)
{
$key = implode('.childs.', explode('.', $key));
return !is_null(data_get($this->items, $key));
}
|
php
|
public function has($key)
{
$key = implode('.childs.', explode('.', $key));
return !is_null(data_get($this->items, $key));
}
|
[
"public",
"function",
"has",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"implode",
"(",
"'.childs.'",
",",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
")",
";",
"return",
"!",
"is_null",
"(",
"data_get",
"(",
"$",
"this",
"->",
"items",
",",
"$",
"key",
")",
")",
";",
"}"
] |
Check whether item by id exists.
@param string $key
@return bool
|
[
"Check",
"whether",
"item",
"by",
"id",
"exists",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Support/Nesty.php#L305-L311
|
228,248
|
genkgo/cache
|
src/Adapter/StashAdapter.php
|
StashAdapter.get
|
public function get($key)
{
$item = $this->pool->getItem($key);
if ($item->isMiss() === false) {
return $this->serializer->deserialize($item->get());
} else {
return null;
}
}
|
php
|
public function get($key)
{
$item = $this->pool->getItem($key);
if ($item->isMiss() === false) {
return $this->serializer->deserialize($item->get());
} else {
return null;
}
}
|
[
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"pool",
"->",
"getItem",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"item",
"->",
"isMiss",
"(",
")",
"===",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"serializer",
"->",
"deserialize",
"(",
"$",
"item",
"->",
"get",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] |
Gets a cache entry
returning null if not in cache
@param $key
@return null|mixed
|
[
"Gets",
"a",
"cache",
"entry",
"returning",
"null",
"if",
"not",
"in",
"cache"
] |
67408e8f1c555d3b098e639d772ac7d7d906118b
|
https://github.com/genkgo/cache/blob/67408e8f1c555d3b098e639d772ac7d7d906118b/src/Adapter/StashAdapter.php#L46-L54
|
228,249
|
antaresproject/core
|
src/components/memory/src/Handlers/Component.php
|
Component.save
|
protected function save($key, $value, $isNew = false, $brandId = false, $flag = null)
{
try {
DB::transaction(function () use ($key, $value, $isNew, $brandId, $flag) {
$name = str_replace('acl_antares/', '', $key);
if (str_contains($key, 'acl_antares')) {
$this->resolver()->updatePermissions($name, $value, $isNew, $brandId);
} elseif ($isNew) {
$name = isset($value['name']) ? $value['name'] : $name;
$model = $this->resolver()->component()->getModel()->newInstance();
$first = $model->query()->where('name', $name)->get()->first();
if (!is_null($first) and $first->exists) {
$model = $first;
}
$model->fill($value + ['status' => ($flag === 'active')]);
if (!$model->save()) {
throw new ComponentNotSavedException('Unable to save primary module configuration');
}
}
});
} catch (Exception $e) {
Log::emergency($e);
throw new ComponentNotSavedException($e);
}
}
|
php
|
protected function save($key, $value, $isNew = false, $brandId = false, $flag = null)
{
try {
DB::transaction(function () use ($key, $value, $isNew, $brandId, $flag) {
$name = str_replace('acl_antares/', '', $key);
if (str_contains($key, 'acl_antares')) {
$this->resolver()->updatePermissions($name, $value, $isNew, $brandId);
} elseif ($isNew) {
$name = isset($value['name']) ? $value['name'] : $name;
$model = $this->resolver()->component()->getModel()->newInstance();
$first = $model->query()->where('name', $name)->get()->first();
if (!is_null($first) and $first->exists) {
$model = $first;
}
$model->fill($value + ['status' => ($flag === 'active')]);
if (!$model->save()) {
throw new ComponentNotSavedException('Unable to save primary module configuration');
}
}
});
} catch (Exception $e) {
Log::emergency($e);
throw new ComponentNotSavedException($e);
}
}
|
[
"protected",
"function",
"save",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"isNew",
"=",
"false",
",",
"$",
"brandId",
"=",
"false",
",",
"$",
"flag",
"=",
"null",
")",
"{",
"try",
"{",
"DB",
"::",
"transaction",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"isNew",
",",
"$",
"brandId",
",",
"$",
"flag",
")",
"{",
"$",
"name",
"=",
"str_replace",
"(",
"'acl_antares/'",
",",
"''",
",",
"$",
"key",
")",
";",
"if",
"(",
"str_contains",
"(",
"$",
"key",
",",
"'acl_antares'",
")",
")",
"{",
"$",
"this",
"->",
"resolver",
"(",
")",
"->",
"updatePermissions",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"isNew",
",",
"$",
"brandId",
")",
";",
"}",
"elseif",
"(",
"$",
"isNew",
")",
"{",
"$",
"name",
"=",
"isset",
"(",
"$",
"value",
"[",
"'name'",
"]",
")",
"?",
"$",
"value",
"[",
"'name'",
"]",
":",
"$",
"name",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"resolver",
"(",
")",
"->",
"component",
"(",
")",
"->",
"getModel",
"(",
")",
"->",
"newInstance",
"(",
")",
";",
"$",
"first",
"=",
"$",
"model",
"->",
"query",
"(",
")",
"->",
"where",
"(",
"'name'",
",",
"$",
"name",
")",
"->",
"get",
"(",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"first",
")",
"and",
"$",
"first",
"->",
"exists",
")",
"{",
"$",
"model",
"=",
"$",
"first",
";",
"}",
"$",
"model",
"->",
"fill",
"(",
"$",
"value",
"+",
"[",
"'status'",
"=>",
"(",
"$",
"flag",
"===",
"'active'",
")",
"]",
")",
";",
"if",
"(",
"!",
"$",
"model",
"->",
"save",
"(",
")",
")",
"{",
"throw",
"new",
"ComponentNotSavedException",
"(",
"'Unable to save primary module configuration'",
")",
";",
"}",
"}",
"}",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Log",
"::",
"emergency",
"(",
"$",
"e",
")",
";",
"throw",
"new",
"ComponentNotSavedException",
"(",
"$",
"e",
")",
";",
"}",
"}"
] |
updates module permission
@param type $key
@param type $value
@param type $isNew
@return boolean
@throws \Exception
|
[
"updates",
"module",
"permission"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/src/Handlers/Component.php#L56-L84
|
228,250
|
antaresproject/core
|
src/components/extension/src/Processors/Acl.php
|
Acl.import
|
public function import(OperationHandlerContract $handler, ExtensionContract $extension, bool $reload = false)
{
$name = $extension->getPackage()->getName();
$filePath = $extension->getPath() . '/acl.php';
if (!File::exists($filePath)) {
$handler->operationInfo(new Operation('Skipping importing ACL settings for ' . $name . '.'));
return;
}
try {
$roleActionList = File::getRequire($filePath);
if ($roleActionList instanceof RoleActionList) {
if ($reload) {
$this->migration->down($name);
$handler->operationInfo(new Operation('ACL settings have been flushed for ' . $name . '.'));
}
$handler->operationInfo(new Operation('Importing ACL settings for ' . $name . '.'));
$this->migration->up($name, $roleActionList);
$handler->operationSuccess(new Operation('The ACL settings have been successfully imported.'));
} else {
$handler->operationFailed(new Operation('Skipping importing ACL settings for ' . $name . ' due to invalid returned object from the file.'));
}
} catch (\Exception $e) {
Log::error($e);
$handler->operationFailed(new Operation($e->getMessage()));
}
}
|
php
|
public function import(OperationHandlerContract $handler, ExtensionContract $extension, bool $reload = false)
{
$name = $extension->getPackage()->getName();
$filePath = $extension->getPath() . '/acl.php';
if (!File::exists($filePath)) {
$handler->operationInfo(new Operation('Skipping importing ACL settings for ' . $name . '.'));
return;
}
try {
$roleActionList = File::getRequire($filePath);
if ($roleActionList instanceof RoleActionList) {
if ($reload) {
$this->migration->down($name);
$handler->operationInfo(new Operation('ACL settings have been flushed for ' . $name . '.'));
}
$handler->operationInfo(new Operation('Importing ACL settings for ' . $name . '.'));
$this->migration->up($name, $roleActionList);
$handler->operationSuccess(new Operation('The ACL settings have been successfully imported.'));
} else {
$handler->operationFailed(new Operation('Skipping importing ACL settings for ' . $name . ' due to invalid returned object from the file.'));
}
} catch (\Exception $e) {
Log::error($e);
$handler->operationFailed(new Operation($e->getMessage()));
}
}
|
[
"public",
"function",
"import",
"(",
"OperationHandlerContract",
"$",
"handler",
",",
"ExtensionContract",
"$",
"extension",
",",
"bool",
"$",
"reload",
"=",
"false",
")",
"{",
"$",
"name",
"=",
"$",
"extension",
"->",
"getPackage",
"(",
")",
"->",
"getName",
"(",
")",
";",
"$",
"filePath",
"=",
"$",
"extension",
"->",
"getPath",
"(",
")",
".",
"'/acl.php'",
";",
"if",
"(",
"!",
"File",
"::",
"exists",
"(",
"$",
"filePath",
")",
")",
"{",
"$",
"handler",
"->",
"operationInfo",
"(",
"new",
"Operation",
"(",
"'Skipping importing ACL settings for '",
".",
"$",
"name",
".",
"'.'",
")",
")",
";",
"return",
";",
"}",
"try",
"{",
"$",
"roleActionList",
"=",
"File",
"::",
"getRequire",
"(",
"$",
"filePath",
")",
";",
"if",
"(",
"$",
"roleActionList",
"instanceof",
"RoleActionList",
")",
"{",
"if",
"(",
"$",
"reload",
")",
"{",
"$",
"this",
"->",
"migration",
"->",
"down",
"(",
"$",
"name",
")",
";",
"$",
"handler",
"->",
"operationInfo",
"(",
"new",
"Operation",
"(",
"'ACL settings have been flushed for '",
".",
"$",
"name",
".",
"'.'",
")",
")",
";",
"}",
"$",
"handler",
"->",
"operationInfo",
"(",
"new",
"Operation",
"(",
"'Importing ACL settings for '",
".",
"$",
"name",
".",
"'.'",
")",
")",
";",
"$",
"this",
"->",
"migration",
"->",
"up",
"(",
"$",
"name",
",",
"$",
"roleActionList",
")",
";",
"$",
"handler",
"->",
"operationSuccess",
"(",
"new",
"Operation",
"(",
"'The ACL settings have been successfully imported.'",
")",
")",
";",
"}",
"else",
"{",
"$",
"handler",
"->",
"operationFailed",
"(",
"new",
"Operation",
"(",
"'Skipping importing ACL settings for '",
".",
"$",
"name",
".",
"' due to invalid returned object from the file.'",
")",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"Log",
"::",
"error",
"(",
"$",
"e",
")",
";",
"$",
"handler",
"->",
"operationFailed",
"(",
"new",
"Operation",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"}"
] |
Import ACL of the given extension.
@param OperationHandlerContract $handler
@param ExtensionContract $extension
@param bool $reload
|
[
"Import",
"ACL",
"of",
"the",
"given",
"extension",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Processors/Acl.php#L41-L70
|
228,251
|
antaresproject/core
|
src/foundation/src/Processor/Security.php
|
Security.form
|
protected function form()
{
return app('antares.form')->of('security', function (FormGrid $form) {
$form->name('Security Form');
$form->fieldset(function (Fieldset $fieldset) {
$fieldset->control('button', 'button')
->attributes(['type' => 'submit', 'class' => 'btn btn-primary',])
->value(trans('antares/foundation::label.save_changes'));
});
});
}
|
php
|
protected function form()
{
return app('antares.form')->of('security', function (FormGrid $form) {
$form->name('Security Form');
$form->fieldset(function (Fieldset $fieldset) {
$fieldset->control('button', 'button')
->attributes(['type' => 'submit', 'class' => 'btn btn-primary',])
->value(trans('antares/foundation::label.save_changes'));
});
});
}
|
[
"protected",
"function",
"form",
"(",
")",
"{",
"return",
"app",
"(",
"'antares.form'",
")",
"->",
"of",
"(",
"'security'",
",",
"function",
"(",
"FormGrid",
"$",
"form",
")",
"{",
"$",
"form",
"->",
"name",
"(",
"'Security Form'",
")",
";",
"$",
"form",
"->",
"fieldset",
"(",
"function",
"(",
"Fieldset",
"$",
"fieldset",
")",
"{",
"$",
"fieldset",
"->",
"control",
"(",
"'button'",
",",
"'button'",
")",
"->",
"attributes",
"(",
"[",
"'type'",
"=>",
"'submit'",
",",
"'class'",
"=>",
"'btn btn-primary'",
",",
"]",
")",
"->",
"value",
"(",
"trans",
"(",
"'antares/foundation::label.save_changes'",
")",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] |
Creates form instance
@return \Antares\Html\Form\FormBuilder
|
[
"Creates",
"form",
"instance"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Processor/Security.php#L66-L79
|
228,252
|
antaresproject/core
|
src/foundation/src/Processor/Security.php
|
Security.submit
|
public function submit(FormResponseContract $listener, Request $request)
{
$response = (array) $this->dispatcher->fire(new SecurityFormSubmitted($listener, $request));
if (count($response)) {
return $response[0];
}
return null;
}
|
php
|
public function submit(FormResponseContract $listener, Request $request)
{
$response = (array) $this->dispatcher->fire(new SecurityFormSubmitted($listener, $request));
if (count($response)) {
return $response[0];
}
return null;
}
|
[
"public",
"function",
"submit",
"(",
"FormResponseContract",
"$",
"listener",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"response",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"dispatcher",
"->",
"fire",
"(",
"new",
"SecurityFormSubmitted",
"(",
"$",
"listener",
",",
"$",
"request",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"response",
")",
")",
"{",
"return",
"$",
"response",
"[",
"0",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Fires an event of the security form with the given request instance.
@param FormResponseContract $listener
@param Request $request
@return mixed
|
[
"Fires",
"an",
"event",
"of",
"the",
"security",
"form",
"with",
"the",
"given",
"request",
"instance",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Processor/Security.php#L88-L96
|
228,253
|
antaresproject/core
|
src/ui/components/datatables/src/Adapter/ColumnFilterAdapter.php
|
ColumnFilterAdapter.save
|
public function save(array $params = [])
{
$index = array_get($params, 'index');
$visibility = array_get($params, 'visible');
$key = array_get($params, 'key');
if (is_null($index) or is_null($visibility) or is_null($key)) {
return false;
}
$request = request();
$session = $request->session();
if ($session->has($key)) {
$data = $session->get($key);
$data[$index] = $visibility === "true";
$session->remove($key);
} else {
$data = [$index => $visibility === "true"];
}
$session->put($key, $data);
$session->save();
return $data;
}
|
php
|
public function save(array $params = [])
{
$index = array_get($params, 'index');
$visibility = array_get($params, 'visible');
$key = array_get($params, 'key');
if (is_null($index) or is_null($visibility) or is_null($key)) {
return false;
}
$request = request();
$session = $request->session();
if ($session->has($key)) {
$data = $session->get($key);
$data[$index] = $visibility === "true";
$session->remove($key);
} else {
$data = [$index => $visibility === "true"];
}
$session->put($key, $data);
$session->save();
return $data;
}
|
[
"public",
"function",
"save",
"(",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"index",
"=",
"array_get",
"(",
"$",
"params",
",",
"'index'",
")",
";",
"$",
"visibility",
"=",
"array_get",
"(",
"$",
"params",
",",
"'visible'",
")",
";",
"$",
"key",
"=",
"array_get",
"(",
"$",
"params",
",",
"'key'",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"index",
")",
"or",
"is_null",
"(",
"$",
"visibility",
")",
"or",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"request",
"=",
"request",
"(",
")",
";",
"$",
"session",
"=",
"$",
"request",
"->",
"session",
"(",
")",
";",
"if",
"(",
"$",
"session",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"$",
"data",
"=",
"$",
"session",
"->",
"get",
"(",
"$",
"key",
")",
";",
"$",
"data",
"[",
"$",
"index",
"]",
"=",
"$",
"visibility",
"===",
"\"true\"",
";",
"$",
"session",
"->",
"remove",
"(",
"$",
"key",
")",
";",
"}",
"else",
"{",
"$",
"data",
"=",
"[",
"$",
"index",
"=>",
"$",
"visibility",
"===",
"\"true\"",
"]",
";",
"}",
"$",
"session",
"->",
"put",
"(",
"$",
"key",
",",
"$",
"data",
")",
";",
"$",
"session",
"->",
"save",
"(",
")",
";",
"return",
"$",
"data",
";",
"}"
] |
Saves visibility columns definition
@param array $params
@return boolean
|
[
"Saves",
"visibility",
"columns",
"definition"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Adapter/ColumnFilterAdapter.php#L83-L106
|
228,254
|
antaresproject/core
|
src/ui/components/datatables/src/Adapter/ColumnFilterAdapter.php
|
ColumnFilterAdapter.getColumns
|
public function getColumns()
{
$session = request()->session();
$key = $this->key();
if (!$session->has($key)) {
return $this->columns;
}
$config = $session->get($key);
foreach ($this->columns as $index => $column) {
if (!isset($config[$index])) {
continue;
}
$column->visible = $config[$index];
}
return $this->columns;
}
|
php
|
public function getColumns()
{
$session = request()->session();
$key = $this->key();
if (!$session->has($key)) {
return $this->columns;
}
$config = $session->get($key);
foreach ($this->columns as $index => $column) {
if (!isset($config[$index])) {
continue;
}
$column->visible = $config[$index];
}
return $this->columns;
}
|
[
"public",
"function",
"getColumns",
"(",
")",
"{",
"$",
"session",
"=",
"request",
"(",
")",
"->",
"session",
"(",
")",
";",
"$",
"key",
"=",
"$",
"this",
"->",
"key",
"(",
")",
";",
"if",
"(",
"!",
"$",
"session",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"columns",
";",
"}",
"$",
"config",
"=",
"$",
"session",
"->",
"get",
"(",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"index",
"=>",
"$",
"column",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"$",
"index",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"column",
"->",
"visible",
"=",
"$",
"config",
"[",
"$",
"index",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"columns",
";",
"}"
] |
Gets column visibility definition
@return array
|
[
"Gets",
"column",
"visibility",
"definition"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Adapter/ColumnFilterAdapter.php#L113-L129
|
228,255
|
antaresproject/core
|
src/components/view/src/Helper/FilterDropdown.php
|
FilterDropdown.prepareData
|
protected function prepareData()
{
$dataProvider = $this->attributes['dataProvider'];
$urlPattern = $this->attributes['urlPattern'];
$return = new Collection();
foreach ($dataProvider as $item) {
$name = isset($item->title) ? $item->title : $item->name;
$url = str_replace('{id}', $item->id, $urlPattern);
$return->push(['url' => handles($url), 'name' => ucfirst($name), 'id' => $item->id]);
}
return $return->sortBy('name');
}
|
php
|
protected function prepareData()
{
$dataProvider = $this->attributes['dataProvider'];
$urlPattern = $this->attributes['urlPattern'];
$return = new Collection();
foreach ($dataProvider as $item) {
$name = isset($item->title) ? $item->title : $item->name;
$url = str_replace('{id}', $item->id, $urlPattern);
$return->push(['url' => handles($url), 'name' => ucfirst($name), 'id' => $item->id]);
}
return $return->sortBy('name');
}
|
[
"protected",
"function",
"prepareData",
"(",
")",
"{",
"$",
"dataProvider",
"=",
"$",
"this",
"->",
"attributes",
"[",
"'dataProvider'",
"]",
";",
"$",
"urlPattern",
"=",
"$",
"this",
"->",
"attributes",
"[",
"'urlPattern'",
"]",
";",
"$",
"return",
"=",
"new",
"Collection",
"(",
")",
";",
"foreach",
"(",
"$",
"dataProvider",
"as",
"$",
"item",
")",
"{",
"$",
"name",
"=",
"isset",
"(",
"$",
"item",
"->",
"title",
")",
"?",
"$",
"item",
"->",
"title",
":",
"$",
"item",
"->",
"name",
";",
"$",
"url",
"=",
"str_replace",
"(",
"'{id}'",
",",
"$",
"item",
"->",
"id",
",",
"$",
"urlPattern",
")",
";",
"$",
"return",
"->",
"push",
"(",
"[",
"'url'",
"=>",
"handles",
"(",
"$",
"url",
")",
",",
"'name'",
"=>",
"ucfirst",
"(",
"$",
"name",
")",
",",
"'id'",
"=>",
"$",
"item",
"->",
"id",
"]",
")",
";",
"}",
"return",
"$",
"return",
"->",
"sortBy",
"(",
"'name'",
")",
";",
"}"
] |
prepares data provider items
@return array
|
[
"prepares",
"data",
"provider",
"items"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Helper/FilterDropdown.php#L76-L87
|
228,256
|
antaresproject/core
|
src/components/view/src/Helper/FilterDropdown.php
|
FilterDropdown.scripts
|
protected function scripts()
{
$container = $this->app->make('antares.asset')->container('antares/foundation::scripts');
$container->inlineScript('version-box', $this->inline());
}
|
php
|
protected function scripts()
{
$container = $this->app->make('antares.asset')->container('antares/foundation::scripts');
$container->inlineScript('version-box', $this->inline());
}
|
[
"protected",
"function",
"scripts",
"(",
")",
"{",
"$",
"container",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'antares.asset'",
")",
"->",
"container",
"(",
"'antares/foundation::scripts'",
")",
";",
"$",
"container",
"->",
"inlineScript",
"(",
"'version-box'",
",",
"$",
"this",
"->",
"inline",
"(",
")",
")",
";",
"}"
] |
inline scripts used by helper
|
[
"inline",
"scripts",
"used",
"by",
"helper"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Helper/FilterDropdown.php#L104-L108
|
228,257
|
brick/http
|
src/Response.php
|
Response.parse
|
public static function parse(string $response) : Response
{
$responseObject = new Response();
if (preg_match('/^HTTP\/([0-9]\.[0-9]) ([0-9]{3}) .*\r\n/', $response, $matches) !== 1) {
throw new \RuntimeException('Could not parse response (error 1).');
}
[$line, $protocolVersion, $statusCode] = $matches;
$responseObject->setProtocolVersion($protocolVersion);
$responseObject->setStatusCode((int) $statusCode);
$response = substr($response, strlen($line));
for (;;) {
$pos = strpos($response, Message::CRLF);
if ($pos === false) {
throw new \RuntimeException('Could not parse response (error 2).');
}
if ($pos === 0) {
break;
}
$header = substr($response, 0, $pos);
if (preg_match('/^(\S+):\s*(.*)$/', $header, $matches) !== 1) {
throw new \RuntimeException('Could not parse response (error 3).');
}
[$line, $name, $value] = $matches;
if (strtolower($name) === 'set-cookie') {
$responseObject->setCookie(Cookie::parse($value));
} else {
$responseObject->addHeader($name, $value);
}
$response = substr($response, strlen($line) + 2);
}
$body = substr($response, 2);
$responseObject->setContent($body);
return $responseObject;
}
|
php
|
public static function parse(string $response) : Response
{
$responseObject = new Response();
if (preg_match('/^HTTP\/([0-9]\.[0-9]) ([0-9]{3}) .*\r\n/', $response, $matches) !== 1) {
throw new \RuntimeException('Could not parse response (error 1).');
}
[$line, $protocolVersion, $statusCode] = $matches;
$responseObject->setProtocolVersion($protocolVersion);
$responseObject->setStatusCode((int) $statusCode);
$response = substr($response, strlen($line));
for (;;) {
$pos = strpos($response, Message::CRLF);
if ($pos === false) {
throw new \RuntimeException('Could not parse response (error 2).');
}
if ($pos === 0) {
break;
}
$header = substr($response, 0, $pos);
if (preg_match('/^(\S+):\s*(.*)$/', $header, $matches) !== 1) {
throw new \RuntimeException('Could not parse response (error 3).');
}
[$line, $name, $value] = $matches;
if (strtolower($name) === 'set-cookie') {
$responseObject->setCookie(Cookie::parse($value));
} else {
$responseObject->addHeader($name, $value);
}
$response = substr($response, strlen($line) + 2);
}
$body = substr($response, 2);
$responseObject->setContent($body);
return $responseObject;
}
|
[
"public",
"static",
"function",
"parse",
"(",
"string",
"$",
"response",
")",
":",
"Response",
"{",
"$",
"responseObject",
"=",
"new",
"Response",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/^HTTP\\/([0-9]\\.[0-9]) ([0-9]{3}) .*\\r\\n/'",
",",
"$",
"response",
",",
"$",
"matches",
")",
"!==",
"1",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Could not parse response (error 1).'",
")",
";",
"}",
"[",
"$",
"line",
",",
"$",
"protocolVersion",
",",
"$",
"statusCode",
"]",
"=",
"$",
"matches",
";",
"$",
"responseObject",
"->",
"setProtocolVersion",
"(",
"$",
"protocolVersion",
")",
";",
"$",
"responseObject",
"->",
"setStatusCode",
"(",
"(",
"int",
")",
"$",
"statusCode",
")",
";",
"$",
"response",
"=",
"substr",
"(",
"$",
"response",
",",
"strlen",
"(",
"$",
"line",
")",
")",
";",
"for",
"(",
";",
";",
")",
"{",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"response",
",",
"Message",
"::",
"CRLF",
")",
";",
"if",
"(",
"$",
"pos",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Could not parse response (error 2).'",
")",
";",
"}",
"if",
"(",
"$",
"pos",
"===",
"0",
")",
"{",
"break",
";",
"}",
"$",
"header",
"=",
"substr",
"(",
"$",
"response",
",",
"0",
",",
"$",
"pos",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/^(\\S+):\\s*(.*)$/'",
",",
"$",
"header",
",",
"$",
"matches",
")",
"!==",
"1",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Could not parse response (error 3).'",
")",
";",
"}",
"[",
"$",
"line",
",",
"$",
"name",
",",
"$",
"value",
"]",
"=",
"$",
"matches",
";",
"if",
"(",
"strtolower",
"(",
"$",
"name",
")",
"===",
"'set-cookie'",
")",
"{",
"$",
"responseObject",
"->",
"setCookie",
"(",
"Cookie",
"::",
"parse",
"(",
"$",
"value",
")",
")",
";",
"}",
"else",
"{",
"$",
"responseObject",
"->",
"addHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"$",
"response",
"=",
"substr",
"(",
"$",
"response",
",",
"strlen",
"(",
"$",
"line",
")",
"+",
"2",
")",
";",
"}",
"$",
"body",
"=",
"substr",
"(",
"$",
"response",
",",
"2",
")",
";",
"$",
"responseObject",
"->",
"setContent",
"(",
"$",
"body",
")",
";",
"return",
"$",
"responseObject",
";",
"}"
] |
Parses a raw response string, including headers and body, and returns a Response object.
@param string $response
@return \Brick\Http\Response
@throws \RuntimeException
|
[
"Parses",
"a",
"raw",
"response",
"string",
"including",
"headers",
"and",
"body",
"and",
"returns",
"a",
"Response",
"object",
"."
] |
1b185b0563d10f9f4293c254aa411545da00b597
|
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Response.php#L84-L131
|
228,258
|
brick/http
|
src/Response.php
|
Response.setStatusCode
|
public function setStatusCode(int $statusCode, string $reasonPhrase = null) : Response
{
if ($statusCode < 100 || $statusCode > 999) {
throw new \InvalidArgumentException('Invalid status code: ' . $statusCode);
}
if ($reasonPhrase === null) {
$reasonPhrase = isset(self::$statusCodes[$statusCode])
? self::$statusCodes[$statusCode]
: 'Unknown';
} else {
$reasonPhrase = (string) $reasonPhrase;
}
$this->statusCode = $statusCode;
$this->reasonPhrase = $reasonPhrase;
return $this;
}
|
php
|
public function setStatusCode(int $statusCode, string $reasonPhrase = null) : Response
{
if ($statusCode < 100 || $statusCode > 999) {
throw new \InvalidArgumentException('Invalid status code: ' . $statusCode);
}
if ($reasonPhrase === null) {
$reasonPhrase = isset(self::$statusCodes[$statusCode])
? self::$statusCodes[$statusCode]
: 'Unknown';
} else {
$reasonPhrase = (string) $reasonPhrase;
}
$this->statusCode = $statusCode;
$this->reasonPhrase = $reasonPhrase;
return $this;
}
|
[
"public",
"function",
"setStatusCode",
"(",
"int",
"$",
"statusCode",
",",
"string",
"$",
"reasonPhrase",
"=",
"null",
")",
":",
"Response",
"{",
"if",
"(",
"$",
"statusCode",
"<",
"100",
"||",
"$",
"statusCode",
">",
"999",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid status code: '",
".",
"$",
"statusCode",
")",
";",
"}",
"if",
"(",
"$",
"reasonPhrase",
"===",
"null",
")",
"{",
"$",
"reasonPhrase",
"=",
"isset",
"(",
"self",
"::",
"$",
"statusCodes",
"[",
"$",
"statusCode",
"]",
")",
"?",
"self",
"::",
"$",
"statusCodes",
"[",
"$",
"statusCode",
"]",
":",
"'Unknown'",
";",
"}",
"else",
"{",
"$",
"reasonPhrase",
"=",
"(",
"string",
")",
"$",
"reasonPhrase",
";",
"}",
"$",
"this",
"->",
"statusCode",
"=",
"$",
"statusCode",
";",
"$",
"this",
"->",
"reasonPhrase",
"=",
"$",
"reasonPhrase",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the status code of this response.
@param int $statusCode The status code.
@param string|null $reasonPhrase An optional reason phrase, or null to use the default.
@return static
@throws \InvalidArgumentException If the status code is not valid.
|
[
"Sets",
"the",
"status",
"code",
"of",
"this",
"response",
"."
] |
1b185b0563d10f9f4293c254aa411545da00b597
|
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Response.php#L163-L181
|
228,259
|
brick/http
|
src/Response.php
|
Response.setCookie
|
public function setCookie(Cookie $cookie) : Response
{
$this->cookies[] = $cookie;
$this->addHeader('Set-Cookie', (string) $cookie);
return $this;
}
|
php
|
public function setCookie(Cookie $cookie) : Response
{
$this->cookies[] = $cookie;
$this->addHeader('Set-Cookie', (string) $cookie);
return $this;
}
|
[
"public",
"function",
"setCookie",
"(",
"Cookie",
"$",
"cookie",
")",
":",
"Response",
"{",
"$",
"this",
"->",
"cookies",
"[",
"]",
"=",
"$",
"cookie",
";",
"$",
"this",
"->",
"addHeader",
"(",
"'Set-Cookie'",
",",
"(",
"string",
")",
"$",
"cookie",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets a cookie on this response.
@param \Brick\Http\Cookie $cookie The cookie to set.
@return static This response.
|
[
"Sets",
"a",
"cookie",
"on",
"this",
"response",
"."
] |
1b185b0563d10f9f4293c254aa411545da00b597
|
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Response.php#L200-L206
|
228,260
|
brick/http
|
src/Response.php
|
Response.send
|
public function send() : bool
{
if (headers_sent()) {
return false;
}
header($this->getStartLine());
foreach ($this->getHeaders() as $name => $values) {
foreach ($values as $value) {
header($name . ': ' . $value, false);
}
}
echo (string) $this->body;
flush();
return true;
}
|
php
|
public function send() : bool
{
if (headers_sent()) {
return false;
}
header($this->getStartLine());
foreach ($this->getHeaders() as $name => $values) {
foreach ($values as $value) {
header($name . ': ' . $value, false);
}
}
echo (string) $this->body;
flush();
return true;
}
|
[
"public",
"function",
"send",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"headers_sent",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"header",
"(",
"$",
"this",
"->",
"getStartLine",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getHeaders",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"header",
"(",
"$",
"name",
".",
"': '",
".",
"$",
"value",
",",
"false",
")",
";",
"}",
"}",
"echo",
"(",
"string",
")",
"$",
"this",
"->",
"body",
";",
"flush",
"(",
")",
";",
"return",
"true",
";",
"}"
] |
Sends the response.
This method will fail (return `false`) if the headers have been already sent.
@return bool Whether the response has been successfully sent.
|
[
"Sends",
"the",
"response",
"."
] |
1b185b0563d10f9f4293c254aa411545da00b597
|
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Response.php#L305-L324
|
228,261
|
tomwalder/php-appengine-search
|
src/Search/Gateway.php
|
Gateway.prepareRequestParams
|
private function prepareRequestParams($obj_request)
{
$obj_params = $obj_request->mutableParams();
$obj_spec = $obj_params->mutableIndexSpec()->setName($this->str_index_name);
if(null !== $this->str_namespace) {
$obj_spec->setNamespace($this->str_namespace);
}
return $obj_params;
}
|
php
|
private function prepareRequestParams($obj_request)
{
$obj_params = $obj_request->mutableParams();
$obj_spec = $obj_params->mutableIndexSpec()->setName($this->str_index_name);
if(null !== $this->str_namespace) {
$obj_spec->setNamespace($this->str_namespace);
}
return $obj_params;
}
|
[
"private",
"function",
"prepareRequestParams",
"(",
"$",
"obj_request",
")",
"{",
"$",
"obj_params",
"=",
"$",
"obj_request",
"->",
"mutableParams",
"(",
")",
";",
"$",
"obj_spec",
"=",
"$",
"obj_params",
"->",
"mutableIndexSpec",
"(",
")",
"->",
"setName",
"(",
"$",
"this",
"->",
"str_index_name",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"str_namespace",
")",
"{",
"$",
"obj_spec",
"->",
"setNamespace",
"(",
"$",
"this",
"->",
"str_namespace",
")",
";",
"}",
"return",
"$",
"obj_params",
";",
"}"
] |
Prepare the request parameters
Index specs: consistency, mode, name, namespace, source, version
@param $obj_request
@return object
|
[
"Prepare",
"the",
"request",
"parameters"
] |
e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba
|
https://github.com/tomwalder/php-appengine-search/blob/e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba/src/Search/Gateway.php#L90-L98
|
228,262
|
tomwalder/php-appengine-search
|
src/Search/Gateway.php
|
Gateway.put
|
public function put(array $arr_docs)
{
$obj_request = new IndexDocumentRequest();
$obj_params = $this->prepareRequestParams($obj_request);
// Other index specs: consistency, mode, name, namespace, source, version
$obj_mapper = new Mapper();
foreach($arr_docs as $obj_doc) {
$obj_mapper->toGoogle($obj_doc, $obj_params->addDocument());
}
$this->execute('IndexDocument', $obj_request, new IndexDocumentResponse());
}
|
php
|
public function put(array $arr_docs)
{
$obj_request = new IndexDocumentRequest();
$obj_params = $this->prepareRequestParams($obj_request);
// Other index specs: consistency, mode, name, namespace, source, version
$obj_mapper = new Mapper();
foreach($arr_docs as $obj_doc) {
$obj_mapper->toGoogle($obj_doc, $obj_params->addDocument());
}
$this->execute('IndexDocument', $obj_request, new IndexDocumentResponse());
}
|
[
"public",
"function",
"put",
"(",
"array",
"$",
"arr_docs",
")",
"{",
"$",
"obj_request",
"=",
"new",
"IndexDocumentRequest",
"(",
")",
";",
"$",
"obj_params",
"=",
"$",
"this",
"->",
"prepareRequestParams",
"(",
"$",
"obj_request",
")",
";",
"// Other index specs: consistency, mode, name, namespace, source, version",
"$",
"obj_mapper",
"=",
"new",
"Mapper",
"(",
")",
";",
"foreach",
"(",
"$",
"arr_docs",
"as",
"$",
"obj_doc",
")",
"{",
"$",
"obj_mapper",
"->",
"toGoogle",
"(",
"$",
"obj_doc",
",",
"$",
"obj_params",
"->",
"addDocument",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"execute",
"(",
"'IndexDocument'",
",",
"$",
"obj_request",
",",
"new",
"IndexDocumentResponse",
"(",
")",
")",
";",
"}"
] |
Put one or more documents into the index
@param Document[] $arr_docs
@throws ApplicationError
@throws \Exception
|
[
"Put",
"one",
"or",
"more",
"documents",
"into",
"the",
"index"
] |
e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba
|
https://github.com/tomwalder/php-appengine-search/blob/e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba/src/Search/Gateway.php#L107-L118
|
228,263
|
tomwalder/php-appengine-search
|
src/Search/Gateway.php
|
Gateway.search
|
public function search(Query $obj_query)
{
$obj_request = new SearchRequest();
$obj_params = $this->prepareRequestParams($obj_request);
// Basics
$obj_params
->setQuery($obj_query->getQuery())
->setLimit($obj_query->getLimit())
->setOffset($obj_query->getOffset())
;
// Sorting
$arr_sorts = $obj_query->getSorts();
if(null !== $arr_sorts && count($arr_sorts) > 0) {
foreach ($arr_sorts as $arr_sort) {
$obj_sort = $obj_params->addSortSpec();
$obj_sort->setSortExpression($arr_sort[0]);
$obj_sort->setSortDescending(Query::DESC === $arr_sort[1]);
}
}
// Match Scoring
if(Query::SCORE_REGULAR === $obj_query->getScorer()) {
$obj_params->mutableScorerSpec()->setScorer(Scorer::MATCH_SCORER)->setLimit($obj_query->getLimit());
} elseif (Query::SCORE_RESCORING === $obj_query->getScorer()) {
$obj_params->mutableScorerSpec()->setScorer(Scorer::RESCORING_MATCH_SCORER)->setLimit($obj_query->getLimit());
}
// Return Fields
$arr_return_fields = $obj_query->getReturnFields();
if(null !== $arr_return_fields && count($arr_return_fields) > 0) {
$obj_fields = $obj_params->mutableFieldSpec();
foreach ($arr_return_fields as $str_field) {
$obj_fields->addName($str_field);
}
}
// Return Expressions
$arr_return_exps = $obj_query->getReturnExpressions();
if(null !== $arr_return_exps && count($arr_return_exps) > 0) {
$obj_fields = $obj_params->mutableFieldSpec();
foreach ($arr_return_exps as $arr_exp) {
$obj_fields->addExpression()->setName($arr_exp[0])->setExpression($arr_exp[1]);
}
}
// Facets
$arr_facets = $obj_query->getFacets();
if(null !== $arr_facets) {
if(count($arr_facets) > 0) {
// We want a specific set of facets in the response
foreach($arr_facets as $str_facet) {
$obj_params->addIncludeFacet()->setName($str_facet);
}
} else {
// We want all facets back...
$obj_params->setAutoDiscoverFacetCount(100);
}
}
$this->execute('Search', $obj_request, new SearchResponse());
return $this->processSearchResponse();
}
|
php
|
public function search(Query $obj_query)
{
$obj_request = new SearchRequest();
$obj_params = $this->prepareRequestParams($obj_request);
// Basics
$obj_params
->setQuery($obj_query->getQuery())
->setLimit($obj_query->getLimit())
->setOffset($obj_query->getOffset())
;
// Sorting
$arr_sorts = $obj_query->getSorts();
if(null !== $arr_sorts && count($arr_sorts) > 0) {
foreach ($arr_sorts as $arr_sort) {
$obj_sort = $obj_params->addSortSpec();
$obj_sort->setSortExpression($arr_sort[0]);
$obj_sort->setSortDescending(Query::DESC === $arr_sort[1]);
}
}
// Match Scoring
if(Query::SCORE_REGULAR === $obj_query->getScorer()) {
$obj_params->mutableScorerSpec()->setScorer(Scorer::MATCH_SCORER)->setLimit($obj_query->getLimit());
} elseif (Query::SCORE_RESCORING === $obj_query->getScorer()) {
$obj_params->mutableScorerSpec()->setScorer(Scorer::RESCORING_MATCH_SCORER)->setLimit($obj_query->getLimit());
}
// Return Fields
$arr_return_fields = $obj_query->getReturnFields();
if(null !== $arr_return_fields && count($arr_return_fields) > 0) {
$obj_fields = $obj_params->mutableFieldSpec();
foreach ($arr_return_fields as $str_field) {
$obj_fields->addName($str_field);
}
}
// Return Expressions
$arr_return_exps = $obj_query->getReturnExpressions();
if(null !== $arr_return_exps && count($arr_return_exps) > 0) {
$obj_fields = $obj_params->mutableFieldSpec();
foreach ($arr_return_exps as $arr_exp) {
$obj_fields->addExpression()->setName($arr_exp[0])->setExpression($arr_exp[1]);
}
}
// Facets
$arr_facets = $obj_query->getFacets();
if(null !== $arr_facets) {
if(count($arr_facets) > 0) {
// We want a specific set of facets in the response
foreach($arr_facets as $str_facet) {
$obj_params->addIncludeFacet()->setName($str_facet);
}
} else {
// We want all facets back...
$obj_params->setAutoDiscoverFacetCount(100);
}
}
$this->execute('Search', $obj_request, new SearchResponse());
return $this->processSearchResponse();
}
|
[
"public",
"function",
"search",
"(",
"Query",
"$",
"obj_query",
")",
"{",
"$",
"obj_request",
"=",
"new",
"SearchRequest",
"(",
")",
";",
"$",
"obj_params",
"=",
"$",
"this",
"->",
"prepareRequestParams",
"(",
"$",
"obj_request",
")",
";",
"// Basics",
"$",
"obj_params",
"->",
"setQuery",
"(",
"$",
"obj_query",
"->",
"getQuery",
"(",
")",
")",
"->",
"setLimit",
"(",
"$",
"obj_query",
"->",
"getLimit",
"(",
")",
")",
"->",
"setOffset",
"(",
"$",
"obj_query",
"->",
"getOffset",
"(",
")",
")",
";",
"// Sorting",
"$",
"arr_sorts",
"=",
"$",
"obj_query",
"->",
"getSorts",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"arr_sorts",
"&&",
"count",
"(",
"$",
"arr_sorts",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"arr_sorts",
"as",
"$",
"arr_sort",
")",
"{",
"$",
"obj_sort",
"=",
"$",
"obj_params",
"->",
"addSortSpec",
"(",
")",
";",
"$",
"obj_sort",
"->",
"setSortExpression",
"(",
"$",
"arr_sort",
"[",
"0",
"]",
")",
";",
"$",
"obj_sort",
"->",
"setSortDescending",
"(",
"Query",
"::",
"DESC",
"===",
"$",
"arr_sort",
"[",
"1",
"]",
")",
";",
"}",
"}",
"// Match Scoring",
"if",
"(",
"Query",
"::",
"SCORE_REGULAR",
"===",
"$",
"obj_query",
"->",
"getScorer",
"(",
")",
")",
"{",
"$",
"obj_params",
"->",
"mutableScorerSpec",
"(",
")",
"->",
"setScorer",
"(",
"Scorer",
"::",
"MATCH_SCORER",
")",
"->",
"setLimit",
"(",
"$",
"obj_query",
"->",
"getLimit",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"Query",
"::",
"SCORE_RESCORING",
"===",
"$",
"obj_query",
"->",
"getScorer",
"(",
")",
")",
"{",
"$",
"obj_params",
"->",
"mutableScorerSpec",
"(",
")",
"->",
"setScorer",
"(",
"Scorer",
"::",
"RESCORING_MATCH_SCORER",
")",
"->",
"setLimit",
"(",
"$",
"obj_query",
"->",
"getLimit",
"(",
")",
")",
";",
"}",
"// Return Fields",
"$",
"arr_return_fields",
"=",
"$",
"obj_query",
"->",
"getReturnFields",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"arr_return_fields",
"&&",
"count",
"(",
"$",
"arr_return_fields",
")",
">",
"0",
")",
"{",
"$",
"obj_fields",
"=",
"$",
"obj_params",
"->",
"mutableFieldSpec",
"(",
")",
";",
"foreach",
"(",
"$",
"arr_return_fields",
"as",
"$",
"str_field",
")",
"{",
"$",
"obj_fields",
"->",
"addName",
"(",
"$",
"str_field",
")",
";",
"}",
"}",
"// Return Expressions",
"$",
"arr_return_exps",
"=",
"$",
"obj_query",
"->",
"getReturnExpressions",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"arr_return_exps",
"&&",
"count",
"(",
"$",
"arr_return_exps",
")",
">",
"0",
")",
"{",
"$",
"obj_fields",
"=",
"$",
"obj_params",
"->",
"mutableFieldSpec",
"(",
")",
";",
"foreach",
"(",
"$",
"arr_return_exps",
"as",
"$",
"arr_exp",
")",
"{",
"$",
"obj_fields",
"->",
"addExpression",
"(",
")",
"->",
"setName",
"(",
"$",
"arr_exp",
"[",
"0",
"]",
")",
"->",
"setExpression",
"(",
"$",
"arr_exp",
"[",
"1",
"]",
")",
";",
"}",
"}",
"// Facets",
"$",
"arr_facets",
"=",
"$",
"obj_query",
"->",
"getFacets",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"arr_facets",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"arr_facets",
")",
">",
"0",
")",
"{",
"// We want a specific set of facets in the response",
"foreach",
"(",
"$",
"arr_facets",
"as",
"$",
"str_facet",
")",
"{",
"$",
"obj_params",
"->",
"addIncludeFacet",
"(",
")",
"->",
"setName",
"(",
"$",
"str_facet",
")",
";",
"}",
"}",
"else",
"{",
"// We want all facets back...",
"$",
"obj_params",
"->",
"setAutoDiscoverFacetCount",
"(",
"100",
")",
";",
"}",
"}",
"$",
"this",
"->",
"execute",
"(",
"'Search'",
",",
"$",
"obj_request",
",",
"new",
"SearchResponse",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"processSearchResponse",
"(",
")",
";",
"}"
] |
Run a Search Query
@param Query $obj_query
@return object
@throws ApplicationError
@throws \Exception
|
[
"Run",
"a",
"Search",
"Query"
] |
e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba
|
https://github.com/tomwalder/php-appengine-search/blob/e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba/src/Search/Gateway.php#L128-L191
|
228,264
|
tomwalder/php-appengine-search
|
src/Search/Gateway.php
|
Gateway.getDocById
|
public function getDocById($str_id)
{
$obj_request = new ListDocumentsRequest();
$obj_params = $this->prepareRequestParams($obj_request);
$obj_params->setStartDocId($str_id)->setLimit(1);
$this->execute('ListDocuments', $obj_request, new ListDocumentsResponse());
$obj_response = $this->processListResponse();
// Verify that the document is the one we want and if not, empty the response
// This works around the lack of a "get-by-id" method on the Google Protocol Buffer
if($obj_response->count > 0) {
if($str_id !== $obj_response->docs[0]->getId()) {
$obj_response->count = 0;
$obj_response->docs = [];
}
}
return $obj_response;
}
|
php
|
public function getDocById($str_id)
{
$obj_request = new ListDocumentsRequest();
$obj_params = $this->prepareRequestParams($obj_request);
$obj_params->setStartDocId($str_id)->setLimit(1);
$this->execute('ListDocuments', $obj_request, new ListDocumentsResponse());
$obj_response = $this->processListResponse();
// Verify that the document is the one we want and if not, empty the response
// This works around the lack of a "get-by-id" method on the Google Protocol Buffer
if($obj_response->count > 0) {
if($str_id !== $obj_response->docs[0]->getId()) {
$obj_response->count = 0;
$obj_response->docs = [];
}
}
return $obj_response;
}
|
[
"public",
"function",
"getDocById",
"(",
"$",
"str_id",
")",
"{",
"$",
"obj_request",
"=",
"new",
"ListDocumentsRequest",
"(",
")",
";",
"$",
"obj_params",
"=",
"$",
"this",
"->",
"prepareRequestParams",
"(",
"$",
"obj_request",
")",
";",
"$",
"obj_params",
"->",
"setStartDocId",
"(",
"$",
"str_id",
")",
"->",
"setLimit",
"(",
"1",
")",
";",
"$",
"this",
"->",
"execute",
"(",
"'ListDocuments'",
",",
"$",
"obj_request",
",",
"new",
"ListDocumentsResponse",
"(",
")",
")",
";",
"$",
"obj_response",
"=",
"$",
"this",
"->",
"processListResponse",
"(",
")",
";",
"// Verify that the document is the one we want and if not, empty the response",
"// This works around the lack of a \"get-by-id\" method on the Google Protocol Buffer",
"if",
"(",
"$",
"obj_response",
"->",
"count",
">",
"0",
")",
"{",
"if",
"(",
"$",
"str_id",
"!==",
"$",
"obj_response",
"->",
"docs",
"[",
"0",
"]",
"->",
"getId",
"(",
")",
")",
"{",
"$",
"obj_response",
"->",
"count",
"=",
"0",
";",
"$",
"obj_response",
"->",
"docs",
"=",
"[",
"]",
";",
"}",
"}",
"return",
"$",
"obj_response",
";",
"}"
] |
Return a single document by ID
@param $str_id
@return array
@throws ApplicationError
@throws \Exception
|
[
"Return",
"a",
"single",
"document",
"by",
"ID"
] |
e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba
|
https://github.com/tomwalder/php-appengine-search/blob/e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba/src/Search/Gateway.php#L201-L218
|
228,265
|
tomwalder/php-appengine-search
|
src/Search/Gateway.php
|
Gateway.delete
|
public function delete(array $arr_ids)
{
$obj_request = new DeleteDocumentRequest();
$obj_params = $this->prepareRequestParams($obj_request);
foreach($arr_ids as $str_id) {
$obj_params->addDocId($str_id);
}
$this->execute('DeleteDocument', $obj_request, new DeleteDocumentResponse());
}
|
php
|
public function delete(array $arr_ids)
{
$obj_request = new DeleteDocumentRequest();
$obj_params = $this->prepareRequestParams($obj_request);
foreach($arr_ids as $str_id) {
$obj_params->addDocId($str_id);
}
$this->execute('DeleteDocument', $obj_request, new DeleteDocumentResponse());
}
|
[
"public",
"function",
"delete",
"(",
"array",
"$",
"arr_ids",
")",
"{",
"$",
"obj_request",
"=",
"new",
"DeleteDocumentRequest",
"(",
")",
";",
"$",
"obj_params",
"=",
"$",
"this",
"->",
"prepareRequestParams",
"(",
"$",
"obj_request",
")",
";",
"foreach",
"(",
"$",
"arr_ids",
"as",
"$",
"str_id",
")",
"{",
"$",
"obj_params",
"->",
"addDocId",
"(",
"$",
"str_id",
")",
";",
"}",
"$",
"this",
"->",
"execute",
"(",
"'DeleteDocument'",
",",
"$",
"obj_request",
",",
"new",
"DeleteDocumentResponse",
"(",
")",
")",
";",
"}"
] |
Delete one or more documents by ID
@param array $arr_ids
|
[
"Delete",
"one",
"or",
"more",
"documents",
"by",
"ID"
] |
e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba
|
https://github.com/tomwalder/php-appengine-search/blob/e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba/src/Search/Gateway.php#L225-L233
|
228,266
|
tomwalder/php-appengine-search
|
src/Search/Gateway.php
|
Gateway.execute
|
private function execute($str_method, ProtocolMessage $obj_request, ProtocolMessage $obj_response)
{
try {
$this->obj_last_request = $obj_request;
$this->obj_last_response = null;
ApiProxy::makeSyncCall('search', $str_method, $obj_request, $obj_response, 60);
$this->obj_last_response = $obj_response;
} catch (ApplicationError $obj_exception) {
throw $obj_exception;
}
}
|
php
|
private function execute($str_method, ProtocolMessage $obj_request, ProtocolMessage $obj_response)
{
try {
$this->obj_last_request = $obj_request;
$this->obj_last_response = null;
ApiProxy::makeSyncCall('search', $str_method, $obj_request, $obj_response, 60);
$this->obj_last_response = $obj_response;
} catch (ApplicationError $obj_exception) {
throw $obj_exception;
}
}
|
[
"private",
"function",
"execute",
"(",
"$",
"str_method",
",",
"ProtocolMessage",
"$",
"obj_request",
",",
"ProtocolMessage",
"$",
"obj_response",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"obj_last_request",
"=",
"$",
"obj_request",
";",
"$",
"this",
"->",
"obj_last_response",
"=",
"null",
";",
"ApiProxy",
"::",
"makeSyncCall",
"(",
"'search'",
",",
"$",
"str_method",
",",
"$",
"obj_request",
",",
"$",
"obj_response",
",",
"60",
")",
";",
"$",
"this",
"->",
"obj_last_response",
"=",
"$",
"obj_response",
";",
"}",
"catch",
"(",
"ApplicationError",
"$",
"obj_exception",
")",
"{",
"throw",
"$",
"obj_exception",
";",
"}",
"}"
] |
Run a Request
@param $str_method
@param ProtocolMessage $obj_request
@param ProtocolMessage $obj_response
@return ProtocolMessage|null|object
@throws ApplicationError
@throws \Exception
|
[
"Run",
"a",
"Request"
] |
e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba
|
https://github.com/tomwalder/php-appengine-search/blob/e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba/src/Search/Gateway.php#L245-L255
|
228,267
|
tomwalder/php-appengine-search
|
src/Search/Gateway.php
|
Gateway.processSearchResponse
|
private function processSearchResponse()
{
/** @var SearchResponse $obj_search_response */
$obj_search_response = $this->obj_last_response;
$obj_response = (object)[
'status' => $this->describeStatusCode($obj_search_response->getStatus()->getCode()),
'hits' => $obj_search_response->getMatchedCount(),
'count' => $obj_search_response->getResultSize(),
'results' => []
];
$obj_mapper = new Mapper();
foreach($obj_search_response->getResultList() as $obj_result) {
/** @var SearchResult $obj_result */
$obj_doc = $obj_mapper->fromGoogle($obj_result->getDocument(), $obj_result->getExpressionList());
$obj_response->results[] = (object)[
'score' => ($obj_result->getScoreSize() > 0 ? $obj_result->getScore(0) : 0),
'doc' => $obj_doc
];
}
// Map facets from results
// @todo Restructure/review response object and moving this code to Mapper
if($obj_search_response->getFacetResultSize() > 0) {
$obj_response->facets = []; // create the empty facets placeholder in the response
/** @var \google\appengine\FacetResult $obj_facet */
foreach($obj_search_response->getFacetResultList() as $obj_facet) {
$arr_facet_values = [];
/** @var \google\appengine\FacetResultValue $obj_facet_value */
foreach($obj_facet->getValueList() as $obj_facet_value) {
$arr_facet_values[] = [
'agg' => $obj_facet_value->getName(),
'count' => $obj_facet_value->getCount()
];
}
$obj_response->facets[$obj_facet->getName()] = $arr_facet_values;
}
}
return $obj_response;
}
|
php
|
private function processSearchResponse()
{
/** @var SearchResponse $obj_search_response */
$obj_search_response = $this->obj_last_response;
$obj_response = (object)[
'status' => $this->describeStatusCode($obj_search_response->getStatus()->getCode()),
'hits' => $obj_search_response->getMatchedCount(),
'count' => $obj_search_response->getResultSize(),
'results' => []
];
$obj_mapper = new Mapper();
foreach($obj_search_response->getResultList() as $obj_result) {
/** @var SearchResult $obj_result */
$obj_doc = $obj_mapper->fromGoogle($obj_result->getDocument(), $obj_result->getExpressionList());
$obj_response->results[] = (object)[
'score' => ($obj_result->getScoreSize() > 0 ? $obj_result->getScore(0) : 0),
'doc' => $obj_doc
];
}
// Map facets from results
// @todo Restructure/review response object and moving this code to Mapper
if($obj_search_response->getFacetResultSize() > 0) {
$obj_response->facets = []; // create the empty facets placeholder in the response
/** @var \google\appengine\FacetResult $obj_facet */
foreach($obj_search_response->getFacetResultList() as $obj_facet) {
$arr_facet_values = [];
/** @var \google\appengine\FacetResultValue $obj_facet_value */
foreach($obj_facet->getValueList() as $obj_facet_value) {
$arr_facet_values[] = [
'agg' => $obj_facet_value->getName(),
'count' => $obj_facet_value->getCount()
];
}
$obj_response->facets[$obj_facet->getName()] = $arr_facet_values;
}
}
return $obj_response;
}
|
[
"private",
"function",
"processSearchResponse",
"(",
")",
"{",
"/** @var SearchResponse $obj_search_response */",
"$",
"obj_search_response",
"=",
"$",
"this",
"->",
"obj_last_response",
";",
"$",
"obj_response",
"=",
"(",
"object",
")",
"[",
"'status'",
"=>",
"$",
"this",
"->",
"describeStatusCode",
"(",
"$",
"obj_search_response",
"->",
"getStatus",
"(",
")",
"->",
"getCode",
"(",
")",
")",
",",
"'hits'",
"=>",
"$",
"obj_search_response",
"->",
"getMatchedCount",
"(",
")",
",",
"'count'",
"=>",
"$",
"obj_search_response",
"->",
"getResultSize",
"(",
")",
",",
"'results'",
"=>",
"[",
"]",
"]",
";",
"$",
"obj_mapper",
"=",
"new",
"Mapper",
"(",
")",
";",
"foreach",
"(",
"$",
"obj_search_response",
"->",
"getResultList",
"(",
")",
"as",
"$",
"obj_result",
")",
"{",
"/** @var SearchResult $obj_result */",
"$",
"obj_doc",
"=",
"$",
"obj_mapper",
"->",
"fromGoogle",
"(",
"$",
"obj_result",
"->",
"getDocument",
"(",
")",
",",
"$",
"obj_result",
"->",
"getExpressionList",
"(",
")",
")",
";",
"$",
"obj_response",
"->",
"results",
"[",
"]",
"=",
"(",
"object",
")",
"[",
"'score'",
"=>",
"(",
"$",
"obj_result",
"->",
"getScoreSize",
"(",
")",
">",
"0",
"?",
"$",
"obj_result",
"->",
"getScore",
"(",
"0",
")",
":",
"0",
")",
",",
"'doc'",
"=>",
"$",
"obj_doc",
"]",
";",
"}",
"// Map facets from results",
"// @todo Restructure/review response object and moving this code to Mapper",
"if",
"(",
"$",
"obj_search_response",
"->",
"getFacetResultSize",
"(",
")",
">",
"0",
")",
"{",
"$",
"obj_response",
"->",
"facets",
"=",
"[",
"]",
";",
"// create the empty facets placeholder in the response",
"/** @var \\google\\appengine\\FacetResult $obj_facet */",
"foreach",
"(",
"$",
"obj_search_response",
"->",
"getFacetResultList",
"(",
")",
"as",
"$",
"obj_facet",
")",
"{",
"$",
"arr_facet_values",
"=",
"[",
"]",
";",
"/** @var \\google\\appengine\\FacetResultValue $obj_facet_value */",
"foreach",
"(",
"$",
"obj_facet",
"->",
"getValueList",
"(",
")",
"as",
"$",
"obj_facet_value",
")",
"{",
"$",
"arr_facet_values",
"[",
"]",
"=",
"[",
"'agg'",
"=>",
"$",
"obj_facet_value",
"->",
"getName",
"(",
")",
",",
"'count'",
"=>",
"$",
"obj_facet_value",
"->",
"getCount",
"(",
")",
"]",
";",
"}",
"$",
"obj_response",
"->",
"facets",
"[",
"$",
"obj_facet",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"arr_facet_values",
";",
"}",
"}",
"return",
"$",
"obj_response",
";",
"}"
] |
Process a search response
@return object
|
[
"Process",
"a",
"search",
"response"
] |
e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba
|
https://github.com/tomwalder/php-appengine-search/blob/e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba/src/Search/Gateway.php#L262-L301
|
228,268
|
tomwalder/php-appengine-search
|
src/Search/Gateway.php
|
Gateway.processListResponse
|
private function processListResponse()
{
/** @var ListDocumentsResponse $obj_list_response */
$obj_list_response = $this->obj_last_response;
$obj_response = (object)[
'status' => $this->describeStatusCode($obj_list_response->getStatus()->getCode()),
'count' => $obj_list_response->getDocumentSize(),
'docs' => []
];
$obj_mapper = new Mapper();
foreach($obj_list_response->getDocumentList() as $obj_document) {
$obj_doc = $obj_mapper->fromGoogle($obj_document);
$obj_response->docs[] = $obj_doc;
}
return $obj_response;
}
|
php
|
private function processListResponse()
{
/** @var ListDocumentsResponse $obj_list_response */
$obj_list_response = $this->obj_last_response;
$obj_response = (object)[
'status' => $this->describeStatusCode($obj_list_response->getStatus()->getCode()),
'count' => $obj_list_response->getDocumentSize(),
'docs' => []
];
$obj_mapper = new Mapper();
foreach($obj_list_response->getDocumentList() as $obj_document) {
$obj_doc = $obj_mapper->fromGoogle($obj_document);
$obj_response->docs[] = $obj_doc;
}
return $obj_response;
}
|
[
"private",
"function",
"processListResponse",
"(",
")",
"{",
"/** @var ListDocumentsResponse $obj_list_response */",
"$",
"obj_list_response",
"=",
"$",
"this",
"->",
"obj_last_response",
";",
"$",
"obj_response",
"=",
"(",
"object",
")",
"[",
"'status'",
"=>",
"$",
"this",
"->",
"describeStatusCode",
"(",
"$",
"obj_list_response",
"->",
"getStatus",
"(",
")",
"->",
"getCode",
"(",
")",
")",
",",
"'count'",
"=>",
"$",
"obj_list_response",
"->",
"getDocumentSize",
"(",
")",
",",
"'docs'",
"=>",
"[",
"]",
"]",
";",
"$",
"obj_mapper",
"=",
"new",
"Mapper",
"(",
")",
";",
"foreach",
"(",
"$",
"obj_list_response",
"->",
"getDocumentList",
"(",
")",
"as",
"$",
"obj_document",
")",
"{",
"$",
"obj_doc",
"=",
"$",
"obj_mapper",
"->",
"fromGoogle",
"(",
"$",
"obj_document",
")",
";",
"$",
"obj_response",
"->",
"docs",
"[",
"]",
"=",
"$",
"obj_doc",
";",
"}",
"return",
"$",
"obj_response",
";",
"}"
] |
Process a document list response
@return object
|
[
"Process",
"a",
"document",
"list",
"response"
] |
e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba
|
https://github.com/tomwalder/php-appengine-search/blob/e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba/src/Search/Gateway.php#L308-L323
|
228,269
|
lawoole/framework
|
src/Homer/Context.php
|
Context.setInvocation
|
public function setInvocation(Invocation $invocation)
{
$this->invocation = $invocation;
$this->setAttachments($invocation->getAttachments());
}
|
php
|
public function setInvocation(Invocation $invocation)
{
$this->invocation = $invocation;
$this->setAttachments($invocation->getAttachments());
}
|
[
"public",
"function",
"setInvocation",
"(",
"Invocation",
"$",
"invocation",
")",
"{",
"$",
"this",
"->",
"invocation",
"=",
"$",
"invocation",
";",
"$",
"this",
"->",
"setAttachments",
"(",
"$",
"invocation",
"->",
"getAttachments",
"(",
")",
")",
";",
"}"
] |
Set the invocation instance.
@param \Lawoole\Homer\Calling\Invocation $invocation
|
[
"Set",
"the",
"invocation",
"instance",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Context.php#L61-L66
|
228,270
|
lawoole/framework
|
src/Homer/Serialize/Serializations/ValidatorSerialization.php
|
ValidatorSerialization.recover
|
public function recover()
{
$validator = ValidatorFacade::make([], []);
foreach ($this->messages as $key => $value) {
foreach (Arr::wrap($value) as $message) {
$validator->errors()->add($key, $message);
}
}
return $validator;
}
|
php
|
public function recover()
{
$validator = ValidatorFacade::make([], []);
foreach ($this->messages as $key => $value) {
foreach (Arr::wrap($value) as $message) {
$validator->errors()->add($key, $message);
}
}
return $validator;
}
|
[
"public",
"function",
"recover",
"(",
")",
"{",
"$",
"validator",
"=",
"ValidatorFacade",
"::",
"make",
"(",
"[",
"]",
",",
"[",
"]",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"messages",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"foreach",
"(",
"Arr",
"::",
"wrap",
"(",
"$",
"value",
")",
"as",
"$",
"message",
")",
"{",
"$",
"validator",
"->",
"errors",
"(",
")",
"->",
"add",
"(",
"$",
"key",
",",
"$",
"message",
")",
";",
"}",
"}",
"return",
"$",
"validator",
";",
"}"
] |
Recover the validator from the serialization.
@return \Illuminate\Contracts\Validation\Validator
|
[
"Recover",
"the",
"validator",
"from",
"the",
"serialization",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Serialize/Serializations/ValidatorSerialization.php#L32-L43
|
228,271
|
antaresproject/core
|
src/ui/components/templates/src/UiComponentsServiceProvider.php
|
UiComponentsServiceProvider.bootMenus
|
public function bootMenus()
{
$name = 'menu.top.right';
view()->composer('antares/foundation::*', function () use ($name) {
if (!Registry::isRegistered('menu.' . $name)) {
$this->app->instance($name, $this->app->make('antares.widget')->make($name));
$selector = new ComponentsSelector($this->app, $name);
$selector->handle();
Registry::set('menu.' . $name, $selector);
}
});
}
|
php
|
public function bootMenus()
{
$name = 'menu.top.right';
view()->composer('antares/foundation::*', function () use ($name) {
if (!Registry::isRegistered('menu.' . $name)) {
$this->app->instance($name, $this->app->make('antares.widget')->make($name));
$selector = new ComponentsSelector($this->app, $name);
$selector->handle();
Registry::set('menu.' . $name, $selector);
}
});
}
|
[
"public",
"function",
"bootMenus",
"(",
")",
"{",
"$",
"name",
"=",
"'menu.top.right'",
";",
"view",
"(",
")",
"->",
"composer",
"(",
"'antares/foundation::*'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"Registry",
"::",
"isRegistered",
"(",
"'menu.'",
".",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"instance",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'antares.widget'",
")",
"->",
"make",
"(",
"$",
"name",
")",
")",
";",
"$",
"selector",
"=",
"new",
"ComponentsSelector",
"(",
"$",
"this",
"->",
"app",
",",
"$",
"name",
")",
";",
"$",
"selector",
"->",
"handle",
"(",
")",
";",
"Registry",
"::",
"set",
"(",
"'menu.'",
".",
"$",
"name",
",",
"$",
"selector",
")",
";",
"}",
"}",
")",
";",
"}"
] |
Booting top left menu
|
[
"Booting",
"top",
"left",
"menu"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/UiComponentsServiceProvider.php#L135-L146
|
228,272
|
crossjoin/PreMailer
|
src/Crossjoin/PreMailer/HtmlFile.php
|
HtmlFile.setFilename
|
protected function setFilename($filename)
{
if (is_string($filename)) {
if (is_readable($filename)) {
$this->filename = $filename;
} elseif (file_exists($filename)) {
throw new \InvalidArgumentException("File '$filename' isn't readable.");
} else {
throw new \InvalidArgumentException("File '$filename' doesn't exist.");
}
} else {
throw new \InvalidArgumentException(
"Invalid type '" . gettype($filename). "' for argument 'filename' given."
);
}
return $this;
}
|
php
|
protected function setFilename($filename)
{
if (is_string($filename)) {
if (is_readable($filename)) {
$this->filename = $filename;
} elseif (file_exists($filename)) {
throw new \InvalidArgumentException("File '$filename' isn't readable.");
} else {
throw new \InvalidArgumentException("File '$filename' doesn't exist.");
}
} else {
throw new \InvalidArgumentException(
"Invalid type '" . gettype($filename). "' for argument 'filename' given."
);
}
return $this;
}
|
[
"protected",
"function",
"setFilename",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"filename",
")",
")",
"{",
"if",
"(",
"is_readable",
"(",
"$",
"filename",
")",
")",
"{",
"$",
"this",
"->",
"filename",
"=",
"$",
"filename",
";",
"}",
"elseif",
"(",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"File '$filename' isn't readable.\"",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"File '$filename' doesn't exist.\"",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid type '\"",
".",
"gettype",
"(",
"$",
"filename",
")",
".",
"\"' for argument 'filename' given.\"",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets the file path of the HTML source file.
@param string $filename
@return $this
|
[
"Sets",
"the",
"file",
"path",
"of",
"the",
"HTML",
"source",
"file",
"."
] |
e1fbd426a9f3ba2d5d00f6641b2509c72bf4f561
|
https://github.com/crossjoin/PreMailer/blob/e1fbd426a9f3ba2d5d00f6641b2509c72bf4f561/src/Crossjoin/PreMailer/HtmlFile.php#L26-L43
|
228,273
|
antaresproject/core
|
src/foundation/src/Providers/FoundationServiceProvider.php
|
FoundationServiceProvider.registerLogFilename
|
protected function registerLogFilename()
{
$handlers = $this->app->make('log')->getMonolog()->getHandlers();
foreach ($handlers as $handler) {
if (!$handler instanceof RotatingFileHandler) {
continue;
}
$filename = (php_sapi_name() === 'cli') ? 'laravel-cli' : 'laravel';
$handler->setFilenameFormat($filename . '-{date}', 'Y-m-d');
}
return;
}
|
php
|
protected function registerLogFilename()
{
$handlers = $this->app->make('log')->getMonolog()->getHandlers();
foreach ($handlers as $handler) {
if (!$handler instanceof RotatingFileHandler) {
continue;
}
$filename = (php_sapi_name() === 'cli') ? 'laravel-cli' : 'laravel';
$handler->setFilenameFormat($filename . '-{date}', 'Y-m-d');
}
return;
}
|
[
"protected",
"function",
"registerLogFilename",
"(",
")",
"{",
"$",
"handlers",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'log'",
")",
"->",
"getMonolog",
"(",
")",
"->",
"getHandlers",
"(",
")",
";",
"foreach",
"(",
"$",
"handlers",
"as",
"$",
"handler",
")",
"{",
"if",
"(",
"!",
"$",
"handler",
"instanceof",
"RotatingFileHandler",
")",
"{",
"continue",
";",
"}",
"$",
"filename",
"=",
"(",
"php_sapi_name",
"(",
")",
"===",
"'cli'",
")",
"?",
"'laravel-cli'",
":",
"'laravel'",
";",
"$",
"handler",
"->",
"setFilenameFormat",
"(",
"$",
"filename",
".",
"'-{date}'",
",",
"'Y-m-d'",
")",
";",
"}",
"return",
";",
"}"
] |
Registers log filename
@return void
|
[
"Registers",
"log",
"filename"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Providers/FoundationServiceProvider.php#L142-L154
|
228,274
|
antaresproject/core
|
src/foundation/src/Providers/FoundationServiceProvider.php
|
FoundationServiceProvider.registerWidgetsFinder
|
protected function registerWidgetsFinder()
{
$this->app->singleton('antares.ui-components.finder', function($app) {
$config = [
'path.app' => $app->make('path'),
'path.base' => $app->make('path.base'),
];
return new Finder($app->make('files'), $config);
});
}
|
php
|
protected function registerWidgetsFinder()
{
$this->app->singleton('antares.ui-components.finder', function($app) {
$config = [
'path.app' => $app->make('path'),
'path.base' => $app->make('path.base'),
];
return new Finder($app->make('files'), $config);
});
}
|
[
"protected",
"function",
"registerWidgetsFinder",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'antares.ui-components.finder'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"config",
"=",
"[",
"'path.app'",
"=>",
"$",
"app",
"->",
"make",
"(",
"'path'",
")",
",",
"'path.base'",
"=>",
"$",
"app",
"->",
"make",
"(",
"'path.base'",
")",
",",
"]",
";",
"return",
"new",
"Finder",
"(",
"$",
"app",
"->",
"make",
"(",
"'files'",
")",
",",
"$",
"config",
")",
";",
"}",
")",
";",
"}"
] |
Register the service provider for Extension Finder.
@return void
|
[
"Register",
"the",
"service",
"provider",
"for",
"Extension",
"Finder",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Providers/FoundationServiceProvider.php#L173-L183
|
228,275
|
antaresproject/core
|
src/foundation/src/Providers/FoundationServiceProvider.php
|
FoundationServiceProvider.registerEvents
|
protected function registerEvents()
{
$this->app->terminating(function () {
$this->app->make('events')->fire('antares.done');
$this->app->make('events')->fire(new AntaresDone());
});
}
|
php
|
protected function registerEvents()
{
$this->app->terminating(function () {
$this->app->make('events')->fire('antares.done');
$this->app->make('events')->fire(new AntaresDone());
});
}
|
[
"protected",
"function",
"registerEvents",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"terminating",
"(",
"function",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'events'",
")",
"->",
"fire",
"(",
"'antares.done'",
")",
";",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'events'",
")",
"->",
"fire",
"(",
"new",
"AntaresDone",
"(",
")",
")",
";",
"}",
")",
";",
"}"
] |
Register additional events for application.
@return void
|
[
"Register",
"additional",
"events",
"for",
"application",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Providers/FoundationServiceProvider.php#L228-L234
|
228,276
|
antaresproject/core
|
src/foundation/src/Providers/FoundationServiceProvider.php
|
FoundationServiceProvider.assignAreaTemplate
|
protected function assignAreaTemplate()
{
$path = realpath(__DIR__ . '/../../');
$area = area();
if (!is_null($area) && is_dir(resource_path('views' . DIRECTORY_SEPARATOR . $area))) {
$this->addViewComponent($area, 'antares/foundation', $path . '/resources/views');
}
$this->addViewComponent('default', 'antares/foundation', $path . '/resources/views');
}
|
php
|
protected function assignAreaTemplate()
{
$path = realpath(__DIR__ . '/../../');
$area = area();
if (!is_null($area) && is_dir(resource_path('views' . DIRECTORY_SEPARATOR . $area))) {
$this->addViewComponent($area, 'antares/foundation', $path . '/resources/views');
}
$this->addViewComponent('default', 'antares/foundation', $path . '/resources/views');
}
|
[
"protected",
"function",
"assignAreaTemplate",
"(",
")",
"{",
"$",
"path",
"=",
"realpath",
"(",
"__DIR__",
".",
"'/../../'",
")",
";",
"$",
"area",
"=",
"area",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"area",
")",
"&&",
"is_dir",
"(",
"resource_path",
"(",
"'views'",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"area",
")",
")",
")",
"{",
"$",
"this",
"->",
"addViewComponent",
"(",
"$",
"area",
",",
"'antares/foundation'",
",",
"$",
"path",
".",
"'/resources/views'",
")",
";",
"}",
"$",
"this",
"->",
"addViewComponent",
"(",
"'default'",
",",
"'antares/foundation'",
",",
"$",
"path",
".",
"'/resources/views'",
")",
";",
"}"
] |
Assign area template based on current area
|
[
"Assign",
"area",
"template",
"based",
"on",
"current",
"area"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Providers/FoundationServiceProvider.php#L294-L302
|
228,277
|
antaresproject/core
|
src/foundation/src/Providers/FoundationServiceProvider.php
|
FoundationServiceProvider.runtime
|
protected function runtime()
{
$filesystem = app(Filesystem::class);
$files = $filesystem->glob(storage_path('license') . '/*.key');
if (!empty($files)) {
app('antares.memory')->make('runtime')->push('instance_key', $filesystem->get($files[0]));
}
}
|
php
|
protected function runtime()
{
$filesystem = app(Filesystem::class);
$files = $filesystem->glob(storage_path('license') . '/*.key');
if (!empty($files)) {
app('antares.memory')->make('runtime')->push('instance_key', $filesystem->get($files[0]));
}
}
|
[
"protected",
"function",
"runtime",
"(",
")",
"{",
"$",
"filesystem",
"=",
"app",
"(",
"Filesystem",
"::",
"class",
")",
";",
"$",
"files",
"=",
"$",
"filesystem",
"->",
"glob",
"(",
"storage_path",
"(",
"'license'",
")",
".",
"'/*.key'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"files",
")",
")",
"{",
"app",
"(",
"'antares.memory'",
")",
"->",
"make",
"(",
"'runtime'",
")",
"->",
"push",
"(",
"'instance_key'",
",",
"$",
"filesystem",
"->",
"get",
"(",
"$",
"files",
"[",
"0",
"]",
")",
")",
";",
"}",
"}"
] |
runtime application configuration
|
[
"runtime",
"application",
"configuration"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Providers/FoundationServiceProvider.php#L307-L314
|
228,278
|
antaresproject/core
|
src/foundation/src/Providers/FoundationServiceProvider.php
|
FoundationServiceProvider.bootWidgetsRouting
|
protected function bootWidgetsRouting()
{
try {
$widgets = $this->app->make('antares.ui-components.finder')->detectRoutes();
$widgets->each(function($widget) {
$widget::routes();
});
return true;
} catch (Exception $e) {
Log::emergency($e);
return false;
}
}
|
php
|
protected function bootWidgetsRouting()
{
try {
$widgets = $this->app->make('antares.ui-components.finder')->detectRoutes();
$widgets->each(function($widget) {
$widget::routes();
});
return true;
} catch (Exception $e) {
Log::emergency($e);
return false;
}
}
|
[
"protected",
"function",
"bootWidgetsRouting",
"(",
")",
"{",
"try",
"{",
"$",
"widgets",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'antares.ui-components.finder'",
")",
"->",
"detectRoutes",
"(",
")",
";",
"$",
"widgets",
"->",
"each",
"(",
"function",
"(",
"$",
"widget",
")",
"{",
"$",
"widget",
"::",
"routes",
"(",
")",
";",
"}",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"Log",
"::",
"emergency",
"(",
"$",
"e",
")",
";",
"return",
"false",
";",
"}",
"}"
] |
boot widgets routing
|
[
"boot",
"widgets",
"routing"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Providers/FoundationServiceProvider.php#L319-L331
|
228,279
|
antaresproject/core
|
src/foundation/src/Providers/FoundationServiceProvider.php
|
FoundationServiceProvider.bootNotificationVariables
|
protected function bootNotificationVariables()
{
if (!app('antares.installed')) {
return;
}
/* @var $notification VariablesService */
if (class_exists(VariablesService::class)) {
$notification = app()->make(VariablesService::class);
$notification->register('foundation', new CoreVariablesProvider());
}
}
|
php
|
protected function bootNotificationVariables()
{
if (!app('antares.installed')) {
return;
}
/* @var $notification VariablesService */
if (class_exists(VariablesService::class)) {
$notification = app()->make(VariablesService::class);
$notification->register('foundation', new CoreVariablesProvider());
}
}
|
[
"protected",
"function",
"bootNotificationVariables",
"(",
")",
"{",
"if",
"(",
"!",
"app",
"(",
"'antares.installed'",
")",
")",
"{",
"return",
";",
"}",
"/* @var $notification VariablesService */",
"if",
"(",
"class_exists",
"(",
"VariablesService",
"::",
"class",
")",
")",
"{",
"$",
"notification",
"=",
"app",
"(",
")",
"->",
"make",
"(",
"VariablesService",
"::",
"class",
")",
";",
"$",
"notification",
"->",
"register",
"(",
"'foundation'",
",",
"new",
"CoreVariablesProvider",
"(",
")",
")",
";",
"}",
"}"
] |
appends notification variables
|
[
"appends",
"notification",
"variables"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Providers/FoundationServiceProvider.php#L355-L367
|
228,280
|
antaresproject/core
|
src/components/html/src/CustomfieldsFinder.php
|
CustomfieldsFinder.getCustomfields
|
protected function getCustomfields()
{
$extensions = extensions();
$return = [];
event('customfields.before.search', $return);
event(new BeforeSearch($return));
foreach ($extensions as $name => $extension) {
$name = 'antares/' . str_replace(['component-', 'module-'], '', $extension['name']);
$config = config($name . '::customfields');
if (empty($config)) {
continue;
}
if (!$this->validate($config)) {
continue;
}
array_walk($config, function(&$value, $key) {
if (is_array($value)) {
foreach ($value as $index => &$customfield) {
if (!class_exists($customfield)) {
unset($value[$index]);
continue;
}
$customfield = app($customfield);
}
} else {
$value = app($value);
}
});
foreach ($config as $name => $customfields) {
if (isset($return[$name])) {
$return[$name] = array_merge($return[$name], $customfields);
} else {
$return[$name] = $customfields;
}
}
}
event('customfields.after.search', [$return]);
event(new AfterSearch($return));
return $return;
}
|
php
|
protected function getCustomfields()
{
$extensions = extensions();
$return = [];
event('customfields.before.search', $return);
event(new BeforeSearch($return));
foreach ($extensions as $name => $extension) {
$name = 'antares/' . str_replace(['component-', 'module-'], '', $extension['name']);
$config = config($name . '::customfields');
if (empty($config)) {
continue;
}
if (!$this->validate($config)) {
continue;
}
array_walk($config, function(&$value, $key) {
if (is_array($value)) {
foreach ($value as $index => &$customfield) {
if (!class_exists($customfield)) {
unset($value[$index]);
continue;
}
$customfield = app($customfield);
}
} else {
$value = app($value);
}
});
foreach ($config as $name => $customfields) {
if (isset($return[$name])) {
$return[$name] = array_merge($return[$name], $customfields);
} else {
$return[$name] = $customfields;
}
}
}
event('customfields.after.search', [$return]);
event(new AfterSearch($return));
return $return;
}
|
[
"protected",
"function",
"getCustomfields",
"(",
")",
"{",
"$",
"extensions",
"=",
"extensions",
"(",
")",
";",
"$",
"return",
"=",
"[",
"]",
";",
"event",
"(",
"'customfields.before.search'",
",",
"$",
"return",
")",
";",
"event",
"(",
"new",
"BeforeSearch",
"(",
"$",
"return",
")",
")",
";",
"foreach",
"(",
"$",
"extensions",
"as",
"$",
"name",
"=>",
"$",
"extension",
")",
"{",
"$",
"name",
"=",
"'antares/'",
".",
"str_replace",
"(",
"[",
"'component-'",
",",
"'module-'",
"]",
",",
"''",
",",
"$",
"extension",
"[",
"'name'",
"]",
")",
";",
"$",
"config",
"=",
"config",
"(",
"$",
"name",
".",
"'::customfields'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"config",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"validate",
"(",
"$",
"config",
")",
")",
"{",
"continue",
";",
"}",
"array_walk",
"(",
"$",
"config",
",",
"function",
"(",
"&",
"$",
"value",
",",
"$",
"key",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"index",
"=>",
"&",
"$",
"customfield",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"customfield",
")",
")",
"{",
"unset",
"(",
"$",
"value",
"[",
"$",
"index",
"]",
")",
";",
"continue",
";",
"}",
"$",
"customfield",
"=",
"app",
"(",
"$",
"customfield",
")",
";",
"}",
"}",
"else",
"{",
"$",
"value",
"=",
"app",
"(",
"$",
"value",
")",
";",
"}",
"}",
")",
";",
"foreach",
"(",
"$",
"config",
"as",
"$",
"name",
"=>",
"$",
"customfields",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"return",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"return",
"[",
"$",
"name",
"]",
"=",
"array_merge",
"(",
"$",
"return",
"[",
"$",
"name",
"]",
",",
"$",
"customfields",
")",
";",
"}",
"else",
"{",
"$",
"return",
"[",
"$",
"name",
"]",
"=",
"$",
"customfields",
";",
"}",
"}",
"}",
"event",
"(",
"'customfields.after.search'",
",",
"[",
"$",
"return",
"]",
")",
";",
"event",
"(",
"new",
"AfterSearch",
"(",
"$",
"return",
")",
")",
";",
"return",
"$",
"return",
";",
"}"
] |
Gets extensions with customfields
@return array
|
[
"Gets",
"extensions",
"with",
"customfields"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/CustomfieldsFinder.php#L69-L113
|
228,281
|
antaresproject/core
|
src/components/html/src/CustomfieldsFinder.php
|
CustomfieldsFinder.validate
|
private function validate(array $config = [])
{
$customfields = [];
foreach ($config as $classname => $customfield) {
if (!class_exists($classname)) {
continue;
}
array_push($customfields, $customfield);
}
return !empty($customfields);
}
|
php
|
private function validate(array $config = [])
{
$customfields = [];
foreach ($config as $classname => $customfield) {
if (!class_exists($classname)) {
continue;
}
array_push($customfields, $customfield);
}
return !empty($customfields);
}
|
[
"private",
"function",
"validate",
"(",
"array",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"customfields",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"config",
"as",
"$",
"classname",
"=>",
"$",
"customfield",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"classname",
")",
")",
"{",
"continue",
";",
"}",
"array_push",
"(",
"$",
"customfields",
",",
"$",
"customfield",
")",
";",
"}",
"return",
"!",
"empty",
"(",
"$",
"customfields",
")",
";",
"}"
] |
Whether customfield configuration is valid
@param array $config
@return boolean
|
[
"Whether",
"customfield",
"configuration",
"is",
"valid"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/CustomfieldsFinder.php#L121-L131
|
228,282
|
antaresproject/core
|
src/components/html/src/CustomfieldsFinder.php
|
CustomfieldsFinder.getConfigurable
|
public function getConfigurable($group = null)
{
if (empty($this->configurable)) {
foreach ($this->customfields as $category => $customfield) {
foreach ($customfield as $field) {
if (!$field->configurable()) {
continue;
}
$this->configurable[strtolower(last(explode('\\', $category)))][] = $field->getName();
}
}
}
return !is_null($group) ? array_get($this->configurable, $group, []) : $this->configurable;
}
|
php
|
public function getConfigurable($group = null)
{
if (empty($this->configurable)) {
foreach ($this->customfields as $category => $customfield) {
foreach ($customfield as $field) {
if (!$field->configurable()) {
continue;
}
$this->configurable[strtolower(last(explode('\\', $category)))][] = $field->getName();
}
}
}
return !is_null($group) ? array_get($this->configurable, $group, []) : $this->configurable;
}
|
[
"public",
"function",
"getConfigurable",
"(",
"$",
"group",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"configurable",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"customfields",
"as",
"$",
"category",
"=>",
"$",
"customfield",
")",
"{",
"foreach",
"(",
"$",
"customfield",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"$",
"field",
"->",
"configurable",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"configurable",
"[",
"strtolower",
"(",
"last",
"(",
"explode",
"(",
"'\\\\'",
",",
"$",
"category",
")",
")",
")",
"]",
"[",
"]",
"=",
"$",
"field",
"->",
"getName",
"(",
")",
";",
"}",
"}",
"}",
"return",
"!",
"is_null",
"(",
"$",
"group",
")",
"?",
"array_get",
"(",
"$",
"this",
"->",
"configurable",
",",
"$",
"group",
",",
"[",
"]",
")",
":",
"$",
"this",
"->",
"configurable",
";",
"}"
] |
Gets configurable customfields
@param String $group
@return array
|
[
"Gets",
"configurable",
"customfields"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/CustomfieldsFinder.php#L139-L152
|
228,283
|
antaresproject/core
|
src/foundation/src/Http/Controllers/Extension/ActionController.php
|
ActionController.setupMiddleware
|
protected function setupMiddleware() {
$this->middleware('antares.auth');
$this->middleware('antares.manage');
$this->middleware('antares.csrf');
$this->canMiddleware('install');
$this->canMiddleware('uninstall');
$this->canMiddleware('activate');
$this->canMiddleware('deactivate');
}
|
php
|
protected function setupMiddleware() {
$this->middleware('antares.auth');
$this->middleware('antares.manage');
$this->middleware('antares.csrf');
$this->canMiddleware('install');
$this->canMiddleware('uninstall');
$this->canMiddleware('activate');
$this->canMiddleware('deactivate');
}
|
[
"protected",
"function",
"setupMiddleware",
"(",
")",
"{",
"$",
"this",
"->",
"middleware",
"(",
"'antares.auth'",
")",
";",
"$",
"this",
"->",
"middleware",
"(",
"'antares.manage'",
")",
";",
"$",
"this",
"->",
"middleware",
"(",
"'antares.csrf'",
")",
";",
"$",
"this",
"->",
"canMiddleware",
"(",
"'install'",
")",
";",
"$",
"this",
"->",
"canMiddleware",
"(",
"'uninstall'",
")",
";",
"$",
"this",
"->",
"canMiddleware",
"(",
"'activate'",
")",
";",
"$",
"this",
"->",
"canMiddleware",
"(",
"'deactivate'",
")",
";",
"}"
] |
Setup controller filters.
@return void
|
[
"Setup",
"controller",
"filters",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Controllers/Extension/ActionController.php#L61-L70
|
228,284
|
antaresproject/core
|
src/foundation/src/Listeners/DatatableMassActionsDependableActions.php
|
DatatableMassActionsDependableActions.addClass
|
protected function addClass($cssClass, &$attributes)
{
$class = array_get($attributes, 'class', '');
if (!str_contains($class, $cssClass)) {
$class .= ' ' . $cssClass;
}
return array_set($attributes, 'class', $class);
}
|
php
|
protected function addClass($cssClass, &$attributes)
{
$class = array_get($attributes, 'class', '');
if (!str_contains($class, $cssClass)) {
$class .= ' ' . $cssClass;
}
return array_set($attributes, 'class', $class);
}
|
[
"protected",
"function",
"addClass",
"(",
"$",
"cssClass",
",",
"&",
"$",
"attributes",
")",
"{",
"$",
"class",
"=",
"array_get",
"(",
"$",
"attributes",
",",
"'class'",
",",
"''",
")",
";",
"if",
"(",
"!",
"str_contains",
"(",
"$",
"class",
",",
"$",
"cssClass",
")",
")",
"{",
"$",
"class",
".=",
"' '",
".",
"$",
"cssClass",
";",
"}",
"return",
"array_set",
"(",
"$",
"attributes",
",",
"'class'",
",",
"$",
"class",
")",
";",
"}"
] |
Add css class to link
@param String $cssClass
@param String $attributes
@return mixed
|
[
"Add",
"css",
"class",
"to",
"link"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Listeners/DatatableMassActionsDependableActions.php#L81-L88
|
228,285
|
antaresproject/core
|
src/components/extension/src/Model/Extension.php
|
Extension.getFriendlyName
|
public function getFriendlyName(): string
{
$extra = $this->getPackage()->getExtra();
$regularName = str_replace(['component-', 'module-'], '', $this->getPackageName());
return (string) Arr::get($extra, 'friendly-name', $regularName);
}
|
php
|
public function getFriendlyName(): string
{
$extra = $this->getPackage()->getExtra();
$regularName = str_replace(['component-', 'module-'], '', $this->getPackageName());
return (string) Arr::get($extra, 'friendly-name', $regularName);
}
|
[
"public",
"function",
"getFriendlyName",
"(",
")",
":",
"string",
"{",
"$",
"extra",
"=",
"$",
"this",
"->",
"getPackage",
"(",
")",
"->",
"getExtra",
"(",
")",
";",
"$",
"regularName",
"=",
"str_replace",
"(",
"[",
"'component-'",
",",
"'module-'",
"]",
",",
"''",
",",
"$",
"this",
"->",
"getPackageName",
"(",
")",
")",
";",
"return",
"(",
"string",
")",
"Arr",
"::",
"get",
"(",
"$",
"extra",
",",
"'friendly-name'",
",",
"$",
"regularName",
")",
";",
"}"
] |
Returns friendly name of the module from the composer extra attribute.
@return string
|
[
"Returns",
"friendly",
"name",
"of",
"the",
"module",
"from",
"the",
"composer",
"extra",
"attribute",
"."
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Model/Extension.php#L218-L224
|
228,286
|
antaresproject/core
|
src/foundation/src/Request.php
|
Request.getController
|
public function getController()
{
if (!is_null(self::$controller)) {
return self::$controller;
}
$controllerParam = array_get($this->routeParams, 'controller');
$match = null;
preg_match("'Foundation\\\Http\\\Controllers\\\(.*?)@'si", $controllerParam, $match);
if (!isset($match[1]) && !preg_match("'Admin\\\(.*?)@'si", $controllerParam, $match)) {
return;
}
self::$controller = str_replace('controller', '', strtolower($match[1]));
return self::$controller;
}
|
php
|
public function getController()
{
if (!is_null(self::$controller)) {
return self::$controller;
}
$controllerParam = array_get($this->routeParams, 'controller');
$match = null;
preg_match("'Foundation\\\Http\\\Controllers\\\(.*?)@'si", $controllerParam, $match);
if (!isset($match[1]) && !preg_match("'Admin\\\(.*?)@'si", $controllerParam, $match)) {
return;
}
self::$controller = str_replace('controller', '', strtolower($match[1]));
return self::$controller;
}
|
[
"public",
"function",
"getController",
"(",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"self",
"::",
"$",
"controller",
")",
")",
"{",
"return",
"self",
"::",
"$",
"controller",
";",
"}",
"$",
"controllerParam",
"=",
"array_get",
"(",
"$",
"this",
"->",
"routeParams",
",",
"'controller'",
")",
";",
"$",
"match",
"=",
"null",
";",
"preg_match",
"(",
"\"'Foundation\\\\\\Http\\\\\\Controllers\\\\\\(.*?)@'si\"",
",",
"$",
"controllerParam",
",",
"$",
"match",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"match",
"[",
"1",
"]",
")",
"&&",
"!",
"preg_match",
"(",
"\"'Admin\\\\\\(.*?)@'si\"",
",",
"$",
"controllerParam",
",",
"$",
"match",
")",
")",
"{",
"return",
";",
"}",
"self",
"::",
"$",
"controller",
"=",
"str_replace",
"(",
"'controller'",
",",
"''",
",",
"strtolower",
"(",
"$",
"match",
"[",
"1",
"]",
")",
")",
";",
"return",
"self",
"::",
"$",
"controller",
";",
"}"
] |
get current controller name by route
@return String
|
[
"get",
"current",
"controller",
"name",
"by",
"route"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Request.php#L71-L86
|
228,287
|
antaresproject/core
|
src/foundation/src/Request.php
|
Request.getControllerClass
|
public function getControllerClass()
{
$controller = array_get($this->routeParams, 'controller');
$match = null;
if (!preg_match('/(.*?)(?=@|$)/', $controller, $match)) {
return;
}
return $match[0];
}
|
php
|
public function getControllerClass()
{
$controller = array_get($this->routeParams, 'controller');
$match = null;
if (!preg_match('/(.*?)(?=@|$)/', $controller, $match)) {
return;
}
return $match[0];
}
|
[
"public",
"function",
"getControllerClass",
"(",
")",
"{",
"$",
"controller",
"=",
"array_get",
"(",
"$",
"this",
"->",
"routeParams",
",",
"'controller'",
")",
";",
"$",
"match",
"=",
"null",
";",
"if",
"(",
"!",
"preg_match",
"(",
"'/(.*?)(?=@|$)/'",
",",
"$",
"controller",
",",
"$",
"match",
")",
")",
"{",
"return",
";",
"}",
"return",
"$",
"match",
"[",
"0",
"]",
";",
"}"
] |
get controller class name
@return String
|
[
"get",
"controller",
"class",
"name"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Request.php#L93-L101
|
228,288
|
antaresproject/core
|
src/foundation/src/Request.php
|
Request.getAction
|
public function getAction()
{
if (!is_null(self::$action)) {
return self::$action;
}
$controllerParam = array_get($this->routeParams, 'controller');
$match = null;
if (!preg_match("/.+?(?=@)@(.*)/", $controllerParam, $match)) {
return;
}
self::$action = strtolower($match[1]);
return self::$action;
}
|
php
|
public function getAction()
{
if (!is_null(self::$action)) {
return self::$action;
}
$controllerParam = array_get($this->routeParams, 'controller');
$match = null;
if (!preg_match("/.+?(?=@)@(.*)/", $controllerParam, $match)) {
return;
}
self::$action = strtolower($match[1]);
return self::$action;
}
|
[
"public",
"function",
"getAction",
"(",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"self",
"::",
"$",
"action",
")",
")",
"{",
"return",
"self",
"::",
"$",
"action",
";",
"}",
"$",
"controllerParam",
"=",
"array_get",
"(",
"$",
"this",
"->",
"routeParams",
",",
"'controller'",
")",
";",
"$",
"match",
"=",
"null",
";",
"if",
"(",
"!",
"preg_match",
"(",
"\"/.+?(?=@)@(.*)/\"",
",",
"$",
"controllerParam",
",",
"$",
"match",
")",
")",
"{",
"return",
";",
"}",
"self",
"::",
"$",
"action",
"=",
"strtolower",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"return",
"self",
"::",
"$",
"action",
";",
"}"
] |
get action name by route
@return String
|
[
"get",
"action",
"name",
"by",
"route"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Request.php#L108-L121
|
228,289
|
antaresproject/core
|
src/foundation/src/Request.php
|
Request.getModule
|
public function getModule()
{
if (!is_null(self::$module)) {
return self::$module;
}
$controllerParam = array_get($this->routeParams, 'controller');
$match = null;
preg_match('/(.*?)(?=@|$)/', $controllerParam, $match);
if (!isset($match[0])) {
return;
}
$reflection = new ReflectionClass($match[0]);
$filename = $reflection->getFileName();
if (!preg_match("'antares(.*?)src'si", $filename, $match)) {
return;
}
$reserved = [
'components', 'modules'
];
self::$module = (str_contains($match[1], 'core')) ? 'core' : trim(str_replace($reserved, '', $match[1]), DIRECTORY_SEPARATOR);
return self::$module;
}
|
php
|
public function getModule()
{
if (!is_null(self::$module)) {
return self::$module;
}
$controllerParam = array_get($this->routeParams, 'controller');
$match = null;
preg_match('/(.*?)(?=@|$)/', $controllerParam, $match);
if (!isset($match[0])) {
return;
}
$reflection = new ReflectionClass($match[0]);
$filename = $reflection->getFileName();
if (!preg_match("'antares(.*?)src'si", $filename, $match)) {
return;
}
$reserved = [
'components', 'modules'
];
self::$module = (str_contains($match[1], 'core')) ? 'core' : trim(str_replace($reserved, '', $match[1]), DIRECTORY_SEPARATOR);
return self::$module;
}
|
[
"public",
"function",
"getModule",
"(",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"self",
"::",
"$",
"module",
")",
")",
"{",
"return",
"self",
"::",
"$",
"module",
";",
"}",
"$",
"controllerParam",
"=",
"array_get",
"(",
"$",
"this",
"->",
"routeParams",
",",
"'controller'",
")",
";",
"$",
"match",
"=",
"null",
";",
"preg_match",
"(",
"'/(.*?)(?=@|$)/'",
",",
"$",
"controllerParam",
",",
"$",
"match",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"match",
"[",
"0",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"match",
"[",
"0",
"]",
")",
";",
"$",
"filename",
"=",
"$",
"reflection",
"->",
"getFileName",
"(",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"\"'antares(.*?)src'si\"",
",",
"$",
"filename",
",",
"$",
"match",
")",
")",
"{",
"return",
";",
"}",
"$",
"reserved",
"=",
"[",
"'components'",
",",
"'modules'",
"]",
";",
"self",
"::",
"$",
"module",
"=",
"(",
"str_contains",
"(",
"$",
"match",
"[",
"1",
"]",
",",
"'core'",
")",
")",
"?",
"'core'",
":",
"trim",
"(",
"str_replace",
"(",
"$",
"reserved",
",",
"''",
",",
"$",
"match",
"[",
"1",
"]",
")",
",",
"DIRECTORY_SEPARATOR",
")",
";",
"return",
"self",
"::",
"$",
"module",
";",
"}"
] |
get module name by route
@return String
|
[
"get",
"module",
"name",
"by",
"route"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Request.php#L128-L149
|
228,290
|
antaresproject/core
|
src/foundation/src/Request.php
|
Request.shouldMakeApiResponse
|
public function shouldMakeApiResponse()
{
$accept = request()->header('Accept');
$accepted = implode('.', [env('API_STANDARDS_TREE'), env('API_SUBTYPE')]);
return request()->wantsJson() && extension_active('api') && str_contains($accept, $accepted) && class_exists('\Antares\Modules\Api\Http\Router\Adapter');
}
|
php
|
public function shouldMakeApiResponse()
{
$accept = request()->header('Accept');
$accepted = implode('.', [env('API_STANDARDS_TREE'), env('API_SUBTYPE')]);
return request()->wantsJson() && extension_active('api') && str_contains($accept, $accepted) && class_exists('\Antares\Modules\Api\Http\Router\Adapter');
}
|
[
"public",
"function",
"shouldMakeApiResponse",
"(",
")",
"{",
"$",
"accept",
"=",
"request",
"(",
")",
"->",
"header",
"(",
"'Accept'",
")",
";",
"$",
"accepted",
"=",
"implode",
"(",
"'.'",
",",
"[",
"env",
"(",
"'API_STANDARDS_TREE'",
")",
",",
"env",
"(",
"'API_SUBTYPE'",
")",
"]",
")",
";",
"return",
"request",
"(",
")",
"->",
"wantsJson",
"(",
")",
"&&",
"extension_active",
"(",
"'api'",
")",
"&&",
"str_contains",
"(",
"$",
"accept",
",",
"$",
"accepted",
")",
"&&",
"class_exists",
"(",
"'\\Antares\\Modules\\Api\\Http\\Router\\Adapter'",
")",
";",
"}"
] |
does the request wants api response
@return boolean
|
[
"does",
"the",
"request",
"wants",
"api",
"response"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Request.php#L156-L161
|
228,291
|
marmelab/SonataElasticaBundle
|
Repository/ElasticaProxyRepository.php
|
ElasticaProxyRepository.getQueryString
|
protected function getQueryString($query)
{
$wrapper = ($query instanceof AbstractQuery) ? array('query' => $query->toArray()) : $query->toArray();
return json_encode($wrapper);
}
|
php
|
protected function getQueryString($query)
{
$wrapper = ($query instanceof AbstractQuery) ? array('query' => $query->toArray()) : $query->toArray();
return json_encode($wrapper);
}
|
[
"protected",
"function",
"getQueryString",
"(",
"$",
"query",
")",
"{",
"$",
"wrapper",
"=",
"(",
"$",
"query",
"instanceof",
"AbstractQuery",
")",
"?",
"array",
"(",
"'query'",
"=>",
"$",
"query",
"->",
"toArray",
"(",
")",
")",
":",
"$",
"query",
"->",
"toArray",
"(",
")",
";",
"return",
"json_encode",
"(",
"$",
"wrapper",
")",
";",
"}"
] |
Useful for debugging with elastic head plugin
@param \Elastica\Query $query
@return string
|
[
"Useful",
"for",
"debugging",
"with",
"elastic",
"head",
"plugin"
] |
7b8a2fde72bca7844060fcae6387641478fe7bdc
|
https://github.com/marmelab/SonataElasticaBundle/blob/7b8a2fde72bca7844060fcae6387641478fe7bdc/Repository/ElasticaProxyRepository.php#L125-L130
|
228,292
|
pxgamer/torrent-parser-php
|
src/WorldWideTorrents.php
|
WorldWideTorrents.search
|
public static function search($search_query)
{
$search_query = urlencode($search_query);
return self::get(self::BASE_URL . '/json.php?dllink=1&q=' . $search_query);
}
|
php
|
public static function search($search_query)
{
$search_query = urlencode($search_query);
return self::get(self::BASE_URL . '/json.php?dllink=1&q=' . $search_query);
}
|
[
"public",
"static",
"function",
"search",
"(",
"$",
"search_query",
")",
"{",
"$",
"search_query",
"=",
"urlencode",
"(",
"$",
"search_query",
")",
";",
"return",
"self",
"::",
"get",
"(",
"self",
"::",
"BASE_URL",
".",
"'/json.php?dllink=1&q='",
".",
"$",
"search_query",
")",
";",
"}"
] |
Search for a specific query string
@param string $search_query
@return Collection
|
[
"Search",
"for",
"a",
"specific",
"query",
"string"
] |
7ad4d44b4701d54630ba775525bd2bd36ee448bb
|
https://github.com/pxgamer/torrent-parser-php/blob/7ad4d44b4701d54630ba775525bd2bd36ee448bb/src/WorldWideTorrents.php#L20-L25
|
228,293
|
pxgamer/torrent-parser-php
|
src/WorldWideTorrents.php
|
WorldWideTorrents.user
|
public static function user($username)
{
$username = urlencode($username);
return self::get(self::BASE_URL . '/json.php?username=' . $username);
}
|
php
|
public static function user($username)
{
$username = urlencode($username);
return self::get(self::BASE_URL . '/json.php?username=' . $username);
}
|
[
"public",
"static",
"function",
"user",
"(",
"$",
"username",
")",
"{",
"$",
"username",
"=",
"urlencode",
"(",
"$",
"username",
")",
";",
"return",
"self",
"::",
"get",
"(",
"self",
"::",
"BASE_URL",
".",
"'/json.php?username='",
".",
"$",
"username",
")",
";",
"}"
] |
Search for torrents by a specific username
@param string $username
@return Collection
|
[
"Search",
"for",
"torrents",
"by",
"a",
"specific",
"username"
] |
7ad4d44b4701d54630ba775525bd2bd36ee448bb
|
https://github.com/pxgamer/torrent-parser-php/blob/7ad4d44b4701d54630ba775525bd2bd36ee448bb/src/WorldWideTorrents.php#L43-L48
|
228,294
|
pxgamer/torrent-parser-php
|
src/WorldWideTorrents.php
|
WorldWideTorrents.createCollection
|
private static function createCollection($responseData)
{
$collection = new Collection();
foreach ($responseData as $element) {
$torrent = new Torrent();
$torrent->title = $element['title'] ?? null;
$torrent->hash = $element['info_hash'] ?? null;
$torrent->link = $element['link'] ?? null;
$torrent->category = $element['category'] ?? null;
$torrent->size = $element['size'] ?? null;
$torrent->date = $element['publish_date'] ?? null;
if ($torrent->size) {
$torrent->size = (int)$torrent->size;
}
if ($torrent->date) {
$torrent->date = new \DateTime($torrent->date);
}
$collection[] = $torrent;
}
return $collection;
}
|
php
|
private static function createCollection($responseData)
{
$collection = new Collection();
foreach ($responseData as $element) {
$torrent = new Torrent();
$torrent->title = $element['title'] ?? null;
$torrent->hash = $element['info_hash'] ?? null;
$torrent->link = $element['link'] ?? null;
$torrent->category = $element['category'] ?? null;
$torrent->size = $element['size'] ?? null;
$torrent->date = $element['publish_date'] ?? null;
if ($torrent->size) {
$torrent->size = (int)$torrent->size;
}
if ($torrent->date) {
$torrent->date = new \DateTime($torrent->date);
}
$collection[] = $torrent;
}
return $collection;
}
|
[
"private",
"static",
"function",
"createCollection",
"(",
"$",
"responseData",
")",
"{",
"$",
"collection",
"=",
"new",
"Collection",
"(",
")",
";",
"foreach",
"(",
"$",
"responseData",
"as",
"$",
"element",
")",
"{",
"$",
"torrent",
"=",
"new",
"Torrent",
"(",
")",
";",
"$",
"torrent",
"->",
"title",
"=",
"$",
"element",
"[",
"'title'",
"]",
"??",
"null",
";",
"$",
"torrent",
"->",
"hash",
"=",
"$",
"element",
"[",
"'info_hash'",
"]",
"??",
"null",
";",
"$",
"torrent",
"->",
"link",
"=",
"$",
"element",
"[",
"'link'",
"]",
"??",
"null",
";",
"$",
"torrent",
"->",
"category",
"=",
"$",
"element",
"[",
"'category'",
"]",
"??",
"null",
";",
"$",
"torrent",
"->",
"size",
"=",
"$",
"element",
"[",
"'size'",
"]",
"??",
"null",
";",
"$",
"torrent",
"->",
"date",
"=",
"$",
"element",
"[",
"'publish_date'",
"]",
"??",
"null",
";",
"if",
"(",
"$",
"torrent",
"->",
"size",
")",
"{",
"$",
"torrent",
"->",
"size",
"=",
"(",
"int",
")",
"$",
"torrent",
"->",
"size",
";",
"}",
"if",
"(",
"$",
"torrent",
"->",
"date",
")",
"{",
"$",
"torrent",
"->",
"date",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"torrent",
"->",
"date",
")",
";",
"}",
"$",
"collection",
"[",
"]",
"=",
"$",
"torrent",
";",
"}",
"return",
"$",
"collection",
";",
"}"
] |
Create a new Collection of Torrent instances
@param array $responseData
@return Collection
|
[
"Create",
"a",
"new",
"Collection",
"of",
"Torrent",
"instances"
] |
7ad4d44b4701d54630ba775525bd2bd36ee448bb
|
https://github.com/pxgamer/torrent-parser-php/blob/7ad4d44b4701d54630ba775525bd2bd36ee448bb/src/WorldWideTorrents.php#L79-L105
|
228,295
|
lawoole/framework
|
src/WebSocket/HandShakeResponse.php
|
HandShakeResponse.accept
|
public static function accept($request, $handler)
{
static::checkRequest($request);
$webSocketAccept = base64_encode(
sha1($request->getWebSocketKey().'258EAFA5-E914-47DA-95CA-C5AB0DC85B11', true)
);
$response = static::create('', self::HTTP_SWITCHING_PROTOCOLS);
$response->header('Upgrade', 'websocket');
$response->header('Connection', 'Upgrade');
$response->header('Sec-WebSocket-Accept', $webSocketAccept);
$response->header('Sec-WebSocket-Version', '13');
// WebSocket connection to 'ws://127.0.0.1:9502/'
// failed: Error during WebSocket handshake:
// Response must not include 'Sec-WebSocket-Protocol' header if not present in request: websocket
if ($webSocketProtocol = $request->getWebSocketProtocol()) {
$response->header('Sec-WebSocket-Protocol', $webSocketProtocol);
}
if ($handler !== null) {
$response->setHandler($handler);
}
return $response;
}
|
php
|
public static function accept($request, $handler)
{
static::checkRequest($request);
$webSocketAccept = base64_encode(
sha1($request->getWebSocketKey().'258EAFA5-E914-47DA-95CA-C5AB0DC85B11', true)
);
$response = static::create('', self::HTTP_SWITCHING_PROTOCOLS);
$response->header('Upgrade', 'websocket');
$response->header('Connection', 'Upgrade');
$response->header('Sec-WebSocket-Accept', $webSocketAccept);
$response->header('Sec-WebSocket-Version', '13');
// WebSocket connection to 'ws://127.0.0.1:9502/'
// failed: Error during WebSocket handshake:
// Response must not include 'Sec-WebSocket-Protocol' header if not present in request: websocket
if ($webSocketProtocol = $request->getWebSocketProtocol()) {
$response->header('Sec-WebSocket-Protocol', $webSocketProtocol);
}
if ($handler !== null) {
$response->setHandler($handler);
}
return $response;
}
|
[
"public",
"static",
"function",
"accept",
"(",
"$",
"request",
",",
"$",
"handler",
")",
"{",
"static",
"::",
"checkRequest",
"(",
"$",
"request",
")",
";",
"$",
"webSocketAccept",
"=",
"base64_encode",
"(",
"sha1",
"(",
"$",
"request",
"->",
"getWebSocketKey",
"(",
")",
".",
"'258EAFA5-E914-47DA-95CA-C5AB0DC85B11'",
",",
"true",
")",
")",
";",
"$",
"response",
"=",
"static",
"::",
"create",
"(",
"''",
",",
"self",
"::",
"HTTP_SWITCHING_PROTOCOLS",
")",
";",
"$",
"response",
"->",
"header",
"(",
"'Upgrade'",
",",
"'websocket'",
")",
";",
"$",
"response",
"->",
"header",
"(",
"'Connection'",
",",
"'Upgrade'",
")",
";",
"$",
"response",
"->",
"header",
"(",
"'Sec-WebSocket-Accept'",
",",
"$",
"webSocketAccept",
")",
";",
"$",
"response",
"->",
"header",
"(",
"'Sec-WebSocket-Version'",
",",
"'13'",
")",
";",
"// WebSocket connection to 'ws://127.0.0.1:9502/'",
"// failed: Error during WebSocket handshake:",
"// Response must not include 'Sec-WebSocket-Protocol' header if not present in request: websocket",
"if",
"(",
"$",
"webSocketProtocol",
"=",
"$",
"request",
"->",
"getWebSocketProtocol",
"(",
")",
")",
"{",
"$",
"response",
"->",
"header",
"(",
"'Sec-WebSocket-Protocol'",
",",
"$",
"webSocketProtocol",
")",
";",
"}",
"if",
"(",
"$",
"handler",
"!==",
"null",
")",
"{",
"$",
"response",
"->",
"setHandler",
"(",
"$",
"handler",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
Accept the handshake request and open the connection.
@param \Illuminate\Http\Request $request
@param \Lawoole\Contracts\WebSocket\WebSocketHandler $handler
@return static
|
[
"Accept",
"the",
"handshake",
"request",
"and",
"open",
"the",
"connection",
"."
] |
ac701a76f5d37c81273b7202ba37094766cb5dfe
|
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/WebSocket/HandShakeResponse.php#L55-L82
|
228,296
|
gggeek/ggwebservices
|
classes/ggxmlrpcresponse.php
|
ggXMLRPCResponse.payload
|
function payload()
{
if ( $this->IsFault )
{
$payload = xmlrpc_encode( array(
"faultCode" => $this->FaultCode,
"faultString" => $this->FaultString ) );
return str_replace( array( '<fault>', '</fault>' ), array( '<methodResponse><fault>', '</fault></methodResponse>' ), $payload );
}
else
{
$payload = xmlrpc_encode( $this->Value );
/// @todo verify if user gave us back an array with faultString / faultCode members,
/// as we will be sending back junk in that case...
return str_replace( array( '<params>', '</params>' ), array( '<methodResponse><params>', '</params></methodResponse>' ), $payload );
}
}
|
php
|
function payload()
{
if ( $this->IsFault )
{
$payload = xmlrpc_encode( array(
"faultCode" => $this->FaultCode,
"faultString" => $this->FaultString ) );
return str_replace( array( '<fault>', '</fault>' ), array( '<methodResponse><fault>', '</fault></methodResponse>' ), $payload );
}
else
{
$payload = xmlrpc_encode( $this->Value );
/// @todo verify if user gave us back an array with faultString / faultCode members,
/// as we will be sending back junk in that case...
return str_replace( array( '<params>', '</params>' ), array( '<methodResponse><params>', '</params></methodResponse>' ), $payload );
}
}
|
[
"function",
"payload",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"IsFault",
")",
"{",
"$",
"payload",
"=",
"xmlrpc_encode",
"(",
"array",
"(",
"\"faultCode\"",
"=>",
"$",
"this",
"->",
"FaultCode",
",",
"\"faultString\"",
"=>",
"$",
"this",
"->",
"FaultString",
")",
")",
";",
"return",
"str_replace",
"(",
"array",
"(",
"'<fault>'",
",",
"'</fault>'",
")",
",",
"array",
"(",
"'<methodResponse><fault>'",
",",
"'</fault></methodResponse>'",
")",
",",
"$",
"payload",
")",
";",
"}",
"else",
"{",
"$",
"payload",
"=",
"xmlrpc_encode",
"(",
"$",
"this",
"->",
"Value",
")",
";",
"/// @todo verify if user gave us back an array with faultString / faultCode members,",
"/// as we will be sending back junk in that case...",
"return",
"str_replace",
"(",
"array",
"(",
"'<params>'",
",",
"'</params>'",
")",
",",
"array",
"(",
"'<methodResponse><params>'",
",",
"'</params></methodResponse>'",
")",
",",
"$",
"payload",
")",
";",
"}",
"}"
] |
Returns the xmlrpc payload for the response.
|
[
"Returns",
"the",
"xmlrpc",
"payload",
"for",
"the",
"response",
"."
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggxmlrpcresponse.php#L18-L34
|
228,297
|
gggeek/ggwebservices
|
classes/ggxmlrpcresponse.php
|
ggXMLRPCResponse.decodeStream
|
function decodeStream( $request, $stream, $headers=false, $cookies=array(), $statuscode="200" )
{
$this->decodeStreamCommon( $request, $stream, $headers, $cookies, $statuscode );
/// @todo refuse bad content-types?
/// @todo test if this automatically groks encoding from xml or not...
$results = xmlrpc_decode( $stream );
if ( $results === null )
{
// invalid XMLRPC response
$this->IsFault = true;
$this->FaultCode = self::INVALIDRESPONSEERROR;
$this->FaultString = self::INVALIDRESPONSESTRING;
}
else
{
if ( !is_array( $results ) || count( $results ) != 2 || !isset( $results['faultCode'] ) || !isset( $results['faultString'] ) )
{
$this->Value = $results;
}
else
{
$this->IsFault = true;
$this->FaultCode = $results['faultCode'];
$this->FaultString = $results['faultString'];
}
}
}
|
php
|
function decodeStream( $request, $stream, $headers=false, $cookies=array(), $statuscode="200" )
{
$this->decodeStreamCommon( $request, $stream, $headers, $cookies, $statuscode );
/// @todo refuse bad content-types?
/// @todo test if this automatically groks encoding from xml or not...
$results = xmlrpc_decode( $stream );
if ( $results === null )
{
// invalid XMLRPC response
$this->IsFault = true;
$this->FaultCode = self::INVALIDRESPONSEERROR;
$this->FaultString = self::INVALIDRESPONSESTRING;
}
else
{
if ( !is_array( $results ) || count( $results ) != 2 || !isset( $results['faultCode'] ) || !isset( $results['faultString'] ) )
{
$this->Value = $results;
}
else
{
$this->IsFault = true;
$this->FaultCode = $results['faultCode'];
$this->FaultString = $results['faultString'];
}
}
}
|
[
"function",
"decodeStream",
"(",
"$",
"request",
",",
"$",
"stream",
",",
"$",
"headers",
"=",
"false",
",",
"$",
"cookies",
"=",
"array",
"(",
")",
",",
"$",
"statuscode",
"=",
"\"200\"",
")",
"{",
"$",
"this",
"->",
"decodeStreamCommon",
"(",
"$",
"request",
",",
"$",
"stream",
",",
"$",
"headers",
",",
"$",
"cookies",
",",
"$",
"statuscode",
")",
";",
"/// @todo refuse bad content-types?",
"/// @todo test if this automatically groks encoding from xml or not...",
"$",
"results",
"=",
"xmlrpc_decode",
"(",
"$",
"stream",
")",
";",
"if",
"(",
"$",
"results",
"===",
"null",
")",
"{",
"// invalid XMLRPC response",
"$",
"this",
"->",
"IsFault",
"=",
"true",
";",
"$",
"this",
"->",
"FaultCode",
"=",
"self",
"::",
"INVALIDRESPONSEERROR",
";",
"$",
"this",
"->",
"FaultString",
"=",
"self",
"::",
"INVALIDRESPONSESTRING",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"results",
")",
"||",
"count",
"(",
"$",
"results",
")",
"!=",
"2",
"||",
"!",
"isset",
"(",
"$",
"results",
"[",
"'faultCode'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"results",
"[",
"'faultString'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"Value",
"=",
"$",
"results",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"IsFault",
"=",
"true",
";",
"$",
"this",
"->",
"FaultCode",
"=",
"$",
"results",
"[",
"'faultCode'",
"]",
";",
"$",
"this",
"->",
"FaultString",
"=",
"$",
"results",
"[",
"'faultString'",
"]",
";",
"}",
"}",
"}"
] |
Decodes the XMLRPC response stream.
@bug apparently xmlrpc_decode happily parses many xml ansers, wuch as eg. a soap response...
|
[
"Decodes",
"the",
"XMLRPC",
"response",
"stream",
"."
] |
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
|
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggxmlrpcresponse.php#L41-L71
|
228,298
|
antaresproject/core
|
src/components/memory/src/Handlers/Primary.php
|
Primary.forceDelete
|
public function forceDelete($key)
{
!is_null($this->cache) && $this->cache->forget($this->cacheKey);
$model = $this->resolver()->where('name', $key);
if (!is_null($model)) {
return $model->delete();
}
return false;
}
|
php
|
public function forceDelete($key)
{
!is_null($this->cache) && $this->cache->forget($this->cacheKey);
$model = $this->resolver()->where('name', $key);
if (!is_null($model)) {
return $model->delete();
}
return false;
}
|
[
"public",
"function",
"forceDelete",
"(",
"$",
"key",
")",
"{",
"!",
"is_null",
"(",
"$",
"this",
"->",
"cache",
")",
"&&",
"$",
"this",
"->",
"cache",
"->",
"forget",
"(",
"$",
"this",
"->",
"cacheKey",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"resolver",
"(",
")",
"->",
"where",
"(",
"'name'",
",",
"$",
"key",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"model",
")",
")",
"{",
"return",
"$",
"model",
"->",
"delete",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
deletes item from resolver
@param String $key
@return boolean
|
[
"deletes",
"item",
"from",
"resolver"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/src/Handlers/Primary.php#L149-L157
|
228,299
|
antaresproject/core
|
src/utils/customfield/src/Traits/Customfields.php
|
Customfields.getAssignedCustomfields
|
protected function getAssignedCustomfields()
{
$customfields = array_get(app('customfields')->get(), get_called_class(), []);
return !is_array($customfields) ? [$customfields] : $customfields;
}
|
php
|
protected function getAssignedCustomfields()
{
$customfields = array_get(app('customfields')->get(), get_called_class(), []);
return !is_array($customfields) ? [$customfields] : $customfields;
}
|
[
"protected",
"function",
"getAssignedCustomfields",
"(",
")",
"{",
"$",
"customfields",
"=",
"array_get",
"(",
"app",
"(",
"'customfields'",
")",
"->",
"get",
"(",
")",
",",
"get_called_class",
"(",
")",
",",
"[",
"]",
")",
";",
"return",
"!",
"is_array",
"(",
"$",
"customfields",
")",
"?",
"[",
"$",
"customfields",
"]",
":",
"$",
"customfields",
";",
"}"
] |
Gets assigned customfieldsa
@return array
|
[
"Gets",
"assigned",
"customfieldsa"
] |
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
|
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/customfield/src/Traits/Customfields.php#L31-L36
|
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.