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
227,900
antaresproject/core
src/foundation/src/Processor/Extension/ModuleConfigure.php
ModuleConfigure.configure
public function configure(Listener $listener, Fluent $extension) { if (!Extension::started($extension->get('name'))) { return $listener->abortWhenRequirementMismatched(); } $this->presenter->setCategory($this->category); $memory = Foundation::memory(); $activeConfig = (array) $memory->get("extensions.active.{$extension->get('name')}.config", []); $baseConfig = (array) $memory->get("extension_{$extension->get('name')}", []); $eloquent = new Fluent(array_merge($activeConfig, $baseConfig)); $form = $this->presenter->configure($eloquent, $extension->get('name')); Event::fire("antares.form: extension.{$extension->get('name')}", [$eloquent, $form]); return $listener->showConfigurationChanger(compact('eloquent', 'form', 'extension')); }
php
public function configure(Listener $listener, Fluent $extension) { if (!Extension::started($extension->get('name'))) { return $listener->abortWhenRequirementMismatched(); } $this->presenter->setCategory($this->category); $memory = Foundation::memory(); $activeConfig = (array) $memory->get("extensions.active.{$extension->get('name')}.config", []); $baseConfig = (array) $memory->get("extension_{$extension->get('name')}", []); $eloquent = new Fluent(array_merge($activeConfig, $baseConfig)); $form = $this->presenter->configure($eloquent, $extension->get('name')); Event::fire("antares.form: extension.{$extension->get('name')}", [$eloquent, $form]); return $listener->showConfigurationChanger(compact('eloquent', 'form', 'extension')); }
[ "public", "function", "configure", "(", "Listener", "$", "listener", ",", "Fluent", "$", "extension", ")", "{", "if", "(", "!", "Extension", "::", "started", "(", "$", "extension", "->", "get", "(", "'name'", ")", ")", ")", "{", "return", "$", "listener", "->", "abortWhenRequirementMismatched", "(", ")", ";", "}", "$", "this", "->", "presenter", "->", "setCategory", "(", "$", "this", "->", "category", ")", ";", "$", "memory", "=", "Foundation", "::", "memory", "(", ")", ";", "$", "activeConfig", "=", "(", "array", ")", "$", "memory", "->", "get", "(", "\"extensions.active.{$extension->get('name')}.config\"", ",", "[", "]", ")", ";", "$", "baseConfig", "=", "(", "array", ")", "$", "memory", "->", "get", "(", "\"extension_{$extension->get('name')}\"", ",", "[", "]", ")", ";", "$", "eloquent", "=", "new", "Fluent", "(", "array_merge", "(", "$", "activeConfig", ",", "$", "baseConfig", ")", ")", ";", "$", "form", "=", "$", "this", "->", "presenter", "->", "configure", "(", "$", "eloquent", ",", "$", "extension", "->", "get", "(", "'name'", ")", ")", ";", "Event", "::", "fire", "(", "\"antares.form: extension.{$extension->get('name')}\"", ",", "[", "$", "eloquent", ",", "$", "form", "]", ")", ";", "return", "$", "listener", "->", "showConfigurationChanger", "(", "compact", "(", "'eloquent'", ",", "'form'", ",", "'extension'", ")", ")", ";", "}" ]
View edit extension configuration page. @param \Antares\Contracts\Extension\Listener\Configure $listener @param \Illuminate\Support\Fluent $extension @return mixed
[ "View", "edit", "extension", "configuration", "page", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Processor/Extension/ModuleConfigure.php#L86-L106
227,901
antaresproject/core
src/foundation/src/Processor/Extension/ModuleConfigure.php
ModuleConfigure.create
public function create(Listener $listener, $category = null) { $eloquent = Foundation::make('antares.component'); $form = $this->presenter->create($eloquent, $category, $this->validator); Event::fire("antares.form: extension.create", [$eloquent, $form]); Event::fire(new FormRender('extension', $form, 'create', $eloquent)); return $listener->showModuleCreator(compact('form', 'category')); }
php
public function create(Listener $listener, $category = null) { $eloquent = Foundation::make('antares.component'); $form = $this->presenter->create($eloquent, $category, $this->validator); Event::fire("antares.form: extension.create", [$eloquent, $form]); Event::fire(new FormRender('extension', $form, 'create', $eloquent)); return $listener->showModuleCreator(compact('form', 'category')); }
[ "public", "function", "create", "(", "Listener", "$", "listener", ",", "$", "category", "=", "null", ")", "{", "$", "eloquent", "=", "Foundation", "::", "make", "(", "'antares.component'", ")", ";", "$", "form", "=", "$", "this", "->", "presenter", "->", "create", "(", "$", "eloquent", ",", "$", "category", ",", "$", "this", "->", "validator", ")", ";", "Event", "::", "fire", "(", "\"antares.form: extension.create\"", ",", "[", "$", "eloquent", ",", "$", "form", "]", ")", ";", "Event", "::", "fire", "(", "new", "FormRender", "(", "'extension'", ",", "$", "form", ",", "'create'", ",", "$", "eloquent", ")", ")", ";", "return", "$", "listener", "->", "showModuleCreator", "(", "compact", "(", "'form'", ",", "'category'", ")", ")", ";", "}" ]
create module form @param String $category @return type
[ "create", "module", "form" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Processor/Extension/ModuleConfigure.php#L166-L174
227,902
antaresproject/core
src/foundation/src/Processor/Extension/ModuleConfigure.php
ModuleConfigure.upload
public function upload(array $input) { $file = $this->resolveTempFileName($input['file']); $input['file']->directory = $file['directory']; $input['file']->filename = $file['filename']; Validator::resolver(function($translator, $data, $rules, $messages) { return new CustomModule($translator, $data, $rules, $messages); }); $validation = $this->validator->on('upload')->with($input, [], [ 'source' => trans('antares/foundation::response.modules.validator.invalid-structure') ]); return ($validation->fails()) ? Response::make($validation->getMessageBag()->first(), 400) : Response::json([ 'html' => $this->manifestDecorator($validation->getManifest()), 'path' => $file['subdir'] . DIRECTORY_SEPARATOR . $file['filename']], 200); }
php
public function upload(array $input) { $file = $this->resolveTempFileName($input['file']); $input['file']->directory = $file['directory']; $input['file']->filename = $file['filename']; Validator::resolver(function($translator, $data, $rules, $messages) { return new CustomModule($translator, $data, $rules, $messages); }); $validation = $this->validator->on('upload')->with($input, [], [ 'source' => trans('antares/foundation::response.modules.validator.invalid-structure') ]); return ($validation->fails()) ? Response::make($validation->getMessageBag()->first(), 400) : Response::json([ 'html' => $this->manifestDecorator($validation->getManifest()), 'path' => $file['subdir'] . DIRECTORY_SEPARATOR . $file['filename']], 200); }
[ "public", "function", "upload", "(", "array", "$", "input", ")", "{", "$", "file", "=", "$", "this", "->", "resolveTempFileName", "(", "$", "input", "[", "'file'", "]", ")", ";", "$", "input", "[", "'file'", "]", "->", "directory", "=", "$", "file", "[", "'directory'", "]", ";", "$", "input", "[", "'file'", "]", "->", "filename", "=", "$", "file", "[", "'filename'", "]", ";", "Validator", "::", "resolver", "(", "function", "(", "$", "translator", ",", "$", "data", ",", "$", "rules", ",", "$", "messages", ")", "{", "return", "new", "CustomModule", "(", "$", "translator", ",", "$", "data", ",", "$", "rules", ",", "$", "messages", ")", ";", "}", ")", ";", "$", "validation", "=", "$", "this", "->", "validator", "->", "on", "(", "'upload'", ")", "->", "with", "(", "$", "input", ",", "[", "]", ",", "[", "'source'", "=>", "trans", "(", "'antares/foundation::response.modules.validator.invalid-structure'", ")", "]", ")", ";", "return", "(", "$", "validation", "->", "fails", "(", ")", ")", "?", "Response", "::", "make", "(", "$", "validation", "->", "getMessageBag", "(", ")", "->", "first", "(", ")", ",", "400", ")", ":", "Response", "::", "json", "(", "[", "'html'", "=>", "$", "this", "->", "manifestDecorator", "(", "$", "validation", "->", "getManifest", "(", ")", ")", ",", "'path'", "=>", "$", "file", "[", "'subdir'", "]", ".", "DIRECTORY_SEPARATOR", ".", "$", "file", "[", "'filename'", "]", "]", ",", "200", ")", ";", "}" ]
upload and validate module compressed file @param array $input @return \Illuminate\Support\Facades\Response
[ "upload", "and", "validate", "module", "compressed", "file" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Processor/Extension/ModuleConfigure.php#L198-L216
227,903
antaresproject/core
src/foundation/src/Processor/Extension/ModuleConfigure.php
ModuleConfigure.extract
public function extract(Listener $listener, $category = null, array $input) { try { $subdir = !is_null($category) ? $category : 'addons'; $target = realpath(app_path() . "/../src/modules/{$subdir}"); if (!is_dir($target)) { throw new \Exception('Invalid path of module provided'); } $name = $input['name']; $path = storage_path() . '/app/uploads/' . $name; if (!file_exists($path)) { throw new \Exception('Invalid path of module package'); } if ($this->unzip($path, $target)) { return $listener->moduleExtracted($category); } return $listener->moduleExtractionError($category); } catch (\Exception $e) { Log::emergency($e); return $listener->moduleExtractionError($category); } }
php
public function extract(Listener $listener, $category = null, array $input) { try { $subdir = !is_null($category) ? $category : 'addons'; $target = realpath(app_path() . "/../src/modules/{$subdir}"); if (!is_dir($target)) { throw new \Exception('Invalid path of module provided'); } $name = $input['name']; $path = storage_path() . '/app/uploads/' . $name; if (!file_exists($path)) { throw new \Exception('Invalid path of module package'); } if ($this->unzip($path, $target)) { return $listener->moduleExtracted($category); } return $listener->moduleExtractionError($category); } catch (\Exception $e) { Log::emergency($e); return $listener->moduleExtractionError($category); } }
[ "public", "function", "extract", "(", "Listener", "$", "listener", ",", "$", "category", "=", "null", ",", "array", "$", "input", ")", "{", "try", "{", "$", "subdir", "=", "!", "is_null", "(", "$", "category", ")", "?", "$", "category", ":", "'addons'", ";", "$", "target", "=", "realpath", "(", "app_path", "(", ")", ".", "\"/../src/modules/{$subdir}\"", ")", ";", "if", "(", "!", "is_dir", "(", "$", "target", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Invalid path of module provided'", ")", ";", "}", "$", "name", "=", "$", "input", "[", "'name'", "]", ";", "$", "path", "=", "storage_path", "(", ")", ".", "'/app/uploads/'", ".", "$", "name", ";", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Invalid path of module package'", ")", ";", "}", "if", "(", "$", "this", "->", "unzip", "(", "$", "path", ",", "$", "target", ")", ")", "{", "return", "$", "listener", "->", "moduleExtracted", "(", "$", "category", ")", ";", "}", "return", "$", "listener", "->", "moduleExtractionError", "(", "$", "category", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "Log", "::", "emergency", "(", "$", "e", ")", ";", "return", "$", "listener", "->", "moduleExtractionError", "(", "$", "category", ")", ";", "}", "}" ]
extraction of module package @param Listener $listener @param String $category @param array $input
[ "extraction", "of", "module", "package" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Processor/Extension/ModuleConfigure.php#L257-L281
227,904
antaresproject/core
src/foundation/src/Notification.php
Notification.push
public function push($params) { foreach ($params as $key => $value) { array_set($this->params, $key, $value); } return $this; }
php
public function push($params) { foreach ($params as $key => $value) { array_set($this->params, $key, $value); } return $this; }
[ "public", "function", "push", "(", "$", "params", ")", "{", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "value", ")", "{", "array_set", "(", "$", "this", "->", "params", ",", "$", "key", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
adds element into params container @param mixed $params @return \Antares\Foundation\Notification
[ "adds", "element", "into", "params", "container" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Notification.php#L71-L77
227,905
coincheckjp/coincheck-php
lib/Coincheck/Transfer.php
Transfer.to_leverage
public function to_leverage($params = array()) { $arr = array( "amount" => $params["amount"], "currency" => $params["currency"] ); $rawResponse = $this->client->request('post', 'api/exchange/transfers/to_leverage', $arr); return $rawResponse; }
php
public function to_leverage($params = array()) { $arr = array( "amount" => $params["amount"], "currency" => $params["currency"] ); $rawResponse = $this->client->request('post', 'api/exchange/transfers/to_leverage', $arr); return $rawResponse; }
[ "public", "function", "to_leverage", "(", "$", "params", "=", "array", "(", ")", ")", "{", "$", "arr", "=", "array", "(", "\"amount\"", "=>", "$", "params", "[", "\"amount\"", "]", ",", "\"currency\"", "=>", "$", "params", "[", "\"currency\"", "]", ")", ";", "$", "rawResponse", "=", "$", "this", "->", "client", "->", "request", "(", "'post'", ",", "'api/exchange/transfers/to_leverage'", ",", "$", "arr", ")", ";", "return", "$", "rawResponse", ";", "}" ]
Transfer Balance to Leverage. @param mixed @return Json Array
[ "Transfer", "Balance", "to", "Leverage", "." ]
5991003cb0ae827697888aeebd0aea0267fad7fa
https://github.com/coincheckjp/coincheck-php/blob/5991003cb0ae827697888aeebd0aea0267fad7fa/lib/Coincheck/Transfer.php#L20-L28
227,906
coincheckjp/coincheck-php
lib/Coincheck/Transfer.php
Transfer.from_leverage
public function from_leverage($params = array()) { $arr = array( "amount" => $params["amount"], "currency" => $params["currency"] ); $rawResponse = $this->client->request('post', 'api/exchange/transfers/from_leverage', $arr); return $rawResponse; }
php
public function from_leverage($params = array()) { $arr = array( "amount" => $params["amount"], "currency" => $params["currency"] ); $rawResponse = $this->client->request('post', 'api/exchange/transfers/from_leverage', $arr); return $rawResponse; }
[ "public", "function", "from_leverage", "(", "$", "params", "=", "array", "(", ")", ")", "{", "$", "arr", "=", "array", "(", "\"amount\"", "=>", "$", "params", "[", "\"amount\"", "]", ",", "\"currency\"", "=>", "$", "params", "[", "\"currency\"", "]", ")", ";", "$", "rawResponse", "=", "$", "this", "->", "client", "->", "request", "(", "'post'", ",", "'api/exchange/transfers/from_leverage'", ",", "$", "arr", ")", ";", "return", "$", "rawResponse", ";", "}" ]
Transfer Balance from Leverage. @param mixed @return Json Array
[ "Transfer", "Balance", "from", "Leverage", "." ]
5991003cb0ae827697888aeebd0aea0267fad7fa
https://github.com/coincheckjp/coincheck-php/blob/5991003cb0ae827697888aeebd0aea0267fad7fa/lib/Coincheck/Transfer.php#L36-L44
227,907
joomla-framework/google-api
src/Auth/OAuth2.php
OAuth2.googlize
protected function googlize() { if (!$this->client->getOption('authurl')) { $this->client->setOption('authurl', 'https://accounts.google.com/o/oauth2/auth'); } if (!$this->client->getOption('tokenurl')) { $this->client->setOption('tokenurl', 'https://accounts.google.com/o/oauth2/token'); } if (!$this->client->getOption('requestparams')) { $this->client->setOption('requestparams', array()); } $params = $this->client->getOption('requestparams'); if (!array_key_exists('access_type', $params)) { $params['access_type'] = 'offline'; } if ($params['access_type'] == 'offline' && $this->client->getOption('userefresh') === null) { $this->client->setOption('userefresh', true); } if (!array_key_exists('approval_prompt', $params)) { $params['approval_prompt'] = 'auto'; } $this->client->setOption('requestparams', $params); return $this->client; }
php
protected function googlize() { if (!$this->client->getOption('authurl')) { $this->client->setOption('authurl', 'https://accounts.google.com/o/oauth2/auth'); } if (!$this->client->getOption('tokenurl')) { $this->client->setOption('tokenurl', 'https://accounts.google.com/o/oauth2/token'); } if (!$this->client->getOption('requestparams')) { $this->client->setOption('requestparams', array()); } $params = $this->client->getOption('requestparams'); if (!array_key_exists('access_type', $params)) { $params['access_type'] = 'offline'; } if ($params['access_type'] == 'offline' && $this->client->getOption('userefresh') === null) { $this->client->setOption('userefresh', true); } if (!array_key_exists('approval_prompt', $params)) { $params['approval_prompt'] = 'auto'; } $this->client->setOption('requestparams', $params); return $this->client; }
[ "protected", "function", "googlize", "(", ")", "{", "if", "(", "!", "$", "this", "->", "client", "->", "getOption", "(", "'authurl'", ")", ")", "{", "$", "this", "->", "client", "->", "setOption", "(", "'authurl'", ",", "'https://accounts.google.com/o/oauth2/auth'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "client", "->", "getOption", "(", "'tokenurl'", ")", ")", "{", "$", "this", "->", "client", "->", "setOption", "(", "'tokenurl'", ",", "'https://accounts.google.com/o/oauth2/token'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "client", "->", "getOption", "(", "'requestparams'", ")", ")", "{", "$", "this", "->", "client", "->", "setOption", "(", "'requestparams'", ",", "array", "(", ")", ")", ";", "}", "$", "params", "=", "$", "this", "->", "client", "->", "getOption", "(", "'requestparams'", ")", ";", "if", "(", "!", "array_key_exists", "(", "'access_type'", ",", "$", "params", ")", ")", "{", "$", "params", "[", "'access_type'", "]", "=", "'offline'", ";", "}", "if", "(", "$", "params", "[", "'access_type'", "]", "==", "'offline'", "&&", "$", "this", "->", "client", "->", "getOption", "(", "'userefresh'", ")", "===", "null", ")", "{", "$", "this", "->", "client", "->", "setOption", "(", "'userefresh'", ",", "true", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "'approval_prompt'", ",", "$", "params", ")", ")", "{", "$", "params", "[", "'approval_prompt'", "]", "=", "'auto'", ";", "}", "$", "this", "->", "client", "->", "setOption", "(", "'requestparams'", ",", "$", "params", ")", ";", "return", "$", "this", "->", "client", ";", "}" ]
Method to fill in Google-specific OAuth settings @return Client Google-configured OAuth2 client. @since 1.0
[ "Method", "to", "fill", "in", "Google", "-", "specific", "OAuth", "settings" ]
c78f06cfaba3f0dfc3ce411a335b417a5f0ee904
https://github.com/joomla-framework/google-api/blob/c78f06cfaba3f0dfc3ce411a335b417a5f0ee904/src/Auth/OAuth2.php#L94-L131
227,908
joomla-framework/google-api
src/Data/Calendar.php
Calendar.removeCalendar
public function removeCalendar($calendarID) { if ($this->isAuthenticated()) { $jdata = $this->query('https://www.googleapis.com/calendar/v3/users/me/calendarList/' . urlencode($calendarID), null, null, 'delete'); if ($jdata->body != '') { throw new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`."); } return true; } return false; }
php
public function removeCalendar($calendarID) { if ($this->isAuthenticated()) { $jdata = $this->query('https://www.googleapis.com/calendar/v3/users/me/calendarList/' . urlencode($calendarID), null, null, 'delete'); if ($jdata->body != '') { throw new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`."); } return true; } return false; }
[ "public", "function", "removeCalendar", "(", "$", "calendarID", ")", "{", "if", "(", "$", "this", "->", "isAuthenticated", "(", ")", ")", "{", "$", "jdata", "=", "$", "this", "->", "query", "(", "'https://www.googleapis.com/calendar/v3/users/me/calendarList/'", ".", "urlencode", "(", "$", "calendarID", ")", ",", "null", ",", "null", ",", "'delete'", ")", ";", "if", "(", "$", "jdata", "->", "body", "!=", "''", ")", "{", "throw", "new", "UnexpectedValueException", "(", "\"Unexpected data received from Google: `{$jdata->body}`.\"", ")", ";", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Method to remove a calendar from a user's calendar list @param string $calendarID ID of calendar to delete @return boolean Success or failure @since 1.0 @throws UnexpectedValueException
[ "Method", "to", "remove", "a", "calendar", "from", "a", "user", "s", "calendar", "list" ]
c78f06cfaba3f0dfc3ce411a335b417a5f0ee904
https://github.com/joomla-framework/google-api/blob/c78f06cfaba3f0dfc3ce411a335b417a5f0ee904/src/Data/Calendar.php#L54-L69
227,909
joomla-framework/google-api
src/Data/Calendar.php
Calendar.createCalendar
public function createCalendar($title, $options = array()) { if ($this->isAuthenticated()) { $options['summary'] = $title; $url = 'https://www.googleapis.com/calendar/v3/calendars'; $jdata = $this->query($url, json_encode($options), array('Content-type' => 'application/json'), 'post'); if ($data = json_decode($jdata->body, true)) { return $data; } throw new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`."); } return false; }
php
public function createCalendar($title, $options = array()) { if ($this->isAuthenticated()) { $options['summary'] = $title; $url = 'https://www.googleapis.com/calendar/v3/calendars'; $jdata = $this->query($url, json_encode($options), array('Content-type' => 'application/json'), 'post'); if ($data = json_decode($jdata->body, true)) { return $data; } throw new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`."); } return false; }
[ "public", "function", "createCalendar", "(", "$", "title", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "isAuthenticated", "(", ")", ")", "{", "$", "options", "[", "'summary'", "]", "=", "$", "title", ";", "$", "url", "=", "'https://www.googleapis.com/calendar/v3/calendars'", ";", "$", "jdata", "=", "$", "this", "->", "query", "(", "$", "url", ",", "json_encode", "(", "$", "options", ")", ",", "array", "(", "'Content-type'", "=>", "'application/json'", ")", ",", "'post'", ")", ";", "if", "(", "$", "data", "=", "json_decode", "(", "$", "jdata", "->", "body", ",", "true", ")", ")", "{", "return", "$", "data", ";", "}", "throw", "new", "UnexpectedValueException", "(", "\"Unexpected data received from Google: `{$jdata->body}`.\"", ")", ";", "}", "return", "false", ";", "}" ]
Method to create a Google Calendar @param string $title New calendar title @param array $options New calendar settings @return mixed Data from Google. @since 1.0 @throws UnexpectedValueException
[ "Method", "to", "create", "a", "Google", "Calendar" ]
c78f06cfaba3f0dfc3ce411a335b417a5f0ee904
https://github.com/joomla-framework/google-api/blob/c78f06cfaba3f0dfc3ce411a335b417a5f0ee904/src/Data/Calendar.php#L252-L269
227,910
joomla-framework/google-api
src/Data/Calendar.php
Calendar.editEvent
public function editEvent($calendarID, $eventID, $options, $notify = false) { if ($this->isAuthenticated()) { $url = 'https://www.googleapis.com/calendar/v3/calendars/'; $url .= urlencode($calendarID) . '/events/' . urlencode($eventID) . ($notify ? '?sendNotifications=true' : ''); $jdata = $this->query($url, json_encode($options), array('Content-type' => 'application/json'), 'put'); if ($data = json_decode($jdata->body, true)) { return $data; } throw new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`."); } return false; }
php
public function editEvent($calendarID, $eventID, $options, $notify = false) { if ($this->isAuthenticated()) { $url = 'https://www.googleapis.com/calendar/v3/calendars/'; $url .= urlencode($calendarID) . '/events/' . urlencode($eventID) . ($notify ? '?sendNotifications=true' : ''); $jdata = $this->query($url, json_encode($options), array('Content-type' => 'application/json'), 'put'); if ($data = json_decode($jdata->body, true)) { return $data; } throw new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`."); } return false; }
[ "public", "function", "editEvent", "(", "$", "calendarID", ",", "$", "eventID", ",", "$", "options", ",", "$", "notify", "=", "false", ")", "{", "if", "(", "$", "this", "->", "isAuthenticated", "(", ")", ")", "{", "$", "url", "=", "'https://www.googleapis.com/calendar/v3/calendars/'", ";", "$", "url", ".=", "urlencode", "(", "$", "calendarID", ")", ".", "'/events/'", ".", "urlencode", "(", "$", "eventID", ")", ".", "(", "$", "notify", "?", "'?sendNotifications=true'", ":", "''", ")", ";", "$", "jdata", "=", "$", "this", "->", "query", "(", "$", "url", ",", "json_encode", "(", "$", "options", ")", ",", "array", "(", "'Content-type'", "=>", "'application/json'", ")", ",", "'put'", ")", ";", "if", "(", "$", "data", "=", "json_decode", "(", "$", "jdata", "->", "body", ",", "true", ")", ")", "{", "return", "$", "data", ";", "}", "throw", "new", "UnexpectedValueException", "(", "\"Unexpected data received from Google: `{$jdata->body}`.\"", ")", ";", "}", "return", "false", ";", "}" ]
Method to edit a Google Calendar event @param string $calendarID Calendar ID @param string $eventID ID of the event to change @param array $options Event settings @param boolean $notify Notify participants of changes @return mixed Data from Google. @since 1.0 @throws UnexpectedValueException
[ "Method", "to", "edit", "a", "Google", "Calendar", "event" ]
c78f06cfaba3f0dfc3ce411a335b417a5f0ee904
https://github.com/joomla-framework/google-api/blob/c78f06cfaba3f0dfc3ce411a335b417a5f0ee904/src/Data/Calendar.php#L570-L587
227,911
antaresproject/core
src/components/extension/src/Processors/Composer.php
Composer.run
public function run(OperationHandlerContract $handler, array $extensionsNames) { if (count($extensionsNames) === 0) { return $handler->operationInfo(new Operation('No extensions to install. Skipping composer.')); } $required = (array) config('components.required', []); $modules = []; if (!empty($required)) { foreach ($extensionsNames as $extension) { list($requiredExtension) = explode(':', $extension); if (!in_array($requiredExtension, $required)) { array_push($modules, $extension); } } } else { $modules = $extensionsNames; } $names = implode(' ', $modules); $command = 'composer require ' . $names . ' --no-progress'; try { $handler->operationInfo(new Operation('Running composer command.')); $process = $this->composerHandler->run($command, function(Process $process, $type, $buffer) use($handler) { $handler->operationInfo(new Operation($buffer)); }); if (!$process->isSuccessful()) { throw new ExtensionException($process->getErrorOutput()); } $this->dispatcher->fire(new Success($command)); return $handler->operationInfo(new Operation('Composer command has been finished.')); } catch (\Exception $e) { Log::error($e); $this->dispatcher->fire(new Failed($command, $e)); return $handler->operationFailed(new Operation($e->getMessage())); } }
php
public function run(OperationHandlerContract $handler, array $extensionsNames) { if (count($extensionsNames) === 0) { return $handler->operationInfo(new Operation('No extensions to install. Skipping composer.')); } $required = (array) config('components.required', []); $modules = []; if (!empty($required)) { foreach ($extensionsNames as $extension) { list($requiredExtension) = explode(':', $extension); if (!in_array($requiredExtension, $required)) { array_push($modules, $extension); } } } else { $modules = $extensionsNames; } $names = implode(' ', $modules); $command = 'composer require ' . $names . ' --no-progress'; try { $handler->operationInfo(new Operation('Running composer command.')); $process = $this->composerHandler->run($command, function(Process $process, $type, $buffer) use($handler) { $handler->operationInfo(new Operation($buffer)); }); if (!$process->isSuccessful()) { throw new ExtensionException($process->getErrorOutput()); } $this->dispatcher->fire(new Success($command)); return $handler->operationInfo(new Operation('Composer command has been finished.')); } catch (\Exception $e) { Log::error($e); $this->dispatcher->fire(new Failed($command, $e)); return $handler->operationFailed(new Operation($e->getMessage())); } }
[ "public", "function", "run", "(", "OperationHandlerContract", "$", "handler", ",", "array", "$", "extensionsNames", ")", "{", "if", "(", "count", "(", "$", "extensionsNames", ")", "===", "0", ")", "{", "return", "$", "handler", "->", "operationInfo", "(", "new", "Operation", "(", "'No extensions to install. Skipping composer.'", ")", ")", ";", "}", "$", "required", "=", "(", "array", ")", "config", "(", "'components.required'", ",", "[", "]", ")", ";", "$", "modules", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "required", ")", ")", "{", "foreach", "(", "$", "extensionsNames", "as", "$", "extension", ")", "{", "list", "(", "$", "requiredExtension", ")", "=", "explode", "(", "':'", ",", "$", "extension", ")", ";", "if", "(", "!", "in_array", "(", "$", "requiredExtension", ",", "$", "required", ")", ")", "{", "array_push", "(", "$", "modules", ",", "$", "extension", ")", ";", "}", "}", "}", "else", "{", "$", "modules", "=", "$", "extensionsNames", ";", "}", "$", "names", "=", "implode", "(", "' '", ",", "$", "modules", ")", ";", "$", "command", "=", "'composer require '", ".", "$", "names", ".", "' --no-progress'", ";", "try", "{", "$", "handler", "->", "operationInfo", "(", "new", "Operation", "(", "'Running composer command.'", ")", ")", ";", "$", "process", "=", "$", "this", "->", "composerHandler", "->", "run", "(", "$", "command", ",", "function", "(", "Process", "$", "process", ",", "$", "type", ",", "$", "buffer", ")", "use", "(", "$", "handler", ")", "{", "$", "handler", "->", "operationInfo", "(", "new", "Operation", "(", "$", "buffer", ")", ")", ";", "}", ")", ";", "if", "(", "!", "$", "process", "->", "isSuccessful", "(", ")", ")", "{", "throw", "new", "ExtensionException", "(", "$", "process", "->", "getErrorOutput", "(", ")", ")", ";", "}", "$", "this", "->", "dispatcher", "->", "fire", "(", "new", "Success", "(", "$", "command", ")", ")", ";", "return", "$", "handler", "->", "operationInfo", "(", "new", "Operation", "(", "'Composer command has been finished.'", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "Log", "::", "error", "(", "$", "e", ")", ";", "$", "this", "->", "dispatcher", "->", "fire", "(", "new", "Failed", "(", "$", "command", ",", "$", "e", ")", ")", ";", "return", "$", "handler", "->", "operationFailed", "(", "new", "Operation", "(", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "}", "}" ]
Run the operation for composer. @param OperationHandlerContract $handler @param array $extensionsNames @return mixed @throws \Exception
[ "Run", "the", "operation", "for", "composer", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Processors/Composer.php#L52-L95
227,912
antaresproject/core
src/foundation/src/Processor/AssetPublisher.php
AssetPublisher.publish
public function publish(Listener $listener, array $input) { $queues = $this->publisher->queued(); try { $this->publisher->connect($input); } catch (ServerException $e) { Log::emergency($e); $this->session->forget('antares.ftp'); return $listener->publishingHasFailed(['error' => $e->getMessage()]); } $this->session->put('antares.ftp', $input); if ($this->publisher->connected() && !empty($queues)) { $this->publisher->execute(); } return $listener->publishingHasSucceed(); }
php
public function publish(Listener $listener, array $input) { $queues = $this->publisher->queued(); try { $this->publisher->connect($input); } catch (ServerException $e) { Log::emergency($e); $this->session->forget('antares.ftp'); return $listener->publishingHasFailed(['error' => $e->getMessage()]); } $this->session->put('antares.ftp', $input); if ($this->publisher->connected() && !empty($queues)) { $this->publisher->execute(); } return $listener->publishingHasSucceed(); }
[ "public", "function", "publish", "(", "Listener", "$", "listener", ",", "array", "$", "input", ")", "{", "$", "queues", "=", "$", "this", "->", "publisher", "->", "queued", "(", ")", ";", "try", "{", "$", "this", "->", "publisher", "->", "connect", "(", "$", "input", ")", ";", "}", "catch", "(", "ServerException", "$", "e", ")", "{", "Log", "::", "emergency", "(", "$", "e", ")", ";", "$", "this", "->", "session", "->", "forget", "(", "'antares.ftp'", ")", ";", "return", "$", "listener", "->", "publishingHasFailed", "(", "[", "'error'", "=>", "$", "e", "->", "getMessage", "(", ")", "]", ")", ";", "}", "$", "this", "->", "session", "->", "put", "(", "'antares.ftp'", ",", "$", "input", ")", ";", "if", "(", "$", "this", "->", "publisher", "->", "connected", "(", ")", "&&", "!", "empty", "(", "$", "queues", ")", ")", "{", "$", "this", "->", "publisher", "->", "execute", "(", ")", ";", "}", "return", "$", "listener", "->", "publishingHasSucceed", "(", ")", ";", "}" ]
Publish process. @param \Antares\Contracts\Foundation\Listener\AssetPublishing $listener @param array $input @return mixed
[ "Publish", "process", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Processor/AssetPublisher.php#L83-L103
227,913
antaresproject/core
src/components/support/src/Support/Fluent.php
Fluent.getActiveMenuRoute
protected function getActiveMenuRoute() { if (is_null($this->activeMenuRoute)) { $this->activeMenuRoute = Registry::get('active_menu_route'); } return $this->activeMenuRoute; }
php
protected function getActiveMenuRoute() { if (is_null($this->activeMenuRoute)) { $this->activeMenuRoute = Registry::get('active_menu_route'); } return $this->activeMenuRoute; }
[ "protected", "function", "getActiveMenuRoute", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "activeMenuRoute", ")", ")", "{", "$", "this", "->", "activeMenuRoute", "=", "Registry", "::", "get", "(", "'active_menu_route'", ")", ";", "}", "return", "$", "this", "->", "activeMenuRoute", ";", "}" ]
Active menu getter @return String
[ "Active", "menu", "getter" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Support/Fluent.php#L80-L86
227,914
antaresproject/core
src/components/support/src/Support/Fluent.php
Fluent.isActive
public function isActive() { if (!isset($this->attributes['link'])) { return false; } $childs = isset($this->attributes['childs']) ? $this->attributes['childs'] : []; if (empty($childs)) { return $this->compare($this->attributes['link']); } foreach ($childs as $child) { if (!isset($child->attributes['link'])) { continue; } if ($this->compare($child->attributes['link'])) { return true; } } return $this->compare($this->attributes['link']); }
php
public function isActive() { if (!isset($this->attributes['link'])) { return false; } $childs = isset($this->attributes['childs']) ? $this->attributes['childs'] : []; if (empty($childs)) { return $this->compare($this->attributes['link']); } foreach ($childs as $child) { if (!isset($child->attributes['link'])) { continue; } if ($this->compare($child->attributes['link'])) { return true; } } return $this->compare($this->attributes['link']); }
[ "public", "function", "isActive", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "attributes", "[", "'link'", "]", ")", ")", "{", "return", "false", ";", "}", "$", "childs", "=", "isset", "(", "$", "this", "->", "attributes", "[", "'childs'", "]", ")", "?", "$", "this", "->", "attributes", "[", "'childs'", "]", ":", "[", "]", ";", "if", "(", "empty", "(", "$", "childs", ")", ")", "{", "return", "$", "this", "->", "compare", "(", "$", "this", "->", "attributes", "[", "'link'", "]", ")", ";", "}", "foreach", "(", "$", "childs", "as", "$", "child", ")", "{", "if", "(", "!", "isset", "(", "$", "child", "->", "attributes", "[", "'link'", "]", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "this", "->", "compare", "(", "$", "child", "->", "attributes", "[", "'link'", "]", ")", ")", "{", "return", "true", ";", "}", "}", "return", "$", "this", "->", "compare", "(", "$", "this", "->", "attributes", "[", "'link'", "]", ")", ";", "}" ]
check whether element has same request url and link attribute @return boolean
[ "check", "whether", "element", "has", "same", "request", "url", "and", "link", "attribute" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Support/Fluent.php#L93-L112
227,915
antaresproject/core
src/components/support/src/Support/Fluent.php
Fluent.compare
protected function compare($url) { $activeMenuRouteUrl = $this->getActiveMenuRoute(); if ($this->url == $url or $url == $activeMenuRouteUrl) { return true; } $segments = $this->segments; $count = count($segments); if ($count !== count(array_filter(explode('/', str_replace(url('/'), '', $url))))) { return false; } $segmented = url('/') . '/' . implode('/', array_slice($segments, 0, $count - 1)); if (count($segments) > 2 && starts_with($url, $segmented)) { return true; } @list($domain, $area, $module, $action) = explode('/', str_replace('http://', '', $url)); if (!isset($segments[1])) { return false; } return ($segments[1] == $module && isset($segments[2]) && (in_array($segments[2], ['index', 'edit']) or is_numeric($segments[2]))); }
php
protected function compare($url) { $activeMenuRouteUrl = $this->getActiveMenuRoute(); if ($this->url == $url or $url == $activeMenuRouteUrl) { return true; } $segments = $this->segments; $count = count($segments); if ($count !== count(array_filter(explode('/', str_replace(url('/'), '', $url))))) { return false; } $segmented = url('/') . '/' . implode('/', array_slice($segments, 0, $count - 1)); if (count($segments) > 2 && starts_with($url, $segmented)) { return true; } @list($domain, $area, $module, $action) = explode('/', str_replace('http://', '', $url)); if (!isset($segments[1])) { return false; } return ($segments[1] == $module && isset($segments[2]) && (in_array($segments[2], ['index', 'edit']) or is_numeric($segments[2]))); }
[ "protected", "function", "compare", "(", "$", "url", ")", "{", "$", "activeMenuRouteUrl", "=", "$", "this", "->", "getActiveMenuRoute", "(", ")", ";", "if", "(", "$", "this", "->", "url", "==", "$", "url", "or", "$", "url", "==", "$", "activeMenuRouteUrl", ")", "{", "return", "true", ";", "}", "$", "segments", "=", "$", "this", "->", "segments", ";", "$", "count", "=", "count", "(", "$", "segments", ")", ";", "if", "(", "$", "count", "!==", "count", "(", "array_filter", "(", "explode", "(", "'/'", ",", "str_replace", "(", "url", "(", "'/'", ")", ",", "''", ",", "$", "url", ")", ")", ")", ")", ")", "{", "return", "false", ";", "}", "$", "segmented", "=", "url", "(", "'/'", ")", ".", "'/'", ".", "implode", "(", "'/'", ",", "array_slice", "(", "$", "segments", ",", "0", ",", "$", "count", "-", "1", ")", ")", ";", "if", "(", "count", "(", "$", "segments", ")", ">", "2", "&&", "starts_with", "(", "$", "url", ",", "$", "segmented", ")", ")", "{", "return", "true", ";", "}", "@", "list", "(", "$", "domain", ",", "$", "area", ",", "$", "module", ",", "$", "action", ")", "=", "explode", "(", "'/'", ",", "str_replace", "(", "'http://'", ",", "''", ",", "$", "url", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "segments", "[", "1", "]", ")", ")", "{", "return", "false", ";", "}", "return", "(", "$", "segments", "[", "1", "]", "==", "$", "module", "&&", "isset", "(", "$", "segments", "[", "2", "]", ")", "&&", "(", "in_array", "(", "$", "segments", "[", "2", "]", ",", "[", "'index'", ",", "'edit'", "]", ")", "or", "is_numeric", "(", "$", "segments", "[", "2", "]", ")", ")", ")", ";", "}" ]
Whether menu item is active @param String $url @return boolean
[ "Whether", "menu", "item", "is", "active" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Support/Fluent.php#L120-L141
227,916
antaresproject/core
src/components/support/src/Support/Fluent.php
Fluent.isFirstChildActive
public function isFirstChildActive() { $url = array_get($this->attributes, 'link', ''); if ($this->getActiveMenuRoute() == $url) { return true; } @list($domain, $area, $module, $action) = explode('/', str_replace('http://', '', $url)); if ($this->url == $url) { return true; } $segments = $this->segments; if (!isset($segments[1])) { return false; } return ($segments[1] == $module && isset($segments[2]) && (in_array($segments[2], ['index', 'edit', 'mail']) or is_numeric($segments[2]))); }
php
public function isFirstChildActive() { $url = array_get($this->attributes, 'link', ''); if ($this->getActiveMenuRoute() == $url) { return true; } @list($domain, $area, $module, $action) = explode('/', str_replace('http://', '', $url)); if ($this->url == $url) { return true; } $segments = $this->segments; if (!isset($segments[1])) { return false; } return ($segments[1] == $module && isset($segments[2]) && (in_array($segments[2], ['index', 'edit', 'mail']) or is_numeric($segments[2]))); }
[ "public", "function", "isFirstChildActive", "(", ")", "{", "$", "url", "=", "array_get", "(", "$", "this", "->", "attributes", ",", "'link'", ",", "''", ")", ";", "if", "(", "$", "this", "->", "getActiveMenuRoute", "(", ")", "==", "$", "url", ")", "{", "return", "true", ";", "}", "@", "list", "(", "$", "domain", ",", "$", "area", ",", "$", "module", ",", "$", "action", ")", "=", "explode", "(", "'/'", ",", "str_replace", "(", "'http://'", ",", "''", ",", "$", "url", ")", ")", ";", "if", "(", "$", "this", "->", "url", "==", "$", "url", ")", "{", "return", "true", ";", "}", "$", "segments", "=", "$", "this", "->", "segments", ";", "if", "(", "!", "isset", "(", "$", "segments", "[", "1", "]", ")", ")", "{", "return", "false", ";", "}", "return", "(", "$", "segments", "[", "1", "]", "==", "$", "module", "&&", "isset", "(", "$", "segments", "[", "2", "]", ")", "&&", "(", "in_array", "(", "$", "segments", "[", "2", "]", ",", "[", "'index'", ",", "'edit'", ",", "'mail'", "]", ")", "or", "is_numeric", "(", "$", "segments", "[", "2", "]", ")", ")", ")", ";", "}" ]
Whether first child is active @return boolean
[ "Whether", "first", "child", "is", "active" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Support/Fluent.php#L159-L174
227,917
antaresproject/core
src/components/extension/src/Processors/Installer.php
Installer.importSettings
private function importSettings(OperationHandlerContract $handler, ExtensionContract $extension) { $settingsPath = $extension->getPath() . '/resources/config/settings.php'; if (File::exists($settingsPath)) { $settings = $this->settingsFactory->createFromConfig($extension->getPath() . '/resources/config/settings.php'); $extension->setSettings($settings); $handler->operationInfo(new Operation('Importing settings.')); } }
php
private function importSettings(OperationHandlerContract $handler, ExtensionContract $extension) { $settingsPath = $extension->getPath() . '/resources/config/settings.php'; if (File::exists($settingsPath)) { $settings = $this->settingsFactory->createFromConfig($extension->getPath() . '/resources/config/settings.php'); $extension->setSettings($settings); $handler->operationInfo(new Operation('Importing settings.')); } }
[ "private", "function", "importSettings", "(", "OperationHandlerContract", "$", "handler", ",", "ExtensionContract", "$", "extension", ")", "{", "$", "settingsPath", "=", "$", "extension", "->", "getPath", "(", ")", ".", "'/resources/config/settings.php'", ";", "if", "(", "File", "::", "exists", "(", "$", "settingsPath", ")", ")", "{", "$", "settings", "=", "$", "this", "->", "settingsFactory", "->", "createFromConfig", "(", "$", "extension", "->", "getPath", "(", ")", ".", "'/resources/config/settings.php'", ")", ";", "$", "extension", "->", "setSettings", "(", "$", "settings", ")", ";", "$", "handler", "->", "operationInfo", "(", "new", "Operation", "(", "'Importing settings.'", ")", ")", ";", "}", "}" ]
Imports the default settings to the @param OperationHandlerContract $handler @param ExtensionContract $extension
[ "Imports", "the", "default", "settings", "to", "the" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Processors/Installer.php#L154-L162
227,918
tomwalder/php-appengine-search
src/Search/Tokenizer.php
Tokenizer.edgeNGram
public function edgeNGram($str_phrase, $int_min_length = 1) { $arr_tokens = []; // Clean-up unwanted characters (assume english for now) $str_phrase = preg_replace('#[^a-z0-9 ]#i', '', $str_phrase); // @todo move this to non-edge ngram function when we have one. // Do we need individual characters? // if($int_min_length < 2) { // $arr_chars = str_split($str_phrase); // $arr_tokens = array_merge($arr_tokens, $arr_chars); // } // Add the words $arr_words = explode(' ', $str_phrase); $arr_tokens = array_merge($arr_tokens, $arr_words); // OK, now split the words foreach($arr_words as $str_word) { $int_letters = strlen($str_word); $arr_ngrams = []; for($int_subs = $int_min_length; $int_subs <= ($int_letters - 1); $int_subs++) { $arr_ngrams[] = substr($str_word, 0, $int_subs); } $arr_tokens = array_merge($arr_tokens, $arr_ngrams); } // Clean up and return return str_replace(' ', ' ', implode(' ', $arr_tokens)); }
php
public function edgeNGram($str_phrase, $int_min_length = 1) { $arr_tokens = []; // Clean-up unwanted characters (assume english for now) $str_phrase = preg_replace('#[^a-z0-9 ]#i', '', $str_phrase); // @todo move this to non-edge ngram function when we have one. // Do we need individual characters? // if($int_min_length < 2) { // $arr_chars = str_split($str_phrase); // $arr_tokens = array_merge($arr_tokens, $arr_chars); // } // Add the words $arr_words = explode(' ', $str_phrase); $arr_tokens = array_merge($arr_tokens, $arr_words); // OK, now split the words foreach($arr_words as $str_word) { $int_letters = strlen($str_word); $arr_ngrams = []; for($int_subs = $int_min_length; $int_subs <= ($int_letters - 1); $int_subs++) { $arr_ngrams[] = substr($str_word, 0, $int_subs); } $arr_tokens = array_merge($arr_tokens, $arr_ngrams); } // Clean up and return return str_replace(' ', ' ', implode(' ', $arr_tokens)); }
[ "public", "function", "edgeNGram", "(", "$", "str_phrase", ",", "$", "int_min_length", "=", "1", ")", "{", "$", "arr_tokens", "=", "[", "]", ";", "// Clean-up unwanted characters (assume english for now)", "$", "str_phrase", "=", "preg_replace", "(", "'#[^a-z0-9 ]#i'", ",", "''", ",", "$", "str_phrase", ")", ";", "// @todo move this to non-edge ngram function when we have one.", "// Do we need individual characters?", "// if($int_min_length < 2) {", "// $arr_chars = str_split($str_phrase);", "// $arr_tokens = array_merge($arr_tokens, $arr_chars);", "// }", "// Add the words", "$", "arr_words", "=", "explode", "(", "' '", ",", "$", "str_phrase", ")", ";", "$", "arr_tokens", "=", "array_merge", "(", "$", "arr_tokens", ",", "$", "arr_words", ")", ";", "// OK, now split the words", "foreach", "(", "$", "arr_words", "as", "$", "str_word", ")", "{", "$", "int_letters", "=", "strlen", "(", "$", "str_word", ")", ";", "$", "arr_ngrams", "=", "[", "]", ";", "for", "(", "$", "int_subs", "=", "$", "int_min_length", ";", "$", "int_subs", "<=", "(", "$", "int_letters", "-", "1", ")", ";", "$", "int_subs", "++", ")", "{", "$", "arr_ngrams", "[", "]", "=", "substr", "(", "$", "str_word", ",", "0", ",", "$", "int_subs", ")", ";", "}", "$", "arr_tokens", "=", "array_merge", "(", "$", "arr_tokens", ",", "$", "arr_ngrams", ")", ";", "}", "// Clean up and return", "return", "str_replace", "(", "' '", ",", "' '", ",", "implode", "(", "' '", ",", "$", "arr_tokens", ")", ")", ";", "}" ]
Change an input string into a list of edge N-Gram tokens for autocomplete usage @param $str_phrase @param $int_min_length @return string
[ "Change", "an", "input", "string", "into", "a", "list", "of", "edge", "N", "-", "Gram", "tokens", "for", "autocomplete", "usage" ]
e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba
https://github.com/tomwalder/php-appengine-search/blob/e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba/src/Search/Tokenizer.php#L33-L63
227,919
antaresproject/core
src/components/view/src/Theme/Theme.php
Theme.setTheme
public function setTheme($theme) { if (!is_null($this->theme)) { $this->resolved && $this->resetViewPaths(); $this->dispatcher->fire("antares.theme.unset: {$this->theme}"); $this->dispatcher->fire(new ThemeUnset($this->theme)); } $this->theme = $theme; $this->dispatcher->fire("antares.theme.set: {$this->theme}"); $this->dispatcher->fire(new ThemeSet($this->theme)); if ($this->resolved) { $this->resolved = false; $this->resolving(); } }
php
public function setTheme($theme) { if (!is_null($this->theme)) { $this->resolved && $this->resetViewPaths(); $this->dispatcher->fire("antares.theme.unset: {$this->theme}"); $this->dispatcher->fire(new ThemeUnset($this->theme)); } $this->theme = $theme; $this->dispatcher->fire("antares.theme.set: {$this->theme}"); $this->dispatcher->fire(new ThemeSet($this->theme)); if ($this->resolved) { $this->resolved = false; $this->resolving(); } }
[ "public", "function", "setTheme", "(", "$", "theme", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "theme", ")", ")", "{", "$", "this", "->", "resolved", "&&", "$", "this", "->", "resetViewPaths", "(", ")", ";", "$", "this", "->", "dispatcher", "->", "fire", "(", "\"antares.theme.unset: {$this->theme}\"", ")", ";", "$", "this", "->", "dispatcher", "->", "fire", "(", "new", "ThemeUnset", "(", "$", "this", "->", "theme", ")", ")", ";", "}", "$", "this", "->", "theme", "=", "$", "theme", ";", "$", "this", "->", "dispatcher", "->", "fire", "(", "\"antares.theme.set: {$this->theme}\"", ")", ";", "$", "this", "->", "dispatcher", "->", "fire", "(", "new", "ThemeSet", "(", "$", "this", "->", "theme", ")", ")", ";", "if", "(", "$", "this", "->", "resolved", ")", "{", "$", "this", "->", "resolved", "=", "false", ";", "$", "this", "->", "resolving", "(", ")", ";", "}", "}" ]
Set the theme, this would also load the theme manifest. @param string $theme @return void
[ "Set", "the", "theme", "this", "would", "also", "load", "the", "theme", "manifest", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Theme/Theme.php#L143-L161
227,920
antaresproject/core
src/components/view/src/Theme/Theme.php
Theme.boot
public function boot() { if ($this->booted) { return false; } $this->booted = true; $themePath = $this->getThemePath(); $autoload = $this->getThemeAutoloadFiles($themePath); foreach ($autoload as $file) { $file = ltrim($file, '/'); $this->files->requireOnce("{$themePath}/{$file}"); } $this->dispatcher->fire("antares.theme.boot: {$this->theme}"); $this->dispatcher->fire(new ThemeBoot($this->theme)); return true; }
php
public function boot() { if ($this->booted) { return false; } $this->booted = true; $themePath = $this->getThemePath(); $autoload = $this->getThemeAutoloadFiles($themePath); foreach ($autoload as $file) { $file = ltrim($file, '/'); $this->files->requireOnce("{$themePath}/{$file}"); } $this->dispatcher->fire("antares.theme.boot: {$this->theme}"); $this->dispatcher->fire(new ThemeBoot($this->theme)); return true; }
[ "public", "function", "boot", "(", ")", "{", "if", "(", "$", "this", "->", "booted", ")", "{", "return", "false", ";", "}", "$", "this", "->", "booted", "=", "true", ";", "$", "themePath", "=", "$", "this", "->", "getThemePath", "(", ")", ";", "$", "autoload", "=", "$", "this", "->", "getThemeAutoloadFiles", "(", "$", "themePath", ")", ";", "foreach", "(", "$", "autoload", "as", "$", "file", ")", "{", "$", "file", "=", "ltrim", "(", "$", "file", ",", "'/'", ")", ";", "$", "this", "->", "files", "->", "requireOnce", "(", "\"{$themePath}/{$file}\"", ")", ";", "}", "$", "this", "->", "dispatcher", "->", "fire", "(", "\"antares.theme.boot: {$this->theme}\"", ")", ";", "$", "this", "->", "dispatcher", "->", "fire", "(", "new", "ThemeBoot", "(", "$", "this", "->", "theme", ")", ")", ";", "return", "true", ";", "}" ]
Boot and Load theme starter files. @return bool
[ "Boot", "and", "Load", "theme", "starter", "files", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Theme/Theme.php#L178-L197
227,921
antaresproject/core
src/components/view/src/Theme/Theme.php
Theme.resolving
public function resolving() { if ($this->resolved) { return false; } $this->resolved = true; $this->dispatcher->fire('antares.theme.resolving', [$this, $this->app]); $this->dispatcher->fire(new ThemeResolving($this, $this->app)); $this->setViewPaths(); return true; }
php
public function resolving() { if ($this->resolved) { return false; } $this->resolved = true; $this->dispatcher->fire('antares.theme.resolving', [$this, $this->app]); $this->dispatcher->fire(new ThemeResolving($this, $this->app)); $this->setViewPaths(); return true; }
[ "public", "function", "resolving", "(", ")", "{", "if", "(", "$", "this", "->", "resolved", ")", "{", "return", "false", ";", "}", "$", "this", "->", "resolved", "=", "true", ";", "$", "this", "->", "dispatcher", "->", "fire", "(", "'antares.theme.resolving'", ",", "[", "$", "this", ",", "$", "this", "->", "app", "]", ")", ";", "$", "this", "->", "dispatcher", "->", "fire", "(", "new", "ThemeResolving", "(", "$", "this", ",", "$", "this", "->", "app", ")", ")", ";", "$", "this", "->", "setViewPaths", "(", ")", ";", "return", "true", ";", "}" ]
Resolving the theme. @return bool
[ "Resolving", "the", "theme", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Theme/Theme.php#L204-L218
227,922
antaresproject/core
src/components/view/src/Theme/Theme.php
Theme.getAvailableThemePaths
public function getAvailableThemePaths() { $paths = []; $themePaths = $this->getThemePaths(); foreach ($themePaths as $path) { $this->files->isDirectory(base_path($path)) && $paths[] = base_path($path); } return $paths; }
php
public function getAvailableThemePaths() { $paths = []; $themePaths = $this->getThemePaths(); foreach ($themePaths as $path) { $this->files->isDirectory(base_path($path)) && $paths[] = base_path($path); } return $paths; }
[ "public", "function", "getAvailableThemePaths", "(", ")", "{", "$", "paths", "=", "[", "]", ";", "$", "themePaths", "=", "$", "this", "->", "getThemePaths", "(", ")", ";", "foreach", "(", "$", "themePaths", "as", "$", "path", ")", "{", "$", "this", "->", "files", "->", "isDirectory", "(", "base_path", "(", "$", "path", ")", ")", "&&", "$", "paths", "[", "]", "=", "base_path", "(", "$", "path", ")", ";", "}", "return", "$", "paths", ";", "}" ]
Get available theme paths. @return array
[ "Get", "available", "theme", "paths", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Theme/Theme.php#L258-L268
227,923
antaresproject/core
src/components/view/src/Theme/Theme.php
Theme.setViewPaths
protected function setViewPaths() { $viewFinder = $this->app->make('view.finder'); $themePaths = $this->getAvailableThemePaths(); if (!empty($themePaths)) { $viewFinder->setPaths(array_merge($themePaths, $viewFinder->getPaths())); } }
php
protected function setViewPaths() { $viewFinder = $this->app->make('view.finder'); $themePaths = $this->getAvailableThemePaths(); if (!empty($themePaths)) { $viewFinder->setPaths(array_merge($themePaths, $viewFinder->getPaths())); } }
[ "protected", "function", "setViewPaths", "(", ")", "{", "$", "viewFinder", "=", "$", "this", "->", "app", "->", "make", "(", "'view.finder'", ")", ";", "$", "themePaths", "=", "$", "this", "->", "getAvailableThemePaths", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "themePaths", ")", ")", "{", "$", "viewFinder", "->", "setPaths", "(", "array_merge", "(", "$", "themePaths", ",", "$", "viewFinder", "->", "getPaths", "(", ")", ")", ")", ";", "}", "}" ]
Set theme paths to view file finder paths. @return void
[ "Set", "theme", "paths", "to", "view", "file", "finder", "paths", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Theme/Theme.php#L313-L322
227,924
antaresproject/core
src/components/view/src/Theme/Theme.php
Theme.resetViewPaths
protected function resetViewPaths() { $viewFinder = $this->app->make('view.finder'); $paths = $viewFinder->getPaths(); foreach ($this->getThemePaths() as $themePath) { ($paths[0] === $themePath) && array_shift($paths); } $viewFinder->setPaths($paths); }
php
protected function resetViewPaths() { $viewFinder = $this->app->make('view.finder'); $paths = $viewFinder->getPaths(); foreach ($this->getThemePaths() as $themePath) { ($paths[0] === $themePath) && array_shift($paths); } $viewFinder->setPaths($paths); }
[ "protected", "function", "resetViewPaths", "(", ")", "{", "$", "viewFinder", "=", "$", "this", "->", "app", "->", "make", "(", "'view.finder'", ")", ";", "$", "paths", "=", "$", "viewFinder", "->", "getPaths", "(", ")", ";", "foreach", "(", "$", "this", "->", "getThemePaths", "(", ")", "as", "$", "themePath", ")", "{", "(", "$", "paths", "[", "0", "]", "===", "$", "themePath", ")", "&&", "array_shift", "(", "$", "paths", ")", ";", "}", "$", "viewFinder", "->", "setPaths", "(", "$", "paths", ")", ";", "}" ]
Reset theme paths to view file finder paths. @return void
[ "Reset", "theme", "paths", "to", "view", "file", "finder", "paths", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Theme/Theme.php#L329-L340
227,925
antaresproject/core
src/components/notifier/src/NotifierServiceProvider.php
NotifierServiceProvider.registerSupportedMailer
protected function registerSupportedMailer() { $this->app->singleton('antares.support.mail', function ($app) { $this->registerSwiftMailer(); $mailer = new Mailer( $app->make('view'), $app->make('antares.swift.mailer'), $app->make('events') ); if ($app->bound('queue')) { $mailer->setQueue($app->make('queue')); } $from = $app->make('antares.memory')->make('primary')->get('email.from'); $config = $app->make('config')->get('mail.from'); $mailer->alwaysFrom(array_get($from, 'address', array_get($config, 'address')), array_get($from, 'name', array_get($config, 'name'))); $to = $app->make('config')->get('mail.to'); if (is_array($to) && isset($to['address'])) { $mailer->alwaysTo($to['address'], $to['name']); } return $mailer; }); }
php
protected function registerSupportedMailer() { $this->app->singleton('antares.support.mail', function ($app) { $this->registerSwiftMailer(); $mailer = new Mailer( $app->make('view'), $app->make('antares.swift.mailer'), $app->make('events') ); if ($app->bound('queue')) { $mailer->setQueue($app->make('queue')); } $from = $app->make('antares.memory')->make('primary')->get('email.from'); $config = $app->make('config')->get('mail.from'); $mailer->alwaysFrom(array_get($from, 'address', array_get($config, 'address')), array_get($from, 'name', array_get($config, 'name'))); $to = $app->make('config')->get('mail.to'); if (is_array($to) && isset($to['address'])) { $mailer->alwaysTo($to['address'], $to['name']); } return $mailer; }); }
[ "protected", "function", "registerSupportedMailer", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'antares.support.mail'", ",", "function", "(", "$", "app", ")", "{", "$", "this", "->", "registerSwiftMailer", "(", ")", ";", "$", "mailer", "=", "new", "Mailer", "(", "$", "app", "->", "make", "(", "'view'", ")", ",", "$", "app", "->", "make", "(", "'antares.swift.mailer'", ")", ",", "$", "app", "->", "make", "(", "'events'", ")", ")", ";", "if", "(", "$", "app", "->", "bound", "(", "'queue'", ")", ")", "{", "$", "mailer", "->", "setQueue", "(", "$", "app", "->", "make", "(", "'queue'", ")", ")", ";", "}", "$", "from", "=", "$", "app", "->", "make", "(", "'antares.memory'", ")", "->", "make", "(", "'primary'", ")", "->", "get", "(", "'email.from'", ")", ";", "$", "config", "=", "$", "app", "->", "make", "(", "'config'", ")", "->", "get", "(", "'mail.from'", ")", ";", "$", "mailer", "->", "alwaysFrom", "(", "array_get", "(", "$", "from", ",", "'address'", ",", "array_get", "(", "$", "config", ",", "'address'", ")", ")", ",", "array_get", "(", "$", "from", ",", "'name'", ",", "array_get", "(", "$", "config", ",", "'name'", ")", ")", ")", ";", "$", "to", "=", "$", "app", "->", "make", "(", "'config'", ")", "->", "get", "(", "'mail.to'", ")", ";", "if", "(", "is_array", "(", "$", "to", ")", "&&", "isset", "(", "$", "to", "[", "'address'", "]", ")", ")", "{", "$", "mailer", "->", "alwaysTo", "(", "$", "to", "[", "'address'", "]", ",", "$", "to", "[", "'name'", "]", ")", ";", "}", "return", "$", "mailer", ";", "}", ")", ";", "}" ]
Register the support mailer @return void
[ "Register", "the", "support", "mailer" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/notifier/src/NotifierServiceProvider.php#L56-L81
227,926
antaresproject/core
src/ui/components/templates/src/Http/Middleware/Middleware.php
Middleware.validateRequest
protected function validateRequest(Request $request) { if (php_sapi_name() === 'cli') { return false; } $route = call_user_func($request->getRouteResolver()); $ignored = $this->container->make('config')->get('antares/ui-components::ignore'); $action = $route->getAction(); if (isset($action['uses']) and $action['uses'] instanceof Closure) { return true; } $resource = array_get($action, 'controller'); foreach ($ignored as $controller => $actions) { foreach ($actions as $action) { if ($resource === "$controller@$action") { return true; } } } return !( $request->method() !== 'GET' or ! empty($request->query())); }
php
protected function validateRequest(Request $request) { if (php_sapi_name() === 'cli') { return false; } $route = call_user_func($request->getRouteResolver()); $ignored = $this->container->make('config')->get('antares/ui-components::ignore'); $action = $route->getAction(); if (isset($action['uses']) and $action['uses'] instanceof Closure) { return true; } $resource = array_get($action, 'controller'); foreach ($ignored as $controller => $actions) { foreach ($actions as $action) { if ($resource === "$controller@$action") { return true; } } } return !( $request->method() !== 'GET' or ! empty($request->query())); }
[ "protected", "function", "validateRequest", "(", "Request", "$", "request", ")", "{", "if", "(", "php_sapi_name", "(", ")", "===", "'cli'", ")", "{", "return", "false", ";", "}", "$", "route", "=", "call_user_func", "(", "$", "request", "->", "getRouteResolver", "(", ")", ")", ";", "$", "ignored", "=", "$", "this", "->", "container", "->", "make", "(", "'config'", ")", "->", "get", "(", "'antares/ui-components::ignore'", ")", ";", "$", "action", "=", "$", "route", "->", "getAction", "(", ")", ";", "if", "(", "isset", "(", "$", "action", "[", "'uses'", "]", ")", "and", "$", "action", "[", "'uses'", "]", "instanceof", "Closure", ")", "{", "return", "true", ";", "}", "$", "resource", "=", "array_get", "(", "$", "action", ",", "'controller'", ")", ";", "foreach", "(", "$", "ignored", "as", "$", "controller", "=>", "$", "actions", ")", "{", "foreach", "(", "$", "actions", "as", "$", "action", ")", "{", "if", "(", "$", "resource", "===", "\"$controller@$action\"", ")", "{", "return", "true", ";", "}", "}", "}", "return", "!", "(", "$", "request", "->", "method", "(", ")", "!==", "'GET'", "or", "!", "empty", "(", "$", "request", "->", "query", "(", ")", ")", ")", ";", "}" ]
Validates ajax request @param Request $request @return boolean
[ "Validates", "ajax", "request" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Http/Middleware/Middleware.php#L70-L95
227,927
tomwalder/php-appengine-search
src/Search/Schema.php
Schema.createDocument
public function createDocument(array $arr_data = null) { $obj_doc = new Document($this); if(null !== $arr_data) { foreach ($arr_data as $str_field => $mix_value) { $obj_doc->__set($str_field, $mix_value); } } return $obj_doc; }
php
public function createDocument(array $arr_data = null) { $obj_doc = new Document($this); if(null !== $arr_data) { foreach ($arr_data as $str_field => $mix_value) { $obj_doc->__set($str_field, $mix_value); } } return $obj_doc; }
[ "public", "function", "createDocument", "(", "array", "$", "arr_data", "=", "null", ")", "{", "$", "obj_doc", "=", "new", "Document", "(", "$", "this", ")", ";", "if", "(", "null", "!==", "$", "arr_data", ")", "{", "foreach", "(", "$", "arr_data", "as", "$", "str_field", "=>", "$", "mix_value", ")", "{", "$", "obj_doc", "->", "__set", "(", "$", "str_field", ",", "$", "mix_value", ")", ";", "}", "}", "return", "$", "obj_doc", ";", "}" ]
Create and return a Document with this Schema Optionally populate with the supplied data @param array|null $arr_data @return Document
[ "Create", "and", "return", "a", "Document", "with", "this", "Schema" ]
e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba
https://github.com/tomwalder/php-appengine-search/blob/e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba/src/Search/Schema.php#L161-L170
227,928
tomwalder/php-appengine-search
src/Search/Schema.php
Schema.addAutoField
public function addAutoField($str_name, $mix_value) { switch(gettype($mix_value)) { case 'integer': case 'double': $this->addNumber($str_name); break; case 'object': if($mix_value instanceof \DateTime) { $this->addDate($str_name); } elseif (method_exists($mix_value, '__toString')) { $this->addText($str_name); } else { // @todo consider exception } break; case 'array': // @todo consider exception case 'string': case 'boolean': // @todo consider exception / numeric case 'resource': // @todo consider exception case 'null': case 'unknown type': // @todo consider exception default: $this->addText($str_name); } return $this; }
php
public function addAutoField($str_name, $mix_value) { switch(gettype($mix_value)) { case 'integer': case 'double': $this->addNumber($str_name); break; case 'object': if($mix_value instanceof \DateTime) { $this->addDate($str_name); } elseif (method_exists($mix_value, '__toString')) { $this->addText($str_name); } else { // @todo consider exception } break; case 'array': // @todo consider exception case 'string': case 'boolean': // @todo consider exception / numeric case 'resource': // @todo consider exception case 'null': case 'unknown type': // @todo consider exception default: $this->addText($str_name); } return $this; }
[ "public", "function", "addAutoField", "(", "$", "str_name", ",", "$", "mix_value", ")", "{", "switch", "(", "gettype", "(", "$", "mix_value", ")", ")", "{", "case", "'integer'", ":", "case", "'double'", ":", "$", "this", "->", "addNumber", "(", "$", "str_name", ")", ";", "break", ";", "case", "'object'", ":", "if", "(", "$", "mix_value", "instanceof", "\\", "DateTime", ")", "{", "$", "this", "->", "addDate", "(", "$", "str_name", ")", ";", "}", "elseif", "(", "method_exists", "(", "$", "mix_value", ",", "'__toString'", ")", ")", "{", "$", "this", "->", "addText", "(", "$", "str_name", ")", ";", "}", "else", "{", "// @todo consider exception", "}", "break", ";", "case", "'array'", ":", "// @todo consider exception", "case", "'string'", ":", "case", "'boolean'", ":", "// @todo consider exception / numeric", "case", "'resource'", ":", "// @todo consider exception", "case", "'null'", ":", "case", "'unknown type'", ":", "// @todo consider exception", "default", ":", "$", "this", "->", "addText", "(", "$", "str_name", ")", ";", "}", "return", "$", "this", ";", "}" ]
Determine field type automatically @param $str_name @param $mix_value @return $this
[ "Determine", "field", "type", "automatically" ]
e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba
https://github.com/tomwalder/php-appengine-search/blob/e34a7f6ddf2f5e8dc51487562d413ca4fd1331ba/src/Search/Schema.php#L190-L218
227,929
arnaud-lb/alb-oembed
lib/Alb/OEmbed/Discovery.php
Discovery.discoverFromHtml
public function discoverFromHtml($html) { $links = $this->findLinks($html); if ( ! $link = reset($links)) { return; } $type = null; switch($link['type']) { case 'application/json+oembed': $type = Provider::TYPE_JSON; break; case 'text/xml+oembed': $type = Provider::TYPE_XML; break; } $url = $link['href']; $endpoint = $this->getEndpointUrl($url); return new Provider($endpoint, $type); }
php
public function discoverFromHtml($html) { $links = $this->findLinks($html); if ( ! $link = reset($links)) { return; } $type = null; switch($link['type']) { case 'application/json+oembed': $type = Provider::TYPE_JSON; break; case 'text/xml+oembed': $type = Provider::TYPE_XML; break; } $url = $link['href']; $endpoint = $this->getEndpointUrl($url); return new Provider($endpoint, $type); }
[ "public", "function", "discoverFromHtml", "(", "$", "html", ")", "{", "$", "links", "=", "$", "this", "->", "findLinks", "(", "$", "html", ")", ";", "if", "(", "!", "$", "link", "=", "reset", "(", "$", "links", ")", ")", "{", "return", ";", "}", "$", "type", "=", "null", ";", "switch", "(", "$", "link", "[", "'type'", "]", ")", "{", "case", "'application/json+oembed'", ":", "$", "type", "=", "Provider", "::", "TYPE_JSON", ";", "break", ";", "case", "'text/xml+oembed'", ":", "$", "type", "=", "Provider", "::", "TYPE_XML", ";", "break", ";", "}", "$", "url", "=", "$", "link", "[", "'href'", "]", ";", "$", "endpoint", "=", "$", "this", "->", "getEndpointUrl", "(", "$", "url", ")", ";", "return", "new", "Provider", "(", "$", "endpoint", ",", "$", "type", ")", ";", "}" ]
Discovers and API endpoint from an HTML document @param string $html HTML document @return Provider A Provider instance or NULL
[ "Discovers", "and", "API", "endpoint", "from", "an", "HTML", "document" ]
a14da0282daf88fe290cd507935ece01e7ec8277
https://github.com/arnaud-lb/alb-oembed/blob/a14da0282daf88fe290cd507935ece01e7ec8277/lib/Alb/OEmbed/Discovery.php#L29-L52
227,930
arnaud-lb/alb-oembed
lib/Alb/OEmbed/Discovery.php
Discovery.getEndpointUrl
public function getEndpointUrl($url) { $components = parse_url($url); if (isset($components['query'])) { parse_str($components['query'], $query); unset($query['url']); $components['query'] = http_build_query($query); } return $this->assembleUrl($components); }
php
public function getEndpointUrl($url) { $components = parse_url($url); if (isset($components['query'])) { parse_str($components['query'], $query); unset($query['url']); $components['query'] = http_build_query($query); } return $this->assembleUrl($components); }
[ "public", "function", "getEndpointUrl", "(", "$", "url", ")", "{", "$", "components", "=", "parse_url", "(", "$", "url", ")", ";", "if", "(", "isset", "(", "$", "components", "[", "'query'", "]", ")", ")", "{", "parse_str", "(", "$", "components", "[", "'query'", "]", ",", "$", "query", ")", ";", "unset", "(", "$", "query", "[", "'url'", "]", ")", ";", "$", "components", "[", "'query'", "]", "=", "http_build_query", "(", "$", "query", ")", ";", "}", "return", "$", "this", "->", "assembleUrl", "(", "$", "components", ")", ";", "}" ]
Returns an endpoint URL from an URL with the 'url' param pre-filled @param string $url URL @return string URL
[ "Returns", "an", "endpoint", "URL", "from", "an", "URL", "with", "the", "url", "param", "pre", "-", "filled" ]
a14da0282daf88fe290cd507935ece01e7ec8277
https://github.com/arnaud-lb/alb-oembed/blob/a14da0282daf88fe290cd507935ece01e7ec8277/lib/Alb/OEmbed/Discovery.php#L92-L103
227,931
lawoole/framework
src/Support/DispatchEvents.php
DispatchEvents.getEventCallbacks
public function getEventCallbacks($event = null) { if ($event === null) { return $this->eventCallbacks; } return $this->eventCallbacks[strtolower($event)] ?? []; }
php
public function getEventCallbacks($event = null) { if ($event === null) { return $this->eventCallbacks; } return $this->eventCallbacks[strtolower($event)] ?? []; }
[ "public", "function", "getEventCallbacks", "(", "$", "event", "=", "null", ")", "{", "if", "(", "$", "event", "===", "null", ")", "{", "return", "$", "this", "->", "eventCallbacks", ";", "}", "return", "$", "this", "->", "eventCallbacks", "[", "strtolower", "(", "$", "event", ")", "]", "??", "[", "]", ";", "}" ]
Get all callbacks for the given event. @param string $event @return array
[ "Get", "all", "callbacks", "for", "the", "given", "event", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Support/DispatchEvents.php#L60-L67
227,932
lawoole/framework
src/Support/DispatchEvents.php
DispatchEvents.dispatchEventToEventCallbacks
protected function dispatchEventToEventCallbacks($event, $arguments) { foreach ($this->getEventCallbacks($event) as $callback) { try { call_user_func_array($callback, $arguments); } catch (Exception $e) { $this->handleException($e); } catch (Throwable $e) { $this->handleException(new FatalThrowableError($e)); } } }
php
protected function dispatchEventToEventCallbacks($event, $arguments) { foreach ($this->getEventCallbacks($event) as $callback) { try { call_user_func_array($callback, $arguments); } catch (Exception $e) { $this->handleException($e); } catch (Throwable $e) { $this->handleException(new FatalThrowableError($e)); } } }
[ "protected", "function", "dispatchEventToEventCallbacks", "(", "$", "event", ",", "$", "arguments", ")", "{", "foreach", "(", "$", "this", "->", "getEventCallbacks", "(", "$", "event", ")", "as", "$", "callback", ")", "{", "try", "{", "call_user_func_array", "(", "$", "callback", ",", "$", "arguments", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "this", "->", "handleException", "(", "$", "e", ")", ";", "}", "catch", "(", "Throwable", "$", "e", ")", "{", "$", "this", "->", "handleException", "(", "new", "FatalThrowableError", "(", "$", "e", ")", ")", ";", "}", "}", "}" ]
Dispatch the event to the event callbacks. @param string $event @param array $arguments
[ "Dispatch", "the", "event", "to", "the", "event", "callbacks", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Support/DispatchEvents.php#L99-L110
227,933
lawoole/framework
src/Support/DispatchEvents.php
DispatchEvents.dispatchEventToEventHandler
protected function dispatchEventToEventHandler($event, $arguments) { if ($this->eventHandler == null || ! method_exists($this->eventHandler, $method = "on{$event}")) { return; } try { $this->eventHandler->$method(...$arguments); } catch (Exception $e) { $this->handleException($e); } catch (Throwable $e) { $this->handleException(new FatalThrowableError($e)); } }
php
protected function dispatchEventToEventHandler($event, $arguments) { if ($this->eventHandler == null || ! method_exists($this->eventHandler, $method = "on{$event}")) { return; } try { $this->eventHandler->$method(...$arguments); } catch (Exception $e) { $this->handleException($e); } catch (Throwable $e) { $this->handleException(new FatalThrowableError($e)); } }
[ "protected", "function", "dispatchEventToEventHandler", "(", "$", "event", ",", "$", "arguments", ")", "{", "if", "(", "$", "this", "->", "eventHandler", "==", "null", "||", "!", "method_exists", "(", "$", "this", "->", "eventHandler", ",", "$", "method", "=", "\"on{$event}\"", ")", ")", "{", "return", ";", "}", "try", "{", "$", "this", "->", "eventHandler", "->", "$", "method", "(", "...", "$", "arguments", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "this", "->", "handleException", "(", "$", "e", ")", ";", "}", "catch", "(", "Throwable", "$", "e", ")", "{", "$", "this", "->", "handleException", "(", "new", "FatalThrowableError", "(", "$", "e", ")", ")", ";", "}", "}" ]
Dispatch the event to the event handler. @param string $event @param array $arguments
[ "Dispatch", "the", "event", "to", "the", "event", "handler", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Support/DispatchEvents.php#L118-L131
227,934
lawoole/framework
src/Support/DispatchEvents.php
DispatchEvents.handleException
protected function handleException(Exception $e) { $handler = $this->app->make(ExceptionHandler::class); $handler->report($e); try { $handler->renderForConsole( $this->app->make(OutputInterface::class), $e ); } catch (Throwable $e) { // } }
php
protected function handleException(Exception $e) { $handler = $this->app->make(ExceptionHandler::class); $handler->report($e); try { $handler->renderForConsole( $this->app->make(OutputInterface::class), $e ); } catch (Throwable $e) { // } }
[ "protected", "function", "handleException", "(", "Exception", "$", "e", ")", "{", "$", "handler", "=", "$", "this", "->", "app", "->", "make", "(", "ExceptionHandler", "::", "class", ")", ";", "$", "handler", "->", "report", "(", "$", "e", ")", ";", "try", "{", "$", "handler", "->", "renderForConsole", "(", "$", "this", "->", "app", "->", "make", "(", "OutputInterface", "::", "class", ")", ",", "$", "e", ")", ";", "}", "catch", "(", "Throwable", "$", "e", ")", "{", "//", "}", "}" ]
Handle the exception with the exception handler. @param \Exception $e
[ "Handle", "the", "exception", "with", "the", "exception", "handler", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Support/DispatchEvents.php#L138-L151
227,935
antaresproject/core
src/components/messages/src/MessageBag.php
MessageBag.extend
public function extend(Closure $callback) { $instance = $this->retrieve(); call_user_func($callback, $instance); return $instance; }
php
public function extend(Closure $callback) { $instance = $this->retrieve(); call_user_func($callback, $instance); return $instance; }
[ "public", "function", "extend", "(", "Closure", "$", "callback", ")", "{", "$", "instance", "=", "$", "this", "->", "retrieve", "(", ")", ";", "call_user_func", "(", "$", "callback", ",", "$", "instance", ")", ";", "return", "$", "instance", ";", "}" ]
Extend Messages instance from session. @param \Closure $callback @return static
[ "Extend", "Messages", "instance", "from", "session", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/messages/src/MessageBag.php#L78-L84
227,936
antaresproject/core
src/foundation/src/Processor/Setting.php
Setting.migrate
public function migrate(SystemUpdateListener $listener) { Foundation::make('antares.publisher.asset')->foundation(); Foundation::make('antares.publisher.migrate')->foundation(); return $listener->systemHasUpdated(); }
php
public function migrate(SystemUpdateListener $listener) { Foundation::make('antares.publisher.asset')->foundation(); Foundation::make('antares.publisher.migrate')->foundation(); return $listener->systemHasUpdated(); }
[ "public", "function", "migrate", "(", "SystemUpdateListener", "$", "listener", ")", "{", "Foundation", "::", "make", "(", "'antares.publisher.asset'", ")", "->", "foundation", "(", ")", ";", "Foundation", "::", "make", "(", "'antares.publisher.migrate'", ")", "->", "foundation", "(", ")", ";", "return", "$", "listener", "->", "systemHasUpdated", "(", ")", ";", "}" ]
Migrate Antares components. @param \Antares\Contracts\Foundation\Listener\SystemUpdater $listener @return mixed
[ "Migrate", "Antares", "components", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Processor/Setting.php#L105-L111
227,937
lawoole/framework
src/Homer/Serialize/Serializations/ThrowableSerialization.php
ThrowableSerialization.serializeThrowable
public function serializeThrowable(Throwable $e) { $this->class = get_class($e); $this->message = $e->getMessage(); $this->properties = []; try { $reflection = new ReflectionClass($this->class); foreach ($reflection->getProperties() as $property) { if ($property->isStatic()) { continue; } $property->setAccessible(true); $name = $property->getName(); if ($name == 'trace') { continue; } $value = $property->getValue($e); $this->properties[$name] = Maker::make($value); } } catch (Throwable $ex) { // } }
php
public function serializeThrowable(Throwable $e) { $this->class = get_class($e); $this->message = $e->getMessage(); $this->properties = []; try { $reflection = new ReflectionClass($this->class); foreach ($reflection->getProperties() as $property) { if ($property->isStatic()) { continue; } $property->setAccessible(true); $name = $property->getName(); if ($name == 'trace') { continue; } $value = $property->getValue($e); $this->properties[$name] = Maker::make($value); } } catch (Throwable $ex) { // } }
[ "public", "function", "serializeThrowable", "(", "Throwable", "$", "e", ")", "{", "$", "this", "->", "class", "=", "get_class", "(", "$", "e", ")", ";", "$", "this", "->", "message", "=", "$", "e", "->", "getMessage", "(", ")", ";", "$", "this", "->", "properties", "=", "[", "]", ";", "try", "{", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "this", "->", "class", ")", ";", "foreach", "(", "$", "reflection", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "if", "(", "$", "property", "->", "isStatic", "(", ")", ")", "{", "continue", ";", "}", "$", "property", "->", "setAccessible", "(", "true", ")", ";", "$", "name", "=", "$", "property", "->", "getName", "(", ")", ";", "if", "(", "$", "name", "==", "'trace'", ")", "{", "continue", ";", "}", "$", "value", "=", "$", "property", "->", "getValue", "(", "$", "e", ")", ";", "$", "this", "->", "properties", "[", "$", "name", "]", "=", "Maker", "::", "make", "(", "$", "value", ")", ";", "}", "}", "catch", "(", "Throwable", "$", "ex", ")", "{", "//", "}", "}" ]
Serialize the throwable. @param \Throwable $e
[ "Serialize", "the", "throwable", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Serialize/Serializations/ThrowableSerialization.php#L47-L77
227,938
lawoole/framework
src/Homer/Serialize/Serializations/ThrowableSerialization.php
ThrowableSerialization.recover
public function recover() { if (! class_exists($this->class)) { return new RuntimeException($this->message); } try { $reflection = new ReflectionClass($this->class); $e = $reflection->newInstanceWithoutConstructor(); if (! $e instanceof Throwable) { throw new RuntimeException("Class [{$this->class}] is not an exception."); } foreach ($reflection->getProperties() as $property) { $name = $property->getName(); if (isset($this->properties[$name])) { $value = $this->properties[$name]; $property->setAccessible(true); $property->setValue($e, $value instanceof Serialization ? $value->recover() : $value); } } return $e; } catch (Throwable $ex) { return new RuntimeException($this->message); } }
php
public function recover() { if (! class_exists($this->class)) { return new RuntimeException($this->message); } try { $reflection = new ReflectionClass($this->class); $e = $reflection->newInstanceWithoutConstructor(); if (! $e instanceof Throwable) { throw new RuntimeException("Class [{$this->class}] is not an exception."); } foreach ($reflection->getProperties() as $property) { $name = $property->getName(); if (isset($this->properties[$name])) { $value = $this->properties[$name]; $property->setAccessible(true); $property->setValue($e, $value instanceof Serialization ? $value->recover() : $value); } } return $e; } catch (Throwable $ex) { return new RuntimeException($this->message); } }
[ "public", "function", "recover", "(", ")", "{", "if", "(", "!", "class_exists", "(", "$", "this", "->", "class", ")", ")", "{", "return", "new", "RuntimeException", "(", "$", "this", "->", "message", ")", ";", "}", "try", "{", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "this", "->", "class", ")", ";", "$", "e", "=", "$", "reflection", "->", "newInstanceWithoutConstructor", "(", ")", ";", "if", "(", "!", "$", "e", "instanceof", "Throwable", ")", "{", "throw", "new", "RuntimeException", "(", "\"Class [{$this->class}] is not an exception.\"", ")", ";", "}", "foreach", "(", "$", "reflection", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "$", "name", "=", "$", "property", "->", "getName", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "properties", "[", "$", "name", "]", ")", ")", "{", "$", "value", "=", "$", "this", "->", "properties", "[", "$", "name", "]", ";", "$", "property", "->", "setAccessible", "(", "true", ")", ";", "$", "property", "->", "setValue", "(", "$", "e", ",", "$", "value", "instanceof", "Serialization", "?", "$", "value", "->", "recover", "(", ")", ":", "$", "value", ")", ";", "}", "}", "return", "$", "e", ";", "}", "catch", "(", "Throwable", "$", "ex", ")", "{", "return", "new", "RuntimeException", "(", "$", "this", "->", "message", ")", ";", "}", "}" ]
Recover the exception from the serialization. @return mixed
[ "Recover", "the", "exception", "from", "the", "serialization", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Serialize/Serializations/ThrowableSerialization.php#L84-L115
227,939
brick/http
src/Cookie.php
Cookie.parse
public static function parse(string $string) : Cookie { $parts = preg_split('/;\s*/', $string); $nameValue = explode('=', array_shift($parts), 2); if (count($nameValue) !== 2) { throw new \InvalidArgumentException('The cookie string is not valid.'); } [$name, $value] = $nameValue; if ($name === '') { throw new \InvalidArgumentException('The cookie string is not valid.'); } if ($value === '') { throw new \InvalidArgumentException('The cookie string is not valid.'); } $value = rawurldecode($value); $expires = 0; $path = null; $domain = null; $secure = false; $httpOnly = false; foreach ($parts as $part) { switch (strtolower($part)) { case 'secure': $secure = true; break; case 'httponly': $httpOnly = true; break; default: $elements = explode('=', $part, 2); if (count($elements) === 2) { switch (strtolower($elements[0])) { case 'expires': // Using @ to suppress the timezone warning, might not be the best thing to do. if (is_int($time = @ strtotime($elements[1]))) { $expires = $time; } break; case 'path': $path = $elements[1]; break; case 'domain': $domain = strtolower(ltrim($elements[1], '.')); } } } } return (new Cookie($name, $value)) ->setExpires($expires) ->setPath($path) ->setDomain($domain) ->setSecure($secure) ->setHttpOnly($httpOnly); }
php
public static function parse(string $string) : Cookie { $parts = preg_split('/;\s*/', $string); $nameValue = explode('=', array_shift($parts), 2); if (count($nameValue) !== 2) { throw new \InvalidArgumentException('The cookie string is not valid.'); } [$name, $value] = $nameValue; if ($name === '') { throw new \InvalidArgumentException('The cookie string is not valid.'); } if ($value === '') { throw new \InvalidArgumentException('The cookie string is not valid.'); } $value = rawurldecode($value); $expires = 0; $path = null; $domain = null; $secure = false; $httpOnly = false; foreach ($parts as $part) { switch (strtolower($part)) { case 'secure': $secure = true; break; case 'httponly': $httpOnly = true; break; default: $elements = explode('=', $part, 2); if (count($elements) === 2) { switch (strtolower($elements[0])) { case 'expires': // Using @ to suppress the timezone warning, might not be the best thing to do. if (is_int($time = @ strtotime($elements[1]))) { $expires = $time; } break; case 'path': $path = $elements[1]; break; case 'domain': $domain = strtolower(ltrim($elements[1], '.')); } } } } return (new Cookie($name, $value)) ->setExpires($expires) ->setPath($path) ->setDomain($domain) ->setSecure($secure) ->setHttpOnly($httpOnly); }
[ "public", "static", "function", "parse", "(", "string", "$", "string", ")", ":", "Cookie", "{", "$", "parts", "=", "preg_split", "(", "'/;\\s*/'", ",", "$", "string", ")", ";", "$", "nameValue", "=", "explode", "(", "'='", ",", "array_shift", "(", "$", "parts", ")", ",", "2", ")", ";", "if", "(", "count", "(", "$", "nameValue", ")", "!==", "2", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The cookie string is not valid.'", ")", ";", "}", "[", "$", "name", ",", "$", "value", "]", "=", "$", "nameValue", ";", "if", "(", "$", "name", "===", "''", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The cookie string is not valid.'", ")", ";", "}", "if", "(", "$", "value", "===", "''", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The cookie string is not valid.'", ")", ";", "}", "$", "value", "=", "rawurldecode", "(", "$", "value", ")", ";", "$", "expires", "=", "0", ";", "$", "path", "=", "null", ";", "$", "domain", "=", "null", ";", "$", "secure", "=", "false", ";", "$", "httpOnly", "=", "false", ";", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "switch", "(", "strtolower", "(", "$", "part", ")", ")", "{", "case", "'secure'", ":", "$", "secure", "=", "true", ";", "break", ";", "case", "'httponly'", ":", "$", "httpOnly", "=", "true", ";", "break", ";", "default", ":", "$", "elements", "=", "explode", "(", "'='", ",", "$", "part", ",", "2", ")", ";", "if", "(", "count", "(", "$", "elements", ")", "===", "2", ")", "{", "switch", "(", "strtolower", "(", "$", "elements", "[", "0", "]", ")", ")", "{", "case", "'expires'", ":", "// Using @ to suppress the timezone warning, might not be the best thing to do.", "if", "(", "is_int", "(", "$", "time", "=", "@", "strtotime", "(", "$", "elements", "[", "1", "]", ")", ")", ")", "{", "$", "expires", "=", "$", "time", ";", "}", "break", ";", "case", "'path'", ":", "$", "path", "=", "$", "elements", "[", "1", "]", ";", "break", ";", "case", "'domain'", ":", "$", "domain", "=", "strtolower", "(", "ltrim", "(", "$", "elements", "[", "1", "]", ",", "'.'", ")", ")", ";", "}", "}", "}", "}", "return", "(", "new", "Cookie", "(", "$", "name", ",", "$", "value", ")", ")", "->", "setExpires", "(", "$", "expires", ")", "->", "setPath", "(", "$", "path", ")", "->", "setDomain", "(", "$", "domain", ")", "->", "setSecure", "(", "$", "secure", ")", "->", "setHttpOnly", "(", "$", "httpOnly", ")", ";", "}" ]
Creates a cookie from the contents of a Set-Cookie header. @param string $string @return Cookie The cookie. @throws \InvalidArgumentException If the cookie string is not valid.
[ "Creates", "a", "cookie", "from", "the", "contents", "of", "a", "Set", "-", "Cookie", "header", "." ]
1b185b0563d10f9f4293c254aa411545da00b597
https://github.com/brick/http/blob/1b185b0563d10f9f4293c254aa411545da00b597/src/Cookie.php#L86-L150
227,940
lawoole/framework
src/Server/Process/Process.php
Process.createSwooleProcess
protected function createSwooleProcess() { $process = new SwooleProcess(function ($process) { $this->running = true; $process->name(sprintf('%s : Process %s', $this->app->name(), $this->getName() ?: $process->pid)); $this->dispatchEvent('Start', $this->server, $this); swoole_event_add($this->swooleProcess->pipe, function () { if (false !== ($data = $this->swooleProcess->read())) { $this->dispatchEvent('Message', $this->server, $this, $data); } }); call_user_func($this->runnableRetriever(), $this->server, $this); }, false, true); $process->setBlocking($this->isBlocking()); return $process; }
php
protected function createSwooleProcess() { $process = new SwooleProcess(function ($process) { $this->running = true; $process->name(sprintf('%s : Process %s', $this->app->name(), $this->getName() ?: $process->pid)); $this->dispatchEvent('Start', $this->server, $this); swoole_event_add($this->swooleProcess->pipe, function () { if (false !== ($data = $this->swooleProcess->read())) { $this->dispatchEvent('Message', $this->server, $this, $data); } }); call_user_func($this->runnableRetriever(), $this->server, $this); }, false, true); $process->setBlocking($this->isBlocking()); return $process; }
[ "protected", "function", "createSwooleProcess", "(", ")", "{", "$", "process", "=", "new", "SwooleProcess", "(", "function", "(", "$", "process", ")", "{", "$", "this", "->", "running", "=", "true", ";", "$", "process", "->", "name", "(", "sprintf", "(", "'%s : Process %s'", ",", "$", "this", "->", "app", "->", "name", "(", ")", ",", "$", "this", "->", "getName", "(", ")", "?", ":", "$", "process", "->", "pid", ")", ")", ";", "$", "this", "->", "dispatchEvent", "(", "'Start'", ",", "$", "this", "->", "server", ",", "$", "this", ")", ";", "swoole_event_add", "(", "$", "this", "->", "swooleProcess", "->", "pipe", ",", "function", "(", ")", "{", "if", "(", "false", "!==", "(", "$", "data", "=", "$", "this", "->", "swooleProcess", "->", "read", "(", ")", ")", ")", "{", "$", "this", "->", "dispatchEvent", "(", "'Message'", ",", "$", "this", "->", "server", ",", "$", "this", ",", "$", "data", ")", ";", "}", "}", ")", ";", "call_user_func", "(", "$", "this", "->", "runnableRetriever", "(", ")", ",", "$", "this", "->", "server", ",", "$", "this", ")", ";", "}", ",", "false", ",", "true", ")", ";", "$", "process", "->", "setBlocking", "(", "$", "this", "->", "isBlocking", "(", ")", ")", ";", "return", "$", "process", ";", "}" ]
Create the Swoole process instance. @return \Swoole\Process
[ "Create", "the", "Swoole", "process", "instance", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/Process/Process.php#L69-L90
227,941
lawoole/framework
src/Server/Process/Process.php
Process.runnableRetriever
protected function runnableRetriever() { $runnable = $this->getRunnable(); if ($runnable && is_callable($runnable)) { return $runnable; } return function ($server, $process) { $this->dispatchEvent('Run', $server, $process); }; }
php
protected function runnableRetriever() { $runnable = $this->getRunnable(); if ($runnable && is_callable($runnable)) { return $runnable; } return function ($server, $process) { $this->dispatchEvent('Run', $server, $process); }; }
[ "protected", "function", "runnableRetriever", "(", ")", "{", "$", "runnable", "=", "$", "this", "->", "getRunnable", "(", ")", ";", "if", "(", "$", "runnable", "&&", "is_callable", "(", "$", "runnable", ")", ")", "{", "return", "$", "runnable", ";", "}", "return", "function", "(", "$", "server", ",", "$", "process", ")", "{", "$", "this", "->", "dispatchEvent", "(", "'Run'", ",", "$", "server", ",", "$", "process", ")", ";", "}", ";", "}" ]
Get the runnable for the process. @return callable
[ "Get", "the", "runnable", "for", "the", "process", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/Process/Process.php#L167-L178
227,942
lawoole/framework
src/Server/Process/Process.php
Process.bind
public function bind(Server $server) { if ($this->isBound()) { throw new LogicException('Process can be bound to server only once.'); } $this->server = $server; $this->dispatchEvent('Bind', $server, $this); }
php
public function bind(Server $server) { if ($this->isBound()) { throw new LogicException('Process can be bound to server only once.'); } $this->server = $server; $this->dispatchEvent('Bind', $server, $this); }
[ "public", "function", "bind", "(", "Server", "$", "server", ")", "{", "if", "(", "$", "this", "->", "isBound", "(", ")", ")", "{", "throw", "new", "LogicException", "(", "'Process can be bound to server only once.'", ")", ";", "}", "$", "this", "->", "server", "=", "$", "server", ";", "$", "this", "->", "dispatchEvent", "(", "'Bind'", ",", "$", "server", ",", "$", "this", ")", ";", "}" ]
Bind the process to the server. @param \Lawoole\Server\Server $server
[ "Bind", "the", "process", "to", "the", "server", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/Process/Process.php#L185-L194
227,943
antaresproject/core
src/ui/components/datatables/src/DatatablesServiceProvider.php
DatatablesServiceProvider.boot
public function boot() { $path = realpath(__DIR__ . '/../'); $this->loadViewsFrom("{$path}/resources/views", 'datatables-helpers'); $this->mergeConfigFrom("{$path}/resources/config/config.php", 'datatables-config'); $this->app->make('antares.app')->namespaced(null, function (Router $router) { require __DIR__ . DIRECTORY_SEPARATOR . 'backend.php'; }); }
php
public function boot() { $path = realpath(__DIR__ . '/../'); $this->loadViewsFrom("{$path}/resources/views", 'datatables-helpers'); $this->mergeConfigFrom("{$path}/resources/config/config.php", 'datatables-config'); $this->app->make('antares.app')->namespaced(null, function (Router $router) { require __DIR__ . DIRECTORY_SEPARATOR . 'backend.php'; }); }
[ "public", "function", "boot", "(", ")", "{", "$", "path", "=", "realpath", "(", "__DIR__", ".", "'/../'", ")", ";", "$", "this", "->", "loadViewsFrom", "(", "\"{$path}/resources/views\"", ",", "'datatables-helpers'", ")", ";", "$", "this", "->", "mergeConfigFrom", "(", "\"{$path}/resources/config/config.php\"", ",", "'datatables-config'", ")", ";", "$", "this", "->", "app", "->", "make", "(", "'antares.app'", ")", "->", "namespaced", "(", "null", ",", "function", "(", "Router", "$", "router", ")", "{", "require", "__DIR__", ".", "DIRECTORY_SEPARATOR", ".", "'backend.php'", ";", "}", ")", ";", "}" ]
Booting service provider
[ "Booting", "service", "provider" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/DatatablesServiceProvider.php#L45-L55
227,944
gggeek/ggwebservices
classes/ggwebservicesserver.php
ggWebservicesServer.showResponse
function showResponse( $functionName, $namespaceURI, &$value ) { $ResponseClass = $this->ResponseClass; $response = new $ResponseClass( $functionName ); $response->setValue( $value ); // allow subclasses to inject in response more info that they have from request $this->prepareResponse( $response ); $payload = $response->payload(); foreach( $response->responseHeaders() as $header => $value ) { header( "$header: $value" ); } //header( "SOAPServer: eZ soap" ); $contentType = $response->contentType(); if ( ( $charset = $response->charset() ) != '') { $contentType .= "; charset=\"$charset\""; } header( "Content-Type: $contentType" ); /// @todo test how this interacts with php/apache later deflating response /// @todo this is mandatory eg. for xmlrpc, but if client uses http 1.1, /// we could omit it for other protocols header( "Content-Length: " . strlen( $payload ) ); if ( ob_get_length() ) ob_end_clean(); print( $payload ); }
php
function showResponse( $functionName, $namespaceURI, &$value ) { $ResponseClass = $this->ResponseClass; $response = new $ResponseClass( $functionName ); $response->setValue( $value ); // allow subclasses to inject in response more info that they have from request $this->prepareResponse( $response ); $payload = $response->payload(); foreach( $response->responseHeaders() as $header => $value ) { header( "$header: $value" ); } //header( "SOAPServer: eZ soap" ); $contentType = $response->contentType(); if ( ( $charset = $response->charset() ) != '') { $contentType .= "; charset=\"$charset\""; } header( "Content-Type: $contentType" ); /// @todo test how this interacts with php/apache later deflating response /// @todo this is mandatory eg. for xmlrpc, but if client uses http 1.1, /// we could omit it for other protocols header( "Content-Length: " . strlen( $payload ) ); if ( ob_get_length() ) ob_end_clean(); print( $payload ); }
[ "function", "showResponse", "(", "$", "functionName", ",", "$", "namespaceURI", ",", "&", "$", "value", ")", "{", "$", "ResponseClass", "=", "$", "this", "->", "ResponseClass", ";", "$", "response", "=", "new", "$", "ResponseClass", "(", "$", "functionName", ")", ";", "$", "response", "->", "setValue", "(", "$", "value", ")", ";", "// allow subclasses to inject in response more info that they have from request", "$", "this", "->", "prepareResponse", "(", "$", "response", ")", ";", "$", "payload", "=", "$", "response", "->", "payload", "(", ")", ";", "foreach", "(", "$", "response", "->", "responseHeaders", "(", ")", "as", "$", "header", "=>", "$", "value", ")", "{", "header", "(", "\"$header: $value\"", ")", ";", "}", "//header( \"SOAPServer: eZ soap\" );", "$", "contentType", "=", "$", "response", "->", "contentType", "(", ")", ";", "if", "(", "(", "$", "charset", "=", "$", "response", "->", "charset", "(", ")", ")", "!=", "''", ")", "{", "$", "contentType", ".=", "\"; charset=\\\"$charset\\\"\"", ";", "}", "header", "(", "\"Content-Type: $contentType\"", ")", ";", "/// @todo test how this interacts with php/apache later deflating response", "/// @todo this is mandatory eg. for xmlrpc, but if client uses http 1.1,", "/// we could omit it for other protocols", "header", "(", "\"Content-Length: \"", ".", "strlen", "(", "$", "payload", ")", ")", ";", "if", "(", "ob_get_length", "(", ")", ")", "ob_end_clean", "(", ")", ";", "print", "(", "$", "payload", ")", ";", "}" ]
Echoes the response, setting http headers and such @todo it would be easier if the request object was passed to this method. Right now we are forced to duplicate extra info coming from the request into the server itself, to reinject it into the response using the prepareResponse() method. Examples: request ID for jsonrpc, desired response type for rest protocol.
[ "Echoes", "the", "response", "setting", "http", "headers", "and", "such" ]
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggwebservicesserver.php#L68-L98
227,945
gggeek/ggwebservices
classes/ggwebservicesserver.php
ggWebservicesServer.processRequest
function processRequest() { /* tis' the job of the index page, not of the class! global $HTTP_SERVER_VARS; if ( $HTTP_SERVER_VARS["REQUEST_METHOD"] != "POST" ) { print( "Error: this web page does only understand POST methods" ); exit(); } */ $namespaceURI = 'unknown_namespace_uri'; /// @todo dechunk, correct encoding, check for supported /// http features of the client, etc... $data = $this->RawPostData; $data = $this->inflateRequest( $data ); if ( $data === false ) { $this->showResponse( 'unknown_function_name', $namespaceURI, new ggWebservicesFault( self::INVALIDCOMPRESSIONERROR, self::INVALIDCOMPRESSIONSTRING ) ); } $request = $this->parseRequest( $data ); if ( !is_object( $request ) ) /// @todo use is_a instead { $this->showResponse( 'unknown_function_name', $namespaceURI, new ggWebservicesFault( self::INVALIDREQUESTERROR, self::INVALIDREQUESTSTRING ) ); } else { $functionName = $request->name(); $params = $request->parameters(); if ( $this->isInternalRequest( $functionName ) ) { $response = $this->handleInternalRequest( $functionName, $params ); } else { $response = $this->handleRequest( $functionName, $params ); } $this->showResponse( $functionName, $namespaceURI, $response ); } }
php
function processRequest() { /* tis' the job of the index page, not of the class! global $HTTP_SERVER_VARS; if ( $HTTP_SERVER_VARS["REQUEST_METHOD"] != "POST" ) { print( "Error: this web page does only understand POST methods" ); exit(); } */ $namespaceURI = 'unknown_namespace_uri'; /// @todo dechunk, correct encoding, check for supported /// http features of the client, etc... $data = $this->RawPostData; $data = $this->inflateRequest( $data ); if ( $data === false ) { $this->showResponse( 'unknown_function_name', $namespaceURI, new ggWebservicesFault( self::INVALIDCOMPRESSIONERROR, self::INVALIDCOMPRESSIONSTRING ) ); } $request = $this->parseRequest( $data ); if ( !is_object( $request ) ) /// @todo use is_a instead { $this->showResponse( 'unknown_function_name', $namespaceURI, new ggWebservicesFault( self::INVALIDREQUESTERROR, self::INVALIDREQUESTSTRING ) ); } else { $functionName = $request->name(); $params = $request->parameters(); if ( $this->isInternalRequest( $functionName ) ) { $response = $this->handleInternalRequest( $functionName, $params ); } else { $response = $this->handleRequest( $functionName, $params ); } $this->showResponse( $functionName, $namespaceURI, $response ); } }
[ "function", "processRequest", "(", ")", "{", "/* tis' the job of the index page, not of the class!\n global $HTTP_SERVER_VARS;\n if ( $HTTP_SERVER_VARS[\"REQUEST_METHOD\"] != \"POST\" )\n {\n print( \"Error: this web page does only understand POST methods\" );\n exit();\n }\n */", "$", "namespaceURI", "=", "'unknown_namespace_uri'", ";", "/// @todo dechunk, correct encoding, check for supported", "/// http features of the client, etc...", "$", "data", "=", "$", "this", "->", "RawPostData", ";", "$", "data", "=", "$", "this", "->", "inflateRequest", "(", "$", "data", ")", ";", "if", "(", "$", "data", "===", "false", ")", "{", "$", "this", "->", "showResponse", "(", "'unknown_function_name'", ",", "$", "namespaceURI", ",", "new", "ggWebservicesFault", "(", "self", "::", "INVALIDCOMPRESSIONERROR", ",", "self", "::", "INVALIDCOMPRESSIONSTRING", ")", ")", ";", "}", "$", "request", "=", "$", "this", "->", "parseRequest", "(", "$", "data", ")", ";", "if", "(", "!", "is_object", "(", "$", "request", ")", ")", "/// @todo use is_a instead", "{", "$", "this", "->", "showResponse", "(", "'unknown_function_name'", ",", "$", "namespaceURI", ",", "new", "ggWebservicesFault", "(", "self", "::", "INVALIDREQUESTERROR", ",", "self", "::", "INVALIDREQUESTSTRING", ")", ")", ";", "}", "else", "{", "$", "functionName", "=", "$", "request", "->", "name", "(", ")", ";", "$", "params", "=", "$", "request", "->", "parameters", "(", ")", ";", "if", "(", "$", "this", "->", "isInternalRequest", "(", "$", "functionName", ")", ")", "{", "$", "response", "=", "$", "this", "->", "handleInternalRequest", "(", "$", "functionName", ",", "$", "params", ")", ";", "}", "else", "{", "$", "response", "=", "$", "this", "->", "handleRequest", "(", "$", "functionName", ",", "$", "params", ")", ";", "}", "$", "this", "->", "showResponse", "(", "$", "functionName", ",", "$", "namespaceURI", ",", "$", "response", ")", ";", "}", "}" ]
Processes the request and prints out the proper response. @todo if function gzinflate does not exist, we should return a more appropriate http-level error
[ "Processes", "the", "request", "and", "prints", "out", "the", "proper", "response", "." ]
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggwebservicesserver.php#L118-L167
227,946
gggeek/ggwebservices
classes/ggwebservicesserver.php
ggWebservicesServer.handleRequest
function handleRequest( $functionName, $params ) { if ( array_key_exists( $functionName, $this->FunctionList ) ) { $paramsOk = false; foreach( $this->FunctionList[$functionName] as $paramDesc ) { $paramsOk = ( ( $paramDesc === null ) || $this->validateParams( $params, $paramDesc['in'] ) ); if ( $paramsOk ) { break; } } if ( $paramsOk ) { // allow to use the dot as namespace separator in webservices $functionName = str_replace( array( '.' ), '_', $functionName ); try { if ( strpos( $functionName, '::' ) ) { return call_user_func_array( explode( '::', $functionName ), $params ); } else { return call_user_func_array( $functionName, $params ); } } catch( Exception $e ) { switch ( $this->exception_handling ) { case 0: return new ggWebservicesFault( $e->getCode(), $e->getMessage() ); case 1: return new ggWebservicesFault( self::GENERICRESPONSEERROR, self::GENERICRESPONSESTRING ); case 2: default: // coder did something weird if we get someting else... throw $e; } } } else { return new ggWebservicesFault( self::INVALIDPARAMSERROR, self::INVALIDPARAMSSTRING ); } } else { return new ggWebservicesFault( self::INVALIDMETHODERROR, self::INVALIDMETHODSTRING . " '$functionName'" ); } }
php
function handleRequest( $functionName, $params ) { if ( array_key_exists( $functionName, $this->FunctionList ) ) { $paramsOk = false; foreach( $this->FunctionList[$functionName] as $paramDesc ) { $paramsOk = ( ( $paramDesc === null ) || $this->validateParams( $params, $paramDesc['in'] ) ); if ( $paramsOk ) { break; } } if ( $paramsOk ) { // allow to use the dot as namespace separator in webservices $functionName = str_replace( array( '.' ), '_', $functionName ); try { if ( strpos( $functionName, '::' ) ) { return call_user_func_array( explode( '::', $functionName ), $params ); } else { return call_user_func_array( $functionName, $params ); } } catch( Exception $e ) { switch ( $this->exception_handling ) { case 0: return new ggWebservicesFault( $e->getCode(), $e->getMessage() ); case 1: return new ggWebservicesFault( self::GENERICRESPONSEERROR, self::GENERICRESPONSESTRING ); case 2: default: // coder did something weird if we get someting else... throw $e; } } } else { return new ggWebservicesFault( self::INVALIDPARAMSERROR, self::INVALIDPARAMSSTRING ); } } else { return new ggWebservicesFault( self::INVALIDMETHODERROR, self::INVALIDMETHODSTRING . " '$functionName'" ); } }
[ "function", "handleRequest", "(", "$", "functionName", ",", "$", "params", ")", "{", "if", "(", "array_key_exists", "(", "$", "functionName", ",", "$", "this", "->", "FunctionList", ")", ")", "{", "$", "paramsOk", "=", "false", ";", "foreach", "(", "$", "this", "->", "FunctionList", "[", "$", "functionName", "]", "as", "$", "paramDesc", ")", "{", "$", "paramsOk", "=", "(", "(", "$", "paramDesc", "===", "null", ")", "||", "$", "this", "->", "validateParams", "(", "$", "params", ",", "$", "paramDesc", "[", "'in'", "]", ")", ")", ";", "if", "(", "$", "paramsOk", ")", "{", "break", ";", "}", "}", "if", "(", "$", "paramsOk", ")", "{", "// allow to use the dot as namespace separator in webservices", "$", "functionName", "=", "str_replace", "(", "array", "(", "'.'", ")", ",", "'_'", ",", "$", "functionName", ")", ";", "try", "{", "if", "(", "strpos", "(", "$", "functionName", ",", "'::'", ")", ")", "{", "return", "call_user_func_array", "(", "explode", "(", "'::'", ",", "$", "functionName", ")", ",", "$", "params", ")", ";", "}", "else", "{", "return", "call_user_func_array", "(", "$", "functionName", ",", "$", "params", ")", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "switch", "(", "$", "this", "->", "exception_handling", ")", "{", "case", "0", ":", "return", "new", "ggWebservicesFault", "(", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "case", "1", ":", "return", "new", "ggWebservicesFault", "(", "self", "::", "GENERICRESPONSEERROR", ",", "self", "::", "GENERICRESPONSESTRING", ")", ";", "case", "2", ":", "default", ":", "// coder did something weird if we get someting else...", "throw", "$", "e", ";", "}", "}", "}", "else", "{", "return", "new", "ggWebservicesFault", "(", "self", "::", "INVALIDPARAMSERROR", ",", "self", "::", "INVALIDPARAMSSTRING", ")", ";", "}", "}", "else", "{", "return", "new", "ggWebservicesFault", "(", "self", "::", "INVALIDMETHODERROR", ",", "self", "::", "INVALIDMETHODSTRING", ".", "\" '$functionName'\"", ")", ";", "}", "}" ]
Verifies if the given request has been registered as an exposed webservice and executes it. Called by processRequest.
[ "Verifies", "if", "the", "given", "request", "has", "been", "registered", "as", "an", "exposed", "webservice", "and", "executes", "it", ".", "Called", "by", "processRequest", "." ]
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggwebservicesserver.php#L221-L273
227,947
gggeek/ggwebservices
classes/ggwebservicesserver.php
ggWebservicesServer.registerObject
function registerObject( $objectName, $includeFile = null ) { // file_exists check is useless, since it does not scan include path. Let coder eat his own dog food... if ( $includeFile !== null ) //&& file_exists( $includeFile ) ) include_once( $includeFile ); if ( class_exists( $objectName ) ) { $methods = get_class_methods( $objectName ); foreach ( $methods as $method ) { /// @todo check also for magic methods not to be registered! if ( strcasecmp ( $objectName, $method ) ) $this->FunctionList[$objectName."::".$method] = array( 'in' => null, 'out' => 'mixed' ); } return true; } else { return false; } }
php
function registerObject( $objectName, $includeFile = null ) { // file_exists check is useless, since it does not scan include path. Let coder eat his own dog food... if ( $includeFile !== null ) //&& file_exists( $includeFile ) ) include_once( $includeFile ); if ( class_exists( $objectName ) ) { $methods = get_class_methods( $objectName ); foreach ( $methods as $method ) { /// @todo check also for magic methods not to be registered! if ( strcasecmp ( $objectName, $method ) ) $this->FunctionList[$objectName."::".$method] = array( 'in' => null, 'out' => 'mixed' ); } return true; } else { return false; } }
[ "function", "registerObject", "(", "$", "objectName", ",", "$", "includeFile", "=", "null", ")", "{", "// file_exists check is useless, since it does not scan include path. Let coder eat his own dog food...", "if", "(", "$", "includeFile", "!==", "null", ")", "//&& file_exists( $includeFile ) )", "include_once", "(", "$", "includeFile", ")", ";", "if", "(", "class_exists", "(", "$", "objectName", ")", ")", "{", "$", "methods", "=", "get_class_methods", "(", "$", "objectName", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "/// @todo check also for magic methods not to be registered!", "if", "(", "strcasecmp", "(", "$", "objectName", ",", "$", "method", ")", ")", "$", "this", "->", "FunctionList", "[", "$", "objectName", ".", "\"::\"", ".", "$", "method", "]", "=", "array", "(", "'in'", "=>", "null", ",", "'out'", "=>", "'mixed'", ")", ";", "}", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Registers all functions of an object on the server. @return bool Returns false if the object could not be registered. @todo add optional introspection-based param registering @todo add single method registration @todo add registration of per-method descriptions
[ "Registers", "all", "functions", "of", "an", "object", "on", "the", "server", "." ]
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggwebservicesserver.php#L307-L328
227,948
antaresproject/core
src/components/messages/src/Extension/FlashMessenger.php
FlashMessenger.checkout
protected function checkout(MessageBag $messages) { $html = ''; $hasError = false; $hasSuccess = false; foreach (['error', 'info', 'success', 'warning'] as $key) { if ($messages->has($key)) { $hasError = (!$hasError && $key == 'error'); $hasSuccess = (!$hasSuccess && $key == 'success'); $flashMessages = $messages->setFormat('<div class="activity-item"> <i class="fa ' . $this->mapping[$key] . '"></i> <div class="activity">:message</div>')->get($key); array_walk($flashMessages, function($current) use ($key, &$html) { $html .= "generate('{$key}', '{$current}');\n"; }); } } return $html; }
php
protected function checkout(MessageBag $messages) { $html = ''; $hasError = false; $hasSuccess = false; foreach (['error', 'info', 'success', 'warning'] as $key) { if ($messages->has($key)) { $hasError = (!$hasError && $key == 'error'); $hasSuccess = (!$hasSuccess && $key == 'success'); $flashMessages = $messages->setFormat('<div class="activity-item"> <i class="fa ' . $this->mapping[$key] . '"></i> <div class="activity">:message</div>')->get($key); array_walk($flashMessages, function($current) use ($key, &$html) { $html .= "generate('{$key}', '{$current}');\n"; }); } } return $html; }
[ "protected", "function", "checkout", "(", "MessageBag", "$", "messages", ")", "{", "$", "html", "=", "''", ";", "$", "hasError", "=", "false", ";", "$", "hasSuccess", "=", "false", ";", "foreach", "(", "[", "'error'", ",", "'info'", ",", "'success'", ",", "'warning'", "]", "as", "$", "key", ")", "{", "if", "(", "$", "messages", "->", "has", "(", "$", "key", ")", ")", "{", "$", "hasError", "=", "(", "!", "$", "hasError", "&&", "$", "key", "==", "'error'", ")", ";", "$", "hasSuccess", "=", "(", "!", "$", "hasSuccess", "&&", "$", "key", "==", "'success'", ")", ";", "$", "flashMessages", "=", "$", "messages", "->", "setFormat", "(", "'<div class=\"activity-item\"> <i class=\"fa '", ".", "$", "this", "->", "mapping", "[", "$", "key", "]", ".", "'\"></i> <div class=\"activity\">:message</div>'", ")", "->", "get", "(", "$", "key", ")", ";", "array_walk", "(", "$", "flashMessages", ",", "function", "(", "$", "current", ")", "use", "(", "$", "key", ",", "&", "$", "html", ")", "{", "$", "html", ".=", "\"generate('{$key}', '{$current}');\\n\"", ";", "}", ")", ";", "}", "}", "return", "$", "html", ";", "}" ]
checkout messages from session container @param MessageBag $messages @return string
[ "checkout", "messages", "from", "session", "container" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/messages/src/Extension/FlashMessenger.php#L108-L128
227,949
antaresproject/core
src/components/html/src/Adapter/FieldPermissionAdapter.php
FieldPermissionAdapter.getFormConfigKey
private function getFormConfigKey($name, array $control) { if ($this->isFrontend($control['component'])) { $control['component'] = 'content'; $control['method'] = 'index'; } return implode(self::separator, [$control['component'], $control['action'], $control['method'], $name]); }
php
private function getFormConfigKey($name, array $control) { if ($this->isFrontend($control['component'])) { $control['component'] = 'content'; $control['method'] = 'index'; } return implode(self::separator, [$control['component'], $control['action'], $control['method'], $name]); }
[ "private", "function", "getFormConfigKey", "(", "$", "name", ",", "array", "$", "control", ")", "{", "if", "(", "$", "this", "->", "isFrontend", "(", "$", "control", "[", "'component'", "]", ")", ")", "{", "$", "control", "[", "'component'", "]", "=", "'content'", ";", "$", "control", "[", "'method'", "]", "=", "'index'", ";", "}", "return", "implode", "(", "self", "::", "separator", ",", "[", "$", "control", "[", "'component'", "]", ",", "$", "control", "[", "'action'", "]", ",", "$", "control", "[", "'method'", "]", ",", "$", "name", "]", ")", ";", "}" ]
form config keyname getter @param String $name @param array $control @return String
[ "form", "config", "keyname", "getter" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Adapter/FieldPermissionAdapter.php#L71-L78
227,950
antaresproject/core
src/components/html/src/Adapter/FieldPermissionAdapter.php
FieldPermissionAdapter.display
protected function display(FieldContract $control, array $displayable = array()) { $name = $control->get('name'); $shouldBeDisplayed = false; if ($control->force_displayable) { return true; } foreach ($displayable as $field) { if ($name == $field['name']) { $shouldBeDisplayed = true; break; } } return $shouldBeDisplayed; }
php
protected function display(FieldContract $control, array $displayable = array()) { $name = $control->get('name'); $shouldBeDisplayed = false; if ($control->force_displayable) { return true; } foreach ($displayable as $field) { if ($name == $field['name']) { $shouldBeDisplayed = true; break; } } return $shouldBeDisplayed; }
[ "protected", "function", "display", "(", "FieldContract", "$", "control", ",", "array", "$", "displayable", "=", "array", "(", ")", ")", "{", "$", "name", "=", "$", "control", "->", "get", "(", "'name'", ")", ";", "$", "shouldBeDisplayed", "=", "false", ";", "if", "(", "$", "control", "->", "force_displayable", ")", "{", "return", "true", ";", "}", "foreach", "(", "$", "displayable", "as", "$", "field", ")", "{", "if", "(", "$", "name", "==", "$", "field", "[", "'name'", "]", ")", "{", "$", "shouldBeDisplayed", "=", "true", ";", "break", ";", "}", "}", "return", "$", "shouldBeDisplayed", ";", "}" ]
resolve field display depends on form configuration @param FieldContract $control @param array $displayable
[ "resolve", "field", "display", "depends", "on", "form", "configuration" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Adapter/FieldPermissionAdapter.php#L128-L143
227,951
antaresproject/core
src/components/html/src/Adapter/FieldPermissionAdapter.php
FieldPermissionAdapter.resolveEditableField
protected function resolveEditableField(FieldContract $control, array $editable = array()) { $name = $control->get('name'); if ($control->force_editable) { return $control; } $shouldBeEdited = false; foreach ($editable as $editableField) { if ($name == $editableField['name']) { $shouldBeEdited = true; break; } } $disable = $shouldBeEdited ? [] : ['disabled' => 'disabled', 'readonly' => 'readonly']; $attributes = array_merge($control->get('attributes'), $disable); $control->attributes($attributes); return $control; }
php
protected function resolveEditableField(FieldContract $control, array $editable = array()) { $name = $control->get('name'); if ($control->force_editable) { return $control; } $shouldBeEdited = false; foreach ($editable as $editableField) { if ($name == $editableField['name']) { $shouldBeEdited = true; break; } } $disable = $shouldBeEdited ? [] : ['disabled' => 'disabled', 'readonly' => 'readonly']; $attributes = array_merge($control->get('attributes'), $disable); $control->attributes($attributes); return $control; }
[ "protected", "function", "resolveEditableField", "(", "FieldContract", "$", "control", ",", "array", "$", "editable", "=", "array", "(", ")", ")", "{", "$", "name", "=", "$", "control", "->", "get", "(", "'name'", ")", ";", "if", "(", "$", "control", "->", "force_editable", ")", "{", "return", "$", "control", ";", "}", "$", "shouldBeEdited", "=", "false", ";", "foreach", "(", "$", "editable", "as", "$", "editableField", ")", "{", "if", "(", "$", "name", "==", "$", "editableField", "[", "'name'", "]", ")", "{", "$", "shouldBeEdited", "=", "true", ";", "break", ";", "}", "}", "$", "disable", "=", "$", "shouldBeEdited", "?", "[", "]", ":", "[", "'disabled'", "=>", "'disabled'", ",", "'readonly'", "=>", "'readonly'", "]", ";", "$", "attributes", "=", "array_merge", "(", "$", "control", "->", "get", "(", "'attributes'", ")", ",", "$", "disable", ")", ";", "$", "control", "->", "attributes", "(", "$", "attributes", ")", ";", "return", "$", "control", ";", "}" ]
resolve field edition depends on form configuration @param FieldContract $control @param array $editable @param array $disabled
[ "resolve", "field", "edition", "depends", "on", "form", "configuration" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Adapter/FieldPermissionAdapter.php#L152-L169
227,952
antaresproject/core
src/components/html/src/Adapter/FieldPermissionAdapter.php
FieldPermissionAdapter.validate
protected function validate($name, $key = null) { if (!is_null($key)) { return Memory::make('forms-config')->get($key); } $control = $this->runtime->get('control', []); /** before middleware gives information about current middleware action and controller * */ if (empty($control)) { return false; } $keyname = $this->getFormConfigKey($name, $control); /** we will get this from cache * */ $configuration = Memory::make('forms-config')->get($keyname); /** when we dont find any information about form in current route * */ if (empty($configuration)) { return false; } /** when current action is not same with action from form configuration * */ if ((int) $control['action_id'] !== (int) $configuration['action']) { return false; } return $configuration; }
php
protected function validate($name, $key = null) { if (!is_null($key)) { return Memory::make('forms-config')->get($key); } $control = $this->runtime->get('control', []); /** before middleware gives information about current middleware action and controller * */ if (empty($control)) { return false; } $keyname = $this->getFormConfigKey($name, $control); /** we will get this from cache * */ $configuration = Memory::make('forms-config')->get($keyname); /** when we dont find any information about form in current route * */ if (empty($configuration)) { return false; } /** when current action is not same with action from form configuration * */ if ((int) $control['action_id'] !== (int) $configuration['action']) { return false; } return $configuration; }
[ "protected", "function", "validate", "(", "$", "name", ",", "$", "key", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "key", ")", ")", "{", "return", "Memory", "::", "make", "(", "'forms-config'", ")", "->", "get", "(", "$", "key", ")", ";", "}", "$", "control", "=", "$", "this", "->", "runtime", "->", "get", "(", "'control'", ",", "[", "]", ")", ";", "/** before middleware gives information about current middleware action and controller * */", "if", "(", "empty", "(", "$", "control", ")", ")", "{", "return", "false", ";", "}", "$", "keyname", "=", "$", "this", "->", "getFormConfigKey", "(", "$", "name", ",", "$", "control", ")", ";", "/** we will get this from cache * */", "$", "configuration", "=", "Memory", "::", "make", "(", "'forms-config'", ")", "->", "get", "(", "$", "keyname", ")", ";", "/** when we dont find any information about form in current route * */", "if", "(", "empty", "(", "$", "configuration", ")", ")", "{", "return", "false", ";", "}", "/** when current action is not same with action from form configuration * */", "if", "(", "(", "int", ")", "$", "control", "[", "'action_id'", "]", "!==", "(", "int", ")", "$", "configuration", "[", "'action'", "]", ")", "{", "return", "false", ";", "}", "return", "$", "configuration", ";", "}" ]
validate current form configuration and matching with route middleware settings @param String $name @param String $key @return boolean|array
[ "validate", "current", "form", "configuration", "and", "matching", "with", "route", "middleware", "settings" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Adapter/FieldPermissionAdapter.php#L178-L201
227,953
antaresproject/core
src/components/support/src/Providers/Traits/MiddlewareProviderTrait.php
MiddlewareProviderTrait.resolveModuleName
protected function resolveModuleName() { if (!isset($this->routeGroup)) { return ''; } return join('.', [str_replace('/', '.', $this->routeGroup), self::$withSuffix]); }
php
protected function resolveModuleName() { if (!isset($this->routeGroup)) { return ''; } return join('.', [str_replace('/', '.', $this->routeGroup), self::$withSuffix]); }
[ "protected", "function", "resolveModuleName", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "routeGroup", ")", ")", "{", "return", "''", ";", "}", "return", "join", "(", "'.'", ",", "[", "str_replace", "(", "'/'", ",", "'.'", ",", "$", "this", "->", "routeGroup", ")", ",", "self", "::", "$", "withSuffix", "]", ")", ";", "}" ]
middleware route keyname creator @return String
[ "middleware", "route", "keyname", "creator" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/support/src/Providers/Traits/MiddlewareProviderTrait.php#L74-L80
227,954
gggeek/ggwebservices
lib/xmlrpc/xmlrpcs.inc.php
xmlrpc_server.serializeDebug
function serializeDebug($charset_encoding='') { // Tough encoding problem: which internal charset should we assume for debug info? // It might contain a copy of raw data received from client, ie with unknown encoding, // intermixed with php generated data and user generated data... // so we split it: system debug is base 64 encoded, // user debug info should be encoded by the end user using the INTERNAL_ENCODING $out = ''; if ($this->debug_info != '') { $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n".base64_encode($this->debug_info)."\n-->\n"; } if($GLOBALS['_xmlrpc_debuginfo']!='') { $out .= "<!-- DEBUG INFO:\n" . xmlrpc_encode_entitites(str_replace('--', '_-', $GLOBALS['_xmlrpc_debuginfo']), $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "\n-->\n"; // NB: a better solution MIGHT be to use CDATA, but we need to insert it // into return payload AFTER the beginning tag //$out .= "<![CDATA[ DEBUG INFO:\n\n" . str_replace(']]>', ']_]_>', $GLOBALS['_xmlrpc_debuginfo']) . "\n]]>\n"; } return $out; }
php
function serializeDebug($charset_encoding='') { // Tough encoding problem: which internal charset should we assume for debug info? // It might contain a copy of raw data received from client, ie with unknown encoding, // intermixed with php generated data and user generated data... // so we split it: system debug is base 64 encoded, // user debug info should be encoded by the end user using the INTERNAL_ENCODING $out = ''; if ($this->debug_info != '') { $out .= "<!-- SERVER DEBUG INFO (BASE64 ENCODED):\n".base64_encode($this->debug_info)."\n-->\n"; } if($GLOBALS['_xmlrpc_debuginfo']!='') { $out .= "<!-- DEBUG INFO:\n" . xmlrpc_encode_entitites(str_replace('--', '_-', $GLOBALS['_xmlrpc_debuginfo']), $GLOBALS['xmlrpc_internalencoding'], $charset_encoding) . "\n-->\n"; // NB: a better solution MIGHT be to use CDATA, but we need to insert it // into return payload AFTER the beginning tag //$out .= "<![CDATA[ DEBUG INFO:\n\n" . str_replace(']]>', ']_]_>', $GLOBALS['_xmlrpc_debuginfo']) . "\n]]>\n"; } return $out; }
[ "function", "serializeDebug", "(", "$", "charset_encoding", "=", "''", ")", "{", "// Tough encoding problem: which internal charset should we assume for debug info?", "// It might contain a copy of raw data received from client, ie with unknown encoding,", "// intermixed with php generated data and user generated data...", "// so we split it: system debug is base 64 encoded,", "// user debug info should be encoded by the end user using the INTERNAL_ENCODING", "$", "out", "=", "''", ";", "if", "(", "$", "this", "->", "debug_info", "!=", "''", ")", "{", "$", "out", ".=", "\"<!-- SERVER DEBUG INFO (BASE64 ENCODED):\\n\"", ".", "base64_encode", "(", "$", "this", "->", "debug_info", ")", ".", "\"\\n-->\\n\"", ";", "}", "if", "(", "$", "GLOBALS", "[", "'_xmlrpc_debuginfo'", "]", "!=", "''", ")", "{", "$", "out", ".=", "\"<!-- DEBUG INFO:\\n\"", ".", "xmlrpc_encode_entitites", "(", "str_replace", "(", "'--'", ",", "'_-'", ",", "$", "GLOBALS", "[", "'_xmlrpc_debuginfo'", "]", ")", ",", "$", "GLOBALS", "[", "'xmlrpc_internalencoding'", "]", ",", "$", "charset_encoding", ")", ".", "\"\\n-->\\n\"", ";", "// NB: a better solution MIGHT be to use CDATA, but we need to insert it", "// into return payload AFTER the beginning tag", "//$out .= \"<![CDATA[ DEBUG INFO:\\n\\n\" . str_replace(']]>', ']_]_>', $GLOBALS['_xmlrpc_debuginfo']) . \"\\n]]>\\n\";", "}", "return", "$", "out", ";", "}" ]
Return a string with the serialized representation of all debug info @param string $charset_encoding the target charset encoding for the serialization @return string an XML comment (or two)
[ "Return", "a", "string", "with", "the", "serialized", "representation", "of", "all", "debug", "info" ]
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/lib/xmlrpc/xmlrpcs.inc.php#L556-L577
227,955
gggeek/ggwebservices
lib/xmlrpc/xmlrpcs.inc.php
xmlrpc_server.service
function service($data=null, $return_payload=false) { if ($data === null) { // workaround for a known bug in php ver. 5.2.2 that broke $HTTP_RAW_POST_DATA $data = file_get_contents('php://input'); } $raw_data = $data; // reset internal debug info $this->debug_info = ''; // Echo back what we received, before parsing it if($this->debug > 1) { $this->debugmsg("+++GOT+++\n" . $data . "\n+++END+++"); } $r = $this->parseRequestHeaders($data, $req_charset, $resp_charset, $resp_encoding); if (!$r) { $r=$this->parseRequest($data, $req_charset); } // save full body of request into response, for more debugging usages $r->raw_data = $raw_data; if($this->debug > 2 && $GLOBALS['_xmlrpcs_occurred_errors']) { $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" . $GLOBALS['_xmlrpcs_occurred_errors'] . "+++END+++"); } $payload=$this->xml_header($resp_charset); if($this->debug > 0) { $payload = $payload . $this->serializeDebug($resp_charset); } // G. Giunta 2006-01-27: do not create response serialization if it has // already happened. Helps building json magic if (empty($r->payload)) { $r->serialize($resp_charset); } $payload = $payload . $r->payload; if ($return_payload) { return $payload; } // if we get a warning/error that has output some text before here, then we cannot // add a new header. We cannot say we are sending xml, either... if(!headers_sent()) { header('Content-Type: '.$r->content_type); // we do not know if client actually told us an accepted charset, but if he did // we have to tell him what we did header("Vary: Accept-Charset"); // http compression of output: only // if we can do it, and we want to do it, and client asked us to, // and php ini settings do not force it already $php_no_self_compress = !ini_get('zlib.output_compression') && (ini_get('output_handler') != 'ob_gzhandler'); if($this->compress_response && function_exists('gzencode') && $resp_encoding != '' && $php_no_self_compress) { if(strpos($resp_encoding, 'gzip') !== false) { $payload = gzencode($payload); header("Content-Encoding: gzip"); header("Vary: Accept-Encoding"); } elseif (strpos($resp_encoding, 'deflate') !== false) { $payload = gzcompress($payload); header("Content-Encoding: deflate"); header("Vary: Accept-Encoding"); } } // do not ouput content-length header if php is compressing output for us: // it will mess up measurements if($php_no_self_compress) { header('Content-Length: ' . (int)strlen($payload)); } } else { error_log('XML-RPC: '.__METHOD__.': http headers already sent before response is fully generated. Check for php warning or error messages'); } print $payload; // return request, in case subclasses want it return $r; }
php
function service($data=null, $return_payload=false) { if ($data === null) { // workaround for a known bug in php ver. 5.2.2 that broke $HTTP_RAW_POST_DATA $data = file_get_contents('php://input'); } $raw_data = $data; // reset internal debug info $this->debug_info = ''; // Echo back what we received, before parsing it if($this->debug > 1) { $this->debugmsg("+++GOT+++\n" . $data . "\n+++END+++"); } $r = $this->parseRequestHeaders($data, $req_charset, $resp_charset, $resp_encoding); if (!$r) { $r=$this->parseRequest($data, $req_charset); } // save full body of request into response, for more debugging usages $r->raw_data = $raw_data; if($this->debug > 2 && $GLOBALS['_xmlrpcs_occurred_errors']) { $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" . $GLOBALS['_xmlrpcs_occurred_errors'] . "+++END+++"); } $payload=$this->xml_header($resp_charset); if($this->debug > 0) { $payload = $payload . $this->serializeDebug($resp_charset); } // G. Giunta 2006-01-27: do not create response serialization if it has // already happened. Helps building json magic if (empty($r->payload)) { $r->serialize($resp_charset); } $payload = $payload . $r->payload; if ($return_payload) { return $payload; } // if we get a warning/error that has output some text before here, then we cannot // add a new header. We cannot say we are sending xml, either... if(!headers_sent()) { header('Content-Type: '.$r->content_type); // we do not know if client actually told us an accepted charset, but if he did // we have to tell him what we did header("Vary: Accept-Charset"); // http compression of output: only // if we can do it, and we want to do it, and client asked us to, // and php ini settings do not force it already $php_no_self_compress = !ini_get('zlib.output_compression') && (ini_get('output_handler') != 'ob_gzhandler'); if($this->compress_response && function_exists('gzencode') && $resp_encoding != '' && $php_no_self_compress) { if(strpos($resp_encoding, 'gzip') !== false) { $payload = gzencode($payload); header("Content-Encoding: gzip"); header("Vary: Accept-Encoding"); } elseif (strpos($resp_encoding, 'deflate') !== false) { $payload = gzcompress($payload); header("Content-Encoding: deflate"); header("Vary: Accept-Encoding"); } } // do not ouput content-length header if php is compressing output for us: // it will mess up measurements if($php_no_self_compress) { header('Content-Length: ' . (int)strlen($payload)); } } else { error_log('XML-RPC: '.__METHOD__.': http headers already sent before response is fully generated. Check for php warning or error messages'); } print $payload; // return request, in case subclasses want it return $r; }
[ "function", "service", "(", "$", "data", "=", "null", ",", "$", "return_payload", "=", "false", ")", "{", "if", "(", "$", "data", "===", "null", ")", "{", "// workaround for a known bug in php ver. 5.2.2 that broke $HTTP_RAW_POST_DATA", "$", "data", "=", "file_get_contents", "(", "'php://input'", ")", ";", "}", "$", "raw_data", "=", "$", "data", ";", "// reset internal debug info", "$", "this", "->", "debug_info", "=", "''", ";", "// Echo back what we received, before parsing it", "if", "(", "$", "this", "->", "debug", ">", "1", ")", "{", "$", "this", "->", "debugmsg", "(", "\"+++GOT+++\\n\"", ".", "$", "data", ".", "\"\\n+++END+++\"", ")", ";", "}", "$", "r", "=", "$", "this", "->", "parseRequestHeaders", "(", "$", "data", ",", "$", "req_charset", ",", "$", "resp_charset", ",", "$", "resp_encoding", ")", ";", "if", "(", "!", "$", "r", ")", "{", "$", "r", "=", "$", "this", "->", "parseRequest", "(", "$", "data", ",", "$", "req_charset", ")", ";", "}", "// save full body of request into response, for more debugging usages", "$", "r", "->", "raw_data", "=", "$", "raw_data", ";", "if", "(", "$", "this", "->", "debug", ">", "2", "&&", "$", "GLOBALS", "[", "'_xmlrpcs_occurred_errors'", "]", ")", "{", "$", "this", "->", "debugmsg", "(", "\"+++PROCESSING ERRORS AND WARNINGS+++\\n\"", ".", "$", "GLOBALS", "[", "'_xmlrpcs_occurred_errors'", "]", ".", "\"+++END+++\"", ")", ";", "}", "$", "payload", "=", "$", "this", "->", "xml_header", "(", "$", "resp_charset", ")", ";", "if", "(", "$", "this", "->", "debug", ">", "0", ")", "{", "$", "payload", "=", "$", "payload", ".", "$", "this", "->", "serializeDebug", "(", "$", "resp_charset", ")", ";", "}", "// G. Giunta 2006-01-27: do not create response serialization if it has", "// already happened. Helps building json magic", "if", "(", "empty", "(", "$", "r", "->", "payload", ")", ")", "{", "$", "r", "->", "serialize", "(", "$", "resp_charset", ")", ";", "}", "$", "payload", "=", "$", "payload", ".", "$", "r", "->", "payload", ";", "if", "(", "$", "return_payload", ")", "{", "return", "$", "payload", ";", "}", "// if we get a warning/error that has output some text before here, then we cannot", "// add a new header. We cannot say we are sending xml, either...", "if", "(", "!", "headers_sent", "(", ")", ")", "{", "header", "(", "'Content-Type: '", ".", "$", "r", "->", "content_type", ")", ";", "// we do not know if client actually told us an accepted charset, but if he did", "// we have to tell him what we did", "header", "(", "\"Vary: Accept-Charset\"", ")", ";", "// http compression of output: only", "// if we can do it, and we want to do it, and client asked us to,", "// and php ini settings do not force it already", "$", "php_no_self_compress", "=", "!", "ini_get", "(", "'zlib.output_compression'", ")", "&&", "(", "ini_get", "(", "'output_handler'", ")", "!=", "'ob_gzhandler'", ")", ";", "if", "(", "$", "this", "->", "compress_response", "&&", "function_exists", "(", "'gzencode'", ")", "&&", "$", "resp_encoding", "!=", "''", "&&", "$", "php_no_self_compress", ")", "{", "if", "(", "strpos", "(", "$", "resp_encoding", ",", "'gzip'", ")", "!==", "false", ")", "{", "$", "payload", "=", "gzencode", "(", "$", "payload", ")", ";", "header", "(", "\"Content-Encoding: gzip\"", ")", ";", "header", "(", "\"Vary: Accept-Encoding\"", ")", ";", "}", "elseif", "(", "strpos", "(", "$", "resp_encoding", ",", "'deflate'", ")", "!==", "false", ")", "{", "$", "payload", "=", "gzcompress", "(", "$", "payload", ")", ";", "header", "(", "\"Content-Encoding: deflate\"", ")", ";", "header", "(", "\"Vary: Accept-Encoding\"", ")", ";", "}", "}", "// do not ouput content-length header if php is compressing output for us:", "// it will mess up measurements", "if", "(", "$", "php_no_self_compress", ")", "{", "header", "(", "'Content-Length: '", ".", "(", "int", ")", "strlen", "(", "$", "payload", ")", ")", ";", "}", "}", "else", "{", "error_log", "(", "'XML-RPC: '", ".", "__METHOD__", ".", "': http headers already sent before response is fully generated. Check for php warning or error messages'", ")", ";", "}", "print", "$", "payload", ";", "// return request, in case subclasses want it", "return", "$", "r", ";", "}" ]
Execute the xmlrpc request, printing the response @param string $data the request body. If null, the http POST request will be examined @return xmlrpcresp the response object (usually not used by caller...) @access public
[ "Execute", "the", "xmlrpc", "request", "printing", "the", "response" ]
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/lib/xmlrpc/xmlrpcs.inc.php#L585-L683
227,956
gggeek/ggwebservices
lib/xmlrpc/xmlrpcs.inc.php
xmlrpc_server.add_to_map
function add_to_map($methodname,$function,$sig=null,$doc=false,$sigdoc=false) { $this->dmap[$methodname] = array( 'function' => $function, 'docstring' => $doc ); if ($sig) { $this->dmap[$methodname]['signature'] = $sig; } if ($sigdoc) { $this->dmap[$methodname]['signature_docs'] = $sigdoc; } }
php
function add_to_map($methodname,$function,$sig=null,$doc=false,$sigdoc=false) { $this->dmap[$methodname] = array( 'function' => $function, 'docstring' => $doc ); if ($sig) { $this->dmap[$methodname]['signature'] = $sig; } if ($sigdoc) { $this->dmap[$methodname]['signature_docs'] = $sigdoc; } }
[ "function", "add_to_map", "(", "$", "methodname", ",", "$", "function", ",", "$", "sig", "=", "null", ",", "$", "doc", "=", "false", ",", "$", "sigdoc", "=", "false", ")", "{", "$", "this", "->", "dmap", "[", "$", "methodname", "]", "=", "array", "(", "'function'", "=>", "$", "function", ",", "'docstring'", "=>", "$", "doc", ")", ";", "if", "(", "$", "sig", ")", "{", "$", "this", "->", "dmap", "[", "$", "methodname", "]", "[", "'signature'", "]", "=", "$", "sig", ";", "}", "if", "(", "$", "sigdoc", ")", "{", "$", "this", "->", "dmap", "[", "$", "methodname", "]", "[", "'signature_docs'", "]", "=", "$", "sigdoc", ";", "}", "}" ]
Add a method to the dispatch map @param string $methodname the name with which the method will be made available @param string $function the php function that will get invoked @param array $sig the array of valid method signatures @param string $doc method documentation @param array $sigdoc the array of valid method signatures docs (one string per param, one for return type) @access public
[ "Add", "a", "method", "to", "the", "dispatch", "map" ]
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/lib/xmlrpc/xmlrpcs.inc.php#L694-L708
227,957
gggeek/ggwebservices
lib/xmlrpc/xmlrpcs.inc.php
xmlrpc_server.verifySignature
function verifySignature($in, $sig) { // check each possible signature in turn if (is_object($in)) { $numParams = $in->getNumParams(); } else { $numParams = count($in); } foreach($sig as $cursig) { if(count($cursig)==$numParams+1) { $itsOK=1; for($n=0; $n<$numParams; $n++) { if (is_object($in)) { $p=$in->getParam($n); if($p->kindOf() == 'scalar') { $pt=$p->scalartyp(); } else { $pt=$p->kindOf(); } } else { $pt= $in[$n] == 'i4' ? 'int' : strtolower($in[$n]); // dispatch maps never use i4... } // param index is $n+1, as first member of sig is return type if($pt != $cursig[$n+1] && $cursig[$n+1] != $GLOBALS['xmlrpcValue']) { $itsOK=0; $pno=$n+1; $wanted=$cursig[$n+1]; $got=$pt; break; } } if($itsOK) { return array(1,''); } } } if(isset($wanted)) { return array(0, "Wanted ${wanted}, got ${got} at param ${pno}"); } else { return array(0, "No method signature matches number of parameters"); } }
php
function verifySignature($in, $sig) { // check each possible signature in turn if (is_object($in)) { $numParams = $in->getNumParams(); } else { $numParams = count($in); } foreach($sig as $cursig) { if(count($cursig)==$numParams+1) { $itsOK=1; for($n=0; $n<$numParams; $n++) { if (is_object($in)) { $p=$in->getParam($n); if($p->kindOf() == 'scalar') { $pt=$p->scalartyp(); } else { $pt=$p->kindOf(); } } else { $pt= $in[$n] == 'i4' ? 'int' : strtolower($in[$n]); // dispatch maps never use i4... } // param index is $n+1, as first member of sig is return type if($pt != $cursig[$n+1] && $cursig[$n+1] != $GLOBALS['xmlrpcValue']) { $itsOK=0; $pno=$n+1; $wanted=$cursig[$n+1]; $got=$pt; break; } } if($itsOK) { return array(1,''); } } } if(isset($wanted)) { return array(0, "Wanted ${wanted}, got ${got} at param ${pno}"); } else { return array(0, "No method signature matches number of parameters"); } }
[ "function", "verifySignature", "(", "$", "in", ",", "$", "sig", ")", "{", "// check each possible signature in turn", "if", "(", "is_object", "(", "$", "in", ")", ")", "{", "$", "numParams", "=", "$", "in", "->", "getNumParams", "(", ")", ";", "}", "else", "{", "$", "numParams", "=", "count", "(", "$", "in", ")", ";", "}", "foreach", "(", "$", "sig", "as", "$", "cursig", ")", "{", "if", "(", "count", "(", "$", "cursig", ")", "==", "$", "numParams", "+", "1", ")", "{", "$", "itsOK", "=", "1", ";", "for", "(", "$", "n", "=", "0", ";", "$", "n", "<", "$", "numParams", ";", "$", "n", "++", ")", "{", "if", "(", "is_object", "(", "$", "in", ")", ")", "{", "$", "p", "=", "$", "in", "->", "getParam", "(", "$", "n", ")", ";", "if", "(", "$", "p", "->", "kindOf", "(", ")", "==", "'scalar'", ")", "{", "$", "pt", "=", "$", "p", "->", "scalartyp", "(", ")", ";", "}", "else", "{", "$", "pt", "=", "$", "p", "->", "kindOf", "(", ")", ";", "}", "}", "else", "{", "$", "pt", "=", "$", "in", "[", "$", "n", "]", "==", "'i4'", "?", "'int'", ":", "strtolower", "(", "$", "in", "[", "$", "n", "]", ")", ";", "// dispatch maps never use i4...", "}", "// param index is $n+1, as first member of sig is return type", "if", "(", "$", "pt", "!=", "$", "cursig", "[", "$", "n", "+", "1", "]", "&&", "$", "cursig", "[", "$", "n", "+", "1", "]", "!=", "$", "GLOBALS", "[", "'xmlrpcValue'", "]", ")", "{", "$", "itsOK", "=", "0", ";", "$", "pno", "=", "$", "n", "+", "1", ";", "$", "wanted", "=", "$", "cursig", "[", "$", "n", "+", "1", "]", ";", "$", "got", "=", "$", "pt", ";", "break", ";", "}", "}", "if", "(", "$", "itsOK", ")", "{", "return", "array", "(", "1", ",", "''", ")", ";", "}", "}", "}", "if", "(", "isset", "(", "$", "wanted", ")", ")", "{", "return", "array", "(", "0", ",", "\"Wanted ${wanted}, got ${got} at param ${pno}\"", ")", ";", "}", "else", "{", "return", "array", "(", "0", ",", "\"No method signature matches number of parameters\"", ")", ";", "}", "}" ]
Verify type and number of parameters received against a list of known signatures @param array $in array of either xmlrpcval objects or xmlrpc type definitions @param array $sig array of known signatures to match against @return array @access private
[ "Verify", "type", "and", "number", "of", "parameters", "received", "against", "a", "list", "of", "known", "signatures" ]
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/lib/xmlrpc/xmlrpcs.inc.php#L717-L776
227,958
lawoole/framework
src/Homer/Serialize/Serializations/ArraySerialization.php
ArraySerialization.recover
public function recover() { return array_map(function ($value) { return $value instanceof Serialization ? $value->recover() : $value; }, $this->values); }
php
public function recover() { return array_map(function ($value) { return $value instanceof Serialization ? $value->recover() : $value; }, $this->values); }
[ "public", "function", "recover", "(", ")", "{", "return", "array_map", "(", "function", "(", "$", "value", ")", "{", "return", "$", "value", "instanceof", "Serialization", "?", "$", "value", "->", "recover", "(", ")", ":", "$", "value", ";", "}", ",", "$", "this", "->", "values", ")", ";", "}" ]
Recover the array from the serialization. @return array|\ArrayAccess
[ "Recover", "the", "array", "from", "the", "serialization", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Homer/Serialize/Serializations/ArraySerialization.php#L32-L37
227,959
antaresproject/core
src/ui/components/datatables/src/Services/DataTable.php
DataTable.getQuery
protected function getQuery($applyGlobalGroupScope = true) { $query = $this->query(); $this->addFilters(); $finalQuery = $this->applyScopes($query); if ($applyGlobalGroupScope) { $this->applyGlobalGroupScope($finalQuery); } $request = app('request'); if ($finalQuery instanceof Collection) { return $finalQuery; } $perPage = $this->getPerPage(); if (!$request->ajax()) { return $finalQuery->skip($request['start'])->take($perPage); } return $finalQuery; }
php
protected function getQuery($applyGlobalGroupScope = true) { $query = $this->query(); $this->addFilters(); $finalQuery = $this->applyScopes($query); if ($applyGlobalGroupScope) { $this->applyGlobalGroupScope($finalQuery); } $request = app('request'); if ($finalQuery instanceof Collection) { return $finalQuery; } $perPage = $this->getPerPage(); if (!$request->ajax()) { return $finalQuery->skip($request['start'])->take($perPage); } return $finalQuery; }
[ "protected", "function", "getQuery", "(", "$", "applyGlobalGroupScope", "=", "true", ")", "{", "$", "query", "=", "$", "this", "->", "query", "(", ")", ";", "$", "this", "->", "addFilters", "(", ")", ";", "$", "finalQuery", "=", "$", "this", "->", "applyScopes", "(", "$", "query", ")", ";", "if", "(", "$", "applyGlobalGroupScope", ")", "{", "$", "this", "->", "applyGlobalGroupScope", "(", "$", "finalQuery", ")", ";", "}", "$", "request", "=", "app", "(", "'request'", ")", ";", "if", "(", "$", "finalQuery", "instanceof", "Collection", ")", "{", "return", "$", "finalQuery", ";", "}", "$", "perPage", "=", "$", "this", "->", "getPerPage", "(", ")", ";", "if", "(", "!", "$", "request", "->", "ajax", "(", ")", ")", "{", "return", "$", "finalQuery", "->", "skip", "(", "$", "request", "[", "'start'", "]", ")", "->", "take", "(", "$", "perPage", ")", ";", "}", "return", "$", "finalQuery", ";", "}" ]
Query getter for defer initialization @param boolean $applyGlobalGroupScope
[ "Query", "getter", "for", "defer", "initialization" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Services/DataTable.php#L152-L170
227,960
antaresproject/core
src/ui/components/datatables/src/Services/DataTable.php
DataTable.addFilters
private function addFilters() { if (empty($this->filters)) { return; } foreach ($this->filters as $filter) { if (!class_exists($filter)) { continue; } $scope = app($filter); $this->addScope($scope); } return; }
php
private function addFilters() { if (empty($this->filters)) { return; } foreach ($this->filters as $filter) { if (!class_exists($filter)) { continue; } $scope = app($filter); $this->addScope($scope); } return; }
[ "private", "function", "addFilters", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "filters", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "filters", "as", "$", "filter", ")", "{", "if", "(", "!", "class_exists", "(", "$", "filter", ")", ")", "{", "continue", ";", "}", "$", "scope", "=", "app", "(", "$", "filter", ")", ";", "$", "this", "->", "addScope", "(", "$", "scope", ")", ";", "}", "return", ";", "}" ]
add filters to datatable instance @return void
[ "add", "filters", "to", "datatable", "instance" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Services/DataTable.php#L202-L216
227,961
antaresproject/core
src/ui/components/datatables/src/Services/DataTable.php
DataTable.prepare
public function prepare($query = null) { $of = is_null($query) ? $this->getQuery() : $query; $datatables = $this->datatables->of($of, get_class($this)); $path = str_replace(url('/'), '', url()->current()); Event::fire("datatables.value.{$path}", [$datatables]); Event::fire(new Value($path, $datatables)); return $datatables; }
php
public function prepare($query = null) { $of = is_null($query) ? $this->getQuery() : $query; $datatables = $this->datatables->of($of, get_class($this)); $path = str_replace(url('/'), '', url()->current()); Event::fire("datatables.value.{$path}", [$datatables]); Event::fire(new Value($path, $datatables)); return $datatables; }
[ "public", "function", "prepare", "(", "$", "query", "=", "null", ")", "{", "$", "of", "=", "is_null", "(", "$", "query", ")", "?", "$", "this", "->", "getQuery", "(", ")", ":", "$", "query", ";", "$", "datatables", "=", "$", "this", "->", "datatables", "->", "of", "(", "$", "of", ",", "get_class", "(", "$", "this", ")", ")", ";", "$", "path", "=", "str_replace", "(", "url", "(", "'/'", ")", ",", "''", ",", "url", "(", ")", "->", "current", "(", ")", ")", ";", "Event", "::", "fire", "(", "\"datatables.value.{$path}\"", ",", "[", "$", "datatables", "]", ")", ";", "Event", "::", "fire", "(", "new", "Value", "(", "$", "path", ",", "$", "datatables", ")", ")", ";", "return", "$", "datatables", ";", "}" ]
prepare datatable instance before @param EloquentBuilder|Collection $query @return \Antares\Datatables\Engines\BaseEngine
[ "prepare", "datatable", "instance", "before" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Services/DataTable.php#L234-L243
227,962
antaresproject/core
src/ui/components/datatables/src/Services/DataTable.php
DataTable.decorateActions
public function decorateActions($row = null) { if (empty($this->tableActions)) { return ''; } $html = app('html'); $section = $html->create('div', $html->raw(implode('', $this->tableActions->toArray())), ['class' => 'mass-actions-menu', 'data-id' => $row->id ? $row->id : ''])->get(); return '<i class="zmdi zmdi-more"></i>' . app('html')->raw($section)->get(); }
php
public function decorateActions($row = null) { if (empty($this->tableActions)) { return ''; } $html = app('html'); $section = $html->create('div', $html->raw(implode('', $this->tableActions->toArray())), ['class' => 'mass-actions-menu', 'data-id' => $row->id ? $row->id : ''])->get(); return '<i class="zmdi zmdi-more"></i>' . app('html')->raw($section)->get(); }
[ "public", "function", "decorateActions", "(", "$", "row", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "tableActions", ")", ")", "{", "return", "''", ";", "}", "$", "html", "=", "app", "(", "'html'", ")", ";", "$", "section", "=", "$", "html", "->", "create", "(", "'div'", ",", "$", "html", "->", "raw", "(", "implode", "(", "''", ",", "$", "this", "->", "tableActions", "->", "toArray", "(", ")", ")", ")", ",", "[", "'class'", "=>", "'mass-actions-menu'", ",", "'data-id'", "=>", "$", "row", "->", "id", "?", "$", "row", "->", "id", ":", "''", "]", ")", "->", "get", "(", ")", ";", "return", "'<i class=\"zmdi zmdi-more\"></i>'", ".", "app", "(", "'html'", ")", "->", "raw", "(", "$", "section", ")", "->", "get", "(", ")", ";", "}" ]
row actions decorator @return String
[ "row", "actions", "decorator" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Services/DataTable.php#L261-L270
227,963
antaresproject/core
src/ui/components/datatables/src/Services/DataTable.php
DataTable.getQuickSearchRow
public function getQuickSearchRow(array $data = []) { $pattern = ''; try { $pattern = $this->getPatternUrl(); } catch (Exception $ex) { } $view = array_get($this->search, 'view'); if (!view()->exists($view)) { return false; } $return = [ 'content' => view($view, $data)->render(), 'category' => array_get($this->search, 'category'), ]; if (!is_null($id = array_get($data, 'id'))) { array_set($return, 'url', str_replace('{id}', $id, $pattern)); } return $return; }
php
public function getQuickSearchRow(array $data = []) { $pattern = ''; try { $pattern = $this->getPatternUrl(); } catch (Exception $ex) { } $view = array_get($this->search, 'view'); if (!view()->exists($view)) { return false; } $return = [ 'content' => view($view, $data)->render(), 'category' => array_get($this->search, 'category'), ]; if (!is_null($id = array_get($data, 'id'))) { array_set($return, 'url', str_replace('{id}', $id, $pattern)); } return $return; }
[ "public", "function", "getQuickSearchRow", "(", "array", "$", "data", "=", "[", "]", ")", "{", "$", "pattern", "=", "''", ";", "try", "{", "$", "pattern", "=", "$", "this", "->", "getPatternUrl", "(", ")", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "}", "$", "view", "=", "array_get", "(", "$", "this", "->", "search", ",", "'view'", ")", ";", "if", "(", "!", "view", "(", ")", "->", "exists", "(", "$", "view", ")", ")", "{", "return", "false", ";", "}", "$", "return", "=", "[", "'content'", "=>", "view", "(", "$", "view", ",", "$", "data", ")", "->", "render", "(", ")", ",", "'category'", "=>", "array_get", "(", "$", "this", "->", "search", ",", "'category'", ")", ",", "]", ";", "if", "(", "!", "is_null", "(", "$", "id", "=", "array_get", "(", "$", "data", ",", "'id'", ")", ")", ")", "{", "array_set", "(", "$", "return", ",", "'url'", ",", "str_replace", "(", "'{id}'", ",", "$", "id", ",", "$", "pattern", ")", ")", ";", "}", "return", "$", "return", ";", "}" ]
Gets quick search params @return String
[ "Gets", "quick", "search", "params" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Services/DataTable.php#L314-L334
227,964
crossjoin/PreMailer
src/Crossjoin/PreMailer/HtmlString.php
HtmlString.setHtmlContent
protected function setHtmlContent($htmlContent) { if (is_string($htmlContent)) { $this->content = $htmlContent; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($htmlContent). "' for argument 'htmlContent' given." ); } return $this; }
php
protected function setHtmlContent($htmlContent) { if (is_string($htmlContent)) { $this->content = $htmlContent; } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($htmlContent). "' for argument 'htmlContent' given." ); } return $this; }
[ "protected", "function", "setHtmlContent", "(", "$", "htmlContent", ")", "{", "if", "(", "is_string", "(", "$", "htmlContent", ")", ")", "{", "$", "this", "->", "content", "=", "$", "htmlContent", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "htmlContent", ")", ".", "\"' for argument 'htmlContent' given.\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the HTML content @param string $htmlContent @return $this
[ "Sets", "the", "HTML", "content" ]
e1fbd426a9f3ba2d5d00f6641b2509c72bf4f561
https://github.com/crossjoin/PreMailer/blob/e1fbd426a9f3ba2d5d00f6641b2509c72bf4f561/src/Crossjoin/PreMailer/HtmlString.php#L26-L37
227,965
antaresproject/core
src/foundation/src/Support/Providers/ModuleServiceProvider.php
ModuleServiceProvider.bootApiRouting
public function bootApiRouting(Router $router) { if (!$this->app->make('antares.request')->shouldMakeApiResponse()) { return; } $routerAdapter = $this->app->make(Adapter::class); $routes = []; /* @var $route \Illuminate\Routing\Route */ foreach ($router->getRoutes()->getRoutes() as $route) { $routeActionName = $route->getActionName(); if (starts_with($routeActionName, $this->namespace)) { $routes[] = $route; } } $routerAdapter->adaptRoutes($routes, $this->namespace); }
php
public function bootApiRouting(Router $router) { if (!$this->app->make('antares.request')->shouldMakeApiResponse()) { return; } $routerAdapter = $this->app->make(Adapter::class); $routes = []; /* @var $route \Illuminate\Routing\Route */ foreach ($router->getRoutes()->getRoutes() as $route) { $routeActionName = $route->getActionName(); if (starts_with($routeActionName, $this->namespace)) { $routes[] = $route; } } $routerAdapter->adaptRoutes($routes, $this->namespace); }
[ "public", "function", "bootApiRouting", "(", "Router", "$", "router", ")", "{", "if", "(", "!", "$", "this", "->", "app", "->", "make", "(", "'antares.request'", ")", "->", "shouldMakeApiResponse", "(", ")", ")", "{", "return", ";", "}", "$", "routerAdapter", "=", "$", "this", "->", "app", "->", "make", "(", "Adapter", "::", "class", ")", ";", "$", "routes", "=", "[", "]", ";", "/* @var $route \\Illuminate\\Routing\\Route */", "foreach", "(", "$", "router", "->", "getRoutes", "(", ")", "->", "getRoutes", "(", ")", "as", "$", "route", ")", "{", "$", "routeActionName", "=", "$", "route", "->", "getActionName", "(", ")", ";", "if", "(", "starts_with", "(", "$", "routeActionName", ",", "$", "this", "->", "namespace", ")", ")", "{", "$", "routes", "[", "]", "=", "$", "route", ";", "}", "}", "$", "routerAdapter", "->", "adaptRoutes", "(", "$", "routes", ",", "$", "this", "->", "namespace", ")", ";", "}" ]
Register router for API requests. @param Router $router
[ "Register", "router", "for", "API", "requests", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Support/Providers/ModuleServiceProvider.php#L161-L182
227,966
antaresproject/core
src/foundation/src/Support/Providers/ModuleServiceProvider.php
ModuleServiceProvider.setExtensionPath
protected function setExtensionPath() { $filename = (new ReflectionClass($this))->getFileName(); return $this->extensionPath = (new SplFileInfo($filename))->getPath(); }
php
protected function setExtensionPath() { $filename = (new ReflectionClass($this))->getFileName(); return $this->extensionPath = (new SplFileInfo($filename))->getPath(); }
[ "protected", "function", "setExtensionPath", "(", ")", "{", "$", "filename", "=", "(", "new", "ReflectionClass", "(", "$", "this", ")", ")", "->", "getFileName", "(", ")", ";", "return", "$", "this", "->", "extensionPath", "=", "(", "new", "SplFileInfo", "(", "$", "filename", ")", ")", "->", "getPath", "(", ")", ";", "}" ]
extension path resolver @return String
[ "extension", "path", "resolver" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Support/Providers/ModuleServiceProvider.php#L189-L194
227,967
antaresproject/core
src/foundation/src/Support/Providers/ModuleServiceProvider.php
ModuleServiceProvider.loadRoutes
protected function loadRoutes() { $path = $this->extensionPath; $routes = [ 'backend' => [ $path . DIRECTORY_SEPARATOR . 'Http' . DIRECTORY_SEPARATOR . 'backend.php', $path . DIRECTORY_SEPARATOR . 'backend.php', $path . DIRECTORY_SEPARATOR . 'routes.php', ], 'frontend' => [ $path . DIRECTORY_SEPARATOR . 'Http' . DIRECTORY_SEPARATOR . 'frontend.php', $path . DIRECTORY_SEPARATOR . 'frontend.php', ] ]; foreach ($routes as $area => $routePaths) { foreach ($routePaths as $route) { if (!file_exists($route)) { continue; } switch ($area) { case 'frontend': $this->loadFrontendRoutesFrom($route); break; case 'backend': $this->loadBackendRoutesFrom($route); break; } } } }
php
protected function loadRoutes() { $path = $this->extensionPath; $routes = [ 'backend' => [ $path . DIRECTORY_SEPARATOR . 'Http' . DIRECTORY_SEPARATOR . 'backend.php', $path . DIRECTORY_SEPARATOR . 'backend.php', $path . DIRECTORY_SEPARATOR . 'routes.php', ], 'frontend' => [ $path . DIRECTORY_SEPARATOR . 'Http' . DIRECTORY_SEPARATOR . 'frontend.php', $path . DIRECTORY_SEPARATOR . 'frontend.php', ] ]; foreach ($routes as $area => $routePaths) { foreach ($routePaths as $route) { if (!file_exists($route)) { continue; } switch ($area) { case 'frontend': $this->loadFrontendRoutesFrom($route); break; case 'backend': $this->loadBackendRoutesFrom($route); break; } } } }
[ "protected", "function", "loadRoutes", "(", ")", "{", "$", "path", "=", "$", "this", "->", "extensionPath", ";", "$", "routes", "=", "[", "'backend'", "=>", "[", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "'Http'", ".", "DIRECTORY_SEPARATOR", ".", "'backend.php'", ",", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "'backend.php'", ",", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "'routes.php'", ",", "]", ",", "'frontend'", "=>", "[", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "'Http'", ".", "DIRECTORY_SEPARATOR", ".", "'frontend.php'", ",", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "'frontend.php'", ",", "]", "]", ";", "foreach", "(", "$", "routes", "as", "$", "area", "=>", "$", "routePaths", ")", "{", "foreach", "(", "$", "routePaths", "as", "$", "route", ")", "{", "if", "(", "!", "file_exists", "(", "$", "route", ")", ")", "{", "continue", ";", "}", "switch", "(", "$", "area", ")", "{", "case", "'frontend'", ":", "$", "this", "->", "loadFrontendRoutesFrom", "(", "$", "route", ")", ";", "break", ";", "case", "'backend'", ":", "$", "this", "->", "loadBackendRoutesFrom", "(", "$", "route", ")", ";", "break", ";", "}", "}", "}", "}" ]
Boot extension routing. @return void
[ "Boot", "extension", "routing", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Support/Providers/ModuleServiceProvider.php#L201-L231
227,968
antaresproject/core
src/foundation/src/Support/Providers/ModuleServiceProvider.php
ModuleServiceProvider.bootMemory
protected function bootMemory() { if (!isset($this->routeGroup) or strlen($this->routeGroup) <= 0) { throw new RuntimeException('Invalid extension route group.'); } $this->app->make('antares.acl')->make($this->routeGroup)->attach( $this->app->make('antares.platform.memory') ); }
php
protected function bootMemory() { if (!isset($this->routeGroup) or strlen($this->routeGroup) <= 0) { throw new RuntimeException('Invalid extension route group.'); } $this->app->make('antares.acl')->make($this->routeGroup)->attach( $this->app->make('antares.platform.memory') ); }
[ "protected", "function", "bootMemory", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "routeGroup", ")", "or", "strlen", "(", "$", "this", "->", "routeGroup", ")", "<=", "0", ")", "{", "throw", "new", "RuntimeException", "(", "'Invalid extension route group.'", ")", ";", "}", "$", "this", "->", "app", "->", "make", "(", "'antares.acl'", ")", "->", "make", "(", "$", "this", "->", "routeGroup", ")", "->", "attach", "(", "$", "this", "->", "app", "->", "make", "(", "'antares.platform.memory'", ")", ")", ";", "}" ]
boots extension memory @throws RuntimeException
[ "boots", "extension", "memory" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Support/Providers/ModuleServiceProvider.php#L238-L247
227,969
antaresproject/core
src/foundation/src/Support/Providers/ModuleServiceProvider.php
ModuleServiceProvider.bootConfiguration
protected function bootConfiguration() { $path = $this->extensionPath . '/../'; $this->addConfigComponent($this->routeGroup, $this->routeGroup, "{$path}/resources/config"); $this->addLanguageComponent($this->routeGroup, $this->routeGroup, "{$path}/resources/lang"); $this->addViewComponent($this->routeGroup, $this->routeGroup, "{$path}/resources/views"); }
php
protected function bootConfiguration() { $path = $this->extensionPath . '/../'; $this->addConfigComponent($this->routeGroup, $this->routeGroup, "{$path}/resources/config"); $this->addLanguageComponent($this->routeGroup, $this->routeGroup, "{$path}/resources/lang"); $this->addViewComponent($this->routeGroup, $this->routeGroup, "{$path}/resources/views"); }
[ "protected", "function", "bootConfiguration", "(", ")", "{", "$", "path", "=", "$", "this", "->", "extensionPath", ".", "'/../'", ";", "$", "this", "->", "addConfigComponent", "(", "$", "this", "->", "routeGroup", ",", "$", "this", "->", "routeGroup", ",", "\"{$path}/resources/config\"", ")", ";", "$", "this", "->", "addLanguageComponent", "(", "$", "this", "->", "routeGroup", ",", "$", "this", "->", "routeGroup", ",", "\"{$path}/resources/lang\"", ")", ";", "$", "this", "->", "addViewComponent", "(", "$", "this", "->", "routeGroup", ",", "$", "this", "->", "routeGroup", ",", "\"{$path}/resources/views\"", ")", ";", "}" ]
boot extension configuration
[ "boot", "extension", "configuration" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Support/Providers/ModuleServiceProvider.php#L252-L258
227,970
antaresproject/core
src/foundation/src/Support/Providers/ModuleServiceProvider.php
ModuleServiceProvider.bind
protected function bind() { if (!isset($this->di)) { return false; } foreach ($this->di as $contract => $object) { $this->app->bind($contract, $object); } }
php
protected function bind() { if (!isset($this->di)) { return false; } foreach ($this->di as $contract => $object) { $this->app->bind($contract, $object); } }
[ "protected", "function", "bind", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "di", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "this", "->", "di", "as", "$", "contract", "=>", "$", "object", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "$", "contract", ",", "$", "object", ")", ";", "}", "}" ]
binds contracts to objects @return boolean
[ "binds", "contracts", "to", "objects" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Support/Providers/ModuleServiceProvider.php#L308-L316
227,971
antaresproject/core
src/foundation/src/Support/Providers/ModuleServiceProvider.php
ModuleServiceProvider.attachMenu
protected function attachMenu($classnames) { $menuComposer = MenuComposer::getInstance(); if (is_array($classnames)) { foreach ($classnames as $classname) { $menuComposer->compose($classname); } return; } return $menuComposer->compose($classnames); }
php
protected function attachMenu($classnames) { $menuComposer = MenuComposer::getInstance(); if (is_array($classnames)) { foreach ($classnames as $classname) { $menuComposer->compose($classname); } return; } return $menuComposer->compose($classnames); }
[ "protected", "function", "attachMenu", "(", "$", "classnames", ")", "{", "$", "menuComposer", "=", "MenuComposer", "::", "getInstance", "(", ")", ";", "if", "(", "is_array", "(", "$", "classnames", ")", ")", "{", "foreach", "(", "$", "classnames", "as", "$", "classname", ")", "{", "$", "menuComposer", "->", "compose", "(", "$", "classname", ")", ";", "}", "return", ";", "}", "return", "$", "menuComposer", "->", "compose", "(", "$", "classnames", ")", ";", "}" ]
attaches menu to application container @param mixed $classnames @return mixed
[ "attaches", "menu", "to", "application", "container" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Support/Providers/ModuleServiceProvider.php#L324-L334
227,972
antaresproject/core
src/foundation/src/Support/Providers/ModuleServiceProvider.php
ModuleServiceProvider.bindContracts
protected function bindContracts() { $dir = dirname((new ReflectionClass(get_called_class()))->getFileName()); $configPath = $dir . '/../resources/config/config.php'; if (!file_exists($configPath)) { return false; } if (empty($di = require $configPath)) { return false; } foreach (array_get($di, 'di', []) as $contract => $class) { $this->app->bind($contract, $class); } }
php
protected function bindContracts() { $dir = dirname((new ReflectionClass(get_called_class()))->getFileName()); $configPath = $dir . '/../resources/config/config.php'; if (!file_exists($configPath)) { return false; } if (empty($di = require $configPath)) { return false; } foreach (array_get($di, 'di', []) as $contract => $class) { $this->app->bind($contract, $class); } }
[ "protected", "function", "bindContracts", "(", ")", "{", "$", "dir", "=", "dirname", "(", "(", "new", "ReflectionClass", "(", "get_called_class", "(", ")", ")", ")", "->", "getFileName", "(", ")", ")", ";", "$", "configPath", "=", "$", "dir", ".", "'/../resources/config/config.php'", ";", "if", "(", "!", "file_exists", "(", "$", "configPath", ")", ")", "{", "return", "false", ";", "}", "if", "(", "empty", "(", "$", "di", "=", "require", "$", "configPath", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "array_get", "(", "$", "di", ",", "'di'", ",", "[", "]", ")", "as", "$", "contract", "=>", "$", "class", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "$", "contract", ",", "$", "class", ")", ";", "}", "}" ]
bind contracts to its classes @return boolean
[ "bind", "contracts", "to", "its", "classes" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Support/Providers/ModuleServiceProvider.php#L341-L355
227,973
antaresproject/core
src/foundation/src/Support/Providers/ModuleServiceProvider.php
ModuleServiceProvider.loadBreadcrumbsFile
private function loadBreadcrumbsFile() { $path = $this->extensionPath . DIRECTORY_SEPARATOR . 'Http' . DIRECTORY_SEPARATOR . 'breadcrumbs.php'; if (file_exists($path)) { $manager = $this->app->instance(Manager::class, $this->app->make(Manager::class)); require_once $path; } }
php
private function loadBreadcrumbsFile() { $path = $this->extensionPath . DIRECTORY_SEPARATOR . 'Http' . DIRECTORY_SEPARATOR . 'breadcrumbs.php'; if (file_exists($path)) { $manager = $this->app->instance(Manager::class, $this->app->make(Manager::class)); require_once $path; } }
[ "private", "function", "loadBreadcrumbsFile", "(", ")", "{", "$", "path", "=", "$", "this", "->", "extensionPath", ".", "DIRECTORY_SEPARATOR", ".", "'Http'", ".", "DIRECTORY_SEPARATOR", ".", "'breadcrumbs.php'", ";", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "$", "manager", "=", "$", "this", "->", "app", "->", "instance", "(", "Manager", "::", "class", ",", "$", "this", "->", "app", "->", "make", "(", "Manager", "::", "class", ")", ")", ";", "require_once", "$", "path", ";", "}", "}" ]
Loads breaedcrumbs file.
[ "Loads", "breaedcrumbs", "file", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Support/Providers/ModuleServiceProvider.php#L360-L369
227,974
antaresproject/core
src/foundation/src/Support/Providers/ModuleServiceProvider.php
ModuleServiceProvider.loadMenuFile
private function loadMenuFile() { $path = $this->extensionPath . DIRECTORY_SEPARATOR . 'Http' . DIRECTORY_SEPARATOR . 'menu.php'; if (file_exists($path)) { $menu = $this->app->make(MenuAssigner::class); require_once $path; } }
php
private function loadMenuFile() { $path = $this->extensionPath . DIRECTORY_SEPARATOR . 'Http' . DIRECTORY_SEPARATOR . 'menu.php'; if (file_exists($path)) { $menu = $this->app->make(MenuAssigner::class); require_once $path; } }
[ "private", "function", "loadMenuFile", "(", ")", "{", "$", "path", "=", "$", "this", "->", "extensionPath", ".", "DIRECTORY_SEPARATOR", ".", "'Http'", ".", "DIRECTORY_SEPARATOR", ".", "'menu.php'", ";", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "$", "menu", "=", "$", "this", "->", "app", "->", "make", "(", "MenuAssigner", "::", "class", ")", ";", "require_once", "$", "path", ";", "}", "}" ]
Loads menu file.
[ "Loads", "menu", "file", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Support/Providers/ModuleServiceProvider.php#L374-L382
227,975
antaresproject/core
src/foundation/src/Support/Providers/ModuleServiceProvider.php
ModuleServiceProvider.importNotifications
protected function importNotifications(string $extension) { $this->afterActivated($extension, function() use($extension) { \Artisan::call('notifications:import', compact('extension')); }); }
php
protected function importNotifications(string $extension) { $this->afterActivated($extension, function() use($extension) { \Artisan::call('notifications:import', compact('extension')); }); }
[ "protected", "function", "importNotifications", "(", "string", "$", "extension", ")", "{", "$", "this", "->", "afterActivated", "(", "$", "extension", ",", "function", "(", ")", "use", "(", "$", "extension", ")", "{", "\\", "Artisan", "::", "call", "(", "'notifications:import'", ",", "compact", "(", "'extension'", ")", ")", ";", "}", ")", ";", "}" ]
Imports notifications after activation of the given extension. @param string $extension Ex. antaresproject/module-sample_module
[ "Imports", "notifications", "after", "activation", "of", "the", "given", "extension", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/foundation/src/Support/Providers/ModuleServiceProvider.php#L412-L417
227,976
antaresproject/core
src/components/extension/src/Dispatcher.php
Dispatcher.registerCollection
public function registerCollection(Extensions $extensions) { foreach ($extensions as $extension) { $this->register($extension); } $this->eventDispatcher->dispatch('antares.after.load-service-providers'); }
php
public function registerCollection(Extensions $extensions) { foreach ($extensions as $extension) { $this->register($extension); } $this->eventDispatcher->dispatch('antares.after.load-service-providers'); }
[ "public", "function", "registerCollection", "(", "Extensions", "$", "extensions", ")", "{", "foreach", "(", "$", "extensions", "as", "$", "extension", ")", "{", "$", "this", "->", "register", "(", "$", "extension", ")", ";", "}", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "'antares.after.load-service-providers'", ")", ";", "}" ]
Register the collection of extensions. @param Extensions $extensions @throws Exception
[ "Register", "the", "collection", "of", "extensions", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Dispatcher.php#L86-L92
227,977
antaresproject/core
src/components/extension/src/Dispatcher.php
Dispatcher.register
public function register(ExtensionContract $extension) { $this->extensions[] = $extension; $this->loader->registerExtensionProviders($extension); }
php
public function register(ExtensionContract $extension) { $this->extensions[] = $extension; $this->loader->registerExtensionProviders($extension); }
[ "public", "function", "register", "(", "ExtensionContract", "$", "extension", ")", "{", "$", "this", "->", "extensions", "[", "]", "=", "$", "extension", ";", "$", "this", "->", "loader", "->", "registerExtensionProviders", "(", "$", "extension", ")", ";", "}" ]
Register the extension. @param ExtensionContract $extension @throws Exception
[ "Register", "the", "extension", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Dispatcher.php#L100-L105
227,978
antaresproject/core
src/components/extension/src/Dispatcher.php
Dispatcher.boot
public function boot() { $this->loader->loadManifest(); foreach ($this->extensions as $extension) { try { $this->eventDispatcher->dispatch(new Booted($extension)); $name = $extension->getPackage()->getName(); $this->eventDispatcher->dispatch('extension.started', [$name, []]); $this->eventDispatcher->dispatch('extension.started: {$name}', [[]]); $this->eventDispatcher->dispatch(new ComponentStarted($name)); $this->eventDispatcher->dispatch('extension.booted', [$name, []]); $this->eventDispatcher->dispatch('extension.booted: {$name}', [[]]); $this->eventDispatcher->dispatch(new ComponentBooted($name)); } catch (Exception $e) { throw $e; } } $this->eventDispatcher->dispatch(new BootedAll()); $this->eventDispatcher->dispatch('antares.extension: booted'); $this->eventDispatcher->dispatch(new ComponentsBooted()); $this->loader->writeManifest(); $this->booted = true; }
php
public function boot() { $this->loader->loadManifest(); foreach ($this->extensions as $extension) { try { $this->eventDispatcher->dispatch(new Booted($extension)); $name = $extension->getPackage()->getName(); $this->eventDispatcher->dispatch('extension.started', [$name, []]); $this->eventDispatcher->dispatch('extension.started: {$name}', [[]]); $this->eventDispatcher->dispatch(new ComponentStarted($name)); $this->eventDispatcher->dispatch('extension.booted', [$name, []]); $this->eventDispatcher->dispatch('extension.booted: {$name}', [[]]); $this->eventDispatcher->dispatch(new ComponentBooted($name)); } catch (Exception $e) { throw $e; } } $this->eventDispatcher->dispatch(new BootedAll()); $this->eventDispatcher->dispatch('antares.extension: booted'); $this->eventDispatcher->dispatch(new ComponentsBooted()); $this->loader->writeManifest(); $this->booted = true; }
[ "public", "function", "boot", "(", ")", "{", "$", "this", "->", "loader", "->", "loadManifest", "(", ")", ";", "foreach", "(", "$", "this", "->", "extensions", "as", "$", "extension", ")", "{", "try", "{", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "new", "Booted", "(", "$", "extension", ")", ")", ";", "$", "name", "=", "$", "extension", "->", "getPackage", "(", ")", "->", "getName", "(", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "'extension.started'", ",", "[", "$", "name", ",", "[", "]", "]", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "'extension.started: {$name}'", ",", "[", "[", "]", "]", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "new", "ComponentStarted", "(", "$", "name", ")", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "'extension.booted'", ",", "[", "$", "name", ",", "[", "]", "]", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "'extension.booted: {$name}'", ",", "[", "[", "]", "]", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "new", "ComponentBooted", "(", "$", "name", ")", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "}", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "new", "BootedAll", "(", ")", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "'antares.extension: booted'", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "new", "ComponentsBooted", "(", ")", ")", ";", "$", "this", "->", "loader", "->", "writeManifest", "(", ")", ";", "$", "this", "->", "booted", "=", "true", ";", "}" ]
Boot all extensions. @throws Exception
[ "Boot", "all", "extensions", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Dispatcher.php#L112-L140
227,979
antaresproject/core
src/components/extension/src/Dispatcher.php
Dispatcher.after
public function after(Closure $callback = null) { if ($callback && $this->booted()) { $this->container->call($callback); } $this->eventDispatcher->listen(BootedAll::class, $callback); $this->eventDispatcher->listen('antares.extension: booted', $callback); $this->eventDispatcher->listen(ComponentsBooted::class, $callback); }
php
public function after(Closure $callback = null) { if ($callback && $this->booted()) { $this->container->call($callback); } $this->eventDispatcher->listen(BootedAll::class, $callback); $this->eventDispatcher->listen('antares.extension: booted', $callback); $this->eventDispatcher->listen(ComponentsBooted::class, $callback); }
[ "public", "function", "after", "(", "Closure", "$", "callback", "=", "null", ")", "{", "if", "(", "$", "callback", "&&", "$", "this", "->", "booted", "(", ")", ")", "{", "$", "this", "->", "container", "->", "call", "(", "$", "callback", ")", ";", "}", "$", "this", "->", "eventDispatcher", "->", "listen", "(", "BootedAll", "::", "class", ",", "$", "callback", ")", ";", "$", "this", "->", "eventDispatcher", "->", "listen", "(", "'antares.extension: booted'", ",", "$", "callback", ")", ";", "$", "this", "->", "eventDispatcher", "->", "listen", "(", "ComponentsBooted", "::", "class", ",", "$", "callback", ")", ";", "}" ]
Create an event listener or execute it directly. @param Closure|null $callback
[ "Create", "an", "event", "listener", "or", "execute", "it", "directly", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Dispatcher.php#L147-L156
227,980
antaresproject/core
src/ui/components/templates/src/Traits/ComponentTrait.php
ComponentTrait.getDefaults
public function getDefaults($args = null) { if (!is_null($args)) { if (is_array($args)) { return array_only($this->defaults, $args); } if (array_key_exists($args, $this->defaults)) { return $this->defaults[$args]; } } return $this->defaults; }
php
public function getDefaults($args = null) { if (!is_null($args)) { if (is_array($args)) { return array_only($this->defaults, $args); } if (array_key_exists($args, $this->defaults)) { return $this->defaults[$args]; } } return $this->defaults; }
[ "public", "function", "getDefaults", "(", "$", "args", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "args", ")", ")", "{", "if", "(", "is_array", "(", "$", "args", ")", ")", "{", "return", "array_only", "(", "$", "this", "->", "defaults", ",", "$", "args", ")", ";", "}", "if", "(", "array_key_exists", "(", "$", "args", ",", "$", "this", "->", "defaults", ")", ")", "{", "return", "$", "this", "->", "defaults", "[", "$", "args", "]", ";", "}", "}", "return", "$", "this", "->", "defaults", ";", "}" ]
Gets defaults attributes @param array | mixed $args @return array
[ "Gets", "defaults", "attributes" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Traits/ComponentTrait.php#L133-L144
227,981
antaresproject/core
src/ui/components/templates/src/Traits/ComponentTrait.php
ComponentTrait.editable
protected function editable() { if (array_key_exists('editable', $this->attributes) && $this->attributes['editable'] == false) { return false; } return in_array('form', get_class_methods($this)); }
php
protected function editable() { if (array_key_exists('editable', $this->attributes) && $this->attributes['editable'] == false) { return false; } return in_array('form', get_class_methods($this)); }
[ "protected", "function", "editable", "(", ")", "{", "if", "(", "array_key_exists", "(", "'editable'", ",", "$", "this", "->", "attributes", ")", "&&", "$", "this", "->", "attributes", "[", "'editable'", "]", "==", "false", ")", "{", "return", "false", ";", "}", "return", "in_array", "(", "'form'", ",", "get_class_methods", "(", "$", "this", ")", ")", ";", "}" ]
Does the ui component has editable attributes @return boolean
[ "Does", "the", "ui", "component", "has", "editable", "attributes" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Traits/ComponentTrait.php#L163-L169
227,982
lawoole/framework
src/Server/ServerSockets/ServerSocket.php
ServerSocket.setOptions
public function setOptions(array $options) { if ($this->server && $this->server->isRunning()) { throw new LogicException('Options cannot be set while the server is running.'); } $this->options = array_diff_key($this->options, $options) + $options; if ($this->swoolePort != null) { $this->swoolePort->set($this->options); } }
php
public function setOptions(array $options) { if ($this->server && $this->server->isRunning()) { throw new LogicException('Options cannot be set while the server is running.'); } $this->options = array_diff_key($this->options, $options) + $options; if ($this->swoolePort != null) { $this->swoolePort->set($this->options); } }
[ "public", "function", "setOptions", "(", "array", "$", "options", ")", "{", "if", "(", "$", "this", "->", "server", "&&", "$", "this", "->", "server", "->", "isRunning", "(", ")", ")", "{", "throw", "new", "LogicException", "(", "'Options cannot be set while the server is running.'", ")", ";", "}", "$", "this", "->", "options", "=", "array_diff_key", "(", "$", "this", "->", "options", ",", "$", "options", ")", "+", "$", "options", ";", "if", "(", "$", "this", "->", "swoolePort", "!=", "null", ")", "{", "$", "this", "->", "swoolePort", "->", "set", "(", "$", "this", "->", "options", ")", ";", "}", "}" ]
Set the server socket options. @param array $options
[ "Set", "the", "server", "socket", "options", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/ServerSockets/ServerSocket.php#L180-L191
227,983
lawoole/framework
src/Server/ServerSockets/ServerSocket.php
ServerSocket.listen
public function listen(Server $server, SwoolePort $swoolePort = null) { if ($this->isBound()) { throw new LogicException('The server socket can be bound to server only once.'); } if ($swoolePort == null) { // If the passed Swoole port is null, that means we are calling this // method directly, so here we need to call the server method "listen" // to do the actual binding. return $server->listen($this); } $this->server = $server; $this->swoolePort = $swoolePort; $this->swoolePort->set($this->options); $this->registerEventCallbacks($this->serverSocketEvents); $this->dispatchEvent('Bind', $server, $this); }
php
public function listen(Server $server, SwoolePort $swoolePort = null) { if ($this->isBound()) { throw new LogicException('The server socket can be bound to server only once.'); } if ($swoolePort == null) { // If the passed Swoole port is null, that means we are calling this // method directly, so here we need to call the server method "listen" // to do the actual binding. return $server->listen($this); } $this->server = $server; $this->swoolePort = $swoolePort; $this->swoolePort->set($this->options); $this->registerEventCallbacks($this->serverSocketEvents); $this->dispatchEvent('Bind', $server, $this); }
[ "public", "function", "listen", "(", "Server", "$", "server", ",", "SwoolePort", "$", "swoolePort", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isBound", "(", ")", ")", "{", "throw", "new", "LogicException", "(", "'The server socket can be bound to server only once.'", ")", ";", "}", "if", "(", "$", "swoolePort", "==", "null", ")", "{", "// If the passed Swoole port is null, that means we are calling this", "// method directly, so here we need to call the server method \"listen\"", "// to do the actual binding.", "return", "$", "server", "->", "listen", "(", "$", "this", ")", ";", "}", "$", "this", "->", "server", "=", "$", "server", ";", "$", "this", "->", "swoolePort", "=", "$", "swoolePort", ";", "$", "this", "->", "swoolePort", "->", "set", "(", "$", "this", "->", "options", ")", ";", "$", "this", "->", "registerEventCallbacks", "(", "$", "this", "->", "serverSocketEvents", ")", ";", "$", "this", "->", "dispatchEvent", "(", "'Bind'", ",", "$", "server", ",", "$", "this", ")", ";", "}" ]
Bind the server socket to a server instance. @param \Lawoole\Server\Server $server @param \Swoole\Server\Port $swoolePort
[ "Bind", "the", "server", "socket", "to", "a", "server", "instance", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/ServerSockets/ServerSocket.php#L209-L230
227,984
lawoole/framework
src/Server/ServerSockets/ServerSocket.php
ServerSocket.getIterator
public function getIterator() { if ($this->isBound() && $this->server->isRunning()) { return $this->swoolePort->connections; } return new EmptyIterator; }
php
public function getIterator() { if ($this->isBound() && $this->server->isRunning()) { return $this->swoolePort->connections; } return new EmptyIterator; }
[ "public", "function", "getIterator", "(", ")", "{", "if", "(", "$", "this", "->", "isBound", "(", ")", "&&", "$", "this", "->", "server", "->", "isRunning", "(", ")", ")", "{", "return", "$", "this", "->", "swoolePort", "->", "connections", ";", "}", "return", "new", "EmptyIterator", ";", "}" ]
Retrieve an iterator for all connections in this port. @return \Iterator
[ "Retrieve", "an", "iterator", "for", "all", "connections", "in", "this", "port", "." ]
ac701a76f5d37c81273b7202ba37094766cb5dfe
https://github.com/lawoole/framework/blob/ac701a76f5d37c81273b7202ba37094766cb5dfe/src/Server/ServerSockets/ServerSocket.php#L255-L262
227,985
gggeek/ggwebservices
classes/ggrestresponse.php
ggRESTResponse.payload
function payload( ) { $contentType = $this->ContentType; // accommodate re-serializing content after we got a forced content-type if ( $pos = strpos( $contentType, ';' ) !== false ) { $contentType = substr( $contentType, 0, $pos ); } if ( $contentType == '' ) { $contentType = $this->defaultContentType; } if ( $this->IsFault ) { // default representation of an error, hand picked $value = array( 'faultCode' => $this->FaultCode, 'faultString' => $this->FaultString ); // send an HTTP error code, since there is no other way to make sure // that the client can tell apart error responses from valid array responses // try some meaningful mapping (it's REST, baby!) switch( $this->FaultCode ) { case ggWebservicesServer::INVALIDMETHODERROR: header( $_SERVER['SERVER_PROTOCOL'].' 404 Not Found' ); break; case ggWebservicesServer::INVALIDPARAMSERROR: case ggWebservicesServer::INVALIDCOMPRESSIONERROR: case ggWebservicesServer::INVALIDREQUESTERROR: header( $_SERVER['SERVER_PROTOCOL'].' 400 Bad Request' ); break; case ggWebservicesServer::INVALIDAUTHERROR: header( $_SERVER['SERVER_PROTOCOL'].' 403 Forbidden' ); break; default: header( $_SERVER['SERVER_PROTOCOL'].' 500 Internal Server Error' ); } } else { $value = $this->Value; } switch( $contentType ) { case 'php': case 'application/x-httpd-php': return var_export( $value ); case 'phps': case 'application/vnd.php.serialized': return serialize( $value ); case 'application/json': $json = json_encode( $value, JSON_FORCE_OBJECT ); if ( $this->JsonpCallback != false ) { $json = $this->JsonpCallback . '(' . $json . ')'; } return $json; case 'text/plain': return is_string( $value ) ? $value : var_export( $value, true ); case 'text/html': // in theory both html and body tags are not mandatory. But getting here is just a case of bad coding anyway return is_string( $value ) ? $value : '<html><body>' . htmlspecialchars( print_r( $value, true ) ) . '</body></html>'; default: header('HTTP/1.1 406 Not Acceptable'); // two 'non standard but existing' mimetype defs for php code and serialized return "REST responses cannot be serialized as '$contentType'. Currently supported: application/json, application/x-httpd-php, application/vnd.php.serialized"; } }
php
function payload( ) { $contentType = $this->ContentType; // accommodate re-serializing content after we got a forced content-type if ( $pos = strpos( $contentType, ';' ) !== false ) { $contentType = substr( $contentType, 0, $pos ); } if ( $contentType == '' ) { $contentType = $this->defaultContentType; } if ( $this->IsFault ) { // default representation of an error, hand picked $value = array( 'faultCode' => $this->FaultCode, 'faultString' => $this->FaultString ); // send an HTTP error code, since there is no other way to make sure // that the client can tell apart error responses from valid array responses // try some meaningful mapping (it's REST, baby!) switch( $this->FaultCode ) { case ggWebservicesServer::INVALIDMETHODERROR: header( $_SERVER['SERVER_PROTOCOL'].' 404 Not Found' ); break; case ggWebservicesServer::INVALIDPARAMSERROR: case ggWebservicesServer::INVALIDCOMPRESSIONERROR: case ggWebservicesServer::INVALIDREQUESTERROR: header( $_SERVER['SERVER_PROTOCOL'].' 400 Bad Request' ); break; case ggWebservicesServer::INVALIDAUTHERROR: header( $_SERVER['SERVER_PROTOCOL'].' 403 Forbidden' ); break; default: header( $_SERVER['SERVER_PROTOCOL'].' 500 Internal Server Error' ); } } else { $value = $this->Value; } switch( $contentType ) { case 'php': case 'application/x-httpd-php': return var_export( $value ); case 'phps': case 'application/vnd.php.serialized': return serialize( $value ); case 'application/json': $json = json_encode( $value, JSON_FORCE_OBJECT ); if ( $this->JsonpCallback != false ) { $json = $this->JsonpCallback . '(' . $json . ')'; } return $json; case 'text/plain': return is_string( $value ) ? $value : var_export( $value, true ); case 'text/html': // in theory both html and body tags are not mandatory. But getting here is just a case of bad coding anyway return is_string( $value ) ? $value : '<html><body>' . htmlspecialchars( print_r( $value, true ) ) . '</body></html>'; default: header('HTTP/1.1 406 Not Acceptable'); // two 'non standard but existing' mimetype defs for php code and serialized return "REST responses cannot be serialized as '$contentType'. Currently supported: application/json, application/x-httpd-php, application/vnd.php.serialized"; } }
[ "function", "payload", "(", ")", "{", "$", "contentType", "=", "$", "this", "->", "ContentType", ";", "// accommodate re-serializing content after we got a forced content-type", "if", "(", "$", "pos", "=", "strpos", "(", "$", "contentType", ",", "';'", ")", "!==", "false", ")", "{", "$", "contentType", "=", "substr", "(", "$", "contentType", ",", "0", ",", "$", "pos", ")", ";", "}", "if", "(", "$", "contentType", "==", "''", ")", "{", "$", "contentType", "=", "$", "this", "->", "defaultContentType", ";", "}", "if", "(", "$", "this", "->", "IsFault", ")", "{", "// default representation of an error, hand picked", "$", "value", "=", "array", "(", "'faultCode'", "=>", "$", "this", "->", "FaultCode", ",", "'faultString'", "=>", "$", "this", "->", "FaultString", ")", ";", "// send an HTTP error code, since there is no other way to make sure", "// that the client can tell apart error responses from valid array responses", "// try some meaningful mapping (it's REST, baby!)", "switch", "(", "$", "this", "->", "FaultCode", ")", "{", "case", "ggWebservicesServer", "::", "INVALIDMETHODERROR", ":", "header", "(", "$", "_SERVER", "[", "'SERVER_PROTOCOL'", "]", ".", "' 404 Not Found'", ")", ";", "break", ";", "case", "ggWebservicesServer", "::", "INVALIDPARAMSERROR", ":", "case", "ggWebservicesServer", "::", "INVALIDCOMPRESSIONERROR", ":", "case", "ggWebservicesServer", "::", "INVALIDREQUESTERROR", ":", "header", "(", "$", "_SERVER", "[", "'SERVER_PROTOCOL'", "]", ".", "' 400 Bad Request'", ")", ";", "break", ";", "case", "ggWebservicesServer", "::", "INVALIDAUTHERROR", ":", "header", "(", "$", "_SERVER", "[", "'SERVER_PROTOCOL'", "]", ".", "' 403 Forbidden'", ")", ";", "break", ";", "default", ":", "header", "(", "$", "_SERVER", "[", "'SERVER_PROTOCOL'", "]", ".", "' 500 Internal Server Error'", ")", ";", "}", "}", "else", "{", "$", "value", "=", "$", "this", "->", "Value", ";", "}", "switch", "(", "$", "contentType", ")", "{", "case", "'php'", ":", "case", "'application/x-httpd-php'", ":", "return", "var_export", "(", "$", "value", ")", ";", "case", "'phps'", ":", "case", "'application/vnd.php.serialized'", ":", "return", "serialize", "(", "$", "value", ")", ";", "case", "'application/json'", ":", "$", "json", "=", "json_encode", "(", "$", "value", ",", "JSON_FORCE_OBJECT", ")", ";", "if", "(", "$", "this", "->", "JsonpCallback", "!=", "false", ")", "{", "$", "json", "=", "$", "this", "->", "JsonpCallback", ".", "'('", ".", "$", "json", ".", "')'", ";", "}", "return", "$", "json", ";", "case", "'text/plain'", ":", "return", "is_string", "(", "$", "value", ")", "?", "$", "value", ":", "var_export", "(", "$", "value", ",", "true", ")", ";", "case", "'text/html'", ":", "// in theory both html and body tags are not mandatory. But getting here is just a case of bad coding anyway", "return", "is_string", "(", "$", "value", ")", "?", "$", "value", ":", "'<html><body>'", ".", "htmlspecialchars", "(", "print_r", "(", "$", "value", ",", "true", ")", ")", ".", "'</body></html>'", ";", "default", ":", "header", "(", "'HTTP/1.1 406 Not Acceptable'", ")", ";", "// two 'non standard but existing' mimetype defs for php code and serialized", "return", "\"REST responses cannot be serialized as '$contentType'. Currently supported: application/json, application/x-httpd-php, application/vnd.php.serialized\"", ";", "}", "}" ]
Returns the payload for the response. Encoding varies depending on what the request asked for @todo add jsonp support for php? note that the validation regexp (in req. class) might need to differ...
[ "Returns", "the", "payload", "for", "the", "response", ".", "Encoding", "varies", "depending", "on", "what", "the", "request", "asked", "for" ]
4f6e1ada1aa94301acd2ef3cd0966c7be06313ec
https://github.com/gggeek/ggwebservices/blob/4f6e1ada1aa94301acd2ef3cd0966c7be06313ec/classes/ggrestresponse.php#L21-L89
227,986
antaresproject/core
src/ui/components/datatables/src/Session/Session.php
Session.getFromSession
protected function getFromSession($key, $perPage) { $session = $this->request->session(); if (!$session->has($key) or $this->request->ajax()) { $session->put($key, $perPage); $session->save(); } return $session->get($key); }
php
protected function getFromSession($key, $perPage) { $session = $this->request->session(); if (!$session->has($key) or $this->request->ajax()) { $session->put($key, $perPage); $session->save(); } return $session->get($key); }
[ "protected", "function", "getFromSession", "(", "$", "key", ",", "$", "perPage", ")", "{", "$", "session", "=", "$", "this", "->", "request", "->", "session", "(", ")", ";", "if", "(", "!", "$", "session", "->", "has", "(", "$", "key", ")", "or", "$", "this", "->", "request", "->", "ajax", "(", ")", ")", "{", "$", "session", "->", "put", "(", "$", "key", ",", "$", "perPage", ")", ";", "$", "session", "->", "save", "(", ")", ";", "}", "return", "$", "session", "->", "get", "(", "$", "key", ")", ";", "}" ]
Get key from session @param String $key @param mixed $perPage @return mixed
[ "Get", "key", "from", "session" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/datatables/src/Session/Session.php#L62-L70
227,987
antaresproject/core
src/ui/components/templates/src/Adapter/AttributesAdapter.php
AttributesAdapter.defaults
public function defaults() { $defaults = $this->config; if (!isset($defaults['width'])) { $defaults['width'] = $defaults['default_width']; } if (!isset($defaults['height'])) { $defaults['height'] = $defaults['default_height']; } return $defaults; }
php
public function defaults() { $defaults = $this->config; if (!isset($defaults['width'])) { $defaults['width'] = $defaults['default_width']; } if (!isset($defaults['height'])) { $defaults['height'] = $defaults['default_height']; } return $defaults; }
[ "public", "function", "defaults", "(", ")", "{", "$", "defaults", "=", "$", "this", "->", "config", ";", "if", "(", "!", "isset", "(", "$", "defaults", "[", "'width'", "]", ")", ")", "{", "$", "defaults", "[", "'width'", "]", "=", "$", "defaults", "[", "'default_width'", "]", ";", "}", "if", "(", "!", "isset", "(", "$", "defaults", "[", "'height'", "]", ")", ")", "{", "$", "defaults", "[", "'height'", "]", "=", "$", "defaults", "[", "'default_height'", "]", ";", "}", "return", "$", "defaults", ";", "}" ]
created defaults dimenstion settings @return array
[ "created", "defaults", "dimenstion", "settings" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Adapter/AttributesAdapter.php#L71-L81
227,988
antaresproject/core
src/ui/components/templates/src/Adapter/AttributesAdapter.php
AttributesAdapter.attributes
public function attributes(array $current = array()) { $attributes = isset($this->params['attributes']) ? $this->params['attributes'] : []; $this->attributes = array_merge($this->config, $attributes, $current); $this->attributes['name'] = $this->name; $this->attributes['x'] = isset($attributes['x']) ? $attributes['x'] : $this->attributes['x']; $this->attributes['y'] = isset($attributes['y']) ? $attributes['y'] : $this->attributes['y']; $width = isset($this->attributes['width']) ? $this->attributes['width'] : $this->attributes['default_width']; $height = isset($this->attributes['height']) ? $this->attributes['height'] : $this->attributes['default_height']; $this->attributes['width'] = isset($attributes['width']) ? $attributes['width'] : $width; $this->attributes['height'] = isset($attributes['height']) ? $attributes['height'] : $height; return $this->attributes; }
php
public function attributes(array $current = array()) { $attributes = isset($this->params['attributes']) ? $this->params['attributes'] : []; $this->attributes = array_merge($this->config, $attributes, $current); $this->attributes['name'] = $this->name; $this->attributes['x'] = isset($attributes['x']) ? $attributes['x'] : $this->attributes['x']; $this->attributes['y'] = isset($attributes['y']) ? $attributes['y'] : $this->attributes['y']; $width = isset($this->attributes['width']) ? $this->attributes['width'] : $this->attributes['default_width']; $height = isset($this->attributes['height']) ? $this->attributes['height'] : $this->attributes['default_height']; $this->attributes['width'] = isset($attributes['width']) ? $attributes['width'] : $width; $this->attributes['height'] = isset($attributes['height']) ? $attributes['height'] : $height; return $this->attributes; }
[ "public", "function", "attributes", "(", "array", "$", "current", "=", "array", "(", ")", ")", "{", "$", "attributes", "=", "isset", "(", "$", "this", "->", "params", "[", "'attributes'", "]", ")", "?", "$", "this", "->", "params", "[", "'attributes'", "]", ":", "[", "]", ";", "$", "this", "->", "attributes", "=", "array_merge", "(", "$", "this", "->", "config", ",", "$", "attributes", ",", "$", "current", ")", ";", "$", "this", "->", "attributes", "[", "'name'", "]", "=", "$", "this", "->", "name", ";", "$", "this", "->", "attributes", "[", "'x'", "]", "=", "isset", "(", "$", "attributes", "[", "'x'", "]", ")", "?", "$", "attributes", "[", "'x'", "]", ":", "$", "this", "->", "attributes", "[", "'x'", "]", ";", "$", "this", "->", "attributes", "[", "'y'", "]", "=", "isset", "(", "$", "attributes", "[", "'y'", "]", ")", "?", "$", "attributes", "[", "'y'", "]", ":", "$", "this", "->", "attributes", "[", "'y'", "]", ";", "$", "width", "=", "isset", "(", "$", "this", "->", "attributes", "[", "'width'", "]", ")", "?", "$", "this", "->", "attributes", "[", "'width'", "]", ":", "$", "this", "->", "attributes", "[", "'default_width'", "]", ";", "$", "height", "=", "isset", "(", "$", "this", "->", "attributes", "[", "'height'", "]", ")", "?", "$", "this", "->", "attributes", "[", "'height'", "]", ":", "$", "this", "->", "attributes", "[", "'default_height'", "]", ";", "$", "this", "->", "attributes", "[", "'width'", "]", "=", "isset", "(", "$", "attributes", "[", "'width'", "]", ")", "?", "$", "attributes", "[", "'width'", "]", ":", "$", "width", ";", "$", "this", "->", "attributes", "[", "'height'", "]", "=", "isset", "(", "$", "attributes", "[", "'height'", "]", ")", "?", "$", "attributes", "[", "'height'", "]", ":", "$", "height", ";", "return", "$", "this", "->", "attributes", ";", "}" ]
widget attributes manager @param array $current @return array
[ "widget", "attributes", "manager" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/ui/components/templates/src/Adapter/AttributesAdapter.php#L104-L118
227,989
antaresproject/core
src/components/html/src/Grid.php
Grid.attributes
public function attributes($key = null, $value = null) { if (is_null($key)) { return $this->attributes; } if (is_array($key)) { $this->attributes = array_merge($this->attributes, $key); } else { $this->attributes[$key] = $value; } return; }
php
public function attributes($key = null, $value = null) { if (is_null($key)) { return $this->attributes; } if (is_array($key)) { $this->attributes = array_merge($this->attributes, $key); } else { $this->attributes[$key] = $value; } return; }
[ "public", "function", "attributes", "(", "$", "key", "=", "null", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "attributes", ";", "}", "if", "(", "is_array", "(", "$", "key", ")", ")", "{", "$", "this", "->", "attributes", "=", "array_merge", "(", "$", "this", "->", "attributes", ",", "$", "key", ")", ";", "}", "else", "{", "$", "this", "->", "attributes", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", ";", "}" ]
Add or append Grid attributes. @param mixed $key @param mixed $value @return array|null
[ "Add", "or", "append", "Grid", "attributes", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Grid.php#L104-L117
227,990
antaresproject/core
src/components/html/src/Grid.php
Grid.of
public function of($name, $callback = null) { $type = $this->definition['name']; if (is_null($type) || !property_exists($this, $type)) { throw new RuntimeException('Not supported.'); } elseif (!isset($this->keyMap[$name])) { throw new InvalidArgumentException("Name [{$name}] is not available."); } $id = $this->keyMap[$name]; if (is_callable($callback)) { call_user_func($callback, $this->{$type}[$id]); } return $this->{$type}[$id]; }
php
public function of($name, $callback = null) { $type = $this->definition['name']; if (is_null($type) || !property_exists($this, $type)) { throw new RuntimeException('Not supported.'); } elseif (!isset($this->keyMap[$name])) { throw new InvalidArgumentException("Name [{$name}] is not available."); } $id = $this->keyMap[$name]; if (is_callable($callback)) { call_user_func($callback, $this->{$type}[$id]); } return $this->{$type}[$id]; }
[ "public", "function", "of", "(", "$", "name", ",", "$", "callback", "=", "null", ")", "{", "$", "type", "=", "$", "this", "->", "definition", "[", "'name'", "]", ";", "if", "(", "is_null", "(", "$", "type", ")", "||", "!", "property_exists", "(", "$", "this", ",", "$", "type", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'Not supported.'", ")", ";", "}", "elseif", "(", "!", "isset", "(", "$", "this", "->", "keyMap", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Name [{$name}] is not available.\"", ")", ";", "}", "$", "id", "=", "$", "this", "->", "keyMap", "[", "$", "name", "]", ";", "if", "(", "is_callable", "(", "$", "callback", ")", ")", "{", "call_user_func", "(", "$", "callback", ",", "$", "this", "->", "{", "$", "type", "}", "[", "$", "id", "]", ")", ";", "}", "return", "$", "this", "->", "{", "$", "type", "}", "[", "$", "id", "]", ";", "}" ]
Allow column overwriting. @param string $name @param mixed|null $callback @return \Illuminate\Support\Fluent @throws \InvalidArgumentException @throws \RuntimeException
[ "Allow", "column", "overwriting", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/html/src/Grid.php#L130-L149
227,991
antaresproject/core
src/components/messages/src/SwalMessanger.php
SwalMessanger.message
public function message($title, $text = null) { if (!in_array($this->type, ['success', 'error', 'info', 'warning'])) { return ''; } $container = $this->assetFactory->container(self::position); $type = $this->resolveType(); return $container->inlineScript('swal-message', $this->inline($type, $title, $text)); }
php
public function message($title, $text = null) { if (!in_array($this->type, ['success', 'error', 'info', 'warning'])) { return ''; } $container = $this->assetFactory->container(self::position); $type = $this->resolveType(); return $container->inlineScript('swal-message', $this->inline($type, $title, $text)); }
[ "public", "function", "message", "(", "$", "title", ",", "$", "text", "=", "null", ")", "{", "if", "(", "!", "in_array", "(", "$", "this", "->", "type", ",", "[", "'success'", ",", "'error'", ",", "'info'", ",", "'warning'", "]", ")", ")", "{", "return", "''", ";", "}", "$", "container", "=", "$", "this", "->", "assetFactory", "->", "container", "(", "self", "::", "position", ")", ";", "$", "type", "=", "$", "this", "->", "resolveType", "(", ")", ";", "return", "$", "container", "->", "inlineScript", "(", "'swal-message'", ",", "$", "this", "->", "inline", "(", "$", "type", ",", "$", "title", ",", "$", "text", ")", ")", ";", "}" ]
Appends inline script to scripts container @param String $title @param String $text @return String
[ "Appends", "inline", "script", "to", "scripts", "container" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/messages/src/SwalMessanger.php#L78-L86
227,992
antaresproject/core
src/components/messages/src/SwalMessanger.php
SwalMessanger.inline
protected function inline($type, $title, $text = null) { $html = (string) $text; $inline = <<<EOD $(document).ready(function(){ swal($.extend({}, APP.swal.$type(), { title: '$title', text: '$html', showConfirmButton: false, showCancelButton: true, cancelButtonText: 'Ok', closeOnConfirm: false, closeOnCancel: true })); }); EOD; return $inline; }
php
protected function inline($type, $title, $text = null) { $html = (string) $text; $inline = <<<EOD $(document).ready(function(){ swal($.extend({}, APP.swal.$type(), { title: '$title', text: '$html', showConfirmButton: false, showCancelButton: true, cancelButtonText: 'Ok', closeOnConfirm: false, closeOnCancel: true })); }); EOD; return $inline; }
[ "protected", "function", "inline", "(", "$", "type", ",", "$", "title", ",", "$", "text", "=", "null", ")", "{", "$", "html", "=", "(", "string", ")", "$", "text", ";", "$", "inline", "=", " <<<EOD\n $(document).ready(function(){ \n swal($.extend({}, APP.swal.$type(), {\n title: '$title',\n text: '$html', \n showConfirmButton: false,\n showCancelButton: true,\n cancelButtonText: 'Ok',\n closeOnConfirm: false,\n closeOnCancel: true\n }));\n });\nEOD", ";", "return", "$", "inline", ";", "}" ]
generate flash messanger inline scripts @return String
[ "generate", "flash", "messanger", "inline", "scripts" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/messages/src/SwalMessanger.php#L103-L120
227,993
antaresproject/core
src/components/view/src/Console/Command.php
Command.form
public function form(array $configuration = array()) { Event::fire('antares.forms', 'commands.' . $this->name); Event::fire(new Form('commands.' . $this->name)); return app('antares.form')->of("antares.command: " . $this->name, function (FormGrid $form) use ($configuration) { $form->name('Command Configuration Form'); $fluent = new Fluent($configuration); $form->simple(handles('antares::automation/update/'), [], $fluent); $form->hidden('id'); $form->fieldset('', function (Fieldset $fieldset) use($configuration) { $fieldset->legend('Command Configuration Form'); $launch = $configuration['launch']; $options = []; foreach ($configuration['launchTimes'] as $option => $value) { if (!is_numeric($option)) { $options[$option] = trans('antares/automation::messages.intervals.' . $option, ['value' => is_array($value) ? implode(', ', $value) : $value]); } else { $options[$value] = trans('antares/automation::messages.intervals.' . $value); } } $fieldset->control('select', 'launch') ->label(trans('Interval')) ->options($options)->value($launch) ->wrapper(['class' => 'w200']); $control = $fieldset->control('checkbox', 'active') ->label(trans('Status')) ->value(1); if ((int) $configuration['active']) { $control->checked(); } if (!$this->getDisablable()) { $control->attributes([ 'disabled' => 'disabled', 'readonly' => 'readonly' ]); } $fieldset->control('button', 'button') ->attributes(['type' => 'submit', 'class' => 'btn btn-primary']) ->value(trans('antares/foundation::label.save_changes')); $fieldset->control('button', 'cancel') ->field(function() { return app('html')->link(handles("antares::automation/index"), trans('antares/foundation::label.cancel'), ['class' => 'btn btn--md btn--default mdl-button mdl-js-button']); }); }); $form->ajaxable(); $form->rules([ 'title' => ['required'], 'description' => ['required', 'max:4000'], ]); }); }
php
public function form(array $configuration = array()) { Event::fire('antares.forms', 'commands.' . $this->name); Event::fire(new Form('commands.' . $this->name)); return app('antares.form')->of("antares.command: " . $this->name, function (FormGrid $form) use ($configuration) { $form->name('Command Configuration Form'); $fluent = new Fluent($configuration); $form->simple(handles('antares::automation/update/'), [], $fluent); $form->hidden('id'); $form->fieldset('', function (Fieldset $fieldset) use($configuration) { $fieldset->legend('Command Configuration Form'); $launch = $configuration['launch']; $options = []; foreach ($configuration['launchTimes'] as $option => $value) { if (!is_numeric($option)) { $options[$option] = trans('antares/automation::messages.intervals.' . $option, ['value' => is_array($value) ? implode(', ', $value) : $value]); } else { $options[$value] = trans('antares/automation::messages.intervals.' . $value); } } $fieldset->control('select', 'launch') ->label(trans('Interval')) ->options($options)->value($launch) ->wrapper(['class' => 'w200']); $control = $fieldset->control('checkbox', 'active') ->label(trans('Status')) ->value(1); if ((int) $configuration['active']) { $control->checked(); } if (!$this->getDisablable()) { $control->attributes([ 'disabled' => 'disabled', 'readonly' => 'readonly' ]); } $fieldset->control('button', 'button') ->attributes(['type' => 'submit', 'class' => 'btn btn-primary']) ->value(trans('antares/foundation::label.save_changes')); $fieldset->control('button', 'cancel') ->field(function() { return app('html')->link(handles("antares::automation/index"), trans('antares/foundation::label.cancel'), ['class' => 'btn btn--md btn--default mdl-button mdl-js-button']); }); }); $form->ajaxable(); $form->rules([ 'title' => ['required'], 'description' => ['required', 'max:4000'], ]); }); }
[ "public", "function", "form", "(", "array", "$", "configuration", "=", "array", "(", ")", ")", "{", "Event", "::", "fire", "(", "'antares.forms'", ",", "'commands.'", ".", "$", "this", "->", "name", ")", ";", "Event", "::", "fire", "(", "new", "Form", "(", "'commands.'", ".", "$", "this", "->", "name", ")", ")", ";", "return", "app", "(", "'antares.form'", ")", "->", "of", "(", "\"antares.command: \"", ".", "$", "this", "->", "name", ",", "function", "(", "FormGrid", "$", "form", ")", "use", "(", "$", "configuration", ")", "{", "$", "form", "->", "name", "(", "'Command Configuration Form'", ")", ";", "$", "fluent", "=", "new", "Fluent", "(", "$", "configuration", ")", ";", "$", "form", "->", "simple", "(", "handles", "(", "'antares::automation/update/'", ")", ",", "[", "]", ",", "$", "fluent", ")", ";", "$", "form", "->", "hidden", "(", "'id'", ")", ";", "$", "form", "->", "fieldset", "(", "''", ",", "function", "(", "Fieldset", "$", "fieldset", ")", "use", "(", "$", "configuration", ")", "{", "$", "fieldset", "->", "legend", "(", "'Command Configuration Form'", ")", ";", "$", "launch", "=", "$", "configuration", "[", "'launch'", "]", ";", "$", "options", "=", "[", "]", ";", "foreach", "(", "$", "configuration", "[", "'launchTimes'", "]", "as", "$", "option", "=>", "$", "value", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "option", ")", ")", "{", "$", "options", "[", "$", "option", "]", "=", "trans", "(", "'antares/automation::messages.intervals.'", ".", "$", "option", ",", "[", "'value'", "=>", "is_array", "(", "$", "value", ")", "?", "implode", "(", "', '", ",", "$", "value", ")", ":", "$", "value", "]", ")", ";", "}", "else", "{", "$", "options", "[", "$", "value", "]", "=", "trans", "(", "'antares/automation::messages.intervals.'", ".", "$", "value", ")", ";", "}", "}", "$", "fieldset", "->", "control", "(", "'select'", ",", "'launch'", ")", "->", "label", "(", "trans", "(", "'Interval'", ")", ")", "->", "options", "(", "$", "options", ")", "->", "value", "(", "$", "launch", ")", "->", "wrapper", "(", "[", "'class'", "=>", "'w200'", "]", ")", ";", "$", "control", "=", "$", "fieldset", "->", "control", "(", "'checkbox'", ",", "'active'", ")", "->", "label", "(", "trans", "(", "'Status'", ")", ")", "->", "value", "(", "1", ")", ";", "if", "(", "(", "int", ")", "$", "configuration", "[", "'active'", "]", ")", "{", "$", "control", "->", "checked", "(", ")", ";", "}", "if", "(", "!", "$", "this", "->", "getDisablable", "(", ")", ")", "{", "$", "control", "->", "attributes", "(", "[", "'disabled'", "=>", "'disabled'", ",", "'readonly'", "=>", "'readonly'", "]", ")", ";", "}", "$", "fieldset", "->", "control", "(", "'button'", ",", "'button'", ")", "->", "attributes", "(", "[", "'type'", "=>", "'submit'", ",", "'class'", "=>", "'btn btn-primary'", "]", ")", "->", "value", "(", "trans", "(", "'antares/foundation::label.save_changes'", ")", ")", ";", "$", "fieldset", "->", "control", "(", "'button'", ",", "'cancel'", ")", "->", "field", "(", "function", "(", ")", "{", "return", "app", "(", "'html'", ")", "->", "link", "(", "handles", "(", "\"antares::automation/index\"", ")", ",", "trans", "(", "'antares/foundation::label.cancel'", ")", ",", "[", "'class'", "=>", "'btn btn--md btn--default mdl-button mdl-js-button'", "]", ")", ";", "}", ")", ";", "}", ")", ";", "$", "form", "->", "ajaxable", "(", ")", ";", "$", "form", "->", "rules", "(", "[", "'title'", "=>", "[", "'required'", "]", ",", "'description'", "=>", "[", "'required'", ",", "'max:4000'", "]", ",", "]", ")", ";", "}", ")", ";", "}" ]
default command form @param array $configuration @return FormBuilder
[ "default", "command", "form" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Console/Command.php#L201-L258
227,994
antaresproject/core
src/components/view/src/Console/Command.php
Command.getConfiguration
protected function getConfiguration() { $model = Jobs::where('name', $this->name)->first(); return unserialize($model->value); }
php
protected function getConfiguration() { $model = Jobs::where('name', $this->name)->first(); return unserialize($model->value); }
[ "protected", "function", "getConfiguration", "(", ")", "{", "$", "model", "=", "Jobs", "::", "where", "(", "'name'", ",", "$", "this", "->", "name", ")", "->", "first", "(", ")", ";", "return", "unserialize", "(", "$", "model", "->", "value", ")", ";", "}" ]
command configuration getter @return array
[ "command", "configuration", "getter" ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/view/src/Console/Command.php#L265-L269
227,995
antaresproject/core
src/components/extension/src/Validators/ExtensionValidator.php
ExtensionValidator.isValid
public function isValid(ExtensionContract $extension) : bool { return ! in_array($extension->getPackage()->getName(), $this->configRepository->getReservedNames(), true); }
php
public function isValid(ExtensionContract $extension) : bool { return ! in_array($extension->getPackage()->getName(), $this->configRepository->getReservedNames(), true); }
[ "public", "function", "isValid", "(", "ExtensionContract", "$", "extension", ")", ":", "bool", "{", "return", "!", "in_array", "(", "$", "extension", "->", "getPackage", "(", ")", "->", "getName", "(", ")", ",", "$", "this", "->", "configRepository", "->", "getReservedNames", "(", ")", ",", "true", ")", ";", "}" ]
Determines if the extension is set properly. @param ExtensionContract $extension @return bool
[ "Determines", "if", "the", "extension", "is", "set", "properly", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Validators/ExtensionValidator.php#L33-L35
227,996
antaresproject/core
src/components/extension/src/Validators/ExtensionValidator.php
ExtensionValidator.validateAssetsPath
public function validateAssetsPath(ExtensionContract $extension) { $targetPath = $this->configRepository->getPublicPath() . '/packages/antares'; if( ! File::isWritable($targetPath) ) { throw new ExtensionException('The package [' . $extension->getPackage()->getName() . '] cannot access to the public assets path in [' . $targetPath . '].'); } }
php
public function validateAssetsPath(ExtensionContract $extension) { $targetPath = $this->configRepository->getPublicPath() . '/packages/antares'; if( ! File::isWritable($targetPath) ) { throw new ExtensionException('The package [' . $extension->getPackage()->getName() . '] cannot access to the public assets path in [' . $targetPath . '].'); } }
[ "public", "function", "validateAssetsPath", "(", "ExtensionContract", "$", "extension", ")", "{", "$", "targetPath", "=", "$", "this", "->", "configRepository", "->", "getPublicPath", "(", ")", ".", "'/packages/antares'", ";", "if", "(", "!", "File", "::", "isWritable", "(", "$", "targetPath", ")", ")", "{", "throw", "new", "ExtensionException", "(", "'The package ['", ".", "$", "extension", "->", "getPackage", "(", ")", "->", "getName", "(", ")", ".", "'] cannot access to the public assets path in ['", ".", "$", "targetPath", ".", "'].'", ")", ";", "}", "}" ]
Check whether the package has a writable public asset. @param ExtensionContract $extension @throws ExtensionException
[ "Check", "whether", "the", "package", "has", "a", "writable", "public", "asset", "." ]
b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2
https://github.com/antaresproject/core/blob/b6d088d9f8a0642e71e8ff7a93997f1f34bc5ca2/src/components/extension/src/Validators/ExtensionValidator.php#L43-L49
227,997
FlorianWolters/PHP-Component-Core-StringUtils
src/main/php/StringEscapeUtils.php
StringEscapeUtils.escapeRegEx
public static function escapeRegEx($str, $delimiter = '/') { return StringUtils::isEmpty($str) ? $str : \preg_quote($str, $delimiter); }
php
public static function escapeRegEx($str, $delimiter = '/') { return StringUtils::isEmpty($str) ? $str : \preg_quote($str, $delimiter); }
[ "public", "static", "function", "escapeRegEx", "(", "$", "str", ",", "$", "delimiter", "=", "'/'", ")", "{", "return", "StringUtils", "::", "isEmpty", "(", "$", "str", ")", "?", "$", "str", ":", "\\", "preg_quote", "(", "$", "str", ",", "$", "delimiter", ")", ";", "}" ]
Escapes the characters in a `string` to be suitable to pass to a regular expression. @param string $str The `string` to escape. @param string $delimiter The regular expression delimiter. @return string The escaped `string` or `null` if `null` `string` input.
[ "Escapes", "the", "characters", "in", "a", "string", "to", "be", "suitable", "to", "pass", "to", "a", "regular", "expression", "." ]
3b5e8762031cf66d6441ee98772fae4be0f5d0aa
https://github.com/FlorianWolters/PHP-Component-Core-StringUtils/blob/3b5e8762031cf66d6441ee98772fae4be0f5d0aa/src/main/php/StringEscapeUtils.php#L99-L104
227,998
crossjoin/PreMailer
src/Crossjoin/PreMailer/PreMailerAbstract.php
PreMailerAbstract.setOption
public function setOption($name, $value) { if (is_string($name)) { if (isset($this->options[$name])) { switch ($name) { case self::OPTION_STYLE_TAG: if (is_int($value)) { if (!in_array($value, [ self::OPTION_STYLE_TAG_BODY, self::OPTION_STYLE_TAG_HEAD, self::OPTION_STYLE_TAG_REMOVE, ])) { throw new \InvalidArgumentException("Invalid value '$value' for option '$name'."); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($value) . "' for value of option '$name'." ); } break; case self::OPTION_HTML_CLASSES: if (is_int($value)) { if (!in_array($value, [ self::OPTION_HTML_CLASSES_REMOVE, self::OPTION_HTML_CLASSES_KEEP, ])) { throw new \InvalidArgumentException("Invalid value '$value' for option '$name'."); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($value) . "' for value of option '$name'." ); } break; case self::OPTION_HTML_COMMENTS: if (is_int($value)) { if (!in_array($value, [ self::OPTION_HTML_COMMENTS_REMOVE, self::OPTION_HTML_COMMENTS_KEEP, ])) { throw new \InvalidArgumentException("Invalid value '$value' for option '$name'."); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($value) . "' for value of option '$name'." ); } break; case self::OPTION_TEXT_LINE_WIDTH: if (is_int($value)) { if ($value <= 0) { throw new \LengthException( "Value '" . gettype($value) . "' for option '$name' is to small." ); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($value) . "' for value of option '$name'." ); } break; case self::OPTION_CSS_WRITER_CLASS: if (is_string($value)) { if (is_subclass_of($value, '\Crossjoin\Css\Writer\WriterAbstract', true) === false) { throw new \InvalidArgumentException( "Invalid value '$value' for option '$name'. " . "The given class has to be a subclass of \\Crossjoin\\Css\\Writer\\WriterAbstract." ); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($value) . "' for value of option '$name'." ); } } $this->options[$name] = $value; } else { throw new \InvalidArgumentException("An option with the name '$name' doesn't exist."); } } else { throw new \InvalidArgumentException("Invalid type '" . gettype($name) . "' for argument 'name'."); } }
php
public function setOption($name, $value) { if (is_string($name)) { if (isset($this->options[$name])) { switch ($name) { case self::OPTION_STYLE_TAG: if (is_int($value)) { if (!in_array($value, [ self::OPTION_STYLE_TAG_BODY, self::OPTION_STYLE_TAG_HEAD, self::OPTION_STYLE_TAG_REMOVE, ])) { throw new \InvalidArgumentException("Invalid value '$value' for option '$name'."); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($value) . "' for value of option '$name'." ); } break; case self::OPTION_HTML_CLASSES: if (is_int($value)) { if (!in_array($value, [ self::OPTION_HTML_CLASSES_REMOVE, self::OPTION_HTML_CLASSES_KEEP, ])) { throw new \InvalidArgumentException("Invalid value '$value' for option '$name'."); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($value) . "' for value of option '$name'." ); } break; case self::OPTION_HTML_COMMENTS: if (is_int($value)) { if (!in_array($value, [ self::OPTION_HTML_COMMENTS_REMOVE, self::OPTION_HTML_COMMENTS_KEEP, ])) { throw new \InvalidArgumentException("Invalid value '$value' for option '$name'."); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($value) . "' for value of option '$name'." ); } break; case self::OPTION_TEXT_LINE_WIDTH: if (is_int($value)) { if ($value <= 0) { throw new \LengthException( "Value '" . gettype($value) . "' for option '$name' is to small." ); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($value) . "' for value of option '$name'." ); } break; case self::OPTION_CSS_WRITER_CLASS: if (is_string($value)) { if (is_subclass_of($value, '\Crossjoin\Css\Writer\WriterAbstract', true) === false) { throw new \InvalidArgumentException( "Invalid value '$value' for option '$name'. " . "The given class has to be a subclass of \\Crossjoin\\Css\\Writer\\WriterAbstract." ); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($value) . "' for value of option '$name'." ); } } $this->options[$name] = $value; } else { throw new \InvalidArgumentException("An option with the name '$name' doesn't exist."); } } else { throw new \InvalidArgumentException("Invalid type '" . gettype($name) . "' for argument 'name'."); } }
[ "public", "function", "setOption", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "name", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "$", "name", "]", ")", ")", "{", "switch", "(", "$", "name", ")", "{", "case", "self", "::", "OPTION_STYLE_TAG", ":", "if", "(", "is_int", "(", "$", "value", ")", ")", "{", "if", "(", "!", "in_array", "(", "$", "value", ",", "[", "self", "::", "OPTION_STYLE_TAG_BODY", ",", "self", "::", "OPTION_STYLE_TAG_HEAD", ",", "self", "::", "OPTION_STYLE_TAG_REMOVE", ",", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid value '$value' for option '$name'.\"", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "value", ")", ".", "\"' for value of option '$name'.\"", ")", ";", "}", "break", ";", "case", "self", "::", "OPTION_HTML_CLASSES", ":", "if", "(", "is_int", "(", "$", "value", ")", ")", "{", "if", "(", "!", "in_array", "(", "$", "value", ",", "[", "self", "::", "OPTION_HTML_CLASSES_REMOVE", ",", "self", "::", "OPTION_HTML_CLASSES_KEEP", ",", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid value '$value' for option '$name'.\"", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "value", ")", ".", "\"' for value of option '$name'.\"", ")", ";", "}", "break", ";", "case", "self", "::", "OPTION_HTML_COMMENTS", ":", "if", "(", "is_int", "(", "$", "value", ")", ")", "{", "if", "(", "!", "in_array", "(", "$", "value", ",", "[", "self", "::", "OPTION_HTML_COMMENTS_REMOVE", ",", "self", "::", "OPTION_HTML_COMMENTS_KEEP", ",", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid value '$value' for option '$name'.\"", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "value", ")", ".", "\"' for value of option '$name'.\"", ")", ";", "}", "break", ";", "case", "self", "::", "OPTION_TEXT_LINE_WIDTH", ":", "if", "(", "is_int", "(", "$", "value", ")", ")", "{", "if", "(", "$", "value", "<=", "0", ")", "{", "throw", "new", "\\", "LengthException", "(", "\"Value '\"", ".", "gettype", "(", "$", "value", ")", ".", "\"' for option '$name' is to small.\"", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "value", ")", ".", "\"' for value of option '$name'.\"", ")", ";", "}", "break", ";", "case", "self", "::", "OPTION_CSS_WRITER_CLASS", ":", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "if", "(", "is_subclass_of", "(", "$", "value", ",", "'\\Crossjoin\\Css\\Writer\\WriterAbstract'", ",", "true", ")", "===", "false", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid value '$value' for option '$name'. \"", ".", "\"The given class has to be a subclass of \\\\Crossjoin\\\\Css\\\\Writer\\\\WriterAbstract.\"", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "value", ")", ".", "\"' for value of option '$name'.\"", ")", ";", "}", "}", "$", "this", "->", "options", "[", "$", "name", "]", "=", "$", "value", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"An option with the name '$name' doesn't exist.\"", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "name", ")", ".", "\"' for argument 'name'.\"", ")", ";", "}", "}" ]
Sets an option for the generation of the mail. @param string $name @param mixed $value
[ "Sets", "an", "option", "for", "the", "generation", "of", "the", "mail", "." ]
e1fbd426a9f3ba2d5d00f6641b2509c72bf4f561
https://github.com/crossjoin/PreMailer/blob/e1fbd426a9f3ba2d5d00f6641b2509c72bf4f561/src/Crossjoin/PreMailer/PreMailerAbstract.php#L90-L172
227,999
crossjoin/PreMailer
src/Crossjoin/PreMailer/PreMailerAbstract.php
PreMailerAbstract.getOption
public function getOption($name) { if (is_string($name)) { if (isset($this->options[$name])) { return $this->options[$name]; } else { throw new \InvalidArgumentException("An option with the name '$name' doesn't exist."); } } else { throw new \InvalidArgumentException("Invalid type '" . gettype($name) . "' for argument 'name'."); } }
php
public function getOption($name) { if (is_string($name)) { if (isset($this->options[$name])) { return $this->options[$name]; } else { throw new \InvalidArgumentException("An option with the name '$name' doesn't exist."); } } else { throw new \InvalidArgumentException("Invalid type '" . gettype($name) . "' for argument 'name'."); } }
[ "public", "function", "getOption", "(", "$", "name", ")", "{", "if", "(", "is_string", "(", "$", "name", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "options", "[", "$", "name", "]", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"An option with the name '$name' doesn't exist.\"", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "name", ")", ".", "\"' for argument 'name'.\"", ")", ";", "}", "}" ]
Gets an option for the generation of the mail. @param string $name @return mixed
[ "Gets", "an", "option", "for", "the", "generation", "of", "the", "mail", "." ]
e1fbd426a9f3ba2d5d00f6641b2509c72bf4f561
https://github.com/crossjoin/PreMailer/blob/e1fbd426a9f3ba2d5d00f6641b2509c72bf4f561/src/Crossjoin/PreMailer/PreMailerAbstract.php#L180-L191