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,100
antaresproject/core
src/components/extension/src/Loader.php
Loader.dispatch
protected function dispatch(array $services) { foreach ($services as $provider => $options) { $this->loadDeferredServiceProvider($provider, $options); $this->loadEagerServiceProvider($provider, $options); $this->loadQueuedServiceProvider($provider, $options); unset($options['instance']); $this->compiled[$provider] = $options; } }
php
protected function dispatch(array $services) { foreach ($services as $provider => $options) { $this->loadDeferredServiceProvider($provider, $options); $this->loadEagerServiceProvider($provider, $options); $this->loadQueuedServiceProvider($provider, $options); unset($options['instance']); $this->compiled[$provider] = $options; } }
[ "protected", "function", "dispatch", "(", "array", "$", "services", ")", "{", "foreach", "(", "$", "services", "as", "$", "provider", "=>", "$", "options", ")", "{", "$", "this", "->", "loadDeferredServiceProvider", "(", "$", "provider", ",", "$", "options", ")", ";", "$", "this", "->", "loadEagerServiceProvider", "(", "$", "provider", ",", "$", "options", ")", ";", "$", "this", "->", "loadQueuedServiceProvider", "(", "$", "provider", ",", "$", "options", ")", ";", "unset", "(", "$", "options", "[", "'instance'", "]", ")", ";", "$", "this", "->", "compiled", "[", "$", "provider", "]", "=", "$", "options", ";", "}", "}" ]
Register all deferred service providers. @param $services @return void
[ "Register", "all", "deferred", "service", "providers", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Loader.php#L139-L150
228,101
antaresproject/core
src/components/extension/src/Loader.php
Loader.registerDeferredServiceProvider
protected function registerDeferredServiceProvider($provider, ServiceProvider $instance): array { $deferred = []; foreach ($instance->provides() as $provide) { $deferred[$provide] = $provider; } return [ 'instance' => $instance, 'eager' => false, 'when' => $instance->when(), 'deferred' => $deferred, ]; }
php
protected function registerDeferredServiceProvider($provider, ServiceProvider $instance): array { $deferred = []; foreach ($instance->provides() as $provide) { $deferred[$provide] = $provider; } return [ 'instance' => $instance, 'eager' => false, 'when' => $instance->when(), 'deferred' => $deferred, ]; }
[ "protected", "function", "registerDeferredServiceProvider", "(", "$", "provider", ",", "ServiceProvider", "$", "instance", ")", ":", "array", "{", "$", "deferred", "=", "[", "]", ";", "foreach", "(", "$", "instance", "->", "provides", "(", ")", "as", "$", "provide", ")", "{", "$", "deferred", "[", "$", "provide", "]", "=", "$", "provider", ";", "}", "return", "[", "'instance'", "=>", "$", "instance", ",", "'eager'", "=>", "false", ",", "'when'", "=>", "$", "instance", "->", "when", "(", ")", ",", "'deferred'", "=>", "$", "deferred", ",", "]", ";", "}" ]
Register deferred service provider. @param string $provider @param ServiceProvider $instance @return array
[ "Register", "deferred", "service", "provider", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Loader.php#L222-L236
228,102
antaresproject/core
src/components/extension/src/Loader.php
Loader.loadEagerServiceProvider
protected function loadEagerServiceProvider($provider, array $options) { if (!$options['eager']) { return; } $instance = Arr::get($options, 'instance', $provider); $this->app->register($instance); }
php
protected function loadEagerServiceProvider($provider, array $options) { if (!$options['eager']) { return; } $instance = Arr::get($options, 'instance', $provider); $this->app->register($instance); }
[ "protected", "function", "loadEagerServiceProvider", "(", "$", "provider", ",", "array", "$", "options", ")", "{", "if", "(", "!", "$", "options", "[", "'eager'", "]", ")", "{", "return", ";", "}", "$", "instance", "=", "Arr", "::", "get", "(", "$", "options", ",", "'instance'", ",", "$", "provider", ")", ";", "$", "this", "->", "app", "->", "register", "(", "$", "instance", ")", ";", "}" ]
Load eager service provider. @param string $provider @param array $options @return void
[ "Load", "eager", "service", "provider", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Loader.php#L280-L289
228,103
antaresproject/core
src/components/extension/src/Loader.php
Loader.loadQueuedServiceProvider
protected function loadQueuedServiceProvider($provider, array $options) { $listeners = (array) Arr::get($options, 'when', []); foreach ($listeners as $listen) { $this->events->listen($listen, function () use ($provider, $options) { $instance = Arr::get($options, 'instance', $provider); $this->app->register($instance); }); } }
php
protected function loadQueuedServiceProvider($provider, array $options) { $listeners = (array) Arr::get($options, 'when', []); foreach ($listeners as $listen) { $this->events->listen($listen, function () use ($provider, $options) { $instance = Arr::get($options, 'instance', $provider); $this->app->register($instance); }); } }
[ "protected", "function", "loadQueuedServiceProvider", "(", "$", "provider", ",", "array", "$", "options", ")", "{", "$", "listeners", "=", "(", "array", ")", "Arr", "::", "get", "(", "$", "options", ",", "'when'", ",", "[", "]", ")", ";", "foreach", "(", "$", "listeners", "as", "$", "listen", ")", "{", "$", "this", "->", "events", "->", "listen", "(", "$", "listen", ",", "function", "(", ")", "use", "(", "$", "provider", ",", "$", "options", ")", "{", "$", "instance", "=", "Arr", "::", "get", "(", "$", "options", ",", "'instance'", ",", "$", "provider", ")", ";", "$", "this", "->", "app", "->", "register", "(", "$", "instance", ")", ";", "}", ")", ";", "}", "}" ]
Load queued service provider. @param string $provider @param array $options @return void
[ "Load", "queued", "service", "provider", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Loader.php#L299-L310
228,104
antaresproject/core
src/components/extension/src/Collections/Extensions.php
Extensions.findByVendorAndName
public function findByVendorAndName(string $vendor, string $name) { $fullName = $vendor . '/' . $name; return $this->first(function(ExtensionContract $extension) use($fullName) { return $extension->getPackage()->getName() === $fullName; }); }
php
public function findByVendorAndName(string $vendor, string $name) { $fullName = $vendor . '/' . $name; return $this->first(function(ExtensionContract $extension) use($fullName) { return $extension->getPackage()->getName() === $fullName; }); }
[ "public", "function", "findByVendorAndName", "(", "string", "$", "vendor", ",", "string", "$", "name", ")", "{", "$", "fullName", "=", "$", "vendor", ".", "'/'", ".", "$", "name", ";", "return", "$", "this", "->", "first", "(", "function", "(", "ExtensionContract", "$", "extension", ")", "use", "(", "$", "fullName", ")", "{", "return", "$", "extension", "->", "getPackage", "(", ")", "->", "getName", "(", ")", "===", "$", "fullName", ";", "}", ")", ";", "}" ]
Returns the first extension by the given vendor and name. @param string $vendor @param string $name @return ExtensionContract|null
[ "Returns", "the", "first", "extension", "by", "the", "given", "vendor", "and", "name", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Collections/Extensions.php#L48-L55
228,105
antaresproject/core
src/components/extension/src/Collections/Extensions.php
Extensions.findByPath
public function findByPath(string $path) { return $this->first(function(ExtensionContract $extension) use($path) { return $extension->getPath() === $path; }); }
php
public function findByPath(string $path) { return $this->first(function(ExtensionContract $extension) use($path) { return $extension->getPath() === $path; }); }
[ "public", "function", "findByPath", "(", "string", "$", "path", ")", "{", "return", "$", "this", "->", "first", "(", "function", "(", "ExtensionContract", "$", "extension", ")", "use", "(", "$", "path", ")", "{", "return", "$", "extension", "->", "getPath", "(", ")", "===", "$", "path", ";", "}", ")", ";", "}" ]
Returns the first extension by the file path. @param string $path @return ExtensionContract|null
[ "Returns", "the", "first", "extension", "by", "the", "file", "path", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Collections/Extensions.php#L63-L68
228,106
antaresproject/core
src/foundation/src/Http/Breadcrumb/Breadcrumb.php
Breadcrumb.onSecurity
public function onSecurity() { Breadcrumbs::register('general-config', function($breadcrumbs) { $breadcrumbs->push('General configuration'); }); Breadcrumbs::register('security', function($breadcrumbs) { $breadcrumbs->parent('general-config'); $breadcrumbs->push('Security', handles('antares/foundation::settings/security')); }); view()->share('breadcrumbs', Breadcrumbs::render('security')); }
php
public function onSecurity() { Breadcrumbs::register('general-config', function($breadcrumbs) { $breadcrumbs->push('General configuration'); }); Breadcrumbs::register('security', function($breadcrumbs) { $breadcrumbs->parent('general-config'); $breadcrumbs->push('Security', handles('antares/foundation::settings/security')); }); view()->share('breadcrumbs', Breadcrumbs::render('security')); }
[ "public", "function", "onSecurity", "(", ")", "{", "Breadcrumbs", "::", "register", "(", "'general-config'", ",", "function", "(", "$", "breadcrumbs", ")", "{", "$", "breadcrumbs", "->", "push", "(", "'General configuration'", ")", ";", "}", ")", ";", "Breadcrumbs", "::", "register", "(", "'security'", ",", "function", "(", "$", "breadcrumbs", ")", "{", "$", "breadcrumbs", "->", "parent", "(", "'general-config'", ")", ";", "$", "breadcrumbs", "->", "push", "(", "'Security'", ",", "handles", "(", "'antares/foundation::settings/security'", ")", ")", ";", "}", ")", ";", "view", "(", ")", "->", "share", "(", "'breadcrumbs'", ",", "Breadcrumbs", "::", "render", "(", "'security'", ")", ")", ";", "}" ]
When shows security section
[ "When", "shows", "security", "section" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Breadcrumb/Breadcrumb.php#L32-L43
228,107
antaresproject/core
src/foundation/src/Http/Breadcrumb/Breadcrumb.php
Breadcrumb.onComponentsList
public function onComponentsList() { if (!Breadcrumbs::exists('modules')) { Breadcrumbs::register('modules', function($breadcrumbs) { $breadcrumbs->push('Modules', handles('antares::modules')); }); } view()->share('breadcrumbs', Breadcrumbs::render('modules')); }
php
public function onComponentsList() { if (!Breadcrumbs::exists('modules')) { Breadcrumbs::register('modules', function($breadcrumbs) { $breadcrumbs->push('Modules', handles('antares::modules')); }); } view()->share('breadcrumbs', Breadcrumbs::render('modules')); }
[ "public", "function", "onComponentsList", "(", ")", "{", "if", "(", "!", "Breadcrumbs", "::", "exists", "(", "'modules'", ")", ")", "{", "Breadcrumbs", "::", "register", "(", "'modules'", ",", "function", "(", "$", "breadcrumbs", ")", "{", "$", "breadcrumbs", "->", "push", "(", "'Modules'", ",", "handles", "(", "'antares::modules'", ")", ")", ";", "}", ")", ";", "}", "view", "(", ")", "->", "share", "(", "'breadcrumbs'", ",", "Breadcrumbs", "::", "render", "(", "'modules'", ")", ")", ";", "}" ]
when shows components list
[ "when", "shows", "components", "list" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Breadcrumb/Breadcrumb.php#L63-L71
228,108
antaresproject/core
src/foundation/src/Http/Breadcrumb/Breadcrumb.php
Breadcrumb.onComponentConfigure
public function onComponentConfigure($component) { $this->onComponentsList(); Breadcrumbs::register('component-configure', function($breadcrumbs) use($component) { $breadcrumbs->parent('components'); $breadcrumbs->push('Configuration: ' . $component->getFullName()); }); view()->share('breadcrumbs', Breadcrumbs::render('component-configure')); }
php
public function onComponentConfigure($component) { $this->onComponentsList(); Breadcrumbs::register('component-configure', function($breadcrumbs) use($component) { $breadcrumbs->parent('components'); $breadcrumbs->push('Configuration: ' . $component->getFullName()); }); view()->share('breadcrumbs', Breadcrumbs::render('component-configure')); }
[ "public", "function", "onComponentConfigure", "(", "$", "component", ")", "{", "$", "this", "->", "onComponentsList", "(", ")", ";", "Breadcrumbs", "::", "register", "(", "'component-configure'", ",", "function", "(", "$", "breadcrumbs", ")", "use", "(", "$", "component", ")", "{", "$", "breadcrumbs", "->", "parent", "(", "'components'", ")", ";", "$", "breadcrumbs", "->", "push", "(", "'Configuration: '", ".", "$", "component", "->", "getFullName", "(", ")", ")", ";", "}", ")", ";", "view", "(", ")", "->", "share", "(", "'breadcrumbs'", ",", "Breadcrumbs", "::", "render", "(", "'component-configure'", ")", ")", ";", "}" ]
when shows component configuration form @param String $component
[ "when", "shows", "component", "configuration", "form" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Http/Breadcrumb/Breadcrumb.php#L78-L86
228,109
brick/http
src/UploadedFileMap.php
UploadedFileMap.buildMap
private static function buildMap(array $files, array & $destination) : void { foreach ($files as $structure) { foreach ($structure as $key => $value) { $subFiles = []; foreach ($files as $uploadKey => $data) { $subFiles[$uploadKey] = $data[$key]; } if (is_array($value)) { $destination[$key] = []; self::buildMap($subFiles, $destination[$key]); } else { $destination[$key] = UploadedFile::create($subFiles); } } // Only one of the entries was needed to get the structure. break; } }
php
private static function buildMap(array $files, array & $destination) : void { foreach ($files as $structure) { foreach ($structure as $key => $value) { $subFiles = []; foreach ($files as $uploadKey => $data) { $subFiles[$uploadKey] = $data[$key]; } if (is_array($value)) { $destination[$key] = []; self::buildMap($subFiles, $destination[$key]); } else { $destination[$key] = UploadedFile::create($subFiles); } } // Only one of the entries was needed to get the structure. break; } }
[ "private", "static", "function", "buildMap", "(", "array", "$", "files", ",", "array", "&", "$", "destination", ")", ":", "void", "{", "foreach", "(", "$", "files", "as", "$", "structure", ")", "{", "foreach", "(", "$", "structure", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "subFiles", "=", "[", "]", ";", "foreach", "(", "$", "files", "as", "$", "uploadKey", "=>", "$", "data", ")", "{", "$", "subFiles", "[", "$", "uploadKey", "]", "=", "$", "data", "[", "$", "key", "]", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "destination", "[", "$", "key", "]", "=", "[", "]", ";", "self", "::", "buildMap", "(", "$", "subFiles", ",", "$", "destination", "[", "$", "key", "]", ")", ";", "}", "else", "{", "$", "destination", "[", "$", "key", "]", "=", "UploadedFile", "::", "create", "(", "$", "subFiles", ")", ";", "}", "}", "// Only one of the entries was needed to get the structure.", "break", ";", "}", "}" ]
Recursively builds the map of UploadedFile instances. @param array $files @param array $destination @return void
[ "Recursively", "builds", "the", "map", "of", "UploadedFile", "instances", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/UploadedFileMap.php#L67-L87
228,110
antaresproject/core
src/foundation/src/Console/Commands/QueueCommand.php
QueueCommand.getParams
protected function getParams($name = null) { $queues = !is_null($name) ? [$name] : $this->getQueues(); $params = [ config('queue.default'), ]; if (empty($queues)) { return $params; } $queue = implode(',', $queues); if ($this->isCli()) { array_push($params, '--queue ' . $queue); } else { $params['--queue'] = $queue; } unset($queues); return $params; }
php
protected function getParams($name = null) { $queues = !is_null($name) ? [$name] : $this->getQueues(); $params = [ config('queue.default'), ]; if (empty($queues)) { return $params; } $queue = implode(',', $queues); if ($this->isCli()) { array_push($params, '--queue ' . $queue); } else { $params['--queue'] = $queue; } unset($queues); return $params; }
[ "protected", "function", "getParams", "(", "$", "name", "=", "null", ")", "{", "$", "queues", "=", "!", "is_null", "(", "$", "name", ")", "?", "[", "$", "name", "]", ":", "$", "this", "->", "getQueues", "(", ")", ";", "$", "params", "=", "[", "config", "(", "'queue.default'", ")", ",", "]", ";", "if", "(", "empty", "(", "$", "queues", ")", ")", "{", "return", "$", "params", ";", "}", "$", "queue", "=", "implode", "(", "','", ",", "$", "queues", ")", ";", "if", "(", "$", "this", "->", "isCli", "(", ")", ")", "{", "array_push", "(", "$", "params", ",", "'--queue '", ".", "$", "queue", ")", ";", "}", "else", "{", "$", "params", "[", "'--queue'", "]", "=", "$", "queue", ";", "}", "unset", "(", "$", "queues", ")", ";", "return", "$", "params", ";", "}" ]
get params depends on queues and execution source @return String
[ "get", "params", "depends", "on", "queues", "and", "execution", "source" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Console/Commands/QueueCommand.php#L141-L161
228,111
gggeek/ggwebservices
lib/ezjscore/ezjscore.inc.php
ezjscoreresp.serialize
function serialize($charset_encoding='') { if ($charset_encoding != '') $this->content_type = $this->content_type . '; charset=' . $charset_encoding; else $this->content_type = $this->content_type; $this->payload = serialize_ezjscoreresp($this, $charset_encoding, $this->content_type); return $this->payload; }
php
function serialize($charset_encoding='') { if ($charset_encoding != '') $this->content_type = $this->content_type . '; charset=' . $charset_encoding; else $this->content_type = $this->content_type; $this->payload = serialize_ezjscoreresp($this, $charset_encoding, $this->content_type); return $this->payload; }
[ "function", "serialize", "(", "$", "charset_encoding", "=", "''", ")", "{", "if", "(", "$", "charset_encoding", "!=", "''", ")", "$", "this", "->", "content_type", "=", "$", "this", "->", "content_type", ".", "'; charset='", ".", "$", "charset_encoding", ";", "else", "$", "this", "->", "content_type", "=", "$", "this", "->", "content_type", ";", "$", "this", "->", "payload", "=", "serialize_ezjscoreresp", "(", "$", "this", ",", "$", "charset_encoding", ",", "$", "this", "->", "content_type", ")", ";", "return", "$", "this", "->", "payload", ";", "}" ]
Returns textual representation of the response. @param string $charset_encoding the charset to be used for serialization. if null, US-ASCII is assumed @return string the json representation of the response @access public
[ "Returns", "textual", "representation", "of", "the", "response", "." ]
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/lib/ezjscore/ezjscore.inc.php#L228-L236
228,112
antaresproject/core
src/components/support/src/Support/Collection.php
Collection.resolveCsvHeader
protected function resolveCsvHeader() { $header = []; if (!$this->isEmpty()) { $single = $this->first(); $header = array_keys(Arr::dot($single)); } return $header; }
php
protected function resolveCsvHeader() { $header = []; if (!$this->isEmpty()) { $single = $this->first(); $header = array_keys(Arr::dot($single)); } return $header; }
[ "protected", "function", "resolveCsvHeader", "(", ")", "{", "$", "header", "=", "[", "]", ";", "if", "(", "!", "$", "this", "->", "isEmpty", "(", ")", ")", "{", "$", "single", "=", "$", "this", "->", "first", "(", ")", ";", "$", "header", "=", "array_keys", "(", "Arr", "::", "dot", "(", "$", "single", ")", ")", ";", "}", "return", "$", "header", ";", "}" ]
Resolve CSV header. @return array
[ "Resolve", "CSV", "header", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Support/Collection.php#L59-L69
228,113
antaresproject/core
src/components/support/src/Support/Collection.php
Collection.except_by_key
public function except_by_key($field, $keys) { return $this->filter(function($fieldset) use($field, $keys) { if (isset($fieldset->{$field}) and in_array($fieldset->{$field}, $keys)) { return false; } }); }
php
public function except_by_key($field, $keys) { return $this->filter(function($fieldset) use($field, $keys) { if (isset($fieldset->{$field}) and in_array($fieldset->{$field}, $keys)) { return false; } }); }
[ "public", "function", "except_by_key", "(", "$", "field", ",", "$", "keys", ")", "{", "return", "$", "this", "->", "filter", "(", "function", "(", "$", "fieldset", ")", "use", "(", "$", "field", ",", "$", "keys", ")", "{", "if", "(", "isset", "(", "$", "fieldset", "->", "{", "$", "field", "}", ")", "and", "in_array", "(", "$", "fieldset", "->", "{", "$", "field", "}", ",", "$", "keys", ")", ")", "{", "return", "false", ";", "}", "}", ")", ";", "}" ]
find elements except elements which has field founded in keys @param String $field @param array $keys @return Collection
[ "find", "elements", "except", "elements", "which", "has", "field", "founded", "in", "keys" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Support/Collection.php#L78-L85
228,114
antaresproject/core
src/components/support/src/Support/Collection.php
Collection.by
public function by($field, $value) { $filtered = $this->filter(function($fieldset) use($field, $value) { if (isset($fieldset->{$field}) and $fieldset->{$field} == $value) { return true; } return false; }); return $filtered->isEmpty() ? null : ($filtered->count() > 1 ? $filtered : $filtered->first()); }
php
public function by($field, $value) { $filtered = $this->filter(function($fieldset) use($field, $value) { if (isset($fieldset->{$field}) and $fieldset->{$field} == $value) { return true; } return false; }); return $filtered->isEmpty() ? null : ($filtered->count() > 1 ? $filtered : $filtered->first()); }
[ "public", "function", "by", "(", "$", "field", ",", "$", "value", ")", "{", "$", "filtered", "=", "$", "this", "->", "filter", "(", "function", "(", "$", "fieldset", ")", "use", "(", "$", "field", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "fieldset", "->", "{", "$", "field", "}", ")", "and", "$", "fieldset", "->", "{", "$", "field", "}", "==", "$", "value", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", ")", ";", "return", "$", "filtered", "->", "isEmpty", "(", ")", "?", "null", ":", "(", "$", "filtered", "->", "count", "(", ")", ">", "1", "?", "$", "filtered", ":", "$", "filtered", "->", "first", "(", ")", ")", ";", "}" ]
finds element in collection by element fieldname and field value @param String $field @param mixed $value @return mixed
[ "finds", "element", "in", "collection", "by", "element", "fieldname", "and", "field", "value" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Support/Collection.php#L94-L103
228,115
antaresproject/core
src/components/extension/src/Manager.php
Manager.getAvailableExtensions
public function getAvailableExtensions(): Extensions { if ($this->availableExtensions instanceof Extensions) { return $this->availableExtensions; } $foundExtensions = $this->filesystemFinder->findExtensions(); $storedExtensions = app('antares.installed') ? $this->extensionsRepository->all() : new Collection(); foreach ($foundExtensions as $foundExtension) { $extension = $storedExtensions->first(function(ExtensionModel $extensionModel) use($foundExtension) { return $extensionModel->getFullName() === $foundExtension->getPackage()->getName(); }); $configFile = $foundExtension->getPath() . '/resources/config/settings.php'; if ($this->filesystem->exists($configFile)) { $foundExtension->setSettings($this->settingsFactory->createFromConfig($configFile)); } if ($extension instanceof ExtensionModel) { $foundExtension->setStatus($extension->getStatus()); $foundExtension->setIsRequired($extension->isRequired()); $foundExtension->getSettings()->updateData($extension->getOptions()); } } return $this->availableExtensions = $foundExtensions; }
php
public function getAvailableExtensions(): Extensions { if ($this->availableExtensions instanceof Extensions) { return $this->availableExtensions; } $foundExtensions = $this->filesystemFinder->findExtensions(); $storedExtensions = app('antares.installed') ? $this->extensionsRepository->all() : new Collection(); foreach ($foundExtensions as $foundExtension) { $extension = $storedExtensions->first(function(ExtensionModel $extensionModel) use($foundExtension) { return $extensionModel->getFullName() === $foundExtension->getPackage()->getName(); }); $configFile = $foundExtension->getPath() . '/resources/config/settings.php'; if ($this->filesystem->exists($configFile)) { $foundExtension->setSettings($this->settingsFactory->createFromConfig($configFile)); } if ($extension instanceof ExtensionModel) { $foundExtension->setStatus($extension->getStatus()); $foundExtension->setIsRequired($extension->isRequired()); $foundExtension->getSettings()->updateData($extension->getOptions()); } } return $this->availableExtensions = $foundExtensions; }
[ "public", "function", "getAvailableExtensions", "(", ")", ":", "Extensions", "{", "if", "(", "$", "this", "->", "availableExtensions", "instanceof", "Extensions", ")", "{", "return", "$", "this", "->", "availableExtensions", ";", "}", "$", "foundExtensions", "=", "$", "this", "->", "filesystemFinder", "->", "findExtensions", "(", ")", ";", "$", "storedExtensions", "=", "app", "(", "'antares.installed'", ")", "?", "$", "this", "->", "extensionsRepository", "->", "all", "(", ")", ":", "new", "Collection", "(", ")", ";", "foreach", "(", "$", "foundExtensions", "as", "$", "foundExtension", ")", "{", "$", "extension", "=", "$", "storedExtensions", "->", "first", "(", "function", "(", "ExtensionModel", "$", "extensionModel", ")", "use", "(", "$", "foundExtension", ")", "{", "return", "$", "extensionModel", "->", "getFullName", "(", ")", "===", "$", "foundExtension", "->", "getPackage", "(", ")", "->", "getName", "(", ")", ";", "}", ")", ";", "$", "configFile", "=", "$", "foundExtension", "->", "getPath", "(", ")", ".", "'/resources/config/settings.php'", ";", "if", "(", "$", "this", "->", "filesystem", "->", "exists", "(", "$", "configFile", ")", ")", "{", "$", "foundExtension", "->", "setSettings", "(", "$", "this", "->", "settingsFactory", "->", "createFromConfig", "(", "$", "configFile", ")", ")", ";", "}", "if", "(", "$", "extension", "instanceof", "ExtensionModel", ")", "{", "$", "foundExtension", "->", "setStatus", "(", "$", "extension", "->", "getStatus", "(", ")", ")", ";", "$", "foundExtension", "->", "setIsRequired", "(", "$", "extension", "->", "isRequired", "(", ")", ")", ";", "$", "foundExtension", "->", "getSettings", "(", ")", "->", "updateData", "(", "$", "extension", "->", "getOptions", "(", ")", ")", ";", "}", "}", "return", "$", "this", "->", "availableExtensions", "=", "$", "foundExtensions", ";", "}" ]
Returns the collection of available extensions. @return Extensions|ExtensionContract[] @throws ExtensionException @throws FileNotFoundException
[ "Returns", "the", "collection", "of", "available", "extensions", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Manager.php#L80-L107
228,116
antaresproject/core
src/components/extension/src/Manager.php
Manager.isInstalled
public function isInstalled(string $name): bool { $extension = $this->getAvailableExtensions()->findByName($this->getNormalizedName($name)); if ($extension instanceof ExtensionContract) { return $extension->isInstalled(); } return false; }
php
public function isInstalled(string $name): bool { $extension = $this->getAvailableExtensions()->findByName($this->getNormalizedName($name)); if ($extension instanceof ExtensionContract) { return $extension->isInstalled(); } return false; }
[ "public", "function", "isInstalled", "(", "string", "$", "name", ")", ":", "bool", "{", "$", "extension", "=", "$", "this", "->", "getAvailableExtensions", "(", ")", "->", "findByName", "(", "$", "this", "->", "getNormalizedName", "(", "$", "name", ")", ")", ";", "if", "(", "$", "extension", "instanceof", "ExtensionContract", ")", "{", "return", "$", "extension", "->", "isInstalled", "(", ")", ";", "}", "return", "false", ";", "}" ]
Verify whether the extension is installed by the given name. @param string $name @return bool @throws ExtensionException @throws FileNotFoundException
[ "Verify", "whether", "the", "extension", "is", "installed", "by", "the", "given", "name", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Manager.php#L117-L126
228,117
antaresproject/core
src/components/extension/src/Manager.php
Manager.isActive
public function isActive(string $name): bool { $extension = $this->getAvailableExtensions()->quessByName($name); if ($extension instanceof ExtensionContract) { return $extension->isActivated(); } return false; }
php
public function isActive(string $name): bool { $extension = $this->getAvailableExtensions()->quessByName($name); if ($extension instanceof ExtensionContract) { return $extension->isActivated(); } return false; }
[ "public", "function", "isActive", "(", "string", "$", "name", ")", ":", "bool", "{", "$", "extension", "=", "$", "this", "->", "getAvailableExtensions", "(", ")", "->", "quessByName", "(", "$", "name", ")", ";", "if", "(", "$", "extension", "instanceof", "ExtensionContract", ")", "{", "return", "$", "extension", "->", "isActivated", "(", ")", ";", "}", "return", "false", ";", "}" ]
Verify whether the extension is active by the given name. @param string $name @return bool @throws ExtensionException @throws FileNotFoundException
[ "Verify", "whether", "the", "extension", "is", "active", "by", "the", "given", "name", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Manager.php#L136-L143
228,118
antaresproject/core
src/components/extension/src/Manager.php
Manager.getActiveExtensionByPath
public function getActiveExtensionByPath(string $path) { $activated = $this->getAvailableExtensions()->filterByActivated(); foreach ($activated as $extension) { if (starts_with($path, $extension->getPath())) { return $extension; } } return false; }
php
public function getActiveExtensionByPath(string $path) { $activated = $this->getAvailableExtensions()->filterByActivated(); foreach ($activated as $extension) { if (starts_with($path, $extension->getPath())) { return $extension; } } return false; }
[ "public", "function", "getActiveExtensionByPath", "(", "string", "$", "path", ")", "{", "$", "activated", "=", "$", "this", "->", "getAvailableExtensions", "(", ")", "->", "filterByActivated", "(", ")", ";", "foreach", "(", "$", "activated", "as", "$", "extension", ")", "{", "if", "(", "starts_with", "(", "$", "path", ",", "$", "extension", "->", "getPath", "(", ")", ")", ")", "{", "return", "$", "extension", ";", "}", "}", "return", "false", ";", "}" ]
Gets active extension by path name @param String $path @return String
[ "Gets", "active", "extension", "by", "path", "name" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Manager.php#L181-L190
228,119
antaresproject/core
src/components/extension/src/Manager.php
Manager.getActualExtension
public function getActualExtension() { $route = Route::getCurrentRoute(); if ($route instanceof \Illuminate\Routing\Route) { $action = $route->getActionName(); if ($action === 'Closure') { return false; } preg_match("/.+?(?=\\\)(.*)\Http/", $action, $matches); return empty($matches) ? false : strtolower(trim($matches[1], '\\')); } return false; }
php
public function getActualExtension() { $route = Route::getCurrentRoute(); if ($route instanceof \Illuminate\Routing\Route) { $action = $route->getActionName(); if ($action === 'Closure') { return false; } preg_match("/.+?(?=\\\)(.*)\Http/", $action, $matches); return empty($matches) ? false : strtolower(trim($matches[1], '\\')); } return false; }
[ "public", "function", "getActualExtension", "(", ")", "{", "$", "route", "=", "Route", "::", "getCurrentRoute", "(", ")", ";", "if", "(", "$", "route", "instanceof", "\\", "Illuminate", "\\", "Routing", "\\", "Route", ")", "{", "$", "action", "=", "$", "route", "->", "getActionName", "(", ")", ";", "if", "(", "$", "action", "===", "'Closure'", ")", "{", "return", "false", ";", "}", "preg_match", "(", "\"/.+?(?=\\\\\\)(.*)\\Http/\"", ",", "$", "action", ",", "$", "matches", ")", ";", "return", "empty", "(", "$", "matches", ")", "?", "false", ":", "strtolower", "(", "trim", "(", "$", "matches", "[", "1", "]", ",", "'\\\\'", ")", ")", ";", "}", "return", "false", ";", "}" ]
get actual extension name based on route @return String @deprecated
[ "get", "actual", "extension", "name", "based", "on", "route" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Manager.php#L269-L285
228,120
antaresproject/core
src/ui/components/datatables/src/Filter/AbstractFilter.php
AbstractFilter.getPatterned
public function getPatterned($value) { if (!is_array($value)) { return str_replace('%value', ucfirst($value), $this->pattern); } else { $return = $this->pattern; foreach ($value as $field) { if (!isset($field['name']) and ! isset($field['value'])) { continue; } if (isset($field['value']) && is_array($field['value'])) { $field['value'] = implode(',', $field['value']); } $return = str_replace('%' . $field['name'], $field['value'], $return); } return $return; } }
php
public function getPatterned($value) { if (!is_array($value)) { return str_replace('%value', ucfirst($value), $this->pattern); } else { $return = $this->pattern; foreach ($value as $field) { if (!isset($field['name']) and ! isset($field['value'])) { continue; } if (isset($field['value']) && is_array($field['value'])) { $field['value'] = implode(',', $field['value']); } $return = str_replace('%' . $field['name'], $field['value'], $return); } return $return; } }
[ "public", "function", "getPatterned", "(", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "return", "str_replace", "(", "'%value'", ",", "ucfirst", "(", "$", "value", ")", ",", "$", "this", "->", "pattern", ")", ";", "}", "else", "{", "$", "return", "=", "$", "this", "->", "pattern", ";", "foreach", "(", "$", "value", "as", "$", "field", ")", "{", "if", "(", "!", "isset", "(", "$", "field", "[", "'name'", "]", ")", "and", "!", "isset", "(", "$", "field", "[", "'value'", "]", ")", ")", "{", "continue", ";", "}", "if", "(", "isset", "(", "$", "field", "[", "'value'", "]", ")", "&&", "is_array", "(", "$", "field", "[", "'value'", "]", ")", ")", "{", "$", "field", "[", "'value'", "]", "=", "implode", "(", "','", ",", "$", "field", "[", "'value'", "]", ")", ";", "}", "$", "return", "=", "str_replace", "(", "'%'", ".", "$", "field", "[", "'name'", "]", ",", "$", "field", "[", "'value'", "]", ",", "$", "return", ")", ";", "}", "return", "$", "return", ";", "}", "}" ]
creates patterned sidebar title @param mixed $value @return String
[ "creates", "patterned", "sidebar", "title" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Filter/AbstractFilter.php#L176-L193
228,121
antaresproject/core
src/ui/components/datatables/src/Filter/AbstractFilter.php
AbstractFilter.getParams
protected function getParams($key = null) { $params = $this->session->get(uri()); return !is_null($key) ? array_get($params, $key) : $params; }
php
protected function getParams($key = null) { $params = $this->session->get(uri()); return !is_null($key) ? array_get($params, $key) : $params; }
[ "protected", "function", "getParams", "(", "$", "key", "=", "null", ")", "{", "$", "params", "=", "$", "this", "->", "session", "->", "get", "(", "uri", "(", ")", ")", ";", "return", "!", "is_null", "(", "$", "key", ")", "?", "array_get", "(", "$", "params", ",", "$", "key", ")", ":", "$", "params", ";", "}" ]
gets filter params from session @return String
[ "gets", "filter", "params", "from", "session" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Filter/AbstractFilter.php#L200-L204
228,122
antaresproject/customfields
src/Console/CustomfieldSync.php
CustomfieldSync.getGroup
protected function getGroup($classname) { $category = FieldCategory::query()->firstOrCreate([ 'name' => strtolower(last(explode('\\', $classname))) ]); return FieldGroup::query()->firstOrCreate([ 'category_id' => $category->id, 'name' => $category->name, ]); }
php
protected function getGroup($classname) { $category = FieldCategory::query()->firstOrCreate([ 'name' => strtolower(last(explode('\\', $classname))) ]); return FieldGroup::query()->firstOrCreate([ 'category_id' => $category->id, 'name' => $category->name, ]); }
[ "protected", "function", "getGroup", "(", "$", "classname", ")", "{", "$", "category", "=", "FieldCategory", "::", "query", "(", ")", "->", "firstOrCreate", "(", "[", "'name'", "=>", "strtolower", "(", "last", "(", "explode", "(", "'\\\\'", ",", "$", "classname", ")", ")", ")", "]", ")", ";", "return", "FieldGroup", "::", "query", "(", ")", "->", "firstOrCreate", "(", "[", "'category_id'", "=>", "$", "category", "->", "id", ",", "'name'", "=>", "$", "category", "->", "name", ",", "]", ")", ";", "}" ]
Gets field group instance @param String $classname @return FieldGroup
[ "Gets", "field", "group", "instance" ]
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Console/CustomfieldSync.php#L97-L106
228,123
antaresproject/customfields
src/Console/CustomfieldSync.php
CustomfieldSync.getFieldType
protected function getFieldType(CustomField $field) { $type = explode(':', $field->type); $where = ['name' => head($type)]; if (count($type) > 1) { $where['type'] = last($type); } return FieldType::query()->where($where)->firstOrFail(['id']); }
php
protected function getFieldType(CustomField $field) { $type = explode(':', $field->type); $where = ['name' => head($type)]; if (count($type) > 1) { $where['type'] = last($type); } return FieldType::query()->where($where)->firstOrFail(['id']); }
[ "protected", "function", "getFieldType", "(", "CustomField", "$", "field", ")", "{", "$", "type", "=", "explode", "(", "':'", ",", "$", "field", "->", "type", ")", ";", "$", "where", "=", "[", "'name'", "=>", "head", "(", "$", "type", ")", "]", ";", "if", "(", "count", "(", "$", "type", ")", ">", "1", ")", "{", "$", "where", "[", "'type'", "]", "=", "last", "(", "$", "type", ")", ";", "}", "return", "FieldType", "::", "query", "(", ")", "->", "where", "(", "$", "where", ")", "->", "firstOrFail", "(", "[", "'id'", "]", ")", ";", "}" ]
Gets field type @param CustomField $field @return FieldType
[ "Gets", "field", "type" ]
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Console/CustomfieldSync.php#L114-L122
228,124
antaresproject/customfields
src/Console/CustomfieldSync.php
CustomfieldSync.saveField
protected function saveField(Brands $brand, CustomField $field, array $insert = []) { if (Field::query()->where(array_merge($insert, ['brand_id' => $brand->id, 'name' => $field->name,]))->first() !== null) { return; } $customfield = Field::query()->firstOrCreate(array_merge($insert, [ 'brand_id' => $brand->id, 'name' => $field->name, 'label' => $field->label, 'imported' => 1, 'force_display' => (int) $field->formAutoDisplay() ])); $this->saveRules($field, $customfield); $this->saveOptions($field, $customfield); return $customfield; }
php
protected function saveField(Brands $brand, CustomField $field, array $insert = []) { if (Field::query()->where(array_merge($insert, ['brand_id' => $brand->id, 'name' => $field->name,]))->first() !== null) { return; } $customfield = Field::query()->firstOrCreate(array_merge($insert, [ 'brand_id' => $brand->id, 'name' => $field->name, 'label' => $field->label, 'imported' => 1, 'force_display' => (int) $field->formAutoDisplay() ])); $this->saveRules($field, $customfield); $this->saveOptions($field, $customfield); return $customfield; }
[ "protected", "function", "saveField", "(", "Brands", "$", "brand", ",", "CustomField", "$", "field", ",", "array", "$", "insert", "=", "[", "]", ")", "{", "if", "(", "Field", "::", "query", "(", ")", "->", "where", "(", "array_merge", "(", "$", "insert", ",", "[", "'brand_id'", "=>", "$", "brand", "->", "id", ",", "'name'", "=>", "$", "field", "->", "name", ",", "]", ")", ")", "->", "first", "(", ")", "!==", "null", ")", "{", "return", ";", "}", "$", "customfield", "=", "Field", "::", "query", "(", ")", "->", "firstOrCreate", "(", "array_merge", "(", "$", "insert", ",", "[", "'brand_id'", "=>", "$", "brand", "->", "id", ",", "'name'", "=>", "$", "field", "->", "name", ",", "'label'", "=>", "$", "field", "->", "label", ",", "'imported'", "=>", "1", ",", "'force_display'", "=>", "(", "int", ")", "$", "field", "->", "formAutoDisplay", "(", ")", "]", ")", ")", ";", "$", "this", "->", "saveRules", "(", "$", "field", ",", "$", "customfield", ")", ";", "$", "this", "->", "saveOptions", "(", "$", "field", ",", "$", "customfield", ")", ";", "return", "$", "customfield", ";", "}" ]
Saves single field @param Brands $brand @param CustomField $field @param array $insert
[ "Saves", "single", "field" ]
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Console/CustomfieldSync.php#L157-L173
228,125
antaresproject/customfields
src/Console/CustomfieldSync.php
CustomfieldSync.saveRules
protected function saveRules(CustomField $field, Field $customfield) { $rules = array_get($field->getRules(), $field->name, []); foreach ($rules as $rule) { $validator = FieldValidator::query()->where(['name' => $rule])->first(); $config = [ 'field_id' => $customfield->id ]; if (is_null($validator)) { $validator = FieldValidator::query()->where(['name' => 'custom'])->firstOrFail(); $config['value'] = $rule; } array_set($config, 'validator_id', $validator->id); FieldValidatorConfig::query()->firstOrNew($config)->save(); } return true; }
php
protected function saveRules(CustomField $field, Field $customfield) { $rules = array_get($field->getRules(), $field->name, []); foreach ($rules as $rule) { $validator = FieldValidator::query()->where(['name' => $rule])->first(); $config = [ 'field_id' => $customfield->id ]; if (is_null($validator)) { $validator = FieldValidator::query()->where(['name' => 'custom'])->firstOrFail(); $config['value'] = $rule; } array_set($config, 'validator_id', $validator->id); FieldValidatorConfig::query()->firstOrNew($config)->save(); } return true; }
[ "protected", "function", "saveRules", "(", "CustomField", "$", "field", ",", "Field", "$", "customfield", ")", "{", "$", "rules", "=", "array_get", "(", "$", "field", "->", "getRules", "(", ")", ",", "$", "field", "->", "name", ",", "[", "]", ")", ";", "foreach", "(", "$", "rules", "as", "$", "rule", ")", "{", "$", "validator", "=", "FieldValidator", "::", "query", "(", ")", "->", "where", "(", "[", "'name'", "=>", "$", "rule", "]", ")", "->", "first", "(", ")", ";", "$", "config", "=", "[", "'field_id'", "=>", "$", "customfield", "->", "id", "]", ";", "if", "(", "is_null", "(", "$", "validator", ")", ")", "{", "$", "validator", "=", "FieldValidator", "::", "query", "(", ")", "->", "where", "(", "[", "'name'", "=>", "'custom'", "]", ")", "->", "firstOrFail", "(", ")", ";", "$", "config", "[", "'value'", "]", "=", "$", "rule", ";", "}", "array_set", "(", "$", "config", ",", "'validator_id'", ",", "$", "validator", "->", "id", ")", ";", "FieldValidatorConfig", "::", "query", "(", ")", "->", "firstOrNew", "(", "$", "config", ")", "->", "save", "(", ")", ";", "}", "return", "true", ";", "}" ]
Saves custom field rules @param CustomField $field @param Field $customfield @return boolean
[ "Saves", "custom", "field", "rules" ]
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Console/CustomfieldSync.php#L182-L198
228,126
antaresproject/customfields
src/Console/CustomfieldSync.php
CustomfieldSync.saveOptions
protected function saveOptions(CustomField $field, Field $customfield) { if (is_null($field->options)) { return false; } $options = ($field->options instanceof Closure) ? call_user_func($field->options) : $field->options; foreach ($options as $value => $label) { FieldTypeOption::query()->firstOrCreate([ 'field_id' => $customfield->id, 'label' => $label, 'value' => $value ]); } return true; }
php
protected function saveOptions(CustomField $field, Field $customfield) { if (is_null($field->options)) { return false; } $options = ($field->options instanceof Closure) ? call_user_func($field->options) : $field->options; foreach ($options as $value => $label) { FieldTypeOption::query()->firstOrCreate([ 'field_id' => $customfield->id, 'label' => $label, 'value' => $value ]); } return true; }
[ "protected", "function", "saveOptions", "(", "CustomField", "$", "field", ",", "Field", "$", "customfield", ")", "{", "if", "(", "is_null", "(", "$", "field", "->", "options", ")", ")", "{", "return", "false", ";", "}", "$", "options", "=", "(", "$", "field", "->", "options", "instanceof", "Closure", ")", "?", "call_user_func", "(", "$", "field", "->", "options", ")", ":", "$", "field", "->", "options", ";", "foreach", "(", "$", "options", "as", "$", "value", "=>", "$", "label", ")", "{", "FieldTypeOption", "::", "query", "(", ")", "->", "firstOrCreate", "(", "[", "'field_id'", "=>", "$", "customfield", "->", "id", ",", "'label'", "=>", "$", "label", ",", "'value'", "=>", "$", "value", "]", ")", ";", "}", "return", "true", ";", "}" ]
Saves customfield options @param CustomField $field @param Field $customfield @return boolean
[ "Saves", "customfield", "options" ]
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Console/CustomfieldSync.php#L207-L221
228,127
antaresproject/core
src/utils/asset/src/Asset.php
Asset.inlineScript
public function inlineScript($name, $source = null, $dependencies = [], $attributes = [], $replaces = []) { $this->register('inline', $name, $source, $dependencies, $attributes, $replaces); }
php
public function inlineScript($name, $source = null, $dependencies = [], $attributes = [], $replaces = []) { $this->register('inline', $name, $source, $dependencies, $attributes, $replaces); }
[ "public", "function", "inlineScript", "(", "$", "name", ",", "$", "source", "=", "null", ",", "$", "dependencies", "=", "[", "]", ",", "$", "attributes", "=", "[", "]", ",", "$", "replaces", "=", "[", "]", ")", "{", "$", "this", "->", "register", "(", "'inline'", ",", "$", "name", ",", "$", "source", ",", "$", "dependencies", ",", "$", "attributes", ",", "$", "replaces", ")", ";", "}" ]
Add a JavaScript code to the registered assets. @param string $name @param string $source @param string|array $dependencies @param string|array $attributes @param string|array $replaces
[ "Add", "a", "JavaScript", "code", "to", "the", "registered", "assets", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/asset/src/Asset.php#L234-L237
228,128
antaresproject/core
src/utils/asset/src/Asset.php
Asset.requireJs
public function requireJs() { $scripts = $this->dispatcher->scripts('script', $this->assets, $this->path); $required = []; $string = ''; if (isset($this->assets['script'])) { foreach ($this->assets['script'] as $js) { if (!is_null($require = array_get($js, 'attributes.require'))) { $required["'" . implode("','", $require) . "'"][] = $js['source']; } } $idx = 0; foreach ($required as $names => $scripts) { $require = "require([$names],function(){ " . "require(['" . implode("','", $scripts) . "'],function(){ :replace })" . " });"; if ($idx > 0) { $string = str_replace(':replace', $require, $string); } else { $string = $require; } ++$idx; } } $inlines = implode('', $this->dispatcher->scripts('inline', $this->assets, $this->path)); $string = !strlen($string) ? $inlines : str_replace(':replace', $inlines . $this->afterLoad(), $string); $require = "['" . implode("','", $scripts) . "']"; return $this->requireInline($require, $string); }
php
public function requireJs() { $scripts = $this->dispatcher->scripts('script', $this->assets, $this->path); $required = []; $string = ''; if (isset($this->assets['script'])) { foreach ($this->assets['script'] as $js) { if (!is_null($require = array_get($js, 'attributes.require'))) { $required["'" . implode("','", $require) . "'"][] = $js['source']; } } $idx = 0; foreach ($required as $names => $scripts) { $require = "require([$names],function(){ " . "require(['" . implode("','", $scripts) . "'],function(){ :replace })" . " });"; if ($idx > 0) { $string = str_replace(':replace', $require, $string); } else { $string = $require; } ++$idx; } } $inlines = implode('', $this->dispatcher->scripts('inline', $this->assets, $this->path)); $string = !strlen($string) ? $inlines : str_replace(':replace', $inlines . $this->afterLoad(), $string); $require = "['" . implode("','", $scripts) . "']"; return $this->requireInline($require, $string); }
[ "public", "function", "requireJs", "(", ")", "{", "$", "scripts", "=", "$", "this", "->", "dispatcher", "->", "scripts", "(", "'script'", ",", "$", "this", "->", "assets", ",", "$", "this", "->", "path", ")", ";", "$", "required", "=", "[", "]", ";", "$", "string", "=", "''", ";", "if", "(", "isset", "(", "$", "this", "->", "assets", "[", "'script'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "assets", "[", "'script'", "]", "as", "$", "js", ")", "{", "if", "(", "!", "is_null", "(", "$", "require", "=", "array_get", "(", "$", "js", ",", "'attributes.require'", ")", ")", ")", "{", "$", "required", "[", "\"'\"", ".", "implode", "(", "\"','\"", ",", "$", "require", ")", ".", "\"'\"", "]", "[", "]", "=", "$", "js", "[", "'source'", "]", ";", "}", "}", "$", "idx", "=", "0", ";", "foreach", "(", "$", "required", "as", "$", "names", "=>", "$", "scripts", ")", "{", "$", "require", "=", "\"require([$names],function(){ \"", ".", "\"require(['\"", ".", "implode", "(", "\"','\"", ",", "$", "scripts", ")", ".", "\"'],function(){ :replace })\"", ".", "\" });\"", ";", "if", "(", "$", "idx", ">", "0", ")", "{", "$", "string", "=", "str_replace", "(", "':replace'", ",", "$", "require", ",", "$", "string", ")", ";", "}", "else", "{", "$", "string", "=", "$", "require", ";", "}", "++", "$", "idx", ";", "}", "}", "$", "inlines", "=", "implode", "(", "''", ",", "$", "this", "->", "dispatcher", "->", "scripts", "(", "'inline'", ",", "$", "this", "->", "assets", ",", "$", "this", "->", "path", ")", ")", ";", "$", "string", "=", "!", "strlen", "(", "$", "string", ")", "?", "$", "inlines", ":", "str_replace", "(", "':replace'", ",", "$", "inlines", ".", "$", "this", "->", "afterLoad", "(", ")", ",", "$", "string", ")", ";", "$", "require", "=", "\"['\"", ".", "implode", "(", "\"','\"", ",", "$", "scripts", ")", ".", "\"']\"", ";", "return", "$", "this", "->", "requireInline", "(", "$", "require", ",", "$", "string", ")", ";", "}" ]
applying RequireJs for scripts @return String
[ "applying", "RequireJs", "for", "scripts" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/asset/src/Asset.php#L381-L414
228,129
antaresproject/core
src/utils/asset/src/Asset.php
Asset.requireInline
protected function requireInline($scripts, $afterLoad = null) { $config = config('require_js'); $main = array_get($config, 'main', ""); $default = array_get($config, 'default', []); $child = array_get($default, 'childs', []); if (isset($default['childs'])) { unset($default['childs']); } $defaults = "'" . implode("','", $default) . "'"; $childs = "'" . implode("','", $child) . "'"; $config = $this->requireJsCache(); $inline = <<<EOD $config require(['$main'], function () { require(["jquery", "jquery-ui","moment", "jquery-ui-daterangepicker","datetimepicker", "qtip"], function ($) { require([$defaults], function () { require([$childs], function () { $afterLoad }); }); }); }); EOD; return $inline; }
php
protected function requireInline($scripts, $afterLoad = null) { $config = config('require_js'); $main = array_get($config, 'main', ""); $default = array_get($config, 'default', []); $child = array_get($default, 'childs', []); if (isset($default['childs'])) { unset($default['childs']); } $defaults = "'" . implode("','", $default) . "'"; $childs = "'" . implode("','", $child) . "'"; $config = $this->requireJsCache(); $inline = <<<EOD $config require(['$main'], function () { require(["jquery", "jquery-ui","moment", "jquery-ui-daterangepicker","datetimepicker", "qtip"], function ($) { require([$defaults], function () { require([$childs], function () { $afterLoad }); }); }); }); EOD; return $inline; }
[ "protected", "function", "requireInline", "(", "$", "scripts", ",", "$", "afterLoad", "=", "null", ")", "{", "$", "config", "=", "config", "(", "'require_js'", ")", ";", "$", "main", "=", "array_get", "(", "$", "config", ",", "'main'", ",", "\"\"", ")", ";", "$", "default", "=", "array_get", "(", "$", "config", ",", "'default'", ",", "[", "]", ")", ";", "$", "child", "=", "array_get", "(", "$", "default", ",", "'childs'", ",", "[", "]", ")", ";", "if", "(", "isset", "(", "$", "default", "[", "'childs'", "]", ")", ")", "{", "unset", "(", "$", "default", "[", "'childs'", "]", ")", ";", "}", "$", "defaults", "=", "\"'\"", ".", "implode", "(", "\"','\"", ",", "$", "default", ")", ".", "\"'\"", ";", "$", "childs", "=", "\"'\"", ".", "implode", "(", "\"','\"", ",", "$", "child", ")", ".", "\"'\"", ";", "$", "config", "=", "$", "this", "->", "requireJsCache", "(", ")", ";", "$", "inline", "=", " <<<EOD\n $config\n require(['$main'], function () {\n\n require([\"jquery\", \"jquery-ui\",\"moment\", \"jquery-ui-daterangepicker\",\"datetimepicker\", \"qtip\"], function ($) {\n \n require([$defaults], function () {\n require([$childs], function () {\n $afterLoad\n });\n });\n });\n }); \n \nEOD", ";", "return", "$", "inline", ";", "}" ]
generate gridstack inline scripts @return String
[ "generate", "gridstack", "inline", "scripts" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/asset/src/Asset.php#L448-L479
228,130
antaresproject/core
src/ui/components/templates/src/Finder.php
Finder.addPath
public function addPath($path) { $trimmed = rtrim($path, '/'); if (!in_array($trimmed, $this->paths)) { $this->paths[] = $trimmed; } return $this; }
php
public function addPath($path) { $trimmed = rtrim($path, '/'); if (!in_array($trimmed, $this->paths)) { $this->paths[] = $trimmed; } return $this; }
[ "public", "function", "addPath", "(", "$", "path", ")", "{", "$", "trimmed", "=", "rtrim", "(", "$", "path", ",", "'/'", ")", ";", "if", "(", "!", "in_array", "(", "$", "trimmed", ",", "$", "this", "->", "paths", ")", ")", "{", "$", "this", "->", "paths", "[", "]", "=", "$", "trimmed", ";", "}", "return", "$", "this", ";", "}" ]
Add a new path to finder. @param string $path @return $this
[ "Add", "a", "new", "path", "to", "finder", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Finder.php#L79-L86
228,131
antaresproject/core
src/ui/components/templates/src/Finder.php
Finder.detectUiComponents
protected function detectUiComponents() { /* @var $extensionsManager Manager */ $extensionsManager = app()->make(Manager::class); $components = []; $directories = []; foreach ($this->paths as $path) { try { $directories[] = $this->files->directories($path); } catch (Exception $ex) { continue; } } $directories = count($directories) ? array_merge(...$directories) : []; $inner = []; foreach ($directories as $index => $directory) { $classBasename = class_basename($directory); if (!in_array($classBasename, ['Widgets', 'UiComponents'], true) || !$extensionsManager->getActiveExtensionByPath($directory)) { unset($directories[$index]); continue; } if (!empty($componentDirectory = $this->files->directories($directory))) { $inner[] = $componentDirectory; } } $inner = count($inner) ? array_merge(...$inner) : []; $directories = array_merge($directories, $inner); foreach ($directories as $directory) { $components[] = $this->files->files($directory); } return count($components) ? array_merge(...$components) : []; }
php
protected function detectUiComponents() { /* @var $extensionsManager Manager */ $extensionsManager = app()->make(Manager::class); $components = []; $directories = []; foreach ($this->paths as $path) { try { $directories[] = $this->files->directories($path); } catch (Exception $ex) { continue; } } $directories = count($directories) ? array_merge(...$directories) : []; $inner = []; foreach ($directories as $index => $directory) { $classBasename = class_basename($directory); if (!in_array($classBasename, ['Widgets', 'UiComponents'], true) || !$extensionsManager->getActiveExtensionByPath($directory)) { unset($directories[$index]); continue; } if (!empty($componentDirectory = $this->files->directories($directory))) { $inner[] = $componentDirectory; } } $inner = count($inner) ? array_merge(...$inner) : []; $directories = array_merge($directories, $inner); foreach ($directories as $directory) { $components[] = $this->files->files($directory); } return count($components) ? array_merge(...$components) : []; }
[ "protected", "function", "detectUiComponents", "(", ")", "{", "/* @var $extensionsManager Manager */", "$", "extensionsManager", "=", "app", "(", ")", "->", "make", "(", "Manager", "::", "class", ")", ";", "$", "components", "=", "[", "]", ";", "$", "directories", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "paths", "as", "$", "path", ")", "{", "try", "{", "$", "directories", "[", "]", "=", "$", "this", "->", "files", "->", "directories", "(", "$", "path", ")", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "continue", ";", "}", "}", "$", "directories", "=", "count", "(", "$", "directories", ")", "?", "array_merge", "(", "...", "$", "directories", ")", ":", "[", "]", ";", "$", "inner", "=", "[", "]", ";", "foreach", "(", "$", "directories", "as", "$", "index", "=>", "$", "directory", ")", "{", "$", "classBasename", "=", "class_basename", "(", "$", "directory", ")", ";", "if", "(", "!", "in_array", "(", "$", "classBasename", ",", "[", "'Widgets'", ",", "'UiComponents'", "]", ",", "true", ")", "||", "!", "$", "extensionsManager", "->", "getActiveExtensionByPath", "(", "$", "directory", ")", ")", "{", "unset", "(", "$", "directories", "[", "$", "index", "]", ")", ";", "continue", ";", "}", "if", "(", "!", "empty", "(", "$", "componentDirectory", "=", "$", "this", "->", "files", "->", "directories", "(", "$", "directory", ")", ")", ")", "{", "$", "inner", "[", "]", "=", "$", "componentDirectory", ";", "}", "}", "$", "inner", "=", "count", "(", "$", "inner", ")", "?", "array_merge", "(", "...", "$", "inner", ")", ":", "[", "]", ";", "$", "directories", "=", "array_merge", "(", "$", "directories", ",", "$", "inner", ")", ";", "foreach", "(", "$", "directories", "as", "$", "directory", ")", "{", "$", "components", "[", "]", "=", "$", "this", "->", "files", "->", "files", "(", "$", "directory", ")", ";", "}", "return", "count", "(", "$", "components", ")", "?", "array_merge", "(", "...", "$", "components", ")", ":", "[", "]", ";", "}" ]
Detects app ui components paths @return array
[ "Detects", "app", "ui", "components", "paths" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Finder.php#L93-L132
228,132
antaresproject/core
src/ui/components/templates/src/Finder.php
Finder.detect
public function detect() { $components = []; $files = $this->detectUiComponents(); foreach ($files as $file) { $name = $this->files->name($file); $params = $this->resolveUIComponentParams($name, $file); if (!$params) { continue; } $components[snake_case($name)] = $params; } return new Collection($components); }
php
public function detect() { $components = []; $files = $this->detectUiComponents(); foreach ($files as $file) { $name = $this->files->name($file); $params = $this->resolveUIComponentParams($name, $file); if (!$params) { continue; } $components[snake_case($name)] = $params; } return new Collection($components); }
[ "public", "function", "detect", "(", ")", "{", "$", "components", "=", "[", "]", ";", "$", "files", "=", "$", "this", "->", "detectUiComponents", "(", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "name", "=", "$", "this", "->", "files", "->", "name", "(", "$", "file", ")", ";", "$", "params", "=", "$", "this", "->", "resolveUIComponentParams", "(", "$", "name", ",", "$", "file", ")", ";", "if", "(", "!", "$", "params", ")", "{", "continue", ";", "}", "$", "components", "[", "snake_case", "(", "$", "name", ")", "]", "=", "$", "params", ";", "}", "return", "new", "Collection", "(", "$", "components", ")", ";", "}" ]
Detect available ui components. @return \Illuminate\Support\Collection
[ "Detect", "available", "ui", "components", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Finder.php#L139-L156
228,133
antaresproject/core
src/ui/components/templates/src/Finder.php
Finder.detectRoutes
public function detectRoutes() { $components = $this->detectUiComponents(); $return = []; foreach ($components as $component) { $name = $this->files->name($component); $namespace = $this->resolveUIComponentNamespace($this->files->get($component)); $return[] = $namespace . '\\' . $name; } return new Collection($return); }
php
public function detectRoutes() { $components = $this->detectUiComponents(); $return = []; foreach ($components as $component) { $name = $this->files->name($component); $namespace = $this->resolveUIComponentNamespace($this->files->get($component)); $return[] = $namespace . '\\' . $name; } return new Collection($return); }
[ "public", "function", "detectRoutes", "(", ")", "{", "$", "components", "=", "$", "this", "->", "detectUiComponents", "(", ")", ";", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "components", "as", "$", "component", ")", "{", "$", "name", "=", "$", "this", "->", "files", "->", "name", "(", "$", "component", ")", ";", "$", "namespace", "=", "$", "this", "->", "resolveUIComponentNamespace", "(", "$", "this", "->", "files", "->", "get", "(", "$", "component", ")", ")", ";", "$", "return", "[", "]", "=", "$", "namespace", ".", "'\\\\'", ".", "$", "name", ";", "}", "return", "new", "Collection", "(", "$", "return", ")", ";", "}" ]
Detects ui component routes @return Collection
[ "Detects", "ui", "component", "routes" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Finder.php#L163-L174
228,134
antaresproject/core
src/ui/components/templates/src/Finder.php
Finder.resolveUIComponentParams
protected function resolveUIComponentParams($name, $file) { $namespace = $this->resolveUIComponentNamespace($this->files->get($file)); if (!class_exists($namespace . '\\' . $name)) { return false; } $instance = app($namespace . '\\' . $name); $hasWidgets = Registry::isRegistered('ui-components'); if (!$hasWidgets) { $collection = new Collection([$instance]); } else { $collection = Registry::get('ui-components'); $collection->push($instance); } $this->resolveDisabledUIComponent($instance); $this->resolveViewedUIComponent($instance); Registry::set('ui-components', $collection); $attributes = $instance->getAttributes(); return array_except($attributes, ['id']); }
php
protected function resolveUIComponentParams($name, $file) { $namespace = $this->resolveUIComponentNamespace($this->files->get($file)); if (!class_exists($namespace . '\\' . $name)) { return false; } $instance = app($namespace . '\\' . $name); $hasWidgets = Registry::isRegistered('ui-components'); if (!$hasWidgets) { $collection = new Collection([$instance]); } else { $collection = Registry::get('ui-components'); $collection->push($instance); } $this->resolveDisabledUIComponent($instance); $this->resolveViewedUIComponent($instance); Registry::set('ui-components', $collection); $attributes = $instance->getAttributes(); return array_except($attributes, ['id']); }
[ "protected", "function", "resolveUIComponentParams", "(", "$", "name", ",", "$", "file", ")", "{", "$", "namespace", "=", "$", "this", "->", "resolveUIComponentNamespace", "(", "$", "this", "->", "files", "->", "get", "(", "$", "file", ")", ")", ";", "if", "(", "!", "class_exists", "(", "$", "namespace", ".", "'\\\\'", ".", "$", "name", ")", ")", "{", "return", "false", ";", "}", "$", "instance", "=", "app", "(", "$", "namespace", ".", "'\\\\'", ".", "$", "name", ")", ";", "$", "hasWidgets", "=", "Registry", "::", "isRegistered", "(", "'ui-components'", ")", ";", "if", "(", "!", "$", "hasWidgets", ")", "{", "$", "collection", "=", "new", "Collection", "(", "[", "$", "instance", "]", ")", ";", "}", "else", "{", "$", "collection", "=", "Registry", "::", "get", "(", "'ui-components'", ")", ";", "$", "collection", "->", "push", "(", "$", "instance", ")", ";", "}", "$", "this", "->", "resolveDisabledUIComponent", "(", "$", "instance", ")", ";", "$", "this", "->", "resolveViewedUIComponent", "(", "$", "instance", ")", ";", "Registry", "::", "set", "(", "'ui-components'", ",", "$", "collection", ")", ";", "$", "attributes", "=", "$", "instance", "->", "getAttributes", "(", ")", ";", "return", "array_except", "(", "$", "attributes", ",", "[", "'id'", "]", ")", ";", "}" ]
Resolves ui component params @param String $name @param String $file @return string
[ "Resolves", "ui", "component", "params" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Finder.php#L183-L207
228,135
antaresproject/core
src/ui/components/templates/src/Finder.php
Finder.resolveDisabledUIComponent
protected function resolveDisabledUIComponent(AbstractTemplate $component, $keyname = 'ui-components.disabled') { $disabled = $component->getDisabled(); if (empty($disabled)) { return false; } $classname = get_class($component); view()->composer($disabled, function() use($keyname, $classname) { $hasWidgets = Registry::isRegistered($keyname); if (!$hasWidgets) { $collection = new Collection([$classname]); } else { $collection = Registry::get($keyname); $collection->push($classname); } Registry::set($keyname, $collection); }); return; }
php
protected function resolveDisabledUIComponent(AbstractTemplate $component, $keyname = 'ui-components.disabled') { $disabled = $component->getDisabled(); if (empty($disabled)) { return false; } $classname = get_class($component); view()->composer($disabled, function() use($keyname, $classname) { $hasWidgets = Registry::isRegistered($keyname); if (!$hasWidgets) { $collection = new Collection([$classname]); } else { $collection = Registry::get($keyname); $collection->push($classname); } Registry::set($keyname, $collection); }); return; }
[ "protected", "function", "resolveDisabledUIComponent", "(", "AbstractTemplate", "$", "component", ",", "$", "keyname", "=", "'ui-components.disabled'", ")", "{", "$", "disabled", "=", "$", "component", "->", "getDisabled", "(", ")", ";", "if", "(", "empty", "(", "$", "disabled", ")", ")", "{", "return", "false", ";", "}", "$", "classname", "=", "get_class", "(", "$", "component", ")", ";", "view", "(", ")", "->", "composer", "(", "$", "disabled", ",", "function", "(", ")", "use", "(", "$", "keyname", ",", "$", "classname", ")", "{", "$", "hasWidgets", "=", "Registry", "::", "isRegistered", "(", "$", "keyname", ")", ";", "if", "(", "!", "$", "hasWidgets", ")", "{", "$", "collection", "=", "new", "Collection", "(", "[", "$", "classname", "]", ")", ";", "}", "else", "{", "$", "collection", "=", "Registry", "::", "get", "(", "$", "keyname", ")", ";", "$", "collection", "->", "push", "(", "$", "classname", ")", ";", "}", "Registry", "::", "set", "(", "$", "keyname", ",", "$", "collection", ")", ";", "}", ")", ";", "return", ";", "}" ]
Resolves which ui components should be disabled on which view @param \Antares\UI\UIComponents\Adapter\AbstractTemplate $component @return boolean|void
[ "Resolves", "which", "ui", "components", "should", "be", "disabled", "on", "which", "view" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Finder.php#L215-L236
228,136
antaresproject/core
src/ui/components/templates/src/Finder.php
Finder.resolveViewedUIComponent
protected function resolveViewedUIComponent(AbstractTemplate $component, $keyname = 'ui-components.viewed') { $viewed = $component->views(); if (empty($viewed)) { return false; } $classname = get_class($component); view()->composer($viewed, function() use($keyname, $classname) { $collection = !Registry::isRegistered($keyname) ? new Collection() : Registry::get($keyname); if (!$collection->contains($classname)) { $collection->push($classname); } Registry::set($keyname, $collection); }); }
php
protected function resolveViewedUIComponent(AbstractTemplate $component, $keyname = 'ui-components.viewed') { $viewed = $component->views(); if (empty($viewed)) { return false; } $classname = get_class($component); view()->composer($viewed, function() use($keyname, $classname) { $collection = !Registry::isRegistered($keyname) ? new Collection() : Registry::get($keyname); if (!$collection->contains($classname)) { $collection->push($classname); } Registry::set($keyname, $collection); }); }
[ "protected", "function", "resolveViewedUIComponent", "(", "AbstractTemplate", "$", "component", ",", "$", "keyname", "=", "'ui-components.viewed'", ")", "{", "$", "viewed", "=", "$", "component", "->", "views", "(", ")", ";", "if", "(", "empty", "(", "$", "viewed", ")", ")", "{", "return", "false", ";", "}", "$", "classname", "=", "get_class", "(", "$", "component", ")", ";", "view", "(", ")", "->", "composer", "(", "$", "viewed", ",", "function", "(", ")", "use", "(", "$", "keyname", ",", "$", "classname", ")", "{", "$", "collection", "=", "!", "Registry", "::", "isRegistered", "(", "$", "keyname", ")", "?", "new", "Collection", "(", ")", ":", "Registry", "::", "get", "(", "$", "keyname", ")", ";", "if", "(", "!", "$", "collection", "->", "contains", "(", "$", "classname", ")", ")", "{", "$", "collection", "->", "push", "(", "$", "classname", ")", ";", "}", "Registry", "::", "set", "(", "$", "keyname", ",", "$", "collection", ")", ";", "}", ")", ";", "}" ]
Resolves viewed ui components @param \Antares\UI\UIComponents\Adapter\AbstractTemplate $component @return boolean|void
[ "Resolves", "viewed", "ui", "components" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Finder.php#L244-L258
228,137
antaresproject/core
src/ui/components/templates/src/Finder.php
Finder.resolveUIComponentNamespace
public function resolveUIComponentNamespace($src, $i = 0) { $tokens = token_get_all($src); $count = count($tokens); $namespace = ''; $namespace_ok = false; while ($i < $count) { $token = $tokens[$i]; if (is_array($token) && $token[0] === T_NAMESPACE) { while (++$i < $count) { if ($tokens[$i] === ';') { $namespace_ok = true; $namespace = trim($namespace); break; } $namespace .= is_array($tokens[$i]) ? $tokens[$i][1] : $tokens[$i]; } break; } $i++; } return (!$namespace_ok) ? null : $namespace; }
php
public function resolveUIComponentNamespace($src, $i = 0) { $tokens = token_get_all($src); $count = count($tokens); $namespace = ''; $namespace_ok = false; while ($i < $count) { $token = $tokens[$i]; if (is_array($token) && $token[0] === T_NAMESPACE) { while (++$i < $count) { if ($tokens[$i] === ';') { $namespace_ok = true; $namespace = trim($namespace); break; } $namespace .= is_array($tokens[$i]) ? $tokens[$i][1] : $tokens[$i]; } break; } $i++; } return (!$namespace_ok) ? null : $namespace; }
[ "public", "function", "resolveUIComponentNamespace", "(", "$", "src", ",", "$", "i", "=", "0", ")", "{", "$", "tokens", "=", "token_get_all", "(", "$", "src", ")", ";", "$", "count", "=", "count", "(", "$", "tokens", ")", ";", "$", "namespace", "=", "''", ";", "$", "namespace_ok", "=", "false", ";", "while", "(", "$", "i", "<", "$", "count", ")", "{", "$", "token", "=", "$", "tokens", "[", "$", "i", "]", ";", "if", "(", "is_array", "(", "$", "token", ")", "&&", "$", "token", "[", "0", "]", "===", "T_NAMESPACE", ")", "{", "while", "(", "++", "$", "i", "<", "$", "count", ")", "{", "if", "(", "$", "tokens", "[", "$", "i", "]", "===", "';'", ")", "{", "$", "namespace_ok", "=", "true", ";", "$", "namespace", "=", "trim", "(", "$", "namespace", ")", ";", "break", ";", "}", "$", "namespace", ".=", "is_array", "(", "$", "tokens", "[", "$", "i", "]", ")", "?", "$", "tokens", "[", "$", "i", "]", "[", "1", "]", ":", "$", "tokens", "[", "$", "i", "]", ";", "}", "break", ";", "}", "$", "i", "++", ";", "}", "return", "(", "!", "$", "namespace_ok", ")", "?", "null", ":", "$", "namespace", ";", "}" ]
Trying to get file namespace from file content @param $src @param int $i @return null|string
[ "Trying", "to", "get", "file", "namespace", "from", "file", "content" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Finder.php#L278-L300
228,138
antaresproject/core
src/ui/components/templates/src/Processor/DefaultProcessor.php
DefaultProcessor.show
public function show($id) { $component = $this->component($id)->templateLayout(); $html = $component->__toString(); if (!strlen($html)) { return $component->render(); } return $html; }
php
public function show($id) { $component = $this->component($id)->templateLayout(); $html = $component->__toString(); if (!strlen($html)) { return $component->render(); } return $html; }
[ "public", "function", "show", "(", "$", "id", ")", "{", "$", "component", "=", "$", "this", "->", "component", "(", "$", "id", ")", "->", "templateLayout", "(", ")", ";", "$", "html", "=", "$", "component", "->", "__toString", "(", ")", ";", "if", "(", "!", "strlen", "(", "$", "html", ")", ")", "{", "return", "$", "component", "->", "render", "(", ")", ";", "}", "return", "$", "html", ";", "}" ]
Functionality of preview widget @param numeric $id @return mixed | array
[ "Functionality", "of", "preview", "widget" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Processor/DefaultProcessor.php#L54-L62
228,139
antaresproject/core
src/ui/components/templates/src/Processor/DefaultProcessor.php
DefaultProcessor.component
protected function component($id) { $model = $this->repository->findOneById($id); if (is_null($model)) { return new JsonResponse(['message' => ''], 200); } $classname = $model->data['classname']; $instance = new $classname; if ($instance->getAttribute('ajaxable') === false) { return new JsonResponse('', 302); } $inputs = Input::get('attributes'); if (!is_null($inputs) and method_exists($instance, 'hydrate')) { $args = empty($inputs) ? [] : unserialize($inputs); $instance->hydrate($args); } return $instance; }
php
protected function component($id) { $model = $this->repository->findOneById($id); if (is_null($model)) { return new JsonResponse(['message' => ''], 200); } $classname = $model->data['classname']; $instance = new $classname; if ($instance->getAttribute('ajaxable') === false) { return new JsonResponse('', 302); } $inputs = Input::get('attributes'); if (!is_null($inputs) and method_exists($instance, 'hydrate')) { $args = empty($inputs) ? [] : unserialize($inputs); $instance->hydrate($args); } return $instance; }
[ "protected", "function", "component", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "repository", "->", "findOneById", "(", "$", "id", ")", ";", "if", "(", "is_null", "(", "$", "model", ")", ")", "{", "return", "new", "JsonResponse", "(", "[", "'message'", "=>", "''", "]", ",", "200", ")", ";", "}", "$", "classname", "=", "$", "model", "->", "data", "[", "'classname'", "]", ";", "$", "instance", "=", "new", "$", "classname", ";", "if", "(", "$", "instance", "->", "getAttribute", "(", "'ajaxable'", ")", "===", "false", ")", "{", "return", "new", "JsonResponse", "(", "''", ",", "302", ")", ";", "}", "$", "inputs", "=", "Input", "::", "get", "(", "'attributes'", ")", ";", "if", "(", "!", "is_null", "(", "$", "inputs", ")", "and", "method_exists", "(", "$", "instance", ",", "'hydrate'", ")", ")", "{", "$", "args", "=", "empty", "(", "$", "inputs", ")", "?", "[", "]", ":", "unserialize", "(", "$", "inputs", ")", ";", "$", "instance", "->", "hydrate", "(", "$", "args", ")", ";", "}", "return", "$", "instance", ";", "}" ]
Renders ui component content @param mixed $id @return JsonResponse
[ "Renders", "ui", "component", "content" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Processor/DefaultProcessor.php#L70-L89
228,140
antaresproject/core
src/ui/components/templates/src/Processor/DefaultProcessor.php
DefaultProcessor.positions
public function positions(array $data = null) { if (!$this->savePosition($data)) { return new JsonResponse(['message' => 'Unable to save ui component positions', 500]); } $id = array_get($data, 'current'); $component = $this->component($id); return ($component instanceof JsonResponse) ? $component : $component->render(); }
php
public function positions(array $data = null) { if (!$this->savePosition($data)) { return new JsonResponse(['message' => 'Unable to save ui component positions', 500]); } $id = array_get($data, 'current'); $component = $this->component($id); return ($component instanceof JsonResponse) ? $component : $component->render(); }
[ "public", "function", "positions", "(", "array", "$", "data", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "savePosition", "(", "$", "data", ")", ")", "{", "return", "new", "JsonResponse", "(", "[", "'message'", "=>", "'Unable to save ui component positions'", ",", "500", "]", ")", ";", "}", "$", "id", "=", "array_get", "(", "$", "data", ",", "'current'", ")", ";", "$", "component", "=", "$", "this", "->", "component", "(", "$", "id", ")", ";", "return", "(", "$", "component", "instanceof", "JsonResponse", ")", "?", "$", "component", ":", "$", "component", "->", "render", "(", ")", ";", "}" ]
Saves current widget positions @param array $data
[ "Saves", "current", "widget", "positions" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Processor/DefaultProcessor.php#L96-L105
228,141
antaresproject/core
src/ui/components/templates/src/Processor/DefaultProcessor.php
DefaultProcessor.savePosition
protected function savePosition(array $data) { DB::transaction(function() use($data) { $widgets = $data['widgets']; foreach ($widgets as $item) { $id = $item['widgetId']; $model = ComponentParams::where('id', $id)->first(); if (is_null($model)) { continue; } $position = array_only($item, ['x', 'y', 'width', 'height']); $data = $model->data; $model->data = array_merge($data, $position); $this->repository->saveEntity($model); } }); return true; }
php
protected function savePosition(array $data) { DB::transaction(function() use($data) { $widgets = $data['widgets']; foreach ($widgets as $item) { $id = $item['widgetId']; $model = ComponentParams::where('id', $id)->first(); if (is_null($model)) { continue; } $position = array_only($item, ['x', 'y', 'width', 'height']); $data = $model->data; $model->data = array_merge($data, $position); $this->repository->saveEntity($model); } }); return true; }
[ "protected", "function", "savePosition", "(", "array", "$", "data", ")", "{", "DB", "::", "transaction", "(", "function", "(", ")", "use", "(", "$", "data", ")", "{", "$", "widgets", "=", "$", "data", "[", "'widgets'", "]", ";", "foreach", "(", "$", "widgets", "as", "$", "item", ")", "{", "$", "id", "=", "$", "item", "[", "'widgetId'", "]", ";", "$", "model", "=", "ComponentParams", "::", "where", "(", "'id'", ",", "$", "id", ")", "->", "first", "(", ")", ";", "if", "(", "is_null", "(", "$", "model", ")", ")", "{", "continue", ";", "}", "$", "position", "=", "array_only", "(", "$", "item", ",", "[", "'x'", ",", "'y'", ",", "'width'", ",", "'height'", "]", ")", ";", "$", "data", "=", "$", "model", "->", "data", ";", "$", "model", "->", "data", "=", "array_merge", "(", "$", "data", ",", "$", "position", ")", ";", "$", "this", "->", "repository", "->", "saveEntity", "(", "$", "model", ")", ";", "}", "}", ")", ";", "return", "true", ";", "}" ]
Saves ui component position change @param array $data @return mixed
[ "Saves", "ui", "component", "position", "change" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Processor/DefaultProcessor.php#L113-L130
228,142
antaresproject/core
src/ui/components/templates/src/Processor/DefaultProcessor.php
DefaultProcessor.view
public function view($id) { $component = null; DB::transaction(function() use($id, &$component) { $resource = Input::get('from'); $model = $this->repository->findOneById($id); if (is_null($model)) { throw new ComponentNotFoundException('Component not found'); } $data = $model->data; $data['disabled'] = false; $model->data = $data; $model->resource = strlen($resource) > 0 ? $resource : uri(); $this->repository->saveEntity($model); $component = app()->make($data['classname']); $attributes = array_only($data, ['x', 'y', 'width', 'height', 'disabled']) + ['id' => $id]; $component->setAttributes($attributes); $inputs = Input::get('attributes'); if (!is_null($attributes) and method_exists($component, 'hydrate')) { $args = empty($inputs) ? [] : unserialize($inputs); $component->hydrate($args); } $component->setView('antares/ui-components::admin.partials._base'); }); return ['component' => $component]; }
php
public function view($id) { $component = null; DB::transaction(function() use($id, &$component) { $resource = Input::get('from'); $model = $this->repository->findOneById($id); if (is_null($model)) { throw new ComponentNotFoundException('Component not found'); } $data = $model->data; $data['disabled'] = false; $model->data = $data; $model->resource = strlen($resource) > 0 ? $resource : uri(); $this->repository->saveEntity($model); $component = app()->make($data['classname']); $attributes = array_only($data, ['x', 'y', 'width', 'height', 'disabled']) + ['id' => $id]; $component->setAttributes($attributes); $inputs = Input::get('attributes'); if (!is_null($attributes) and method_exists($component, 'hydrate')) { $args = empty($inputs) ? [] : unserialize($inputs); $component->hydrate($args); } $component->setView('antares/ui-components::admin.partials._base'); }); return ['component' => $component]; }
[ "public", "function", "view", "(", "$", "id", ")", "{", "$", "component", "=", "null", ";", "DB", "::", "transaction", "(", "function", "(", ")", "use", "(", "$", "id", ",", "&", "$", "component", ")", "{", "$", "resource", "=", "Input", "::", "get", "(", "'from'", ")", ";", "$", "model", "=", "$", "this", "->", "repository", "->", "findOneById", "(", "$", "id", ")", ";", "if", "(", "is_null", "(", "$", "model", ")", ")", "{", "throw", "new", "ComponentNotFoundException", "(", "'Component not found'", ")", ";", "}", "$", "data", "=", "$", "model", "->", "data", ";", "$", "data", "[", "'disabled'", "]", "=", "false", ";", "$", "model", "->", "data", "=", "$", "data", ";", "$", "model", "->", "resource", "=", "strlen", "(", "$", "resource", ")", ">", "0", "?", "$", "resource", ":", "uri", "(", ")", ";", "$", "this", "->", "repository", "->", "saveEntity", "(", "$", "model", ")", ";", "$", "component", "=", "app", "(", ")", "->", "make", "(", "$", "data", "[", "'classname'", "]", ")", ";", "$", "attributes", "=", "array_only", "(", "$", "data", ",", "[", "'x'", ",", "'y'", ",", "'width'", ",", "'height'", ",", "'disabled'", "]", ")", "+", "[", "'id'", "=>", "$", "id", "]", ";", "$", "component", "->", "setAttributes", "(", "$", "attributes", ")", ";", "$", "inputs", "=", "Input", "::", "get", "(", "'attributes'", ")", ";", "if", "(", "!", "is_null", "(", "$", "attributes", ")", "and", "method_exists", "(", "$", "component", ",", "'hydrate'", ")", ")", "{", "$", "args", "=", "empty", "(", "$", "inputs", ")", "?", "[", "]", ":", "unserialize", "(", "$", "inputs", ")", ";", "$", "component", "->", "hydrate", "(", "$", "args", ")", ";", "}", "$", "component", "->", "setView", "(", "'antares/ui-components::admin.partials._base'", ")", ";", "}", ")", ";", "return", "[", "'component'", "=>", "$", "component", "]", ";", "}" ]
Creates instance of ui component @param numeric $id @return array
[ "Creates", "instance", "of", "ui", "component" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Processor/DefaultProcessor.php#L138-L170
228,143
fruitcake/php-recaptcha
src/ReCaptcha.php
ReCaptcha.getInvisibleWidget
public function getInvisibleWidget($formId, $buttonLabel = 'Submit', $buttonClass ='') { $hash = md5(uniqid($formId, true)); return sprintf( '<script> function onSubmit%s(token) { document.getElementById("%s").submit(); } </script> <button class="g-recaptcha %s" data-sitekey="%s" data-callback=\'onSubmit%s\'>%s</button> ', $hash, $formId, $buttonClass, $this->siteKey, $hash, $buttonLabel); }
php
public function getInvisibleWidget($formId, $buttonLabel = 'Submit', $buttonClass ='') { $hash = md5(uniqid($formId, true)); return sprintf( '<script> function onSubmit%s(token) { document.getElementById("%s").submit(); } </script> <button class="g-recaptcha %s" data-sitekey="%s" data-callback=\'onSubmit%s\'>%s</button> ', $hash, $formId, $buttonClass, $this->siteKey, $hash, $buttonLabel); }
[ "public", "function", "getInvisibleWidget", "(", "$", "formId", ",", "$", "buttonLabel", "=", "'Submit'", ",", "$", "buttonClass", "=", "''", ")", "{", "$", "hash", "=", "md5", "(", "uniqid", "(", "$", "formId", ",", "true", ")", ")", ";", "return", "sprintf", "(", "'<script>\n function onSubmit%s(token) {\n document.getElementById(\"%s\").submit();\n }\n</script>\n<button class=\"g-recaptcha %s\" data-sitekey=\"%s\" data-callback=\\'onSubmit%s\\'>%s</button>\n'", ",", "$", "hash", ",", "$", "formId", ",", "$", "buttonClass", ",", "$", "this", "->", "siteKey", ",", "$", "hash", ",", "$", "buttonLabel", ")", ";", "}" ]
Render a button for the invisible captcha @param $formId @param string $buttonLabel @param string $buttonClass @return string
[ "Render", "a", "button", "for", "the", "invisible", "captcha" ]
5bc298dba83bfe971814abb77cef1dd249860da3
https://github.com/fruitcake/php-recaptcha/blob/5bc298dba83bfe971814abb77cef1dd249860da3/src/ReCaptcha.php#L154-L166
228,144
fruitcake/php-recaptcha
src/ReCaptcha.php
ReCaptcha.verify
public function verify($response, $remoteip = null) { $params = array( 'secret' => $this->secret, 'response' => $response, 'remoteip' => $remoteip, ); $response = $this->fetchResponse($params); if ($response['success']) { $this->errors = array(); return true; } else { $this->errors = isset($response['error-codes']) ? $response['error-codes'] : array(); return false; } }
php
public function verify($response, $remoteip = null) { $params = array( 'secret' => $this->secret, 'response' => $response, 'remoteip' => $remoteip, ); $response = $this->fetchResponse($params); if ($response['success']) { $this->errors = array(); return true; } else { $this->errors = isset($response['error-codes']) ? $response['error-codes'] : array(); return false; } }
[ "public", "function", "verify", "(", "$", "response", ",", "$", "remoteip", "=", "null", ")", "{", "$", "params", "=", "array", "(", "'secret'", "=>", "$", "this", "->", "secret", ",", "'response'", "=>", "$", "response", ",", "'remoteip'", "=>", "$", "remoteip", ",", ")", ";", "$", "response", "=", "$", "this", "->", "fetchResponse", "(", "$", "params", ")", ";", "if", "(", "$", "response", "[", "'success'", "]", ")", "{", "$", "this", "->", "errors", "=", "array", "(", ")", ";", "return", "true", ";", "}", "else", "{", "$", "this", "->", "errors", "=", "isset", "(", "$", "response", "[", "'error-codes'", "]", ")", "?", "$", "response", "[", "'error-codes'", "]", ":", "array", "(", ")", ";", "return", "false", ";", "}", "}" ]
Verify a response string @param string $response @param string $remoteip @return bool
[ "Verify", "a", "response", "string" ]
5bc298dba83bfe971814abb77cef1dd249860da3
https://github.com/fruitcake/php-recaptcha/blob/5bc298dba83bfe971814abb77cef1dd249860da3/src/ReCaptcha.php#L175-L192
228,145
fruitcake/php-recaptcha
src/ReCaptcha.php
ReCaptcha.verifyGlobals
public function verifyGlobals() { $response = isset($_POST["g-recaptcha-response"]) ? $_POST["g-recaptcha-response"] : ''; $remoteip = isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : null; return $this->verify($response, $remoteip); }
php
public function verifyGlobals() { $response = isset($_POST["g-recaptcha-response"]) ? $_POST["g-recaptcha-response"] : ''; $remoteip = isset($_SERVER["REMOTE_ADDR"]) ? $_SERVER["REMOTE_ADDR"] : null; return $this->verify($response, $remoteip); }
[ "public", "function", "verifyGlobals", "(", ")", "{", "$", "response", "=", "isset", "(", "$", "_POST", "[", "\"g-recaptcha-response\"", "]", ")", "?", "$", "_POST", "[", "\"g-recaptcha-response\"", "]", ":", "''", ";", "$", "remoteip", "=", "isset", "(", "$", "_SERVER", "[", "\"REMOTE_ADDR\"", "]", ")", "?", "$", "_SERVER", "[", "\"REMOTE_ADDR\"", "]", ":", "null", ";", "return", "$", "this", "->", "verify", "(", "$", "response", ",", "$", "remoteip", ")", ";", "}" ]
Verify the response using the GLOBAL vars @return bool
[ "Verify", "the", "response", "using", "the", "GLOBAL", "vars" ]
5bc298dba83bfe971814abb77cef1dd249860da3
https://github.com/fruitcake/php-recaptcha/blob/5bc298dba83bfe971814abb77cef1dd249860da3/src/ReCaptcha.php#L199-L205
228,146
fruitcake/php-recaptcha
src/ReCaptcha.php
ReCaptcha.verifyRequest
public function verifyRequest(Request $request = null) { $request = $request ?: $this->request; $response = $request->request->get('g-recaptcha-response'); $remoteip = $request->getClientIp(); return $this->verify($response, $remoteip); }
php
public function verifyRequest(Request $request = null) { $request = $request ?: $this->request; $response = $request->request->get('g-recaptcha-response'); $remoteip = $request->getClientIp(); return $this->verify($response, $remoteip); }
[ "public", "function", "verifyRequest", "(", "Request", "$", "request", "=", "null", ")", "{", "$", "request", "=", "$", "request", "?", ":", "$", "this", "->", "request", ";", "$", "response", "=", "$", "request", "->", "request", "->", "get", "(", "'g-recaptcha-response'", ")", ";", "$", "remoteip", "=", "$", "request", "->", "getClientIp", "(", ")", ";", "return", "$", "this", "->", "verify", "(", "$", "response", ",", "$", "remoteip", ")", ";", "}" ]
Verify the response using a Symfony Request object @param \Symfony\Component\HttpFoundation\Request $request @return bool
[ "Verify", "the", "response", "using", "a", "Symfony", "Request", "object" ]
5bc298dba83bfe971814abb77cef1dd249860da3
https://github.com/fruitcake/php-recaptcha/blob/5bc298dba83bfe971814abb77cef1dd249860da3/src/ReCaptcha.php#L213-L220
228,147
fruitcake/php-recaptcha
src/ReCaptcha.php
ReCaptcha.getErrorMessage
public function getErrorMessage() { $messages = array(); foreach ($this->errors as $error) { if (isset($this->errorMessages[$error])) { $messages[] = $this->errorMessages[$error]; } else{ $messages[] = $error; } } return implode(' ', $messages); }
php
public function getErrorMessage() { $messages = array(); foreach ($this->errors as $error) { if (isset($this->errorMessages[$error])) { $messages[] = $this->errorMessages[$error]; } else{ $messages[] = $error; } } return implode(' ', $messages); }
[ "public", "function", "getErrorMessage", "(", ")", "{", "$", "messages", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "errors", "as", "$", "error", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "errorMessages", "[", "$", "error", "]", ")", ")", "{", "$", "messages", "[", "]", "=", "$", "this", "->", "errorMessages", "[", "$", "error", "]", ";", "}", "else", "{", "$", "messages", "[", "]", "=", "$", "error", ";", "}", "}", "return", "implode", "(", "' '", ",", "$", "messages", ")", ";", "}" ]
Get the error messages as human readable message
[ "Get", "the", "error", "messages", "as", "human", "readable", "message" ]
5bc298dba83bfe971814abb77cef1dd249860da3
https://github.com/fruitcake/php-recaptcha/blob/5bc298dba83bfe971814abb77cef1dd249860da3/src/ReCaptcha.php#L235-L247
228,148
fruitcake/php-recaptcha
src/ReCaptcha.php
ReCaptcha.fetchResponse
protected function fetchResponse($params) { $qs = http_build_query($params); $response = file_get_contents($this->verifyUrl . '?' . $qs); return json_decode($response, true); }
php
protected function fetchResponse($params) { $qs = http_build_query($params); $response = file_get_contents($this->verifyUrl . '?' . $qs); return json_decode($response, true); }
[ "protected", "function", "fetchResponse", "(", "$", "params", ")", "{", "$", "qs", "=", "http_build_query", "(", "$", "params", ")", ";", "$", "response", "=", "file_get_contents", "(", "$", "this", "->", "verifyUrl", ".", "'?'", ".", "$", "qs", ")", ";", "return", "json_decode", "(", "$", "response", ",", "true", ")", ";", "}" ]
Get a response from the API
[ "Get", "a", "response", "from", "the", "API" ]
5bc298dba83bfe971814abb77cef1dd249860da3
https://github.com/fruitcake/php-recaptcha/blob/5bc298dba83bfe971814abb77cef1dd249860da3/src/ReCaptcha.php#L252-L258
228,149
antaresproject/core
src/components/view/src/Theme/ThemeManager.php
ThemeManager.createAntaresDriver
protected function createAntaresDriver() { $theme = new Theme($this->app, $this->app->make('events'), $this->app->make('files')); return $theme->initiate(); }
php
protected function createAntaresDriver() { $theme = new Theme($this->app, $this->app->make('events'), $this->app->make('files')); return $theme->initiate(); }
[ "protected", "function", "createAntaresDriver", "(", ")", "{", "$", "theme", "=", "new", "Theme", "(", "$", "this", "->", "app", ",", "$", "this", "->", "app", "->", "make", "(", "'events'", ")", ",", "$", "this", "->", "app", "->", "make", "(", "'files'", ")", ")", ";", "return", "$", "theme", "->", "initiate", "(", ")", ";", "}" ]
Create an instance of the antares theme driver. @return \Antares\Contracts\Theme\Theme
[ "Create", "an", "instance", "of", "the", "antares", "theme", "driver", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Theme/ThemeManager.php#L35-L40
228,150
coincheckjp/coincheck-php
lib/Coincheck/Coincheck.php
Coincheck.request
public function request($method, $path, $paramData) { if($method == 'get' && count($paramData) > 0) { $path = $path . '?' . http_build_query($paramData); $paramData=array(); } $this->setSignature($path, $paramData); $req = $this->client->createRequest($method, $path, array()); if($method == 'post' || $method == 'delete') { foreach ($paramData as $k => $v) { $req->setPostField($k, $v); } } try { $res = $req->send(); return $res->json(); } catch (\Guzzle\Common\Exception\RuntimeException $e) { echo $e->getResponse()->getBody(); } }
php
public function request($method, $path, $paramData) { if($method == 'get' && count($paramData) > 0) { $path = $path . '?' . http_build_query($paramData); $paramData=array(); } $this->setSignature($path, $paramData); $req = $this->client->createRequest($method, $path, array()); if($method == 'post' || $method == 'delete') { foreach ($paramData as $k => $v) { $req->setPostField($k, $v); } } try { $res = $req->send(); return $res->json(); } catch (\Guzzle\Common\Exception\RuntimeException $e) { echo $e->getResponse()->getBody(); } }
[ "public", "function", "request", "(", "$", "method", ",", "$", "path", ",", "$", "paramData", ")", "{", "if", "(", "$", "method", "==", "'get'", "&&", "count", "(", "$", "paramData", ")", ">", "0", ")", "{", "$", "path", "=", "$", "path", ".", "'?'", ".", "http_build_query", "(", "$", "paramData", ")", ";", "$", "paramData", "=", "array", "(", ")", ";", "}", "$", "this", "->", "setSignature", "(", "$", "path", ",", "$", "paramData", ")", ";", "$", "req", "=", "$", "this", "->", "client", "->", "createRequest", "(", "$", "method", ",", "$", "path", ",", "array", "(", ")", ")", ";", "if", "(", "$", "method", "==", "'post'", "||", "$", "method", "==", "'delete'", ")", "{", "foreach", "(", "$", "paramData", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "req", "->", "setPostField", "(", "$", "k", ",", "$", "v", ")", ";", "}", "}", "try", "{", "$", "res", "=", "$", "req", "->", "send", "(", ")", ";", "return", "$", "res", "->", "json", "(", ")", ";", "}", "catch", "(", "\\", "Guzzle", "\\", "Common", "\\", "Exception", "\\", "RuntimeException", "$", "e", ")", "{", "echo", "$", "e", "->", "getResponse", "(", ")", "->", "getBody", "(", ")", ";", "}", "}" ]
Dispatch API request @param string $operation Target action @param object $paramData Request data
[ "Dispatch", "API", "request" ]
5991003cb0ae827697888aeebd0aea0267fad7fa
https://github.com/coincheckjp/coincheck-php/blob/5991003cb0ae827697888aeebd0aea0267fad7fa/lib/Coincheck/Coincheck.php#L105-L124
228,151
overclokk/cookie
src/Cookie.php
Cookie.forever
public function forever( $name, $value, $expire = 0 ) { if ( 0 === $expire ) { $expire = 31536000 * 5; } return $this->set( $name, $value, $expire ); }
php
public function forever( $name, $value, $expire = 0 ) { if ( 0 === $expire ) { $expire = 31536000 * 5; } return $this->set( $name, $value, $expire ); }
[ "public", "function", "forever", "(", "$", "name", ",", "$", "value", ",", "$", "expire", "=", "0", ")", "{", "if", "(", "0", "===", "$", "expire", ")", "{", "$", "expire", "=", "31536000", "*", "5", ";", "}", "return", "$", "this", "->", "set", "(", "$", "name", ",", "$", "value", ",", "$", "expire", ")", ";", "}" ]
Store a cookie for a long, long time. @author https://github.com/codezero-be @param string $name The cookie name. @param string $value The cookie value. @return bool If output exists prior to calling this function, setcookie() will fail and return FALSE. If setcookie() successfully runs, it will return TRUE. This does not indicate whether the user accepted the cookie.
[ "Store", "a", "cookie", "for", "a", "long", "long", "time", "." ]
d546068cb4042d35ca121ae50996d536c641f8e3
https://github.com/overclokk/cookie/blob/d546068cb4042d35ca121ae50996d536c641f8e3/src/Cookie.php#L105-L112
228,152
antaresproject/core
src/components/extension/src/FilesystemFinder.php
FilesystemFinder.findExtensions
public function findExtensions(): Extensions { $extensions = new Extensions(); foreach ($this->configRepository->getPaths() as $path) { $composerPattern = $this->configRepository->getRootPath() . '/' . $path . '/composer.json'; $composerFiles = $this->filesystem->glob($composerPattern); if ($composerFiles === false) { throw new ExtensionException('Error occurs when looking for extensions in the [' . $composerPattern . '] path.'); } foreach ($composerFiles as $composerFile) { $package = $this->extensionFactory->getComposerPackage($composerFile); if (!in_array($package->getType(), self::$validTypes, true)) { continue; } $extension = $this->extensionFactory->create($composerFile); if (!$this->extensionValidator->isValid($extension)) { throw new ExtensionException('The extension [' . $extension->getPackage()->getName() . '] is not valid.'); } $extensions->push($extension); } } return $extensions; }
php
public function findExtensions(): Extensions { $extensions = new Extensions(); foreach ($this->configRepository->getPaths() as $path) { $composerPattern = $this->configRepository->getRootPath() . '/' . $path . '/composer.json'; $composerFiles = $this->filesystem->glob($composerPattern); if ($composerFiles === false) { throw new ExtensionException('Error occurs when looking for extensions in the [' . $composerPattern . '] path.'); } foreach ($composerFiles as $composerFile) { $package = $this->extensionFactory->getComposerPackage($composerFile); if (!in_array($package->getType(), self::$validTypes, true)) { continue; } $extension = $this->extensionFactory->create($composerFile); if (!$this->extensionValidator->isValid($extension)) { throw new ExtensionException('The extension [' . $extension->getPackage()->getName() . '] is not valid.'); } $extensions->push($extension); } } return $extensions; }
[ "public", "function", "findExtensions", "(", ")", ":", "Extensions", "{", "$", "extensions", "=", "new", "Extensions", "(", ")", ";", "foreach", "(", "$", "this", "->", "configRepository", "->", "getPaths", "(", ")", "as", "$", "path", ")", "{", "$", "composerPattern", "=", "$", "this", "->", "configRepository", "->", "getRootPath", "(", ")", ".", "'/'", ".", "$", "path", ".", "'/composer.json'", ";", "$", "composerFiles", "=", "$", "this", "->", "filesystem", "->", "glob", "(", "$", "composerPattern", ")", ";", "if", "(", "$", "composerFiles", "===", "false", ")", "{", "throw", "new", "ExtensionException", "(", "'Error occurs when looking for extensions in the ['", ".", "$", "composerPattern", ".", "'] path.'", ")", ";", "}", "foreach", "(", "$", "composerFiles", "as", "$", "composerFile", ")", "{", "$", "package", "=", "$", "this", "->", "extensionFactory", "->", "getComposerPackage", "(", "$", "composerFile", ")", ";", "if", "(", "!", "in_array", "(", "$", "package", "->", "getType", "(", ")", ",", "self", "::", "$", "validTypes", ",", "true", ")", ")", "{", "continue", ";", "}", "$", "extension", "=", "$", "this", "->", "extensionFactory", "->", "create", "(", "$", "composerFile", ")", ";", "if", "(", "!", "$", "this", "->", "extensionValidator", "->", "isValid", "(", "$", "extension", ")", ")", "{", "throw", "new", "ExtensionException", "(", "'The extension ['", ".", "$", "extension", "->", "getPackage", "(", ")", "->", "getName", "(", ")", ".", "'] is not valid.'", ")", ";", "}", "$", "extensions", "->", "push", "(", "$", "extension", ")", ";", "}", "}", "return", "$", "extensions", ";", "}" ]
Returns the collection with all available extensions in the file system. @return Extensions|ExtensionContract[] @throws ExtensionException @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
[ "Returns", "the", "collection", "with", "all", "available", "extensions", "in", "the", "file", "system", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/FilesystemFinder.php#L69-L103
228,153
antaresproject/core
src/components/extension/src/FilesystemFinder.php
FilesystemFinder.resolveNamespace
public function resolveNamespace(string $path, bool $asPackage = false): string { $file = new File($path); $pathInfo = array_filter(explode(DIRECTORY_SEPARATOR, trim(str_replace([$this->configRepository->getRootPath(), 'src'], '', $file->getRealPath()), DIRECTORY_SEPARATOR))); $prefix = 'antares'; $namespaces = []; foreach ($pathInfo as $name) { if ($name === 'core') { $namespaces[] = $asPackage ? 'foundation' : $name; break; } if ($name === 'app') { $namespaces[] = 'foundation'; break; } if ($name === 'src') { break; } if (in_array($name, ['components', 'modules'], true)) { continue; } $namespaces[] = $name; } return $prefix . '/' . implode('/', $namespaces); }
php
public function resolveNamespace(string $path, bool $asPackage = false): string { $file = new File($path); $pathInfo = array_filter(explode(DIRECTORY_SEPARATOR, trim(str_replace([$this->configRepository->getRootPath(), 'src'], '', $file->getRealPath()), DIRECTORY_SEPARATOR))); $prefix = 'antares'; $namespaces = []; foreach ($pathInfo as $name) { if ($name === 'core') { $namespaces[] = $asPackage ? 'foundation' : $name; break; } if ($name === 'app') { $namespaces[] = 'foundation'; break; } if ($name === 'src') { break; } if (in_array($name, ['components', 'modules'], true)) { continue; } $namespaces[] = $name; } return $prefix . '/' . implode('/', $namespaces); }
[ "public", "function", "resolveNamespace", "(", "string", "$", "path", ",", "bool", "$", "asPackage", "=", "false", ")", ":", "string", "{", "$", "file", "=", "new", "File", "(", "$", "path", ")", ";", "$", "pathInfo", "=", "array_filter", "(", "explode", "(", "DIRECTORY_SEPARATOR", ",", "trim", "(", "str_replace", "(", "[", "$", "this", "->", "configRepository", "->", "getRootPath", "(", ")", ",", "'src'", "]", ",", "''", ",", "$", "file", "->", "getRealPath", "(", ")", ")", ",", "DIRECTORY_SEPARATOR", ")", ")", ")", ";", "$", "prefix", "=", "'antares'", ";", "$", "namespaces", "=", "[", "]", ";", "foreach", "(", "$", "pathInfo", "as", "$", "name", ")", "{", "if", "(", "$", "name", "===", "'core'", ")", "{", "$", "namespaces", "[", "]", "=", "$", "asPackage", "?", "'foundation'", ":", "$", "name", ";", "break", ";", "}", "if", "(", "$", "name", "===", "'app'", ")", "{", "$", "namespaces", "[", "]", "=", "'foundation'", ";", "break", ";", "}", "if", "(", "$", "name", "===", "'src'", ")", "{", "break", ";", "}", "if", "(", "in_array", "(", "$", "name", ",", "[", "'components'", ",", "'modules'", "]", ",", "true", ")", ")", "{", "continue", ";", "}", "$", "namespaces", "[", "]", "=", "$", "name", ";", "}", "return", "$", "prefix", ".", "'/'", ".", "implode", "(", "'/'", ",", "$", "namespaces", ")", ";", "}" ]
Resolves a component or a module namespace by the given file path. @param string $path @param bool $asPackage @return string @throws \Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException
[ "Resolves", "a", "component", "or", "a", "module", "namespace", "by", "the", "given", "file", "path", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/FilesystemFinder.php#L113-L139
228,154
antaresproject/core
src/components/extension/src/FilesystemFinder.php
FilesystemFinder.resolveExtensionPath
public function resolveExtensionPath($path): string { $app = rtrim(base_path('app'), '/'); $base = rtrim(base_path(), '/'); return str_replace( ['app::', 'vendor::antares', 'base::'], ["{$app}/", "{$base}/src", "{$base}/"], $path ); }
php
public function resolveExtensionPath($path): string { $app = rtrim(base_path('app'), '/'); $base = rtrim(base_path(), '/'); return str_replace( ['app::', 'vendor::antares', 'base::'], ["{$app}/", "{$base}/src", "{$base}/"], $path ); }
[ "public", "function", "resolveExtensionPath", "(", "$", "path", ")", ":", "string", "{", "$", "app", "=", "rtrim", "(", "base_path", "(", "'app'", ")", ",", "'/'", ")", ";", "$", "base", "=", "rtrim", "(", "base_path", "(", ")", ",", "'/'", ")", ";", "return", "str_replace", "(", "[", "'app::'", ",", "'vendor::antares'", ",", "'base::'", "]", ",", "[", "\"{$app}/\"", ",", "\"{$base}/src\"", ",", "\"{$base}/\"", "]", ",", "$", "path", ")", ";", "}" ]
Resolve extension path. @param string $path @return string
[ "Resolve", "extension", "path", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/FilesystemFinder.php#L147-L155
228,155
gggeek/ggwebservices
classes/ggsoaprequest.php
ggSOAPRequest.encodeValue
static function encodeValue( $doc, $name, $value ) { switch ( gettype( $value ) ) { case "string" : { $node = $doc->createElement( $name, $value ); $node->setAttribute( ggSOAPRequest::XSI_PREFIX . ':type', ggSOAPRequest::XSD_PREFIX . ':string' ); return $node; } break; case "boolean" : { $node = $doc->createElement( $name, $value ? 'true' : 'false' ); $node->setAttribute( ggSOAPRequest::XSI_PREFIX . ':type', ggSOAPRequest::XSD_PREFIX . ':boolean' ); return $node; } break; case "integer" : { $node = $doc->createElement( $name, $value ); $node->setAttribute( ggSOAPRequest::XSI_PREFIX . ':type', ggSOAPRequest::XSD_PREFIX . ':int' ); return $node; } break; case "double" : { $node = $doc->createElement( $name, $value ); $node->setAttribute( ggSOAPRequest::XSI_PREFIX . ':type', ggSOAPRequest::XSD_PREFIX . ':float' ); return $node; } break; case "array" : { $arrayCount = count( $value ); $isStruct = false; // Check for struct $i = 0; foreach( $value as $key => $val ) { if ( $i !== $key ) { $isStruct = true; break; } $i++; } if ( $isStruct == true ) { $node = $doc->createElement( $name ); $node->setAttribute( ggSOAPRequest::XSI_PREFIX . ':type', ggSOAPRequest::ENC_PREFIX . ':SOAPStruct' ); foreach( $value as $key => $val ) { $subNode = ggSOAPRequest::encodeValue( $doc, (string)$key, $val ); $node->appendChild( $subNode ); } return $node; } else { $node = $doc->createElement( $name ); $node->setAttribute( ggSOAPRequest::XSI_PREFIX . ':type', ggSOAPRequest::ENC_PREFIX . ':Array' ); $node->setAttribute( ggSOAPRequest::ENC_PREFIX . ':arrayType', ggSOAPRequest::XSD_PREFIX . ":string[$arrayCount]" ); foreach ( $value as $arrayItem ) { $subNode = ggSOAPRequest::encodeValue( $doc, "item", $arrayItem ); $node->appendChild( $subNode ); } return $node; } } break; } return false; }
php
static function encodeValue( $doc, $name, $value ) { switch ( gettype( $value ) ) { case "string" : { $node = $doc->createElement( $name, $value ); $node->setAttribute( ggSOAPRequest::XSI_PREFIX . ':type', ggSOAPRequest::XSD_PREFIX . ':string' ); return $node; } break; case "boolean" : { $node = $doc->createElement( $name, $value ? 'true' : 'false' ); $node->setAttribute( ggSOAPRequest::XSI_PREFIX . ':type', ggSOAPRequest::XSD_PREFIX . ':boolean' ); return $node; } break; case "integer" : { $node = $doc->createElement( $name, $value ); $node->setAttribute( ggSOAPRequest::XSI_PREFIX . ':type', ggSOAPRequest::XSD_PREFIX . ':int' ); return $node; } break; case "double" : { $node = $doc->createElement( $name, $value ); $node->setAttribute( ggSOAPRequest::XSI_PREFIX . ':type', ggSOAPRequest::XSD_PREFIX . ':float' ); return $node; } break; case "array" : { $arrayCount = count( $value ); $isStruct = false; // Check for struct $i = 0; foreach( $value as $key => $val ) { if ( $i !== $key ) { $isStruct = true; break; } $i++; } if ( $isStruct == true ) { $node = $doc->createElement( $name ); $node->setAttribute( ggSOAPRequest::XSI_PREFIX . ':type', ggSOAPRequest::ENC_PREFIX . ':SOAPStruct' ); foreach( $value as $key => $val ) { $subNode = ggSOAPRequest::encodeValue( $doc, (string)$key, $val ); $node->appendChild( $subNode ); } return $node; } else { $node = $doc->createElement( $name ); $node->setAttribute( ggSOAPRequest::XSI_PREFIX . ':type', ggSOAPRequest::ENC_PREFIX . ':Array' ); $node->setAttribute( ggSOAPRequest::ENC_PREFIX . ':arrayType', ggSOAPRequest::XSD_PREFIX . ":string[$arrayCount]" ); foreach ( $value as $arrayItem ) { $subNode = ggSOAPRequest::encodeValue( $doc, "item", $arrayItem ); $node->appendChild( $subNode ); } return $node; } } break; } return false; }
[ "static", "function", "encodeValue", "(", "$", "doc", ",", "$", "name", ",", "$", "value", ")", "{", "switch", "(", "gettype", "(", "$", "value", ")", ")", "{", "case", "\"string\"", ":", "{", "$", "node", "=", "$", "doc", "->", "createElement", "(", "$", "name", ",", "$", "value", ")", ";", "$", "node", "->", "setAttribute", "(", "ggSOAPRequest", "::", "XSI_PREFIX", ".", "':type'", ",", "ggSOAPRequest", "::", "XSD_PREFIX", ".", "':string'", ")", ";", "return", "$", "node", ";", "}", "break", ";", "case", "\"boolean\"", ":", "{", "$", "node", "=", "$", "doc", "->", "createElement", "(", "$", "name", ",", "$", "value", "?", "'true'", ":", "'false'", ")", ";", "$", "node", "->", "setAttribute", "(", "ggSOAPRequest", "::", "XSI_PREFIX", ".", "':type'", ",", "ggSOAPRequest", "::", "XSD_PREFIX", ".", "':boolean'", ")", ";", "return", "$", "node", ";", "}", "break", ";", "case", "\"integer\"", ":", "{", "$", "node", "=", "$", "doc", "->", "createElement", "(", "$", "name", ",", "$", "value", ")", ";", "$", "node", "->", "setAttribute", "(", "ggSOAPRequest", "::", "XSI_PREFIX", ".", "':type'", ",", "ggSOAPRequest", "::", "XSD_PREFIX", ".", "':int'", ")", ";", "return", "$", "node", ";", "}", "break", ";", "case", "\"double\"", ":", "{", "$", "node", "=", "$", "doc", "->", "createElement", "(", "$", "name", ",", "$", "value", ")", ";", "$", "node", "->", "setAttribute", "(", "ggSOAPRequest", "::", "XSI_PREFIX", ".", "':type'", ",", "ggSOAPRequest", "::", "XSD_PREFIX", ".", "':float'", ")", ";", "return", "$", "node", ";", "}", "break", ";", "case", "\"array\"", ":", "{", "$", "arrayCount", "=", "count", "(", "$", "value", ")", ";", "$", "isStruct", "=", "false", ";", "// Check for struct", "$", "i", "=", "0", ";", "foreach", "(", "$", "value", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "$", "i", "!==", "$", "key", ")", "{", "$", "isStruct", "=", "true", ";", "break", ";", "}", "$", "i", "++", ";", "}", "if", "(", "$", "isStruct", "==", "true", ")", "{", "$", "node", "=", "$", "doc", "->", "createElement", "(", "$", "name", ")", ";", "$", "node", "->", "setAttribute", "(", "ggSOAPRequest", "::", "XSI_PREFIX", ".", "':type'", ",", "ggSOAPRequest", "::", "ENC_PREFIX", ".", "':SOAPStruct'", ")", ";", "foreach", "(", "$", "value", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "subNode", "=", "ggSOAPRequest", "::", "encodeValue", "(", "$", "doc", ",", "(", "string", ")", "$", "key", ",", "$", "val", ")", ";", "$", "node", "->", "appendChild", "(", "$", "subNode", ")", ";", "}", "return", "$", "node", ";", "}", "else", "{", "$", "node", "=", "$", "doc", "->", "createElement", "(", "$", "name", ")", ";", "$", "node", "->", "setAttribute", "(", "ggSOAPRequest", "::", "XSI_PREFIX", ".", "':type'", ",", "ggSOAPRequest", "::", "ENC_PREFIX", ".", "':Array'", ")", ";", "$", "node", "->", "setAttribute", "(", "ggSOAPRequest", "::", "ENC_PREFIX", ".", "':arrayType'", ",", "ggSOAPRequest", "::", "XSD_PREFIX", ".", "\":string[$arrayCount]\"", ")", ";", "foreach", "(", "$", "value", "as", "$", "arrayItem", ")", "{", "$", "subNode", "=", "ggSOAPRequest", "::", "encodeValue", "(", "$", "doc", ",", "\"item\"", ",", "$", "arrayItem", ")", ";", "$", "node", "->", "appendChild", "(", "$", "subNode", ")", ";", "}", "return", "$", "node", ";", "}", "}", "break", ";", "}", "return", "false", ";", "}" ]
Encodes a PHP variable into a SOAP datatype. @todo move this logic into ggWSDLParser class @param DOMDocument $doc @param string $name @param mixed $value @return DOMElement|false
[ "Encodes", "a", "PHP", "variable", "into", "a", "SOAP", "datatype", "." ]
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggsoaprequest.php#L81-L167
228,156
antaresproject/core
src/components/exception/Handler.php
Handler.argumentsToString
protected function argumentsToString($args) { $count = 0; $isAssoc = $args !== array_values($args); foreach ($args as $key => $value) { $count++; if ($count >= 5) { if ($count > 5) { unset($args[$key]); } else { $args[$key] = '...'; } continue; } if (is_object($value)) { $args[$key] = get_class($value); } elseif (is_bool($value)) { $args[$key] = $value ? 'true' : 'false'; } elseif (is_string($value)) { if (strlen($value) > 64) { $args[$key] = '"' . substr($value, 0, 64) . '..."'; } else { $args[$key] = '"' . $value . '"'; } } elseif (is_array($value)) { $args[$key] = 'array(' . $this->argumentsToString($value) . ')'; } elseif ($value === null) { $args[$key] = 'null'; } elseif (is_resource($value)) { $args[$key] = 'resource'; } if (is_string($key)) { $args[$key] = '"' . $key . '" => ' . $args[$key]; } elseif ($isAssoc) { $args[$key] = $key . ' => ' . $args[$key]; } } $out = implode(", ", $args); return $out; }
php
protected function argumentsToString($args) { $count = 0; $isAssoc = $args !== array_values($args); foreach ($args as $key => $value) { $count++; if ($count >= 5) { if ($count > 5) { unset($args[$key]); } else { $args[$key] = '...'; } continue; } if (is_object($value)) { $args[$key] = get_class($value); } elseif (is_bool($value)) { $args[$key] = $value ? 'true' : 'false'; } elseif (is_string($value)) { if (strlen($value) > 64) { $args[$key] = '"' . substr($value, 0, 64) . '..."'; } else { $args[$key] = '"' . $value . '"'; } } elseif (is_array($value)) { $args[$key] = 'array(' . $this->argumentsToString($value) . ')'; } elseif ($value === null) { $args[$key] = 'null'; } elseif (is_resource($value)) { $args[$key] = 'resource'; } if (is_string($key)) { $args[$key] = '"' . $key . '" => ' . $args[$key]; } elseif ($isAssoc) { $args[$key] = $key . ' => ' . $args[$key]; } } $out = implode(", ", $args); return $out; }
[ "protected", "function", "argumentsToString", "(", "$", "args", ")", "{", "$", "count", "=", "0", ";", "$", "isAssoc", "=", "$", "args", "!==", "array_values", "(", "$", "args", ")", ";", "foreach", "(", "$", "args", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "count", "++", ";", "if", "(", "$", "count", ">=", "5", ")", "{", "if", "(", "$", "count", ">", "5", ")", "{", "unset", "(", "$", "args", "[", "$", "key", "]", ")", ";", "}", "else", "{", "$", "args", "[", "$", "key", "]", "=", "'...'", ";", "}", "continue", ";", "}", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "$", "args", "[", "$", "key", "]", "=", "get_class", "(", "$", "value", ")", ";", "}", "elseif", "(", "is_bool", "(", "$", "value", ")", ")", "{", "$", "args", "[", "$", "key", "]", "=", "$", "value", "?", "'true'", ":", "'false'", ";", "}", "elseif", "(", "is_string", "(", "$", "value", ")", ")", "{", "if", "(", "strlen", "(", "$", "value", ")", ">", "64", ")", "{", "$", "args", "[", "$", "key", "]", "=", "'\"'", ".", "substr", "(", "$", "value", ",", "0", ",", "64", ")", ".", "'...\"'", ";", "}", "else", "{", "$", "args", "[", "$", "key", "]", "=", "'\"'", ".", "$", "value", ".", "'\"'", ";", "}", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "args", "[", "$", "key", "]", "=", "'array('", ".", "$", "this", "->", "argumentsToString", "(", "$", "value", ")", ".", "')'", ";", "}", "elseif", "(", "$", "value", "===", "null", ")", "{", "$", "args", "[", "$", "key", "]", "=", "'null'", ";", "}", "elseif", "(", "is_resource", "(", "$", "value", ")", ")", "{", "$", "args", "[", "$", "key", "]", "=", "'resource'", ";", "}", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "$", "args", "[", "$", "key", "]", "=", "'\"'", ".", "$", "key", ".", "'\" => '", ".", "$", "args", "[", "$", "key", "]", ";", "}", "elseif", "(", "$", "isAssoc", ")", "{", "$", "args", "[", "$", "key", "]", "=", "$", "key", ".", "' => '", ".", "$", "args", "[", "$", "key", "]", ";", "}", "}", "$", "out", "=", "implode", "(", "\", \"", ",", "$", "args", ")", ";", "return", "$", "out", ";", "}" ]
arguments to String decorator @param array $args @return String
[ "arguments", "to", "String", "decorator" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/exception/Handler.php#L266-L310
228,157
antaresproject/core
src/components/html/src/Form/ClientScript.php
ClientScript.addClientValidation
public function addClientValidation(&$grid) { $rules = $grid->rules; $form = $grid->attributes; if (!array_key_exists('id', $form)) { $id = $this->generateID(); $grid->attributes(array_merge($form, ['id' => $id])); $form['id'] = $id; } if (!empty($rules)) { $form['data-toggle'] = "validator"; $this->attachScripts(); $this->attachRules($grid, $rules); } if ($grid->ajaxable !== false) { $this->ajaxValidation->build($grid); } return ['form' => $form, 'fieldsets' => $grid->fieldsets()]; }
php
public function addClientValidation(&$grid) { $rules = $grid->rules; $form = $grid->attributes; if (!array_key_exists('id', $form)) { $id = $this->generateID(); $grid->attributes(array_merge($form, ['id' => $id])); $form['id'] = $id; } if (!empty($rules)) { $form['data-toggle'] = "validator"; $this->attachScripts(); $this->attachRules($grid, $rules); } if ($grid->ajaxable !== false) { $this->ajaxValidation->build($grid); } return ['form' => $form, 'fieldsets' => $grid->fieldsets()]; }
[ "public", "function", "addClientValidation", "(", "&", "$", "grid", ")", "{", "$", "rules", "=", "$", "grid", "->", "rules", ";", "$", "form", "=", "$", "grid", "->", "attributes", ";", "if", "(", "!", "array_key_exists", "(", "'id'", ",", "$", "form", ")", ")", "{", "$", "id", "=", "$", "this", "->", "generateID", "(", ")", ";", "$", "grid", "->", "attributes", "(", "array_merge", "(", "$", "form", ",", "[", "'id'", "=>", "$", "id", "]", ")", ")", ";", "$", "form", "[", "'id'", "]", "=", "$", "id", ";", "}", "if", "(", "!", "empty", "(", "$", "rules", ")", ")", "{", "$", "form", "[", "'data-toggle'", "]", "=", "\"validator\"", ";", "$", "this", "->", "attachScripts", "(", ")", ";", "$", "this", "->", "attachRules", "(", "$", "grid", ",", "$", "rules", ")", ";", "}", "if", "(", "$", "grid", "->", "ajaxable", "!==", "false", ")", "{", "$", "this", "->", "ajaxValidation", "->", "build", "(", "$", "grid", ")", ";", "}", "return", "[", "'form'", "=>", "$", "form", ",", "'fieldsets'", "=>", "$", "grid", "->", "fieldsets", "(", ")", "]", ";", "}" ]
create client side form validator @param \Antares\Contracts\Html\Grid $grid @return array
[ "create", "client", "side", "form", "validator" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/ClientScript.php#L83-L104
228,158
antaresproject/core
src/components/html/src/Form/ClientScript.php
ClientScript.attachRules
protected function attachRules(&$grid, array $rules = null) { $fieldsets = $grid->fieldsets(); if (!empty(Input::get('ajax')) && Request::ajax() && !is_null($key = Input::get('key'))) { $name = Crypt::decrypt($key); $fieldsets = $this->fieldPermissionAdapter->resolveFields($fieldsets, $name); if (empty($fieldsets)) { return false; } } $controls = []; foreach ($fieldsets as $fieldset) { foreach ($fieldset->controls as $control) { array_push($controls, method_exists($control, 'getName') ? $control->getType() : $control->name); } } $rulesDispatcher = new RulesDispatcher($rules); $grid->rules($rulesDispatcher->getSupported($controls)); foreach ($fieldsets as $fieldset) { foreach ($fieldset->controls as $control) { $validation = $this->resolveRules($control, $rules); if (method_exists($control, 'setAttributes')) { $control->setAttributes(array_merge($control->getAttributes(), $validation)); } else { $control->attributes = array_merge($control->attributes, $validation); } } } }
php
protected function attachRules(&$grid, array $rules = null) { $fieldsets = $grid->fieldsets(); if (!empty(Input::get('ajax')) && Request::ajax() && !is_null($key = Input::get('key'))) { $name = Crypt::decrypt($key); $fieldsets = $this->fieldPermissionAdapter->resolveFields($fieldsets, $name); if (empty($fieldsets)) { return false; } } $controls = []; foreach ($fieldsets as $fieldset) { foreach ($fieldset->controls as $control) { array_push($controls, method_exists($control, 'getName') ? $control->getType() : $control->name); } } $rulesDispatcher = new RulesDispatcher($rules); $grid->rules($rulesDispatcher->getSupported($controls)); foreach ($fieldsets as $fieldset) { foreach ($fieldset->controls as $control) { $validation = $this->resolveRules($control, $rules); if (method_exists($control, 'setAttributes')) { $control->setAttributes(array_merge($control->getAttributes(), $validation)); } else { $control->attributes = array_merge($control->attributes, $validation); } } } }
[ "protected", "function", "attachRules", "(", "&", "$", "grid", ",", "array", "$", "rules", "=", "null", ")", "{", "$", "fieldsets", "=", "$", "grid", "->", "fieldsets", "(", ")", ";", "if", "(", "!", "empty", "(", "Input", "::", "get", "(", "'ajax'", ")", ")", "&&", "Request", "::", "ajax", "(", ")", "&&", "!", "is_null", "(", "$", "key", "=", "Input", "::", "get", "(", "'key'", ")", ")", ")", "{", "$", "name", "=", "Crypt", "::", "decrypt", "(", "$", "key", ")", ";", "$", "fieldsets", "=", "$", "this", "->", "fieldPermissionAdapter", "->", "resolveFields", "(", "$", "fieldsets", ",", "$", "name", ")", ";", "if", "(", "empty", "(", "$", "fieldsets", ")", ")", "{", "return", "false", ";", "}", "}", "$", "controls", "=", "[", "]", ";", "foreach", "(", "$", "fieldsets", "as", "$", "fieldset", ")", "{", "foreach", "(", "$", "fieldset", "->", "controls", "as", "$", "control", ")", "{", "array_push", "(", "$", "controls", ",", "method_exists", "(", "$", "control", ",", "'getName'", ")", "?", "$", "control", "->", "getType", "(", ")", ":", "$", "control", "->", "name", ")", ";", "}", "}", "$", "rulesDispatcher", "=", "new", "RulesDispatcher", "(", "$", "rules", ")", ";", "$", "grid", "->", "rules", "(", "$", "rulesDispatcher", "->", "getSupported", "(", "$", "controls", ")", ")", ";", "foreach", "(", "$", "fieldsets", "as", "$", "fieldset", ")", "{", "foreach", "(", "$", "fieldset", "->", "controls", "as", "$", "control", ")", "{", "$", "validation", "=", "$", "this", "->", "resolveRules", "(", "$", "control", ",", "$", "rules", ")", ";", "if", "(", "method_exists", "(", "$", "control", ",", "'setAttributes'", ")", ")", "{", "$", "control", "->", "setAttributes", "(", "array_merge", "(", "$", "control", "->", "getAttributes", "(", ")", ",", "$", "validation", ")", ")", ";", "}", "else", "{", "$", "control", "->", "attributes", "=", "array_merge", "(", "$", "control", "->", "attributes", ",", "$", "validation", ")", ";", "}", "}", "}", "}" ]
attach rules to form controls @param array $fieldsets @param array $rules
[ "attach", "rules", "to", "form", "controls" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/ClientScript.php#L112-L144
228,159
antaresproject/core
src/components/html/src/Form/ClientScript.php
ClientScript.resolveRule
protected function resolveRule($rule) { $validation = []; if (is_array($rule)) { return $validation; } switch ($rule) { case 'required': $validation['required'] = 'required'; break; default: if (str_contains($rule, ':') && !str_contains($rule, 'unique')) { list($name, $value) = explode(':', $rule); $validation["data-{$name}length"] = $value; } break; } return $validation; }
php
protected function resolveRule($rule) { $validation = []; if (is_array($rule)) { return $validation; } switch ($rule) { case 'required': $validation['required'] = 'required'; break; default: if (str_contains($rule, ':') && !str_contains($rule, 'unique')) { list($name, $value) = explode(':', $rule); $validation["data-{$name}length"] = $value; } break; } return $validation; }
[ "protected", "function", "resolveRule", "(", "$", "rule", ")", "{", "$", "validation", "=", "[", "]", ";", "if", "(", "is_array", "(", "$", "rule", ")", ")", "{", "return", "$", "validation", ";", "}", "switch", "(", "$", "rule", ")", "{", "case", "'required'", ":", "$", "validation", "[", "'required'", "]", "=", "'required'", ";", "break", ";", "default", ":", "if", "(", "str_contains", "(", "$", "rule", ",", "':'", ")", "&&", "!", "str_contains", "(", "$", "rule", ",", "'unique'", ")", ")", "{", "list", "(", "$", "name", ",", "$", "value", ")", "=", "explode", "(", "':'", ",", "$", "rule", ")", ";", "$", "validation", "[", "\"data-{$name}length\"", "]", "=", "$", "value", ";", "}", "break", ";", "}", "return", "$", "validation", ";", "}" ]
resolve single form rule @param String $rule @return array
[ "resolve", "single", "form", "rule" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/ClientScript.php#L164-L183
228,160
antaresproject/core
src/components/html/src/Form/ClientScript.php
ClientScript.attachScripts
protected function attachScripts() { $scripts = $this->container->make('config')->get('antares/html::form.scripts.client-side'); $container = $this->container->make('antares.asset')->container($scripts['position']); foreach ($scripts['resources'] as $name => $path) { $container->add($name, $path); } return; }
php
protected function attachScripts() { $scripts = $this->container->make('config')->get('antares/html::form.scripts.client-side'); $container = $this->container->make('antares.asset')->container($scripts['position']); foreach ($scripts['resources'] as $name => $path) { $container->add($name, $path); } return; }
[ "protected", "function", "attachScripts", "(", ")", "{", "$", "scripts", "=", "$", "this", "->", "container", "->", "make", "(", "'config'", ")", "->", "get", "(", "'antares/html::form.scripts.client-side'", ")", ";", "$", "container", "=", "$", "this", "->", "container", "->", "make", "(", "'antares.asset'", ")", "->", "container", "(", "$", "scripts", "[", "'position'", "]", ")", ";", "foreach", "(", "$", "scripts", "[", "'resources'", "]", "as", "$", "name", "=>", "$", "path", ")", "{", "$", "container", "->", "add", "(", "$", "name", ",", "$", "path", ")", ";", "}", "return", ";", "}" ]
attach validator client side scripts
[ "attach", "validator", "client", "side", "scripts" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Form/ClientScript.php#L188-L196
228,161
antaresproject/core
src/components/memory/src/DefaultHandler.php
DefaultHandler.getItemsFromCache
protected function getItemsFromCache() { return 'cli' === PHP_SAPI ? $this->getItemsFromDatabase() : $this->cache->rememberForever($this->cacheKey, function () { return $this->getItemsFromDatabase(); }); }
php
protected function getItemsFromCache() { return 'cli' === PHP_SAPI ? $this->getItemsFromDatabase() : $this->cache->rememberForever($this->cacheKey, function () { return $this->getItemsFromDatabase(); }); }
[ "protected", "function", "getItemsFromCache", "(", ")", "{", "return", "'cli'", "===", "PHP_SAPI", "?", "$", "this", "->", "getItemsFromDatabase", "(", ")", ":", "$", "this", "->", "cache", "->", "rememberForever", "(", "$", "this", "->", "cacheKey", ",", "function", "(", ")", "{", "return", "$", "this", "->", "getItemsFromDatabase", "(", ")", ";", "}", ")", ";", "}" ]
Get items from cache. @return array
[ "Get", "items", "from", "cache", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/src/DefaultHandler.php#L107-L112
228,162
antaresproject/core
src/components/memory/src/DefaultHandler.php
DefaultHandler.forceForgetCache
public function forceForgetCache() { return !is_null($this->cache) ? $this->cache->forget($this->cacheKey) : true; }
php
public function forceForgetCache() { return !is_null($this->cache) ? $this->cache->forget($this->cacheKey) : true; }
[ "public", "function", "forceForgetCache", "(", ")", "{", "return", "!", "is_null", "(", "$", "this", "->", "cache", ")", "?", "$", "this", "->", "cache", "->", "forget", "(", "$", "this", "->", "cacheKey", ")", ":", "true", ";", "}" ]
forcing delete cache @return boolean
[ "forcing", "delete", "cache" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/memory/src/DefaultHandler.php#L132-L135
228,163
antaresproject/core
src/utils/asset/src/DependencyResolver.php
DependencyResolver.evaluateAssetWithDependencies
protected function evaluateAssetWithDependencies($asset, $original, &$sorted, &$assets) { foreach ($assets[$asset]['dependencies'] as $key => $dependency) { if (! $this->dependencyIsValid($asset, $dependency, $original, $assets)) { unset($assets[$asset]['dependencies'][$key]); continue; } if (isset($sorted[$dependency])) { unset($assets[$asset]['dependencies'][$key]); } } }
php
protected function evaluateAssetWithDependencies($asset, $original, &$sorted, &$assets) { foreach ($assets[$asset]['dependencies'] as $key => $dependency) { if (! $this->dependencyIsValid($asset, $dependency, $original, $assets)) { unset($assets[$asset]['dependencies'][$key]); continue; } if (isset($sorted[$dependency])) { unset($assets[$asset]['dependencies'][$key]); } } }
[ "protected", "function", "evaluateAssetWithDependencies", "(", "$", "asset", ",", "$", "original", ",", "&", "$", "sorted", ",", "&", "$", "assets", ")", "{", "foreach", "(", "$", "assets", "[", "$", "asset", "]", "[", "'dependencies'", "]", "as", "$", "key", "=>", "$", "dependency", ")", "{", "if", "(", "!", "$", "this", "->", "dependencyIsValid", "(", "$", "asset", ",", "$", "dependency", ",", "$", "original", ",", "$", "assets", ")", ")", "{", "unset", "(", "$", "assets", "[", "$", "asset", "]", "[", "'dependencies'", "]", "[", "$", "key", "]", ")", ";", "continue", ";", "}", "if", "(", "isset", "(", "$", "sorted", "[", "$", "dependency", "]", ")", ")", "{", "unset", "(", "$", "assets", "[", "$", "asset", "]", "[", "'dependencies'", "]", "[", "$", "key", "]", ")", ";", "}", "}", "}" ]
Evaluate an asset with dependencies. @param string $asset @param array $original @param array $sorted @param array $assets @return void
[ "Evaluate", "an", "asset", "with", "dependencies", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/asset/src/DependencyResolver.php#L81-L94
228,164
antaresproject/core
src/utils/asset/src/DependencyResolver.php
DependencyResolver.replaceAssetDependencies
protected function replaceAssetDependencies(&$assets) { foreach ($assets as $asset => $value) { if (empty($replaces = $value['replaces'])) { continue; } foreach ($replaces as $replace) { unset($assets[$replace]); } $this->resolveDependenciesForAsset($assets, $asset, $replaces); } }
php
protected function replaceAssetDependencies(&$assets) { foreach ($assets as $asset => $value) { if (empty($replaces = $value['replaces'])) { continue; } foreach ($replaces as $replace) { unset($assets[$replace]); } $this->resolveDependenciesForAsset($assets, $asset, $replaces); } }
[ "protected", "function", "replaceAssetDependencies", "(", "&", "$", "assets", ")", "{", "foreach", "(", "$", "assets", "as", "$", "asset", "=>", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "replaces", "=", "$", "value", "[", "'replaces'", "]", ")", ")", "{", "continue", ";", "}", "foreach", "(", "$", "replaces", "as", "$", "replace", ")", "{", "unset", "(", "$", "assets", "[", "$", "replace", "]", ")", ";", "}", "$", "this", "->", "resolveDependenciesForAsset", "(", "$", "assets", ",", "$", "asset", ",", "$", "replaces", ")", ";", "}", "}" ]
Replace asset dependencies. @param array $assets @return void
[ "Replace", "asset", "dependencies", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/asset/src/DependencyResolver.php#L137-L150
228,165
antaresproject/core
src/utils/asset/src/DependencyResolver.php
DependencyResolver.resolveDependenciesForAsset
protected function resolveDependenciesForAsset(&$assets, $asset, $replaces) { foreach ($assets as $name => $value) { $changed = false; foreach ($value['dependencies'] as $key => $dependency) { if (in_array($dependency, $replaces)) { $changed = true; unset($value['dependencies'][$key]); } } if ($changed) { $value['dependencies'][] = $asset; $assets[$name]['dependencies'] = $value['dependencies']; } } $assets[$asset]['replaces'] = []; }
php
protected function resolveDependenciesForAsset(&$assets, $asset, $replaces) { foreach ($assets as $name => $value) { $changed = false; foreach ($value['dependencies'] as $key => $dependency) { if (in_array($dependency, $replaces)) { $changed = true; unset($value['dependencies'][$key]); } } if ($changed) { $value['dependencies'][] = $asset; $assets[$name]['dependencies'] = $value['dependencies']; } } $assets[$asset]['replaces'] = []; }
[ "protected", "function", "resolveDependenciesForAsset", "(", "&", "$", "assets", ",", "$", "asset", ",", "$", "replaces", ")", "{", "foreach", "(", "$", "assets", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "changed", "=", "false", ";", "foreach", "(", "$", "value", "[", "'dependencies'", "]", "as", "$", "key", "=>", "$", "dependency", ")", "{", "if", "(", "in_array", "(", "$", "dependency", ",", "$", "replaces", ")", ")", "{", "$", "changed", "=", "true", ";", "unset", "(", "$", "value", "[", "'dependencies'", "]", "[", "$", "key", "]", ")", ";", "}", "}", "if", "(", "$", "changed", ")", "{", "$", "value", "[", "'dependencies'", "]", "[", "]", "=", "$", "asset", ";", "$", "assets", "[", "$", "name", "]", "[", "'dependencies'", "]", "=", "$", "value", "[", "'dependencies'", "]", ";", "}", "}", "$", "assets", "[", "$", "asset", "]", "[", "'replaces'", "]", "=", "[", "]", ";", "}" ]
Resolve asset dependencies after replacement. @param array $assets @param string $asset @param array $replaces @return array
[ "Resolve", "asset", "dependencies", "after", "replacement", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/asset/src/DependencyResolver.php#L161-L180
228,166
antaresproject/core
src/ui/components/datatables/src/Adapter/FilterAdapter.php
FilterAdapter.getDeleteSidebarItem
public function getDeleteSidebarItem($column, $config, $value = null) { if (!isset($config['classname']) or ! class_exists($config['classname']) or ! isset($config['values'])) { return false; } $instance = $this->app->make($config['classname']); $values = !is_null($value) ? [$value] : $config['values']; if (!is_array($values)) { return false; } $names = []; foreach ($values as $key => $value) { $names[] = $instance->getPatterned($value); $instance->setFormData(new Collection($value)); } $name = implode(', ', array_unique($names)); return view('datatables-helpers::partials._deleted', compact('rel', 'value', 'column', 'instance', 'config'))->with([ 'route' => $this->route, 'name' => $name ]) ->render(); }
php
public function getDeleteSidebarItem($column, $config, $value = null) { if (!isset($config['classname']) or ! class_exists($config['classname']) or ! isset($config['values'])) { return false; } $instance = $this->app->make($config['classname']); $values = !is_null($value) ? [$value] : $config['values']; if (!is_array($values)) { return false; } $names = []; foreach ($values as $key => $value) { $names[] = $instance->getPatterned($value); $instance->setFormData(new Collection($value)); } $name = implode(', ', array_unique($names)); return view('datatables-helpers::partials._deleted', compact('rel', 'value', 'column', 'instance', 'config'))->with([ 'route' => $this->route, 'name' => $name ]) ->render(); }
[ "public", "function", "getDeleteSidebarItem", "(", "$", "column", ",", "$", "config", ",", "$", "value", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", "'classname'", "]", ")", "or", "!", "class_exists", "(", "$", "config", "[", "'classname'", "]", ")", "or", "!", "isset", "(", "$", "config", "[", "'values'", "]", ")", ")", "{", "return", "false", ";", "}", "$", "instance", "=", "$", "this", "->", "app", "->", "make", "(", "$", "config", "[", "'classname'", "]", ")", ";", "$", "values", "=", "!", "is_null", "(", "$", "value", ")", "?", "[", "$", "value", "]", ":", "$", "config", "[", "'values'", "]", ";", "if", "(", "!", "is_array", "(", "$", "values", ")", ")", "{", "return", "false", ";", "}", "$", "names", "=", "[", "]", ";", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "names", "[", "]", "=", "$", "instance", "->", "getPatterned", "(", "$", "value", ")", ";", "$", "instance", "->", "setFormData", "(", "new", "Collection", "(", "$", "value", ")", ")", ";", "}", "$", "name", "=", "implode", "(", "', '", ",", "array_unique", "(", "$", "names", ")", ")", ";", "return", "view", "(", "'datatables-helpers::partials._deleted'", ",", "compact", "(", "'rel'", ",", "'value'", ",", "'column'", ",", "'instance'", ",", "'config'", ")", ")", "->", "with", "(", "[", "'route'", "=>", "$", "this", "->", "route", ",", "'name'", "=>", "$", "name", "]", ")", "->", "render", "(", ")", ";", "}" ]
creates removable sidebar filter items @param String $column @param array $config @param mixed $value @return boolean|string
[ "creates", "removable", "sidebar", "filter", "items" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Adapter/FilterAdapter.php#L124-L147
228,167
lawoole/framework
src/Http/HttpServerSocketHandler.php
HttpServerSocketHandler.loadMiddleware
protected function loadMiddleware() { $config = $this->app->make('config'); $this->router->middlewarePriority = $this->middlewarePriority; $this->middleware = $config->get('http.middleware', []); $middlewareGroups = $config->get('http.middleware_groups', []); foreach ($middlewareGroups as $key => $middleware) { $this->router->middlewareGroup($key, $middleware); } $routeMiddleware = $config->get('http.route_middleware', []); foreach ($routeMiddleware as $key => $middleware) { $this->router->aliasMiddleware($key, $middleware); } }
php
protected function loadMiddleware() { $config = $this->app->make('config'); $this->router->middlewarePriority = $this->middlewarePriority; $this->middleware = $config->get('http.middleware', []); $middlewareGroups = $config->get('http.middleware_groups', []); foreach ($middlewareGroups as $key => $middleware) { $this->router->middlewareGroup($key, $middleware); } $routeMiddleware = $config->get('http.route_middleware', []); foreach ($routeMiddleware as $key => $middleware) { $this->router->aliasMiddleware($key, $middleware); } }
[ "protected", "function", "loadMiddleware", "(", ")", "{", "$", "config", "=", "$", "this", "->", "app", "->", "make", "(", "'config'", ")", ";", "$", "this", "->", "router", "->", "middlewarePriority", "=", "$", "this", "->", "middlewarePriority", ";", "$", "this", "->", "middleware", "=", "$", "config", "->", "get", "(", "'http.middleware'", ",", "[", "]", ")", ";", "$", "middlewareGroups", "=", "$", "config", "->", "get", "(", "'http.middleware_groups'", ",", "[", "]", ")", ";", "foreach", "(", "$", "middlewareGroups", "as", "$", "key", "=>", "$", "middleware", ")", "{", "$", "this", "->", "router", "->", "middlewareGroup", "(", "$", "key", ",", "$", "middleware", ")", ";", "}", "$", "routeMiddleware", "=", "$", "config", "->", "get", "(", "'http.route_middleware'", ",", "[", "]", ")", ";", "foreach", "(", "$", "routeMiddleware", "as", "$", "key", "=>", "$", "middleware", ")", "{", "$", "this", "->", "router", "->", "aliasMiddleware", "(", "$", "key", ",", "$", "middleware", ")", ";", "}", "}" ]
Load all configured middleware.
[ "Load", "all", "configured", "middleware", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Http/HttpServerSocketHandler.php#L68-L87
228,168
lawoole/framework
src/Http/HttpServerSocketHandler.php
HttpServerSocketHandler.handleRequest
protected function handleRequest($request, $respondent) { try { $this->app->instance('respondent', $respondent); $request->enableHttpMethodParameterOverride(); $response = $this->sendRequestThroughRouter($request); } catch (Exception $e) { $this->reportException($e); $response = $this->handleException($request, $e); } catch (Throwable $e) { $this->reportException($e = new FatalThrowableError($e)); $response = $this->handleException($request, $e); } $this->app->forgetInstance('respondent'); return $response; }
php
protected function handleRequest($request, $respondent) { try { $this->app->instance('respondent', $respondent); $request->enableHttpMethodParameterOverride(); $response = $this->sendRequestThroughRouter($request); } catch (Exception $e) { $this->reportException($e); $response = $this->handleException($request, $e); } catch (Throwable $e) { $this->reportException($e = new FatalThrowableError($e)); $response = $this->handleException($request, $e); } $this->app->forgetInstance('respondent'); return $response; }
[ "protected", "function", "handleRequest", "(", "$", "request", ",", "$", "respondent", ")", "{", "try", "{", "$", "this", "->", "app", "->", "instance", "(", "'respondent'", ",", "$", "respondent", ")", ";", "$", "request", "->", "enableHttpMethodParameterOverride", "(", ")", ";", "$", "response", "=", "$", "this", "->", "sendRequestThroughRouter", "(", "$", "request", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "this", "->", "reportException", "(", "$", "e", ")", ";", "$", "response", "=", "$", "this", "->", "handleException", "(", "$", "request", ",", "$", "e", ")", ";", "}", "catch", "(", "Throwable", "$", "e", ")", "{", "$", "this", "->", "reportException", "(", "$", "e", "=", "new", "FatalThrowableError", "(", "$", "e", ")", ")", ";", "$", "response", "=", "$", "this", "->", "handleException", "(", "$", "request", ",", "$", "e", ")", ";", "}", "$", "this", "->", "app", "->", "forgetInstance", "(", "'respondent'", ")", ";", "return", "$", "response", ";", "}" ]
Process the request and get response. @param \Illuminate\Http\Request $request @param \Lawoole\Http\Respondent $respondent @return \Symfony\Component\HttpFoundation\Response
[ "Process", "the", "request", "and", "get", "response", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Http/HttpServerSocketHandler.php#L126-L147
228,169
lawoole/framework
src/Http/HttpServerSocketHandler.php
HttpServerSocketHandler.createHttpRequest
protected function createHttpRequest($request) { return new Request( $request->get ?? [], $request->post ?? [], [], $request->cookie ?? [], $request->files ?? [], $this->parseRequestServer($request), $request->rawContent() ); }
php
protected function createHttpRequest($request) { return new Request( $request->get ?? [], $request->post ?? [], [], $request->cookie ?? [], $request->files ?? [], $this->parseRequestServer($request), $request->rawContent() ); }
[ "protected", "function", "createHttpRequest", "(", "$", "request", ")", "{", "return", "new", "Request", "(", "$", "request", "->", "get", "??", "[", "]", ",", "$", "request", "->", "post", "??", "[", "]", ",", "[", "]", ",", "$", "request", "->", "cookie", "??", "[", "]", ",", "$", "request", "->", "files", "??", "[", "]", ",", "$", "this", "->", "parseRequestServer", "(", "$", "request", ")", ",", "$", "request", "->", "rawContent", "(", ")", ")", ";", "}" ]
Create a Http request from the Swoole request. @param \Swoole\Http\Request $request @return \Illuminate\Http\Request
[ "Create", "a", "Http", "request", "from", "the", "Swoole", "request", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Http/HttpServerSocketHandler.php#L156-L162
228,170
lawoole/framework
src/Http/HttpServerSocketHandler.php
HttpServerSocketHandler.reportException
protected function reportException(Exception $e) { $handler = $this->app->make(ExceptionHandler::class); $handler->report($e); }
php
protected function reportException(Exception $e) { $handler = $this->app->make(ExceptionHandler::class); $handler->report($e); }
[ "protected", "function", "reportException", "(", "Exception", "$", "e", ")", "{", "$", "handler", "=", "$", "this", "->", "app", "->", "make", "(", "ExceptionHandler", "::", "class", ")", ";", "$", "handler", "->", "report", "(", "$", "e", ")", ";", "}" ]
Report the exception to a response. @param \Exception $e
[ "Report", "the", "exception", "to", "a", "response", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Http/HttpServerSocketHandler.php#L252-L257
228,171
antaresproject/customfields
src/Events/FormValidate.php
FormValidate.handle
public function handle(Grid $grid) { $name = $grid->name; $extension = app('antares.extension')->getActualExtension(); if (is_null($name) or is_null($extension)) { return false; } $namespace = $extension . '.' . $name; if (is_null(app('antares.memory')->make('registry')->get($namespace))) { return false; } $gridRules = !is_array($grid->rules) ? [] : $grid->rules; $rules = array_merge($gridRules, $this->getRulesForCustomFields($namespace)); $grid->rules($rules); return true; }
php
public function handle(Grid $grid) { $name = $grid->name; $extension = app('antares.extension')->getActualExtension(); if (is_null($name) or is_null($extension)) { return false; } $namespace = $extension . '.' . $name; if (is_null(app('antares.memory')->make('registry')->get($namespace))) { return false; } $gridRules = !is_array($grid->rules) ? [] : $grid->rules; $rules = array_merge($gridRules, $this->getRulesForCustomFields($namespace)); $grid->rules($rules); return true; }
[ "public", "function", "handle", "(", "Grid", "$", "grid", ")", "{", "$", "name", "=", "$", "grid", "->", "name", ";", "$", "extension", "=", "app", "(", "'antares.extension'", ")", "->", "getActualExtension", "(", ")", ";", "if", "(", "is_null", "(", "$", "name", ")", "or", "is_null", "(", "$", "extension", ")", ")", "{", "return", "false", ";", "}", "$", "namespace", "=", "$", "extension", ".", "'.'", ".", "$", "name", ";", "if", "(", "is_null", "(", "app", "(", "'antares.memory'", ")", "->", "make", "(", "'registry'", ")", "->", "get", "(", "$", "namespace", ")", ")", ")", "{", "return", "false", ";", "}", "$", "gridRules", "=", "!", "is_array", "(", "$", "grid", "->", "rules", ")", "?", "[", "]", ":", "$", "grid", "->", "rules", ";", "$", "rules", "=", "array_merge", "(", "$", "gridRules", ",", "$", "this", "->", "getRulesForCustomFields", "(", "$", "namespace", ")", ")", ";", "$", "grid", "->", "rules", "(", "$", "rules", ")", ";", "return", "true", ";", "}" ]
fire event to attach customfields rules to form grid @param Grid $grid @return boolean
[ "fire", "event", "to", "attach", "customfields", "rules", "to", "form", "grid" ]
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Events/FormValidate.php#L36-L52
228,172
antaresproject/customfields
src/Events/FormValidate.php
FormValidate.getRulesForCustomFields
protected function getRulesForCustomFields($namespace) { $rules = []; $brand = antares('memory')->get('brand.default'); $collection = app('antares.customfields.model.view')->query()->where('namespace', $namespace)->where('brand_id', $brand)->get(); if ($collection->isEmpty()) { return $rules; } $collection->each(function($item) use(&$rules) { $validators = []; $item->config->each(function($config) use(&$validators) { $name = $config->validator->name; $name == 'regex' && $config->value = implode('', ['[', $config->value, ']']); $rule = ((!is_null($config->value) ? ':' . $config->value : '')); $validators[] = $name . $rule; }); $rules[$item->name] = $validators; }); return $rules; }
php
protected function getRulesForCustomFields($namespace) { $rules = []; $brand = antares('memory')->get('brand.default'); $collection = app('antares.customfields.model.view')->query()->where('namespace', $namespace)->where('brand_id', $brand)->get(); if ($collection->isEmpty()) { return $rules; } $collection->each(function($item) use(&$rules) { $validators = []; $item->config->each(function($config) use(&$validators) { $name = $config->validator->name; $name == 'regex' && $config->value = implode('', ['[', $config->value, ']']); $rule = ((!is_null($config->value) ? ':' . $config->value : '')); $validators[] = $name . $rule; }); $rules[$item->name] = $validators; }); return $rules; }
[ "protected", "function", "getRulesForCustomFields", "(", "$", "namespace", ")", "{", "$", "rules", "=", "[", "]", ";", "$", "brand", "=", "antares", "(", "'memory'", ")", "->", "get", "(", "'brand.default'", ")", ";", "$", "collection", "=", "app", "(", "'antares.customfields.model.view'", ")", "->", "query", "(", ")", "->", "where", "(", "'namespace'", ",", "$", "namespace", ")", "->", "where", "(", "'brand_id'", ",", "$", "brand", ")", "->", "get", "(", ")", ";", "if", "(", "$", "collection", "->", "isEmpty", "(", ")", ")", "{", "return", "$", "rules", ";", "}", "$", "collection", "->", "each", "(", "function", "(", "$", "item", ")", "use", "(", "&", "$", "rules", ")", "{", "$", "validators", "=", "[", "]", ";", "$", "item", "->", "config", "->", "each", "(", "function", "(", "$", "config", ")", "use", "(", "&", "$", "validators", ")", "{", "$", "name", "=", "$", "config", "->", "validator", "->", "name", ";", "$", "name", "==", "'regex'", "&&", "$", "config", "->", "value", "=", "implode", "(", "''", ",", "[", "'['", ",", "$", "config", "->", "value", ",", "']'", "]", ")", ";", "$", "rule", "=", "(", "(", "!", "is_null", "(", "$", "config", "->", "value", ")", "?", "':'", ".", "$", "config", "->", "value", ":", "''", ")", ")", ";", "$", "validators", "[", "]", "=", "$", "name", ".", "$", "rule", ";", "}", ")", ";", "$", "rules", "[", "$", "item", "->", "name", "]", "=", "$", "validators", ";", "}", ")", ";", "return", "$", "rules", ";", "}" ]
get rules for customfields @param String $namespace @return array
[ "get", "rules", "for", "customfields" ]
7e7fd9dec91249c946592c31dbd3994a3d41c1bd
https://github.com/antaresproject/customfields/blob/7e7fd9dec91249c946592c31dbd3994a3d41c1bd/src/Events/FormValidate.php#L60-L81
228,173
antaresproject/core
src/components/extension/src/RouteGenerator.php
RouteGenerator.domain
public function domain($forceBase = false) { $pattern = $this->domain; if ($pattern === null && $forceBase === true) { $pattern = $this->baseUrl; } elseif (Str::contains($pattern, '{{domain}}')) { $pattern = str_replace('{{domain}}', $this->baseUrl, $pattern); } return $pattern; }
php
public function domain($forceBase = false) { $pattern = $this->domain; if ($pattern === null && $forceBase === true) { $pattern = $this->baseUrl; } elseif (Str::contains($pattern, '{{domain}}')) { $pattern = str_replace('{{domain}}', $this->baseUrl, $pattern); } return $pattern; }
[ "public", "function", "domain", "(", "$", "forceBase", "=", "false", ")", "{", "$", "pattern", "=", "$", "this", "->", "domain", ";", "if", "(", "$", "pattern", "===", "null", "&&", "$", "forceBase", "===", "true", ")", "{", "$", "pattern", "=", "$", "this", "->", "baseUrl", ";", "}", "elseif", "(", "Str", "::", "contains", "(", "$", "pattern", ",", "'{{domain}}'", ")", ")", "{", "$", "pattern", "=", "str_replace", "(", "'{{domain}}'", ",", "$", "this", "->", "baseUrl", ",", "$", "pattern", ")", ";", "}", "return", "$", "pattern", ";", "}" ]
Get route domain. @param bool $forceBase @return string
[ "Get", "route", "domain", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/RouteGenerator.php#L94-L105
228,174
antaresproject/core
src/components/extension/src/RouteGenerator.php
RouteGenerator.prefix
public function prefix($forceBase = false) { if (!is_string($this->prefix)) { return '/'; } $pattern = trim($this->prefix, '/'); if ($this->domain === null && $forceBase === true) { $pattern = trim($this->basePrefix, '/') . "/{$pattern}"; $pattern = trim($pattern, '/'); } empty($pattern) && $pattern = '/'; return $pattern; }
php
public function prefix($forceBase = false) { if (!is_string($this->prefix)) { return '/'; } $pattern = trim($this->prefix, '/'); if ($this->domain === null && $forceBase === true) { $pattern = trim($this->basePrefix, '/') . "/{$pattern}"; $pattern = trim($pattern, '/'); } empty($pattern) && $pattern = '/'; return $pattern; }
[ "public", "function", "prefix", "(", "$", "forceBase", "=", "false", ")", "{", "if", "(", "!", "is_string", "(", "$", "this", "->", "prefix", ")", ")", "{", "return", "'/'", ";", "}", "$", "pattern", "=", "trim", "(", "$", "this", "->", "prefix", ",", "'/'", ")", ";", "if", "(", "$", "this", "->", "domain", "===", "null", "&&", "$", "forceBase", "===", "true", ")", "{", "$", "pattern", "=", "trim", "(", "$", "this", "->", "basePrefix", ",", "'/'", ")", ".", "\"/{$pattern}\"", ";", "$", "pattern", "=", "trim", "(", "$", "pattern", ",", "'/'", ")", ";", "}", "empty", "(", "$", "pattern", ")", "&&", "$", "pattern", "=", "'/'", ";", "return", "$", "pattern", ";", "}" ]
Get route prefix. @param bool $forceBase @return string
[ "Get", "route", "prefix", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/RouteGenerator.php#L152-L165
228,175
antaresproject/core
src/components/extension/src/RouteGenerator.php
RouteGenerator.root
public function root() { $http = ($this->request->secure() ? 'https' : 'http'); $domain = trim($this->domain(true), '/'); $prefix = $this->prefix(true); return trim("{$http}://{$domain}/{$prefix}", '/'); }
php
public function root() { $http = ($this->request->secure() ? 'https' : 'http'); $domain = trim($this->domain(true), '/'); $prefix = $this->prefix(true); return trim("{$http}://{$domain}/{$prefix}", '/'); }
[ "public", "function", "root", "(", ")", "{", "$", "http", "=", "(", "$", "this", "->", "request", "->", "secure", "(", ")", "?", "'https'", ":", "'http'", ")", ";", "$", "domain", "=", "trim", "(", "$", "this", "->", "domain", "(", "true", ")", ",", "'/'", ")", ";", "$", "prefix", "=", "$", "this", "->", "prefix", "(", "true", ")", ";", "return", "trim", "(", "\"{$http}://{$domain}/{$prefix}\"", ",", "'/'", ")", ";", "}" ]
Get route root. @return string
[ "Get", "route", "root", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/RouteGenerator.php#L172-L179
228,176
antaresproject/core
src/components/extension/src/RouteGenerator.php
RouteGenerator.setBaseUrl
public function setBaseUrl($root) { $baseUrl = str_replace(['https://', 'http://'], '', $root); $base = explode('/', $baseUrl, 2); if (count($base) > 1) { $this->basePrefix = array_pop($base); } $this->baseUrl = array_shift($base); return $this; }
php
public function setBaseUrl($root) { $baseUrl = str_replace(['https://', 'http://'], '', $root); $base = explode('/', $baseUrl, 2); if (count($base) > 1) { $this->basePrefix = array_pop($base); } $this->baseUrl = array_shift($base); return $this; }
[ "public", "function", "setBaseUrl", "(", "$", "root", ")", "{", "$", "baseUrl", "=", "str_replace", "(", "[", "'https://'", ",", "'http://'", "]", ",", "''", ",", "$", "root", ")", ";", "$", "base", "=", "explode", "(", "'/'", ",", "$", "baseUrl", ",", "2", ")", ";", "if", "(", "count", "(", "$", "base", ")", ">", "1", ")", "{", "$", "this", "->", "basePrefix", "=", "array_pop", "(", "$", "base", ")", ";", "}", "$", "this", "->", "baseUrl", "=", "array_shift", "(", "$", "base", ")", ";", "return", "$", "this", ";", "}" ]
Set base URL. @param string $root @return $this
[ "Set", "base", "URL", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/RouteGenerator.php#L188-L201
228,177
antaresproject/core
src/components/extension/src/RouteGenerator.php
RouteGenerator.to
public function to($to) { $root = $this->root(); $to = trim($to, '/'); $pattern = trim("{$root}/{$to}", '/'); return $pattern !== '/' ? $pattern : ''; }
php
public function to($to) { $root = $this->root(); $to = trim($to, '/'); $pattern = trim("{$root}/{$to}", '/'); return $pattern !== '/' ? $pattern : ''; }
[ "public", "function", "to", "(", "$", "to", ")", "{", "$", "root", "=", "$", "this", "->", "root", "(", ")", ";", "$", "to", "=", "trim", "(", "$", "to", ",", "'/'", ")", ";", "$", "pattern", "=", "trim", "(", "\"{$root}/{$to}\"", ",", "'/'", ")", ";", "return", "$", "pattern", "!==", "'/'", "?", "$", "pattern", ":", "''", ";", "}" ]
Get route to. @param string $to @return string
[ "Get", "route", "to", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/RouteGenerator.php#L210-L217
228,178
antaresproject/core
src/utils/customfield/src/CustomField.php
CustomField.setField
public function setField(Closure $value) { $this->onValidate(); $this->attributes['field'] = $value; @list($name, $type) = explode(':', $this->attributes['type']); $whereType = [ 'name' => $name, ]; if (!is_null($type)) { array_set($whereType, 'type', $type); } $typeModel = FieldType::query()->where($whereType)->firstOrFail(); $where = [ 'name' => $this->name, 'brand_id' => brand_id(), 'imported' => 1, 'type_id' => $typeModel->id, 'force_display' => 1 ]; $field = FieldView::query()->where($where)->first(); if (is_null($field)) { return $this; } $this->attributes($field); return $this; }
php
public function setField(Closure $value) { $this->onValidate(); $this->attributes['field'] = $value; @list($name, $type) = explode(':', $this->attributes['type']); $whereType = [ 'name' => $name, ]; if (!is_null($type)) { array_set($whereType, 'type', $type); } $typeModel = FieldType::query()->where($whereType)->firstOrFail(); $where = [ 'name' => $this->name, 'brand_id' => brand_id(), 'imported' => 1, 'type_id' => $typeModel->id, 'force_display' => 1 ]; $field = FieldView::query()->where($where)->first(); if (is_null($field)) { return $this; } $this->attributes($field); return $this; }
[ "public", "function", "setField", "(", "Closure", "$", "value", ")", "{", "$", "this", "->", "onValidate", "(", ")", ";", "$", "this", "->", "attributes", "[", "'field'", "]", "=", "$", "value", ";", "@", "list", "(", "$", "name", ",", "$", "type", ")", "=", "explode", "(", "':'", ",", "$", "this", "->", "attributes", "[", "'type'", "]", ")", ";", "$", "whereType", "=", "[", "'name'", "=>", "$", "name", ",", "]", ";", "if", "(", "!", "is_null", "(", "$", "type", ")", ")", "{", "array_set", "(", "$", "whereType", ",", "'type'", ",", "$", "type", ")", ";", "}", "$", "typeModel", "=", "FieldType", "::", "query", "(", ")", "->", "where", "(", "$", "whereType", ")", "->", "firstOrFail", "(", ")", ";", "$", "where", "=", "[", "'name'", "=>", "$", "this", "->", "name", ",", "'brand_id'", "=>", "brand_id", "(", ")", ",", "'imported'", "=>", "1", ",", "'type_id'", "=>", "$", "typeModel", "->", "id", ",", "'force_display'", "=>", "1", "]", ";", "$", "field", "=", "FieldView", "::", "query", "(", ")", "->", "where", "(", "$", "where", ")", "->", "first", "(", ")", ";", "if", "(", "is_null", "(", "$", "field", ")", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "attributes", "(", "$", "field", ")", ";", "return", "$", "this", ";", "}" ]
Field attribute setter @param Closure $value @return $this
[ "Field", "attribute", "setter" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/customfield/src/CustomField.php#L182-L210
228,179
antaresproject/core
src/utils/customfield/src/CustomField.php
CustomField.queryAttributes
private function queryAttributes(Model $model) { $data = [ 'user_id' => user()->id, 'namespace' => get_class($model), 'foreign_id' => $model->id ]; (is_null($this->field)) ? array_set($data, 'field_class', get_called_class()) : array_set($data, 'field_id', $this->field->id); return $data; }
php
private function queryAttributes(Model $model) { $data = [ 'user_id' => user()->id, 'namespace' => get_class($model), 'foreign_id' => $model->id ]; (is_null($this->field)) ? array_set($data, 'field_class', get_called_class()) : array_set($data, 'field_id', $this->field->id); return $data; }
[ "private", "function", "queryAttributes", "(", "Model", "$", "model", ")", "{", "$", "data", "=", "[", "'user_id'", "=>", "user", "(", ")", "->", "id", ",", "'namespace'", "=>", "get_class", "(", "$", "model", ")", ",", "'foreign_id'", "=>", "$", "model", "->", "id", "]", ";", "(", "is_null", "(", "$", "this", "->", "field", ")", ")", "?", "array_set", "(", "$", "data", ",", "'field_class'", ",", "get_called_class", "(", ")", ")", ":", "array_set", "(", "$", "data", ",", "'field_id'", ",", "$", "this", "->", "field", "->", "id", ")", ";", "return", "$", "data", ";", "}" ]
Gets value query attributes @param Model $model @return array
[ "Gets", "value", "query", "attributes" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/customfield/src/CustomField.php#L236-L245
228,180
antaresproject/core
src/utils/customfield/src/CustomField.php
CustomField.getValue
public function getValue() { $data = $this->queryAttributes($this->model); $fieldData = FieldData::query()->where($data)->first(['data']); return !is_null($fieldData) ? $fieldData->data : null; }
php
public function getValue() { $data = $this->queryAttributes($this->model); $fieldData = FieldData::query()->where($data)->first(['data']); return !is_null($fieldData) ? $fieldData->data : null; }
[ "public", "function", "getValue", "(", ")", "{", "$", "data", "=", "$", "this", "->", "queryAttributes", "(", "$", "this", "->", "model", ")", ";", "$", "fieldData", "=", "FieldData", "::", "query", "(", ")", "->", "where", "(", "$", "data", ")", "->", "first", "(", "[", "'data'", "]", ")", ";", "return", "!", "is_null", "(", "$", "fieldData", ")", "?", "$", "fieldData", "->", "data", ":", "null", ";", "}" ]
Gets customfield value @return mixed
[ "Gets", "customfield", "value" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/utils/customfield/src/CustomField.php#L265-L270
228,181
brick/http
src/Message.php
Message.getHeaders
public function getHeaders() : array { $headers = []; foreach ($this->headers as $name => $values) { $name = implode('-', array_map('ucfirst', explode('-', strtolower($name)))); $headers[$name] = $values; } return $headers; }
php
public function getHeaders() : array { $headers = []; foreach ($this->headers as $name => $values) { $name = implode('-', array_map('ucfirst', explode('-', strtolower($name)))); $headers[$name] = $values; } return $headers; }
[ "public", "function", "getHeaders", "(", ")", ":", "array", "{", "$", "headers", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "headers", "as", "$", "name", "=>", "$", "values", ")", "{", "$", "name", "=", "implode", "(", "'-'", ",", "array_map", "(", "'ucfirst'", ",", "explode", "(", "'-'", ",", "strtolower", "(", "$", "name", ")", ")", ")", ")", ";", "$", "headers", "[", "$", "name", "]", "=", "$", "values", ";", "}", "return", "$", "headers", ";", "}" ]
Gets all message headers. The keys represent the header name as it will be sent over the wire, and each value is an array of strings associated with the header. @return array
[ "Gets", "all", "message", "headers", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Message.php#L64-L74
228,182
brick/http
src/Message.php
Message.getFirstHeader
public function getFirstHeader(string $name) : ?string { $name = strtolower($name); return isset($this->headers[$name]) ? reset($this->headers[$name]) : null; }
php
public function getFirstHeader(string $name) : ?string { $name = strtolower($name); return isset($this->headers[$name]) ? reset($this->headers[$name]) : null; }
[ "public", "function", "getFirstHeader", "(", "string", "$", "name", ")", ":", "?", "string", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "return", "isset", "(", "$", "this", "->", "headers", "[", "$", "name", "]", ")", "?", "reset", "(", "$", "this", "->", "headers", "[", "$", "name", "]", ")", ":", "null", ";", "}" ]
Returns the value of the first header by the given case-insensitive name, or null if no such header is present. @param string $name @return string|null
[ "Returns", "the", "value", "of", "the", "first", "header", "by", "the", "given", "case", "-", "insensitive", "name", "or", "null", "if", "no", "such", "header", "is", "present", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Message.php#L115-L120
228,183
brick/http
src/Message.php
Message.getLastHeader
public function getLastHeader(string $name) : ?string { $name = strtolower($name); return isset($this->headers[$name]) ? end($this->headers[$name]) : null; }
php
public function getLastHeader(string $name) : ?string { $name = strtolower($name); return isset($this->headers[$name]) ? end($this->headers[$name]) : null; }
[ "public", "function", "getLastHeader", "(", "string", "$", "name", ")", ":", "?", "string", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "return", "isset", "(", "$", "this", "->", "headers", "[", "$", "name", "]", ")", "?", "end", "(", "$", "this", "->", "headers", "[", "$", "name", "]", ")", ":", "null", ";", "}" ]
Returns the value of the last header by the given case-insensitive name, or null if no such header is present. @param string $name @return string|null
[ "Returns", "the", "value", "of", "the", "last", "header", "by", "the", "given", "case", "-", "insensitive", "name", "or", "null", "if", "no", "such", "header", "is", "present", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Message.php#L129-L134
228,184
brick/http
src/Message.php
Message.setHeader
public function setHeader(string $name, $value) : Message { $name = strtolower($name); $this->headers[$name] = is_array($value) ? array_values($value) : [$value]; return $this; }
php
public function setHeader(string $name, $value) : Message { $name = strtolower($name); $this->headers[$name] = is_array($value) ? array_values($value) : [$value]; return $this; }
[ "public", "function", "setHeader", "(", "string", "$", "name", ",", "$", "value", ")", ":", "Message", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "$", "this", "->", "headers", "[", "$", "name", "]", "=", "is_array", "(", "$", "value", ")", "?", "array_values", "(", "$", "value", ")", ":", "[", "$", "value", "]", ";", "return", "$", "this", ";", "}" ]
Sets a header, replacing any existing values of any headers with the same case-insensitive name. The header value MUST be a string or an array of strings. @param string $name @param string|array $value @return static
[ "Sets", "a", "header", "replacing", "any", "existing", "values", "of", "any", "headers", "with", "the", "same", "case", "-", "insensitive", "name", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Message.php#L160-L166
228,185
brick/http
src/Message.php
Message.addHeader
public function addHeader(string $name, $value) : Message { $name = strtolower($name); if (is_array($value)) { $value = array_values($value); $this->headers[$name] = isset($this->headers[$name]) ? array_merge($this->headers[$name], $value) : $value; } else { $this->headers[$name][] = $value; } return $this; }
php
public function addHeader(string $name, $value) : Message { $name = strtolower($name); if (is_array($value)) { $value = array_values($value); $this->headers[$name] = isset($this->headers[$name]) ? array_merge($this->headers[$name], $value) : $value; } else { $this->headers[$name][] = $value; } return $this; }
[ "public", "function", "addHeader", "(", "string", "$", "name", ",", "$", "value", ")", ":", "Message", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "array_values", "(", "$", "value", ")", ";", "$", "this", "->", "headers", "[", "$", "name", "]", "=", "isset", "(", "$", "this", "->", "headers", "[", "$", "name", "]", ")", "?", "array_merge", "(", "$", "this", "->", "headers", "[", "$", "name", "]", ",", "$", "value", ")", ":", "$", "value", ";", "}", "else", "{", "$", "this", "->", "headers", "[", "$", "name", "]", "[", "]", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Appends a header value to any existing values associated with the given header name. @param string $name @param string|array $value @return static
[ "Appends", "a", "header", "value", "to", "any", "existing", "values", "associated", "with", "the", "given", "header", "name", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Message.php#L195-L209
228,186
brick/http
src/Message.php
Message.addHeaders
public function addHeaders(array $headers) : Message { foreach ($headers as $name => $value) { $this->addHeader($name, $value); } return $this; }
php
public function addHeaders(array $headers) : Message { foreach ($headers as $name => $value) { $this->addHeader($name, $value); } return $this; }
[ "public", "function", "addHeaders", "(", "array", "$", "headers", ")", ":", "Message", "{", "foreach", "(", "$", "headers", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "this", "->", "addHeader", "(", "$", "name", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Merges in an associative array of headers. Each array key MUST be a string representing the case-insensitive name of a header. Each value MUST be either a string or an array of strings. For each value, the value is appended to any existing header of the same name, or, if a header does not already exist by the given name, then the header is added. @param array $headers @return static
[ "Merges", "in", "an", "associative", "array", "of", "headers", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Message.php#L224-L231
228,187
brick/http
src/Message.php
Message.removeHeader
public function removeHeader(string $name) : Message { $name = strtolower($name); unset($this->headers[$name]); return $this; }
php
public function removeHeader(string $name) : Message { $name = strtolower($name); unset($this->headers[$name]); return $this; }
[ "public", "function", "removeHeader", "(", "string", "$", "name", ")", ":", "Message", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "unset", "(", "$", "this", "->", "headers", "[", "$", "name", "]", ")", ";", "return", "$", "this", ";", "}" ]
Removes a specific header by case-insensitive name. @param string $name @return static
[ "Removes", "a", "specific", "header", "by", "case", "-", "insensitive", "name", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Message.php#L240-L246
228,188
brick/http
src/Message.php
Message.isContentType
public function isContentType(string $contentType) : bool { $thisContentType = $this->getHeader('Content-Type'); $pos = strpos($thisContentType, ';'); if ($pos !== false) { $thisContentType = substr($thisContentType, 0, $pos); } return strtolower($contentType) === strtolower($thisContentType); }
php
public function isContentType(string $contentType) : bool { $thisContentType = $this->getHeader('Content-Type'); $pos = strpos($thisContentType, ';'); if ($pos !== false) { $thisContentType = substr($thisContentType, 0, $pos); } return strtolower($contentType) === strtolower($thisContentType); }
[ "public", "function", "isContentType", "(", "string", "$", "contentType", ")", ":", "bool", "{", "$", "thisContentType", "=", "$", "this", "->", "getHeader", "(", "'Content-Type'", ")", ";", "$", "pos", "=", "strpos", "(", "$", "thisContentType", ",", "';'", ")", ";", "if", "(", "$", "pos", "!==", "false", ")", "{", "$", "thisContentType", "=", "substr", "(", "$", "thisContentType", ",", "0", ",", "$", "pos", ")", ";", "}", "return", "strtolower", "(", "$", "contentType", ")", "===", "strtolower", "(", "$", "thisContentType", ")", ";", "}" ]
Returns whether this message has the given Content-Type. The given Content-Type must consist of the type and subtype, without parameters. The comparison is case-insensitive, as per RFC 1521. @param string $contentType The Content-Type to check, such as `text/html`. @return bool
[ "Returns", "whether", "this", "message", "has", "the", "given", "Content", "-", "Type", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Message.php#L327-L338
228,189
lawoole/framework
src/Foundation/Providers/ScheduleServiceProvider.php
ScheduleServiceProvider.loadSchedule
protected function loadSchedule($schedule) { if (($schedules = $this->app['config']['console.schedules']) == null) { return; } foreach ($schedules as $definition) { $type = $definition['type'] ?? 'command'; if (! method_exists($this, $method = 'define'.ucfirst($type).'Schedule')) { throw new InvalidArgumentException("Schedule [{$type}] is not support."); } $this->$method($schedule, $definition); } }
php
protected function loadSchedule($schedule) { if (($schedules = $this->app['config']['console.schedules']) == null) { return; } foreach ($schedules as $definition) { $type = $definition['type'] ?? 'command'; if (! method_exists($this, $method = 'define'.ucfirst($type).'Schedule')) { throw new InvalidArgumentException("Schedule [{$type}] is not support."); } $this->$method($schedule, $definition); } }
[ "protected", "function", "loadSchedule", "(", "$", "schedule", ")", "{", "if", "(", "(", "$", "schedules", "=", "$", "this", "->", "app", "[", "'config'", "]", "[", "'console.schedules'", "]", ")", "==", "null", ")", "{", "return", ";", "}", "foreach", "(", "$", "schedules", "as", "$", "definition", ")", "{", "$", "type", "=", "$", "definition", "[", "'type'", "]", "??", "'command'", ";", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "method", "=", "'define'", ".", "ucfirst", "(", "$", "type", ")", ".", "'Schedule'", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Schedule [{$type}] is not support.\"", ")", ";", "}", "$", "this", "->", "$", "method", "(", "$", "schedule", ",", "$", "definition", ")", ";", "}", "}" ]
Load the schedule tasks. @param \Illuminate\Console\Scheduling\Schedule $schedule
[ "Load", "the", "schedule", "tasks", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Foundation/Providers/ScheduleServiceProvider.php#L33-L48
228,190
lawoole/framework
src/Foundation/Providers/ScheduleServiceProvider.php
ScheduleServiceProvider.defineCommandSchedule
protected function defineCommandSchedule(Schedule $schedule, array $definition) { $arguments = $definition['arguments'] ?? []; $event = $schedule->command($definition['command'], $arguments); $this->configureEvent($event, $definition); }
php
protected function defineCommandSchedule(Schedule $schedule, array $definition) { $arguments = $definition['arguments'] ?? []; $event = $schedule->command($definition['command'], $arguments); $this->configureEvent($event, $definition); }
[ "protected", "function", "defineCommandSchedule", "(", "Schedule", "$", "schedule", ",", "array", "$", "definition", ")", "{", "$", "arguments", "=", "$", "definition", "[", "'arguments'", "]", "??", "[", "]", ";", "$", "event", "=", "$", "schedule", "->", "command", "(", "$", "definition", "[", "'command'", "]", ",", "$", "arguments", ")", ";", "$", "this", "->", "configureEvent", "(", "$", "event", ",", "$", "definition", ")", ";", "}" ]
Define schedule command. @param \Illuminate\Console\Scheduling\Schedule $schedule @param array $definition
[ "Define", "schedule", "command", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Foundation/Providers/ScheduleServiceProvider.php#L56-L63
228,191
lawoole/framework
src/Foundation/Providers/ScheduleServiceProvider.php
ScheduleServiceProvider.defineCallbackSchedule
protected function defineCallbackSchedule(Schedule $schedule, array $definition) { $arguments = $definition['arguments'] ?? []; $event = $schedule->call($definition['callback'], $arguments); $this->configureEvent($event, $definition); }
php
protected function defineCallbackSchedule(Schedule $schedule, array $definition) { $arguments = $definition['arguments'] ?? []; $event = $schedule->call($definition['callback'], $arguments); $this->configureEvent($event, $definition); }
[ "protected", "function", "defineCallbackSchedule", "(", "Schedule", "$", "schedule", ",", "array", "$", "definition", ")", "{", "$", "arguments", "=", "$", "definition", "[", "'arguments'", "]", "??", "[", "]", ";", "$", "event", "=", "$", "schedule", "->", "call", "(", "$", "definition", "[", "'callback'", "]", ",", "$", "arguments", ")", ";", "$", "this", "->", "configureEvent", "(", "$", "event", ",", "$", "definition", ")", ";", "}" ]
Define schedule callback. @param \Illuminate\Console\Scheduling\Schedule $schedule @param array $definition
[ "Define", "schedule", "callback", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Foundation/Providers/ScheduleServiceProvider.php#L71-L78
228,192
lawoole/framework
src/Foundation/Providers/ScheduleServiceProvider.php
ScheduleServiceProvider.defineScriptSchedule
protected function defineScriptSchedule(Schedule $schedule, array $definition) { $arguments = $definition['arguments'] ?? []; $event = $schedule->exec($definition['script'], $arguments); $this->configureEvent($event, $definition); }
php
protected function defineScriptSchedule(Schedule $schedule, array $definition) { $arguments = $definition['arguments'] ?? []; $event = $schedule->exec($definition['script'], $arguments); $this->configureEvent($event, $definition); }
[ "protected", "function", "defineScriptSchedule", "(", "Schedule", "$", "schedule", ",", "array", "$", "definition", ")", "{", "$", "arguments", "=", "$", "definition", "[", "'arguments'", "]", "??", "[", "]", ";", "$", "event", "=", "$", "schedule", "->", "exec", "(", "$", "definition", "[", "'script'", "]", ",", "$", "arguments", ")", ";", "$", "this", "->", "configureEvent", "(", "$", "event", ",", "$", "definition", ")", ";", "}" ]
Define schedule script. @param \Illuminate\Console\Scheduling\Schedule $schedule @param array $definition
[ "Define", "schedule", "script", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Foundation/Providers/ScheduleServiceProvider.php#L86-L93
228,193
lawoole/framework
src/Foundation/Providers/ScheduleServiceProvider.php
ScheduleServiceProvider.defineJobSchedule
protected function defineJobSchedule(Schedule $schedule, array $definition) { $queue = $definition['queue'] ?? []; $event = $schedule->job($definition['job'], $queue); $this->configureEvent($event, $definition); }
php
protected function defineJobSchedule(Schedule $schedule, array $definition) { $queue = $definition['queue'] ?? []; $event = $schedule->job($definition['job'], $queue); $this->configureEvent($event, $definition); }
[ "protected", "function", "defineJobSchedule", "(", "Schedule", "$", "schedule", ",", "array", "$", "definition", ")", "{", "$", "queue", "=", "$", "definition", "[", "'queue'", "]", "??", "[", "]", ";", "$", "event", "=", "$", "schedule", "->", "job", "(", "$", "definition", "[", "'job'", "]", ",", "$", "queue", ")", ";", "$", "this", "->", "configureEvent", "(", "$", "event", ",", "$", "definition", ")", ";", "}" ]
Define schedule job. @param \Illuminate\Console\Scheduling\Schedule $schedule @param array $definition
[ "Define", "schedule", "job", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Foundation/Providers/ScheduleServiceProvider.php#L101-L108
228,194
lawoole/framework
src/Foundation/Providers/ScheduleServiceProvider.php
ScheduleServiceProvider.configureEvent
protected function configureEvent($event, array $definition) { if (isset($definition['cron'])) { $event->cron($definition['cron']); } if (isset($definition['singleton']) && $definition['singleton']) { $event->onOneServer(); } if (isset($definition['mutex']) && $definition['mutex']) { $event->withoutOverlapping(); } }
php
protected function configureEvent($event, array $definition) { if (isset($definition['cron'])) { $event->cron($definition['cron']); } if (isset($definition['singleton']) && $definition['singleton']) { $event->onOneServer(); } if (isset($definition['mutex']) && $definition['mutex']) { $event->withoutOverlapping(); } }
[ "protected", "function", "configureEvent", "(", "$", "event", ",", "array", "$", "definition", ")", "{", "if", "(", "isset", "(", "$", "definition", "[", "'cron'", "]", ")", ")", "{", "$", "event", "->", "cron", "(", "$", "definition", "[", "'cron'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "definition", "[", "'singleton'", "]", ")", "&&", "$", "definition", "[", "'singleton'", "]", ")", "{", "$", "event", "->", "onOneServer", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "definition", "[", "'mutex'", "]", ")", "&&", "$", "definition", "[", "'mutex'", "]", ")", "{", "$", "event", "->", "withoutOverlapping", "(", ")", ";", "}", "}" ]
Configure the schedule event. @param \Illuminate\Console\Scheduling\Event $event @param array $definition
[ "Configure", "the", "schedule", "event", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Foundation/Providers/ScheduleServiceProvider.php#L116-L129
228,195
antaresproject/core
src/ui/components/datatables/src/Engines/QueryBuilderEngine.php
QueryBuilderEngine.compileColumnQuery
protected function compileColumnQuery($query, $method, $parameters, $column, $keyword) { if (method_exists($query, $method) && count($parameters) <= with(new \ReflectionMethod($query, $method))->getNumberOfParameters() ) { if (Str::contains(Str::lower($method), 'raw') || Str::contains(Str::lower($method), 'exists') ) { call_user_func_array( [$query, $method], $this->parameterize($parameters, $keyword) ); } else { call_user_func_array( [$query, $method], $this->parameterize($column, $parameters, $keyword) ); } } }
php
protected function compileColumnQuery($query, $method, $parameters, $column, $keyword) { if (method_exists($query, $method) && count($parameters) <= with(new \ReflectionMethod($query, $method))->getNumberOfParameters() ) { if (Str::contains(Str::lower($method), 'raw') || Str::contains(Str::lower($method), 'exists') ) { call_user_func_array( [$query, $method], $this->parameterize($parameters, $keyword) ); } else { call_user_func_array( [$query, $method], $this->parameterize($column, $parameters, $keyword) ); } } }
[ "protected", "function", "compileColumnQuery", "(", "$", "query", ",", "$", "method", ",", "$", "parameters", ",", "$", "column", ",", "$", "keyword", ")", "{", "if", "(", "method_exists", "(", "$", "query", ",", "$", "method", ")", "&&", "count", "(", "$", "parameters", ")", "<=", "with", "(", "new", "\\", "ReflectionMethod", "(", "$", "query", ",", "$", "method", ")", ")", "->", "getNumberOfParameters", "(", ")", ")", "{", "if", "(", "Str", "::", "contains", "(", "Str", "::", "lower", "(", "$", "method", ")", ",", "'raw'", ")", "||", "Str", "::", "contains", "(", "Str", "::", "lower", "(", "$", "method", ")", ",", "'exists'", ")", ")", "{", "call_user_func_array", "(", "[", "$", "query", ",", "$", "method", "]", ",", "$", "this", "->", "parameterize", "(", "$", "parameters", ",", "$", "keyword", ")", ")", ";", "}", "else", "{", "call_user_func_array", "(", "[", "$", "query", ",", "$", "method", "]", ",", "$", "this", "->", "parameterize", "(", "$", "column", ",", "$", "parameters", ",", "$", "keyword", ")", ")", ";", "}", "}", "}" ]
Perform filter column on selected field. @param mixed $query @param string|Closure $method @param mixed $parameters @param string $column @param string $keyword
[ "Perform", "filter", "column", "on", "selected", "field", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Engines/QueryBuilderEngine.php#L188-L203
228,196
antaresproject/core
src/ui/components/datatables/src/Engines/QueryBuilderEngine.php
QueryBuilderEngine.parameterize
protected function parameterize() { $args = func_get_args(); $keyword = count($args) > 2 ? $args[2] : $args[1]; $parameters = Helper::buildParameters($args); $parameters = Helper::replacePatternWithKeyword($parameters, $keyword, '$1'); return $parameters; }
php
protected function parameterize() { $args = func_get_args(); $keyword = count($args) > 2 ? $args[2] : $args[1]; $parameters = Helper::buildParameters($args); $parameters = Helper::replacePatternWithKeyword($parameters, $keyword, '$1'); return $parameters; }
[ "protected", "function", "parameterize", "(", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "keyword", "=", "count", "(", "$", "args", ")", ">", "2", "?", "$", "args", "[", "2", "]", ":", "$", "args", "[", "1", "]", ";", "$", "parameters", "=", "Helper", "::", "buildParameters", "(", "$", "args", ")", ";", "$", "parameters", "=", "Helper", "::", "replacePatternWithKeyword", "(", "$", "parameters", ",", "$", "keyword", ",", "'$1'", ")", ";", "return", "$", "parameters", ";", "}" ]
Build Query Builder Parameters. @return array
[ "Build", "Query", "Builder", "Parameters", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Engines/QueryBuilderEngine.php#L210-L218
228,197
antaresproject/core
src/ui/components/datatables/src/Engines/QueryBuilderEngine.php
QueryBuilderEngine.compileRelationSearch
protected function compileRelationSearch($query, $relation, $column, $keyword) { $myQuery = clone $this->query; $myQuery->orWhereHas($relation, function ($q) use ($column, $keyword, $query) { $sql = $q->select($this->connection->raw('count(1)')) ->where($column, 'like', $keyword) ->toSql(); $sql = "($sql) >= 1"; $query->orWhereRaw($sql, [$keyword]); }); }
php
protected function compileRelationSearch($query, $relation, $column, $keyword) { $myQuery = clone $this->query; $myQuery->orWhereHas($relation, function ($q) use ($column, $keyword, $query) { $sql = $q->select($this->connection->raw('count(1)')) ->where($column, 'like', $keyword) ->toSql(); $sql = "($sql) >= 1"; $query->orWhereRaw($sql, [$keyword]); }); }
[ "protected", "function", "compileRelationSearch", "(", "$", "query", ",", "$", "relation", ",", "$", "column", ",", "$", "keyword", ")", "{", "$", "myQuery", "=", "clone", "$", "this", "->", "query", ";", "$", "myQuery", "->", "orWhereHas", "(", "$", "relation", ",", "function", "(", "$", "q", ")", "use", "(", "$", "column", ",", "$", "keyword", ",", "$", "query", ")", "{", "$", "sql", "=", "$", "q", "->", "select", "(", "$", "this", "->", "connection", "->", "raw", "(", "'count(1)'", ")", ")", "->", "where", "(", "$", "column", ",", "'like'", ",", "$", "keyword", ")", "->", "toSql", "(", ")", ";", "$", "sql", "=", "\"($sql) >= 1\"", ";", "$", "query", "->", "orWhereRaw", "(", "$", "sql", ",", "[", "$", "keyword", "]", ")", ";", "}", ")", ";", "}" ]
Add relation query on global search. @param mixed $query @param string $relation @param string $column @param string $keyword
[ "Add", "relation", "query", "on", "global", "search", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Engines/QueryBuilderEngine.php#L242-L252
228,198
antaresproject/core
src/ui/components/datatables/src/Engines/QueryBuilderEngine.php
QueryBuilderEngine.compileGlobalSearch
protected function compileGlobalSearch($query, $column, $keyword) { if ($this->isSmartSearch()) { $column = $this->castColumn($column); $sql = $column . ' LIKE ?'; if ($this->isCaseInsensitive()) { $sql = 'LOWER(' . $column . ') LIKE ?'; $keyword = Str::lower($keyword); } $query->orWhereRaw($sql, [$keyword]); } else { // exact match $query->orWhereRaw("$column like ?", [$keyword]); } }
php
protected function compileGlobalSearch($query, $column, $keyword) { if ($this->isSmartSearch()) { $column = $this->castColumn($column); $sql = $column . ' LIKE ?'; if ($this->isCaseInsensitive()) { $sql = 'LOWER(' . $column . ') LIKE ?'; $keyword = Str::lower($keyword); } $query->orWhereRaw($sql, [$keyword]); } else { // exact match $query->orWhereRaw("$column like ?", [$keyword]); } }
[ "protected", "function", "compileGlobalSearch", "(", "$", "query", ",", "$", "column", ",", "$", "keyword", ")", "{", "if", "(", "$", "this", "->", "isSmartSearch", "(", ")", ")", "{", "$", "column", "=", "$", "this", "->", "castColumn", "(", "$", "column", ")", ";", "$", "sql", "=", "$", "column", ".", "' LIKE ?'", ";", "if", "(", "$", "this", "->", "isCaseInsensitive", "(", ")", ")", "{", "$", "sql", "=", "'LOWER('", ".", "$", "column", ".", "') LIKE ?'", ";", "$", "keyword", "=", "Str", "::", "lower", "(", "$", "keyword", ")", ";", "}", "$", "query", "->", "orWhereRaw", "(", "$", "sql", ",", "[", "$", "keyword", "]", ")", ";", "}", "else", "{", "// exact match", "$", "query", "->", "orWhereRaw", "(", "\"$column like ?\"", ",", "[", "$", "keyword", "]", ")", ";", "}", "}" ]
Add a query on global search. @param mixed $query @param string $column @param string $keyword
[ "Add", "a", "query", "on", "global", "search", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Engines/QueryBuilderEngine.php#L261-L276
228,199
antaresproject/core
src/ui/components/datatables/src/Engines/QueryBuilderEngine.php
QueryBuilderEngine.castColumn
public function castColumn($column) { $column = $this->connection->getQueryGrammar()->wrap($column); if ($this->database === 'pgsql') { $column = 'CAST(' . $column . ' as TEXT)'; } elseif ($this->database === 'firebird') { $column = 'CAST(' . $column . ' as VARCHAR(255))'; } return $column; }
php
public function castColumn($column) { $column = $this->connection->getQueryGrammar()->wrap($column); if ($this->database === 'pgsql') { $column = 'CAST(' . $column . ' as TEXT)'; } elseif ($this->database === 'firebird') { $column = 'CAST(' . $column . ' as VARCHAR(255))'; } return $column; }
[ "public", "function", "castColumn", "(", "$", "column", ")", "{", "$", "column", "=", "$", "this", "->", "connection", "->", "getQueryGrammar", "(", ")", "->", "wrap", "(", "$", "column", ")", ";", "if", "(", "$", "this", "->", "database", "===", "'pgsql'", ")", "{", "$", "column", "=", "'CAST('", ".", "$", "column", ".", "' as TEXT)'", ";", "}", "elseif", "(", "$", "this", "->", "database", "===", "'firebird'", ")", "{", "$", "column", "=", "'CAST('", ".", "$", "column", ".", "' as VARCHAR(255))'", ";", "}", "return", "$", "column", ";", "}" ]
Wrap a column and cast in pgsql. @param string $column @return string
[ "Wrap", "a", "column", "and", "cast", "in", "pgsql", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Engines/QueryBuilderEngine.php#L284-L294