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
partition
stringclasses
1 value
helsingborg-stad/multisite-role-propagation
source/php/Profile.php
Profile.getUserRoles
public function getUserRoles($user_id) { $roles = array(); foreach ((array) get_sites() as $site) { //Get user role if ($site->blog_id != 1) { $userSettings = get_user_meta($user_id, $this->db->prefix . $site->blog_id . '_capabilities', true); } else { $userSettings = get_user_meta($user_id, $this->db->prefix . 'capabilities', true); } //Store to settings array if (is_array($userSettings)) { $roles[$site->blog_id] = key($userSettings); } else { $roles[$site->blog_id] = false; } } return $roles; }
php
public function getUserRoles($user_id) { $roles = array(); foreach ((array) get_sites() as $site) { //Get user role if ($site->blog_id != 1) { $userSettings = get_user_meta($user_id, $this->db->prefix . $site->blog_id . '_capabilities', true); } else { $userSettings = get_user_meta($user_id, $this->db->prefix . 'capabilities', true); } //Store to settings array if (is_array($userSettings)) { $roles[$site->blog_id] = key($userSettings); } else { $roles[$site->blog_id] = false; } } return $roles; }
[ "public", "function", "getUserRoles", "(", "$", "user_id", ")", "{", "$", "roles", "=", "array", "(", ")", ";", "foreach", "(", "(", "array", ")", "get_sites", "(", ")", "as", "$", "site", ")", "{", "//Get user role", "if", "(", "$", "site", "->", "blog_id", "!=", "1", ")", "{", "$", "userSettings", "=", "get_user_meta", "(", "$", "user_id", ",", "$", "this", "->", "db", "->", "prefix", ".", "$", "site", "->", "blog_id", ".", "'_capabilities'", ",", "true", ")", ";", "}", "else", "{", "$", "userSettings", "=", "get_user_meta", "(", "$", "user_id", ",", "$", "this", "->", "db", "->", "prefix", ".", "'capabilities'", ",", "true", ")", ";", "}", "//Store to settings array", "if", "(", "is_array", "(", "$", "userSettings", ")", ")", "{", "$", "roles", "[", "$", "site", "->", "blog_id", "]", "=", "key", "(", "$", "userSettings", ")", ";", "}", "else", "{", "$", "roles", "[", "$", "site", "->", "blog_id", "]", "=", "false", ";", "}", "}", "return", "$", "roles", ";", "}" ]
Get roles that are defined at each site @return array
[ "Get", "roles", "that", "are", "defined", "at", "each", "site" ]
16d4992b8d32b3e3d8ef99ed51d37ac54bf917cc
https://github.com/helsingborg-stad/multisite-role-propagation/blob/16d4992b8d32b3e3d8ef99ed51d37ac54bf917cc/source/php/Profile.php#L92-L114
train
Hnto/nuki
src/Handlers/Http/Output/Renderers/JsonRenderer.php
JsonRenderer.isValidJson
public function isValidJson(string $data) : bool { json_decode($data); if (json_last_error() !== JSON_ERROR_NONE) { return false; } return true; }
php
public function isValidJson(string $data) : bool { json_decode($data); if (json_last_error() !== JSON_ERROR_NONE) { return false; } return true; }
[ "public", "function", "isValidJson", "(", "string", "$", "data", ")", ":", "bool", "{", "json_decode", "(", "$", "data", ")", ";", "if", "(", "json_last_error", "(", ")", "!==", "JSON_ERROR_NONE", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Check if json is valid @param string $data @return bool
[ "Check", "if", "json", "is", "valid" ]
c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c
https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Handlers/Http/Output/Renderers/JsonRenderer.php#L57-L65
train
Hnto/nuki
src/Handlers/Http/Output/Renderers/JsonRenderer.php
JsonRenderer.createJson
private function createJson() { $content = $this->getContent()->get(); $json = json_encode( $content, JSON_PRESERVE_ZERO_FRACTION | JSON_BIGINT_AS_STRING | JSON_NUMERIC_CHECK | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); if (!$this->isValidJson($json)) { throw new \Nuki\Exceptions\Base('Encoded json string is not valid, check input'); } return $json; }
php
private function createJson() { $content = $this->getContent()->get(); $json = json_encode( $content, JSON_PRESERVE_ZERO_FRACTION | JSON_BIGINT_AS_STRING | JSON_NUMERIC_CHECK | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); if (!$this->isValidJson($json)) { throw new \Nuki\Exceptions\Base('Encoded json string is not valid, check input'); } return $json; }
[ "private", "function", "createJson", "(", ")", "{", "$", "content", "=", "$", "this", "->", "getContent", "(", ")", "->", "get", "(", ")", ";", "$", "json", "=", "json_encode", "(", "$", "content", ",", "JSON_PRESERVE_ZERO_FRACTION", "|", "JSON_BIGINT_AS_STRING", "|", "JSON_NUMERIC_CHECK", "|", "JSON_PRETTY_PRINT", "|", "JSON_UNESCAPED_SLASHES", ")", ";", "if", "(", "!", "$", "this", "->", "isValidJson", "(", "$", "json", ")", ")", "{", "throw", "new", "\\", "Nuki", "\\", "Exceptions", "\\", "Base", "(", "'Encoded json string is not valid, check input'", ")", ";", "}", "return", "$", "json", ";", "}" ]
Create json object @return string @throws \Nuki\Exceptions\Base
[ "Create", "json", "object" ]
c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c
https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Handlers/Http/Output/Renderers/JsonRenderer.php#L73-L89
train
Moro4125/team-migrations-common
sources/MigrationManager.php
MigrationManager.doCreate
public function doCreate(callable $callbackAskNameAndService) { assert($this->_dispatcher); assert($this->_container); $this->_clearStatProperties(); $this->_dispatcher->dispatch(self::EVENT_INIT_SERVICE, OnInitService::create()); try { $this->notify(self::STATE_FIRED); $modulesAndFiles = $this->_findModulesAndMigrationFiles(); $migrations = $this->_parseMigrationFiles($modulesAndFiles); $folders = array_map('dirname', $modulesAndFiles[$this->getProjectName()]); asort($folders); $migrationsPath = reset($folders) ?: $this->getProjectPath().DIRECTORY_SEPARATOR.'migrations'; file_exists($migrationsPath) || mkdir($migrationsPath, 0775, true); $this->notify(self::STATE_FIND_MIGRATIONS); list($name, $service) = $callbackAskNameAndService(array_keys($folders), array_keys($migrations)); if (empty($name)) { $this->_printError(self::ERROR_EMPTY_FILE_NAME); } elseif (empty($service)) { $this->_printError(self::ERROR_EMPTY_SERVICE_NAME); } else { $this->_filePutContents($migrationsPath.DIRECTORY_SEPARATOR.$name.'.ini', implode("\n", [ "; File $name.ini by ".(getenv('USERNAME') ?: getenv('USER') ?: 'unknown user'), '', '['.self::INI_SECTION_MIGRATION.']', self::INI_KEY_CREATED.'="'.date('Y-m-d H:i O').'"', self::INI_KEY_SERVICE.'="'.$service.'"', '', '['.self::INI_SECTION_ACTIONS.']', 'a001="php> echo \'Migration applied!\'.PHP_EOL;"', 'r001="php> echo \'Migration rejected!\'.PHP_EOL;"', '', ])); } $this->notify(self::STATE_COMPLETE); } catch (Exception $exception) { $this->_printError($exception); $this->notify(self::STATE_COMPLETE); } finally { $this->_stateMigrationName = null; $this->_state = self::STATE_INITIALIZED; $this->_dispatcher->dispatch(self::EVENT_FREE_SERVICE, OnFreeService::create()); } }
php
public function doCreate(callable $callbackAskNameAndService) { assert($this->_dispatcher); assert($this->_container); $this->_clearStatProperties(); $this->_dispatcher->dispatch(self::EVENT_INIT_SERVICE, OnInitService::create()); try { $this->notify(self::STATE_FIRED); $modulesAndFiles = $this->_findModulesAndMigrationFiles(); $migrations = $this->_parseMigrationFiles($modulesAndFiles); $folders = array_map('dirname', $modulesAndFiles[$this->getProjectName()]); asort($folders); $migrationsPath = reset($folders) ?: $this->getProjectPath().DIRECTORY_SEPARATOR.'migrations'; file_exists($migrationsPath) || mkdir($migrationsPath, 0775, true); $this->notify(self::STATE_FIND_MIGRATIONS); list($name, $service) = $callbackAskNameAndService(array_keys($folders), array_keys($migrations)); if (empty($name)) { $this->_printError(self::ERROR_EMPTY_FILE_NAME); } elseif (empty($service)) { $this->_printError(self::ERROR_EMPTY_SERVICE_NAME); } else { $this->_filePutContents($migrationsPath.DIRECTORY_SEPARATOR.$name.'.ini', implode("\n", [ "; File $name.ini by ".(getenv('USERNAME') ?: getenv('USER') ?: 'unknown user'), '', '['.self::INI_SECTION_MIGRATION.']', self::INI_KEY_CREATED.'="'.date('Y-m-d H:i O').'"', self::INI_KEY_SERVICE.'="'.$service.'"', '', '['.self::INI_SECTION_ACTIONS.']', 'a001="php> echo \'Migration applied!\'.PHP_EOL;"', 'r001="php> echo \'Migration rejected!\'.PHP_EOL;"', '', ])); } $this->notify(self::STATE_COMPLETE); } catch (Exception $exception) { $this->_printError($exception); $this->notify(self::STATE_COMPLETE); } finally { $this->_stateMigrationName = null; $this->_state = self::STATE_INITIALIZED; $this->_dispatcher->dispatch(self::EVENT_FREE_SERVICE, OnFreeService::create()); } }
[ "public", "function", "doCreate", "(", "callable", "$", "callbackAskNameAndService", ")", "{", "assert", "(", "$", "this", "->", "_dispatcher", ")", ";", "assert", "(", "$", "this", "->", "_container", ")", ";", "$", "this", "->", "_clearStatProperties", "(", ")", ";", "$", "this", "->", "_dispatcher", "->", "dispatch", "(", "self", "::", "EVENT_INIT_SERVICE", ",", "OnInitService", "::", "create", "(", ")", ")", ";", "try", "{", "$", "this", "->", "notify", "(", "self", "::", "STATE_FIRED", ")", ";", "$", "modulesAndFiles", "=", "$", "this", "->", "_findModulesAndMigrationFiles", "(", ")", ";", "$", "migrations", "=", "$", "this", "->", "_parseMigrationFiles", "(", "$", "modulesAndFiles", ")", ";", "$", "folders", "=", "array_map", "(", "'dirname'", ",", "$", "modulesAndFiles", "[", "$", "this", "->", "getProjectName", "(", ")", "]", ")", ";", "asort", "(", "$", "folders", ")", ";", "$", "migrationsPath", "=", "reset", "(", "$", "folders", ")", "?", ":", "$", "this", "->", "getProjectPath", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "'migrations'", ";", "file_exists", "(", "$", "migrationsPath", ")", "||", "mkdir", "(", "$", "migrationsPath", ",", "0775", ",", "true", ")", ";", "$", "this", "->", "notify", "(", "self", "::", "STATE_FIND_MIGRATIONS", ")", ";", "list", "(", "$", "name", ",", "$", "service", ")", "=", "$", "callbackAskNameAndService", "(", "array_keys", "(", "$", "folders", ")", ",", "array_keys", "(", "$", "migrations", ")", ")", ";", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "$", "this", "->", "_printError", "(", "self", "::", "ERROR_EMPTY_FILE_NAME", ")", ";", "}", "elseif", "(", "empty", "(", "$", "service", ")", ")", "{", "$", "this", "->", "_printError", "(", "self", "::", "ERROR_EMPTY_SERVICE_NAME", ")", ";", "}", "else", "{", "$", "this", "->", "_filePutContents", "(", "$", "migrationsPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "name", ".", "'.ini'", ",", "implode", "(", "\"\\n\"", ",", "[", "\"; File $name.ini by \"", ".", "(", "getenv", "(", "'USERNAME'", ")", "?", ":", "getenv", "(", "'USER'", ")", "?", ":", "'unknown user'", ")", ",", "''", ",", "'['", ".", "self", "::", "INI_SECTION_MIGRATION", ".", "']'", ",", "self", "::", "INI_KEY_CREATED", ".", "'=\"'", ".", "date", "(", "'Y-m-d H:i O'", ")", ".", "'\"'", ",", "self", "::", "INI_KEY_SERVICE", ".", "'=\"'", ".", "$", "service", ".", "'\"'", ",", "''", ",", "'['", ".", "self", "::", "INI_SECTION_ACTIONS", ".", "']'", ",", "'a001=\"php> echo \\'Migration applied!\\'.PHP_EOL;\"'", ",", "'r001=\"php> echo \\'Migration rejected!\\'.PHP_EOL;\"'", ",", "''", ",", "]", ")", ")", ";", "}", "$", "this", "->", "notify", "(", "self", "::", "STATE_COMPLETE", ")", ";", "}", "catch", "(", "Exception", "$", "exception", ")", "{", "$", "this", "->", "_printError", "(", "$", "exception", ")", ";", "$", "this", "->", "notify", "(", "self", "::", "STATE_COMPLETE", ")", ";", "}", "finally", "{", "$", "this", "->", "_stateMigrationName", "=", "null", ";", "$", "this", "->", "_state", "=", "self", "::", "STATE_INITIALIZED", ";", "$", "this", "->", "_dispatcher", "->", "dispatch", "(", "self", "::", "EVENT_FREE_SERVICE", ",", "OnFreeService", "::", "create", "(", ")", ")", ";", "}", "}" ]
Create INI file template for new migration. @param callable $callbackAskNameAndService
[ "Create", "INI", "file", "template", "for", "new", "migration", "." ]
0f3ec5d61fce9df3cfc4102e0fa42ad856bda460
https://github.com/Moro4125/team-migrations-common/blob/0f3ec5d61fce9df3cfc4102e0fa42ad856bda460/sources/MigrationManager.php#L409-L471
train
Moro4125/team-migrations-common
sources/MigrationManager.php
MigrationManager.doStatus
public function doStatus() { assert($this->_dispatcher); assert($this->_container); $this->_clearStatProperties(); $this->_dispatcher->dispatch(self::EVENT_INIT_SERVICE, OnInitService::create()); try { $this->notify(self::STATE_FIRED); $modulesAndFiles = $this->_findModulesAndMigrationFiles(); $migrations = $this->_parseMigrationFiles($modulesAndFiles); $this->notify(self::STATE_FIND_MIGRATIONS); $actions = $this->_askMigrationList($modulesAndFiles, $migrations); $actions = $this->_sortMigrationsList($actions); $this->notify(self::STATE_MIGRATIONS_ASKED); $states = [self::STATE_MIGRATION_STORED, self::STATE_MIGRATION_ROLLBACK, self::STATE_MIGRATION_APPLY]; foreach (array_combine($states, [$actions[2], $actions[0], $actions[1]]) as $state => $migrations) { foreach (array_keys($migrations) as $migrationName) { $this->_stateMigrationName = $migrationName; $this->notify($state); } } $this->notify(self::STATE_COMPLETE); } catch (Exception $exception) { $this->_printError($exception); $this->notify(self::STATE_COMPLETE); } finally { $this->_stateMigrationName = null; $this->_state = self::STATE_INITIALIZED; $this->_dispatcher->dispatch(self::EVENT_FREE_SERVICE, OnFreeService::create()); } }
php
public function doStatus() { assert($this->_dispatcher); assert($this->_container); $this->_clearStatProperties(); $this->_dispatcher->dispatch(self::EVENT_INIT_SERVICE, OnInitService::create()); try { $this->notify(self::STATE_FIRED); $modulesAndFiles = $this->_findModulesAndMigrationFiles(); $migrations = $this->_parseMigrationFiles($modulesAndFiles); $this->notify(self::STATE_FIND_MIGRATIONS); $actions = $this->_askMigrationList($modulesAndFiles, $migrations); $actions = $this->_sortMigrationsList($actions); $this->notify(self::STATE_MIGRATIONS_ASKED); $states = [self::STATE_MIGRATION_STORED, self::STATE_MIGRATION_ROLLBACK, self::STATE_MIGRATION_APPLY]; foreach (array_combine($states, [$actions[2], $actions[0], $actions[1]]) as $state => $migrations) { foreach (array_keys($migrations) as $migrationName) { $this->_stateMigrationName = $migrationName; $this->notify($state); } } $this->notify(self::STATE_COMPLETE); } catch (Exception $exception) { $this->_printError($exception); $this->notify(self::STATE_COMPLETE); } finally { $this->_stateMigrationName = null; $this->_state = self::STATE_INITIALIZED; $this->_dispatcher->dispatch(self::EVENT_FREE_SERVICE, OnFreeService::create()); } }
[ "public", "function", "doStatus", "(", ")", "{", "assert", "(", "$", "this", "->", "_dispatcher", ")", ";", "assert", "(", "$", "this", "->", "_container", ")", ";", "$", "this", "->", "_clearStatProperties", "(", ")", ";", "$", "this", "->", "_dispatcher", "->", "dispatch", "(", "self", "::", "EVENT_INIT_SERVICE", ",", "OnInitService", "::", "create", "(", ")", ")", ";", "try", "{", "$", "this", "->", "notify", "(", "self", "::", "STATE_FIRED", ")", ";", "$", "modulesAndFiles", "=", "$", "this", "->", "_findModulesAndMigrationFiles", "(", ")", ";", "$", "migrations", "=", "$", "this", "->", "_parseMigrationFiles", "(", "$", "modulesAndFiles", ")", ";", "$", "this", "->", "notify", "(", "self", "::", "STATE_FIND_MIGRATIONS", ")", ";", "$", "actions", "=", "$", "this", "->", "_askMigrationList", "(", "$", "modulesAndFiles", ",", "$", "migrations", ")", ";", "$", "actions", "=", "$", "this", "->", "_sortMigrationsList", "(", "$", "actions", ")", ";", "$", "this", "->", "notify", "(", "self", "::", "STATE_MIGRATIONS_ASKED", ")", ";", "$", "states", "=", "[", "self", "::", "STATE_MIGRATION_STORED", ",", "self", "::", "STATE_MIGRATION_ROLLBACK", ",", "self", "::", "STATE_MIGRATION_APPLY", "]", ";", "foreach", "(", "array_combine", "(", "$", "states", ",", "[", "$", "actions", "[", "2", "]", ",", "$", "actions", "[", "0", "]", ",", "$", "actions", "[", "1", "]", "]", ")", "as", "$", "state", "=>", "$", "migrations", ")", "{", "foreach", "(", "array_keys", "(", "$", "migrations", ")", "as", "$", "migrationName", ")", "{", "$", "this", "->", "_stateMigrationName", "=", "$", "migrationName", ";", "$", "this", "->", "notify", "(", "$", "state", ")", ";", "}", "}", "$", "this", "->", "notify", "(", "self", "::", "STATE_COMPLETE", ")", ";", "}", "catch", "(", "Exception", "$", "exception", ")", "{", "$", "this", "->", "_printError", "(", "$", "exception", ")", ";", "$", "this", "->", "notify", "(", "self", "::", "STATE_COMPLETE", ")", ";", "}", "finally", "{", "$", "this", "->", "_stateMigrationName", "=", "null", ";", "$", "this", "->", "_state", "=", "self", "::", "STATE_INITIALIZED", ";", "$", "this", "->", "_dispatcher", "->", "dispatch", "(", "self", "::", "EVENT_FREE_SERVICE", ",", "OnFreeService", "::", "create", "(", ")", ")", ";", "}", "}" ]
Execute status command.
[ "Execute", "status", "command", "." ]
0f3ec5d61fce9df3cfc4102e0fa42ad856bda460
https://github.com/Moro4125/team-migrations-common/blob/0f3ec5d61fce9df3cfc4102e0fa42ad856bda460/sources/MigrationManager.php#L488-L534
train
Moro4125/team-migrations-common
sources/MigrationManager.php
MigrationManager.notify
public function notify($state = null) { assert($state === null || is_int($state)); $this->_state = intval($state) ?: $this->_state; /** @var \SplObserver $observer */ foreach ($this->_observers as $observer) { $observer->update($this); } }
php
public function notify($state = null) { assert($state === null || is_int($state)); $this->_state = intval($state) ?: $this->_state; /** @var \SplObserver $observer */ foreach ($this->_observers as $observer) { $observer->update($this); } }
[ "public", "function", "notify", "(", "$", "state", "=", "null", ")", "{", "assert", "(", "$", "state", "===", "null", "||", "is_int", "(", "$", "state", ")", ")", ";", "$", "this", "->", "_state", "=", "intval", "(", "$", "state", ")", "?", ":", "$", "this", "->", "_state", ";", "/** @var \\SplObserver $observer */", "foreach", "(", "$", "this", "->", "_observers", "as", "$", "observer", ")", "{", "$", "observer", "->", "update", "(", "$", "this", ")", ";", "}", "}" ]
Notify any observers about state change. @param null|int $state
[ "Notify", "any", "observers", "about", "state", "change", "." ]
0f3ec5d61fce9df3cfc4102e0fa42ad856bda460
https://github.com/Moro4125/team-migrations-common/blob/0f3ec5d61fce9df3cfc4102e0fa42ad856bda460/sources/MigrationManager.php#L630-L640
train
Moro4125/team-migrations-common
sources/MigrationManager.php
MigrationManager._clearStatProperties
protected function _clearStatProperties() { $this->_statErrors = 0; $this->_statMigrationsTotal = 0; $this->_statMigrationForCommit = 0; $this->_statMigrationForRollback = 0; $this->_statMigrationRejected = 0; $this->_statMigrationApplied = 0; }
php
protected function _clearStatProperties() { $this->_statErrors = 0; $this->_statMigrationsTotal = 0; $this->_statMigrationForCommit = 0; $this->_statMigrationForRollback = 0; $this->_statMigrationRejected = 0; $this->_statMigrationApplied = 0; }
[ "protected", "function", "_clearStatProperties", "(", ")", "{", "$", "this", "->", "_statErrors", "=", "0", ";", "$", "this", "->", "_statMigrationsTotal", "=", "0", ";", "$", "this", "->", "_statMigrationForCommit", "=", "0", ";", "$", "this", "->", "_statMigrationForRollback", "=", "0", ";", "$", "this", "->", "_statMigrationRejected", "=", "0", ";", "$", "this", "->", "_statMigrationApplied", "=", "0", ";", "}" ]
Reset properties with statistic information.
[ "Reset", "properties", "with", "statistic", "information", "." ]
0f3ec5d61fce9df3cfc4102e0fa42ad856bda460
https://github.com/Moro4125/team-migrations-common/blob/0f3ec5d61fce9df3cfc4102e0fa42ad856bda460/sources/MigrationManager.php#L645-L653
train
SandratraRM/mora-core
src/Control/Controller.php
Controller.doAction
public function doAction($action,$params){ if(method_exists($this,$action)){ $this->$action($params); } else{ $this->ActionNotFound($action,$params); } }
php
public function doAction($action,$params){ if(method_exists($this,$action)){ $this->$action($params); } else{ $this->ActionNotFound($action,$params); } }
[ "public", "function", "doAction", "(", "$", "action", ",", "$", "params", ")", "{", "if", "(", "method_exists", "(", "$", "this", ",", "$", "action", ")", ")", "{", "$", "this", "->", "$", "action", "(", "$", "params", ")", ";", "}", "else", "{", "$", "this", "->", "ActionNotFound", "(", "$", "action", ",", "$", "params", ")", ";", "}", "}" ]
Execute the action if it exists, else calling ActionNotFound method @param string $action The action name @param array $params An array that olds the arguments part of the request
[ "Execute", "the", "action", "if", "it", "exists", "else", "calling", "ActionNotFound", "method" ]
9cd8e16e4b619798a51dc2ac66ddd8d22caf7baa
https://github.com/SandratraRM/mora-core/blob/9cd8e16e4b619798a51dc2ac66ddd8d22caf7baa/src/Control/Controller.php#L16-L23
train
translationexchange/tml-php-clientsdk
library/Tr8n/Tokens/DecorationTokenizer.php
DecorationTokenizer.fragmentize
public function fragmentize() { $re = implode('|', array( self::RE_SHORT_TOKEN_START, self::RE_SHORT_TOKEN_END, self::RE_LONG_TOKEN_START, self::RE_LONG_TOKEN_END, self::RE_TEXT )); preg_match_all('/'.$re.'/', $this->text, $matches); $this->fragments = $matches[0]; $this->tokens = array(); }
php
public function fragmentize() { $re = implode('|', array( self::RE_SHORT_TOKEN_START, self::RE_SHORT_TOKEN_END, self::RE_LONG_TOKEN_START, self::RE_LONG_TOKEN_END, self::RE_TEXT )); preg_match_all('/'.$re.'/', $this->text, $matches); $this->fragments = $matches[0]; $this->tokens = array(); }
[ "public", "function", "fragmentize", "(", ")", "{", "$", "re", "=", "implode", "(", "'|'", ",", "array", "(", "self", "::", "RE_SHORT_TOKEN_START", ",", "self", "::", "RE_SHORT_TOKEN_END", ",", "self", "::", "RE_LONG_TOKEN_START", ",", "self", "::", "RE_LONG_TOKEN_END", ",", "self", "::", "RE_TEXT", ")", ")", ";", "preg_match_all", "(", "'/'", ".", "$", "re", ".", "'/'", ",", "$", "this", "->", "text", ",", "$", "matches", ")", ";", "$", "this", "->", "fragments", "=", "$", "matches", "[", "0", "]", ";", "$", "this", "->", "tokens", "=", "array", "(", ")", ";", "}" ]
Splits texts into fragments, where some fragments are tokens, others are text
[ "Splits", "texts", "into", "fragments", "where", "some", "fragments", "are", "tokens", "others", "are", "text" ]
fe51473824e62cfd883c6aa0c6a3783a16ce8425
https://github.com/translationexchange/tml-php-clientsdk/blob/fe51473824e62cfd883c6aa0c6a3783a16ce8425/library/Tr8n/Tokens/DecorationTokenizer.php#L105-L115
train
PenoaksDev/Milky-Framework
src/Milky/Facades/View.php
View.escape
public static function escape( $value ) { if ( $value instanceof Htmlable ) return $value->toHtml(); return htmlentities( $value, ENT_QUOTES, 'UTF-8', false ); }
php
public static function escape( $value ) { if ( $value instanceof Htmlable ) return $value->toHtml(); return htmlentities( $value, ENT_QUOTES, 'UTF-8', false ); }
[ "public", "static", "function", "escape", "(", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "Htmlable", ")", "return", "$", "value", "->", "toHtml", "(", ")", ";", "return", "htmlentities", "(", "$", "value", ",", "ENT_QUOTES", ",", "'UTF-8'", ",", "false", ")", ";", "}" ]
Escape HTML entities in a string. @param Htmlable|string $value @return string
[ "Escape", "HTML", "entities", "in", "a", "string", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Facades/View.php#L489-L495
train
marando/Units
src/Marando/Units/Angle.php
Angle.dms
public static function dms($d, $m = 0, $s = 0, $f = 0) { $asec = static::dmsf2asec($d, $m, $s, $f); return static::mas($asec * 1000); }
php
public static function dms($d, $m = 0, $s = 0, $f = 0) { $asec = static::dmsf2asec($d, $m, $s, $f); return static::mas($asec * 1000); }
[ "public", "static", "function", "dms", "(", "$", "d", ",", "$", "m", "=", "0", ",", "$", "s", "=", "0", ",", "$", "f", "=", "0", ")", "{", "$", "asec", "=", "static", "::", "dmsf2asec", "(", "$", "d", ",", "$", "m", ",", "$", "s", ",", "$", "f", ")", ";", "return", "static", "::", "mas", "(", "$", "asec", "*", "1000", ")", ";", "}" ]
Creates a new angle from degree, arcminute and arcsecond components. @param int $d Degree component @param int $m Arcminute component @param int|double $s Arcsecond component @param int|double $f Fractional arcsecond component @return static
[ "Creates", "a", "new", "angle", "from", "degree", "arcminute", "and", "arcsecond", "components", "." ]
1721f16a2fdbd3fd8acb9061d393ce9ef1ce6e70
https://github.com/marando/Units/blob/1721f16a2fdbd3fd8acb9061d393ce9ef1ce6e70/src/Marando/Units/Angle.php#L122-L127
train
marando/Units
src/Marando/Units/Angle.php
Angle.time
public static function time(Time $time, Time $interval = null) { $secInDay = Time::days(1)->sec; $interval = $interval ? $interval->sec : $secInDay; return static::deg($time->sec / $interval * 360); }
php
public static function time(Time $time, Time $interval = null) { $secInDay = Time::days(1)->sec; $interval = $interval ? $interval->sec : $secInDay; return static::deg($time->sec / $interval * 360); }
[ "public", "static", "function", "time", "(", "Time", "$", "time", ",", "Time", "$", "interval", "=", "null", ")", "{", "$", "secInDay", "=", "Time", "::", "days", "(", "1", ")", "->", "sec", ";", "$", "interval", "=", "$", "interval", "?", "$", "interval", "->", "sec", ":", "$", "secInDay", ";", "return", "static", "::", "deg", "(", "$", "time", "->", "sec", "/", "$", "interval", "*", "360", ")", ";", "}" ]
Creates a new angle equal to the number of revolutions of a duration of time within a specified time interval. @param Time $time @param Time $interval @return Angle
[ "Creates", "a", "new", "angle", "equal", "to", "the", "number", "of", "revolutions", "of", "a", "duration", "of", "time", "within", "a", "specified", "time", "interval", "." ]
1721f16a2fdbd3fd8acb9061d393ce9ef1ce6e70
https://github.com/marando/Units/blob/1721f16a2fdbd3fd8acb9061d393ce9ef1ce6e70/src/Marando/Units/Angle.php#L174-L180
train
marando/Units
src/Marando/Units/Angle.php
Angle.atan2
public static function atan2($y, $x) { $y = $y instanceof Angle ? $y->rad : $y; $x = $x instanceof Angle ? $x->rad : $x; return static::rad(atan2($y, $x)); }
php
public static function atan2($y, $x) { $y = $y instanceof Angle ? $y->rad : $y; $x = $x instanceof Angle ? $x->rad : $x; return static::rad(atan2($y, $x)); }
[ "public", "static", "function", "atan2", "(", "$", "y", ",", "$", "x", ")", "{", "$", "y", "=", "$", "y", "instanceof", "Angle", "?", "$", "y", "->", "rad", ":", "$", "y", ";", "$", "x", "=", "$", "x", "instanceof", "Angle", "?", "$", "x", "->", "rad", ":", "$", "x", ";", "return", "static", "::", "rad", "(", "atan2", "(", "$", "y", ",", "$", "x", ")", ")", ";", "}" ]
Creates a new angle from the arc tangent of two Angle instances or float values expressed in radians. @param float|Angle $y Dividend @param float|Angle $x Divisor @return static
[ "Creates", "a", "new", "angle", "from", "the", "arc", "tangent", "of", "two", "Angle", "instances", "or", "float", "values", "expressed", "in", "radians", "." ]
1721f16a2fdbd3fd8acb9061d393ce9ef1ce6e70
https://github.com/marando/Units/blob/1721f16a2fdbd3fd8acb9061d393ce9ef1ce6e70/src/Marando/Units/Angle.php#L201-L207
train
marando/Units
src/Marando/Units/Angle.php
Angle.toTime
public function toTime(Time $interval = null) { $secInDay = Time::days(1)->sec; $interval = $interval ? $interval->sec : $secInDay; return Time::sec(($this->deg / 360) * $interval); }
php
public function toTime(Time $interval = null) { $secInDay = Time::days(1)->sec; $interval = $interval ? $interval->sec : $secInDay; return Time::sec(($this->deg / 360) * $interval); }
[ "public", "function", "toTime", "(", "Time", "$", "interval", "=", "null", ")", "{", "$", "secInDay", "=", "Time", "::", "days", "(", "1", ")", "->", "sec", ";", "$", "interval", "=", "$", "interval", "?", "$", "interval", "->", "sec", ":", "$", "secInDay", ";", "return", "Time", "::", "sec", "(", "(", "$", "this", "->", "deg", "/", "360", ")", "*", "$", "interval", ")", ";", "}" ]
Converts this instance to a proportion of time passed within a specified time interval where 360 degrees is equal to the interval. @param Time $interval @return Time
[ "Converts", "this", "instance", "to", "a", "proportion", "of", "time", "passed", "within", "a", "specified", "time", "interval", "where", "360", "degrees", "is", "equal", "to", "the", "interval", "." ]
1721f16a2fdbd3fd8acb9061d393ce9ef1ce6e70
https://github.com/marando/Units/blob/1721f16a2fdbd3fd8acb9061d393ce9ef1ce6e70/src/Marando/Units/Angle.php#L339-L345
train
modulusphp/support
Mix.php
Mix.make
public static function make(string $path, string $manifestDirectory) : string { static $manifest; if ($manifestDirectory && strpos($manifestDirectory, DIRECTORY_SEPARATOR) !== 0) { $manifestDirectory = DIRECTORY_SEPARATOR . "{$manifestDirectory}"; } if (!$manifest) { if (!file_exists($manifestPath = (DEPConfig::$appdir . 'public' . DIRECTORY_SEPARATOR . 'mix-manifest.json') )) { throw new MixException('The Mix manifest does not exist.'); } $manifest = json_decode(file_get_contents($manifestPath), true); } if (strpos($path, DIRECTORY_SEPARATOR) !== 0) { $path = DIRECTORY_SEPARATOR . "{$path}"; } if (! array_key_exists($path, $manifest)) { throw new MixException( "Unable to locate Mix file: $path. Please check your ". 'webpack.mix.js output paths and try again.' ); } return $manifest[$path]; }
php
public static function make(string $path, string $manifestDirectory) : string { static $manifest; if ($manifestDirectory && strpos($manifestDirectory, DIRECTORY_SEPARATOR) !== 0) { $manifestDirectory = DIRECTORY_SEPARATOR . "{$manifestDirectory}"; } if (!$manifest) { if (!file_exists($manifestPath = (DEPConfig::$appdir . 'public' . DIRECTORY_SEPARATOR . 'mix-manifest.json') )) { throw new MixException('The Mix manifest does not exist.'); } $manifest = json_decode(file_get_contents($manifestPath), true); } if (strpos($path, DIRECTORY_SEPARATOR) !== 0) { $path = DIRECTORY_SEPARATOR . "{$path}"; } if (! array_key_exists($path, $manifest)) { throw new MixException( "Unable to locate Mix file: $path. Please check your ". 'webpack.mix.js output paths and try again.' ); } return $manifest[$path]; }
[ "public", "static", "function", "make", "(", "string", "$", "path", ",", "string", "$", "manifestDirectory", ")", ":", "string", "{", "static", "$", "manifest", ";", "if", "(", "$", "manifestDirectory", "&&", "strpos", "(", "$", "manifestDirectory", ",", "DIRECTORY_SEPARATOR", ")", "!==", "0", ")", "{", "$", "manifestDirectory", "=", "DIRECTORY_SEPARATOR", ".", "\"{$manifestDirectory}\"", ";", "}", "if", "(", "!", "$", "manifest", ")", "{", "if", "(", "!", "file_exists", "(", "$", "manifestPath", "=", "(", "DEPConfig", "::", "$", "appdir", ".", "'public'", ".", "DIRECTORY_SEPARATOR", ".", "'mix-manifest.json'", ")", ")", ")", "{", "throw", "new", "MixException", "(", "'The Mix manifest does not exist.'", ")", ";", "}", "$", "manifest", "=", "json_decode", "(", "file_get_contents", "(", "$", "manifestPath", ")", ",", "true", ")", ";", "}", "if", "(", "strpos", "(", "$", "path", ",", "DIRECTORY_SEPARATOR", ")", "!==", "0", ")", "{", "$", "path", "=", "DIRECTORY_SEPARATOR", ".", "\"{$path}\"", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "path", ",", "$", "manifest", ")", ")", "{", "throw", "new", "MixException", "(", "\"Unable to locate Mix file: $path. Please check your \"", ".", "'webpack.mix.js output paths and try again.'", ")", ";", "}", "return", "$", "manifest", "[", "$", "path", "]", ";", "}" ]
Get mix file @param string $path @param string $manifestDirectory @return string $manifest[$path]
[ "Get", "mix", "file" ]
b5c5b48dcbeb379e6cd1f29159dc8cdacef3adab
https://github.com/modulusphp/support/blob/b5c5b48dcbeb379e6cd1f29159dc8cdacef3adab/Mix.php#L17-L43
train
indigoram89/laravel-fields
src/HasFields.php
HasFields.field
public function field(string $key, $value = null, $description = null) { if ( ! $field = $this->fields->where('key', $key)->first()) { $this->fields->push( $field = $this->fields()->firstOrNew(compact('key')) ); } $field->setDefaultValue($value); $field->setDefaultDescription($description); $field->save(); return $field; }
php
public function field(string $key, $value = null, $description = null) { if ( ! $field = $this->fields->where('key', $key)->first()) { $this->fields->push( $field = $this->fields()->firstOrNew(compact('key')) ); } $field->setDefaultValue($value); $field->setDefaultDescription($description); $field->save(); return $field; }
[ "public", "function", "field", "(", "string", "$", "key", ",", "$", "value", "=", "null", ",", "$", "description", "=", "null", ")", "{", "if", "(", "!", "$", "field", "=", "$", "this", "->", "fields", "->", "where", "(", "'key'", ",", "$", "key", ")", "->", "first", "(", ")", ")", "{", "$", "this", "->", "fields", "->", "push", "(", "$", "field", "=", "$", "this", "->", "fields", "(", ")", "->", "firstOrNew", "(", "compact", "(", "'key'", ")", ")", ")", ";", "}", "$", "field", "->", "setDefaultValue", "(", "$", "value", ")", ";", "$", "field", "->", "setDefaultDescription", "(", "$", "description", ")", ";", "$", "field", "->", "save", "(", ")", ";", "return", "$", "field", ";", "}" ]
Get or create a field. @param string $key @param string|array|null $value @param string|array|null $description @return \Indigoram89\Fields\Field
[ "Get", "or", "create", "a", "field", "." ]
1cb34eb4e653b82577531951ed94bd73a1009112
https://github.com/indigoram89/laravel-fields/blob/1cb34eb4e653b82577531951ed94bd73a1009112/src/HasFields.php#L27-L41
train
vukbgit/PHPCraft.Subject
src/Traits/CRUD.php
CRUD.extractPrimaryKeyValue
protected function extractPrimaryKeyValue($record, $returnAs) { $record = (object) $record; $values = []; foreach((array) $this->ORMParameters['primaryKey'] as $field) { $values[$field] = $record->$field; } switch($returnAs) { case 's': return implode('|', $values); break; case 'a': return $values; break; } }
php
protected function extractPrimaryKeyValue($record, $returnAs) { $record = (object) $record; $values = []; foreach((array) $this->ORMParameters['primaryKey'] as $field) { $values[$field] = $record->$field; } switch($returnAs) { case 's': return implode('|', $values); break; case 'a': return $values; break; } }
[ "protected", "function", "extractPrimaryKeyValue", "(", "$", "record", ",", "$", "returnAs", ")", "{", "$", "record", "=", "(", "object", ")", "$", "record", ";", "$", "values", "=", "[", "]", ";", "foreach", "(", "(", "array", ")", "$", "this", "->", "ORMParameters", "[", "'primaryKey'", "]", "as", "$", "field", ")", "{", "$", "values", "[", "$", "field", "]", "=", "$", "record", "->", "$", "field", ";", "}", "switch", "(", "$", "returnAs", ")", "{", "case", "'s'", ":", "return", "implode", "(", "'|'", ",", "$", "values", ")", ";", "break", ";", "case", "'a'", ":", "return", "$", "values", ";", "break", ";", "}", "}" ]
Builds primary key value for a record @param mixed $record array or object with record data; @param string $returnAs s = string (imploded by | in case of composite key) | a = array
[ "Builds", "primary", "key", "value", "for", "a", "record" ]
a43ad7868098ff1e7bda6819547ea64f9a853732
https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Traits/CRUD.php#L93-L108
train
vukbgit/PHPCraft.Subject
src/Traits/CRUD.php
CRUD.purgePrimaryKeyValue
protected function purgePrimaryKeyValue(&$record) { foreach((array) $this->ORMParameters['primaryKey'] as $field) { if(is_array($record) && (isset($record[$field]) || $record[$field] === null)) { unset($record[$field]); } elseif(is_object($record) && isset($record->$field) ) { unset($record->$field); } } }
php
protected function purgePrimaryKeyValue(&$record) { foreach((array) $this->ORMParameters['primaryKey'] as $field) { if(is_array($record) && (isset($record[$field]) || $record[$field] === null)) { unset($record[$field]); } elseif(is_object($record) && isset($record->$field) ) { unset($record->$field); } } }
[ "protected", "function", "purgePrimaryKeyValue", "(", "&", "$", "record", ")", "{", "foreach", "(", "(", "array", ")", "$", "this", "->", "ORMParameters", "[", "'primaryKey'", "]", "as", "$", "field", ")", "{", "if", "(", "is_array", "(", "$", "record", ")", "&&", "(", "isset", "(", "$", "record", "[", "$", "field", "]", ")", "||", "$", "record", "[", "$", "field", "]", "===", "null", ")", ")", "{", "unset", "(", "$", "record", "[", "$", "field", "]", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "record", ")", "&&", "isset", "(", "$", "record", "->", "$", "field", ")", ")", "{", "unset", "(", "$", "record", "->", "$", "field", ")", ";", "}", "}", "}" ]
Purges primary key value for a record @param mixed $record array or object with record data
[ "Purges", "primary", "key", "value", "for", "a", "record" ]
a43ad7868098ff1e7bda6819547ea64f9a853732
https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Traits/CRUD.php#L114-L123
train
vukbgit/PHPCraft.Subject
src/Traits/CRUD.php
CRUD.execList
protected function execList() { //check if parent primary key is into route if(!empty($this->ancestors)) { end($this->ancestors); $parentPrimaryKey = current($this->ancestors); } else { $parentPrimaryKey = []; } //get records $this->templateParameters['records'] = $this->get($parentPrimaryKey); // form translations $this->loadTranslations('list', sprintf('private/global/locales/%s/list.ini', LANGUAGE)); //get table filter $this->templateParameters['table_filter'] = []; $this->templateParameters['table_filter']['field'] = $this->cookies->get(sprintf('table_filter_%s_field', $this->name)); $this->templateParameters['table_filter']['input'] = $this->cookies->get(sprintf('table_filter_%s_input', $this->name)); //render $this->renderTemplate(); }
php
protected function execList() { //check if parent primary key is into route if(!empty($this->ancestors)) { end($this->ancestors); $parentPrimaryKey = current($this->ancestors); } else { $parentPrimaryKey = []; } //get records $this->templateParameters['records'] = $this->get($parentPrimaryKey); // form translations $this->loadTranslations('list', sprintf('private/global/locales/%s/list.ini', LANGUAGE)); //get table filter $this->templateParameters['table_filter'] = []; $this->templateParameters['table_filter']['field'] = $this->cookies->get(sprintf('table_filter_%s_field', $this->name)); $this->templateParameters['table_filter']['input'] = $this->cookies->get(sprintf('table_filter_%s_input', $this->name)); //render $this->renderTemplate(); }
[ "protected", "function", "execList", "(", ")", "{", "//check if parent primary key is into route", "if", "(", "!", "empty", "(", "$", "this", "->", "ancestors", ")", ")", "{", "end", "(", "$", "this", "->", "ancestors", ")", ";", "$", "parentPrimaryKey", "=", "current", "(", "$", "this", "->", "ancestors", ")", ";", "}", "else", "{", "$", "parentPrimaryKey", "=", "[", "]", ";", "}", "//get records", "$", "this", "->", "templateParameters", "[", "'records'", "]", "=", "$", "this", "->", "get", "(", "$", "parentPrimaryKey", ")", ";", "// form translations", "$", "this", "->", "loadTranslations", "(", "'list'", ",", "sprintf", "(", "'private/global/locales/%s/list.ini'", ",", "LANGUAGE", ")", ")", ";", "//get table filter", "$", "this", "->", "templateParameters", "[", "'table_filter'", "]", "=", "[", "]", ";", "$", "this", "->", "templateParameters", "[", "'table_filter'", "]", "[", "'field'", "]", "=", "$", "this", "->", "cookies", "->", "get", "(", "sprintf", "(", "'table_filter_%s_field'", ",", "$", "this", "->", "name", ")", ")", ";", "$", "this", "->", "templateParameters", "[", "'table_filter'", "]", "[", "'input'", "]", "=", "$", "this", "->", "cookies", "->", "get", "(", "sprintf", "(", "'table_filter_%s_input'", ",", "$", "this", "->", "name", ")", ")", ";", "//render", "$", "this", "->", "renderTemplate", "(", ")", ";", "}" ]
Displays list table
[ "Displays", "list", "table" ]
a43ad7868098ff1e7bda6819547ea64f9a853732
https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Traits/CRUD.php#L128-L147
train
vukbgit/PHPCraft.Subject
src/Traits/CRUD.php
CRUD.execInsertForm
protected function execInsertForm() { // form translations $this->loadTranslations('form', sprintf('private/global/locales/%s/form.ini', LANGUAGE)); // render template $this->renderTemplate(sprintf('%s/%s/save-form', AREA, $this->name)); }
php
protected function execInsertForm() { // form translations $this->loadTranslations('form', sprintf('private/global/locales/%s/form.ini', LANGUAGE)); // render template $this->renderTemplate(sprintf('%s/%s/save-form', AREA, $this->name)); }
[ "protected", "function", "execInsertForm", "(", ")", "{", "// form translations", "$", "this", "->", "loadTranslations", "(", "'form'", ",", "sprintf", "(", "'private/global/locales/%s/form.ini'", ",", "LANGUAGE", ")", ")", ";", "// render template", "$", "this", "->", "renderTemplate", "(", "sprintf", "(", "'%s/%s/save-form'", ",", "AREA", ",", "$", "this", "->", "name", ")", ")", ";", "}" ]
Displays insert form
[ "Displays", "insert", "form" ]
a43ad7868098ff1e7bda6819547ea64f9a853732
https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Traits/CRUD.php#L152-L158
train
vukbgit/PHPCraft.Subject
src/Traits/CRUD.php
CRUD.execUpdateForm
protected function execUpdateForm() { // form translations $this->loadTranslations('form', sprintf('private/global/locales/%s/form.ini', LANGUAGE)); // get record $this->templateParameters['record'] = $this->getByPrimaryKey($this->primaryKeyValue); // render template $this->renderTemplate(sprintf('%s/%s/save-form', AREA, $this->name)); }
php
protected function execUpdateForm() { // form translations $this->loadTranslations('form', sprintf('private/global/locales/%s/form.ini', LANGUAGE)); // get record $this->templateParameters['record'] = $this->getByPrimaryKey($this->primaryKeyValue); // render template $this->renderTemplate(sprintf('%s/%s/save-form', AREA, $this->name)); }
[ "protected", "function", "execUpdateForm", "(", ")", "{", "// form translations", "$", "this", "->", "loadTranslations", "(", "'form'", ",", "sprintf", "(", "'private/global/locales/%s/form.ini'", ",", "LANGUAGE", ")", ")", ";", "// get record", "$", "this", "->", "templateParameters", "[", "'record'", "]", "=", "$", "this", "->", "getByPrimaryKey", "(", "$", "this", "->", "primaryKeyValue", ")", ";", "// render template", "$", "this", "->", "renderTemplate", "(", "sprintf", "(", "'%s/%s/save-form'", ",", "AREA", ",", "$", "this", "->", "name", ")", ")", ";", "}" ]
Displays update form
[ "Displays", "update", "form" ]
a43ad7868098ff1e7bda6819547ea64f9a853732
https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Traits/CRUD.php#L163-L171
train
vukbgit/PHPCraft.Subject
src/Traits/CRUD.php
CRUD.execInsert
public function execInsert($redirectAction = false) { // database translations $this->loadTranslations('database', sprintf('private/global/locales/%s/database.ini', LANGUAGE)); //validate and extract input $input = $this->processSaveInput(filter_input_array(INPUT_POST, $this->configuration['subjects'][$this->name]['CRUD']['inputFields'])); if($input) { try{ //ORM update $this->purgePrimaryKeyValue($input); if($this->insert($input)) { $this->messages->save('cookies','success',sprintf($this->translations[$this->name]['CRUD']['insert-success'], $this->translations[$this->name]['singular'])); } } catch(\PDOException $exception) { $this->messages->save('cookies', 'danger', $this->handleError($exception)); if(!isset($redirectAction)) { $redirectAction = 'insert-form'; } } } //redirect $redirectAction = $redirectAction ? $redirectAction : 'list'; $this->httpResponse = $this->httpResponse->withHeader('Location', $redirectAction); }
php
public function execInsert($redirectAction = false) { // database translations $this->loadTranslations('database', sprintf('private/global/locales/%s/database.ini', LANGUAGE)); //validate and extract input $input = $this->processSaveInput(filter_input_array(INPUT_POST, $this->configuration['subjects'][$this->name]['CRUD']['inputFields'])); if($input) { try{ //ORM update $this->purgePrimaryKeyValue($input); if($this->insert($input)) { $this->messages->save('cookies','success',sprintf($this->translations[$this->name]['CRUD']['insert-success'], $this->translations[$this->name]['singular'])); } } catch(\PDOException $exception) { $this->messages->save('cookies', 'danger', $this->handleError($exception)); if(!isset($redirectAction)) { $redirectAction = 'insert-form'; } } } //redirect $redirectAction = $redirectAction ? $redirectAction : 'list'; $this->httpResponse = $this->httpResponse->withHeader('Location', $redirectAction); }
[ "public", "function", "execInsert", "(", "$", "redirectAction", "=", "false", ")", "{", "// database translations", "$", "this", "->", "loadTranslations", "(", "'database'", ",", "sprintf", "(", "'private/global/locales/%s/database.ini'", ",", "LANGUAGE", ")", ")", ";", "//validate and extract input", "$", "input", "=", "$", "this", "->", "processSaveInput", "(", "filter_input_array", "(", "INPUT_POST", ",", "$", "this", "->", "configuration", "[", "'subjects'", "]", "[", "$", "this", "->", "name", "]", "[", "'CRUD'", "]", "[", "'inputFields'", "]", ")", ")", ";", "if", "(", "$", "input", ")", "{", "try", "{", "//ORM update", "$", "this", "->", "purgePrimaryKeyValue", "(", "$", "input", ")", ";", "if", "(", "$", "this", "->", "insert", "(", "$", "input", ")", ")", "{", "$", "this", "->", "messages", "->", "save", "(", "'cookies'", ",", "'success'", ",", "sprintf", "(", "$", "this", "->", "translations", "[", "$", "this", "->", "name", "]", "[", "'CRUD'", "]", "[", "'insert-success'", "]", ",", "$", "this", "->", "translations", "[", "$", "this", "->", "name", "]", "[", "'singular'", "]", ")", ")", ";", "}", "}", "catch", "(", "\\", "PDOException", "$", "exception", ")", "{", "$", "this", "->", "messages", "->", "save", "(", "'cookies'", ",", "'danger'", ",", "$", "this", "->", "handleError", "(", "$", "exception", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "redirectAction", ")", ")", "{", "$", "redirectAction", "=", "'insert-form'", ";", "}", "}", "}", "//redirect", "$", "redirectAction", "=", "$", "redirectAction", "?", "$", "redirectAction", ":", "'list'", ";", "$", "this", "->", "httpResponse", "=", "$", "this", "->", "httpResponse", "->", "withHeader", "(", "'Location'", ",", "$", "redirectAction", ")", ";", "}" ]
Insert record action @param string $redirectAction
[ "Insert", "record", "action" ]
a43ad7868098ff1e7bda6819547ea64f9a853732
https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Traits/CRUD.php#L198-L221
train
vukbgit/PHPCraft.Subject
src/Traits/CRUD.php
CRUD.execUpdate
public function execUpdate($redirectAction = false) { // database translations $this->loadTranslations('database', sprintf('private/global/locales/%s/database.ini', LANGUAGE)); //validate and extract input $input = $this->processSaveInput(filter_input_array(INPUT_POST, $this->configuration['subjects'][$this->name]['CRUD']['inputFields'])); if($input) { //extract primary key value $primaryKeyValue = $this->extractPrimaryKeyValue($input, 'a'); try{ //ORM insert $this->purgePrimaryKeyValue($input); if($this->update($primaryKeyValue, $input)) { $this->messages->save('cookies','success',sprintf($this->translations[$this->name]['CRUD']['update-success'], $this->translations[$this->name]['singular'])); } } catch(\PDOException $exception) { $this->messages->save('cookies', 'danger', $this->handleError($exception)); if(!isset($redirectAction)) { $redirectAction = 'update-form/' . $this->extractPrimaryKeyValue($input, 's'); } } } //redirect $redirectAction = $redirectAction ? $redirectAction : 'list'; $this->httpResponse = $this->httpResponse->withHeader('Location', $redirectAction); }
php
public function execUpdate($redirectAction = false) { // database translations $this->loadTranslations('database', sprintf('private/global/locales/%s/database.ini', LANGUAGE)); //validate and extract input $input = $this->processSaveInput(filter_input_array(INPUT_POST, $this->configuration['subjects'][$this->name]['CRUD']['inputFields'])); if($input) { //extract primary key value $primaryKeyValue = $this->extractPrimaryKeyValue($input, 'a'); try{ //ORM insert $this->purgePrimaryKeyValue($input); if($this->update($primaryKeyValue, $input)) { $this->messages->save('cookies','success',sprintf($this->translations[$this->name]['CRUD']['update-success'], $this->translations[$this->name]['singular'])); } } catch(\PDOException $exception) { $this->messages->save('cookies', 'danger', $this->handleError($exception)); if(!isset($redirectAction)) { $redirectAction = 'update-form/' . $this->extractPrimaryKeyValue($input, 's'); } } } //redirect $redirectAction = $redirectAction ? $redirectAction : 'list'; $this->httpResponse = $this->httpResponse->withHeader('Location', $redirectAction); }
[ "public", "function", "execUpdate", "(", "$", "redirectAction", "=", "false", ")", "{", "// database translations", "$", "this", "->", "loadTranslations", "(", "'database'", ",", "sprintf", "(", "'private/global/locales/%s/database.ini'", ",", "LANGUAGE", ")", ")", ";", "//validate and extract input", "$", "input", "=", "$", "this", "->", "processSaveInput", "(", "filter_input_array", "(", "INPUT_POST", ",", "$", "this", "->", "configuration", "[", "'subjects'", "]", "[", "$", "this", "->", "name", "]", "[", "'CRUD'", "]", "[", "'inputFields'", "]", ")", ")", ";", "if", "(", "$", "input", ")", "{", "//extract primary key value", "$", "primaryKeyValue", "=", "$", "this", "->", "extractPrimaryKeyValue", "(", "$", "input", ",", "'a'", ")", ";", "try", "{", "//ORM insert", "$", "this", "->", "purgePrimaryKeyValue", "(", "$", "input", ")", ";", "if", "(", "$", "this", "->", "update", "(", "$", "primaryKeyValue", ",", "$", "input", ")", ")", "{", "$", "this", "->", "messages", "->", "save", "(", "'cookies'", ",", "'success'", ",", "sprintf", "(", "$", "this", "->", "translations", "[", "$", "this", "->", "name", "]", "[", "'CRUD'", "]", "[", "'update-success'", "]", ",", "$", "this", "->", "translations", "[", "$", "this", "->", "name", "]", "[", "'singular'", "]", ")", ")", ";", "}", "}", "catch", "(", "\\", "PDOException", "$", "exception", ")", "{", "$", "this", "->", "messages", "->", "save", "(", "'cookies'", ",", "'danger'", ",", "$", "this", "->", "handleError", "(", "$", "exception", ")", ")", ";", "if", "(", "!", "isset", "(", "$", "redirectAction", ")", ")", "{", "$", "redirectAction", "=", "'update-form/'", ".", "$", "this", "->", "extractPrimaryKeyValue", "(", "$", "input", ",", "'s'", ")", ";", "}", "}", "}", "//redirect", "$", "redirectAction", "=", "$", "redirectAction", "?", "$", "redirectAction", ":", "'list'", ";", "$", "this", "->", "httpResponse", "=", "$", "this", "->", "httpResponse", "->", "withHeader", "(", "'Location'", ",", "$", "redirectAction", ")", ";", "}" ]
Update record action @param string $redirectAction
[ "Update", "record", "action" ]
a43ad7868098ff1e7bda6819547ea64f9a853732
https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Traits/CRUD.php#L227-L252
train
vukbgit/PHPCraft.Subject
src/Traits/CRUD.php
CRUD.execDelete
public function execDelete($redirectAction = false) { // database translations $this->loadTranslations('database', sprintf('private/global/locales/%s/database.ini', LANGUAGE)); //validate and extract input $input = $this->processSaveInput(filter_input_array(INPUT_POST, $this->configuration['subjects'][$this->name]['CRUD']['inputFields'])); if($input) { //extract primary key value $primaryKeyValue = $this->extractPrimaryKeyValue($input, 'a'); try{ //ORM insert $this->delete($primaryKeyValue); $this->messages->save('cookies','success',sprintf($this->translations[$this->name]['CRUD']['delete-success'], $this->translations[$this->name]['singular'])); } catch(\PDOException $exception) { $this->messages->save('cookies', 'danger', $this->handleError($exception)); $redirectAction = 'deleteForm/' . $this->extractPrimaryKeyValue($input, 's'); } } //redirect $redirectAction = $redirectAction ? $redirectAction : 'list'; $this->httpResponse = $this->httpResponse->withHeader('Location', $redirectAction); }
php
public function execDelete($redirectAction = false) { // database translations $this->loadTranslations('database', sprintf('private/global/locales/%s/database.ini', LANGUAGE)); //validate and extract input $input = $this->processSaveInput(filter_input_array(INPUT_POST, $this->configuration['subjects'][$this->name]['CRUD']['inputFields'])); if($input) { //extract primary key value $primaryKeyValue = $this->extractPrimaryKeyValue($input, 'a'); try{ //ORM insert $this->delete($primaryKeyValue); $this->messages->save('cookies','success',sprintf($this->translations[$this->name]['CRUD']['delete-success'], $this->translations[$this->name]['singular'])); } catch(\PDOException $exception) { $this->messages->save('cookies', 'danger', $this->handleError($exception)); $redirectAction = 'deleteForm/' . $this->extractPrimaryKeyValue($input, 's'); } } //redirect $redirectAction = $redirectAction ? $redirectAction : 'list'; $this->httpResponse = $this->httpResponse->withHeader('Location', $redirectAction); }
[ "public", "function", "execDelete", "(", "$", "redirectAction", "=", "false", ")", "{", "// database translations", "$", "this", "->", "loadTranslations", "(", "'database'", ",", "sprintf", "(", "'private/global/locales/%s/database.ini'", ",", "LANGUAGE", ")", ")", ";", "//validate and extract input", "$", "input", "=", "$", "this", "->", "processSaveInput", "(", "filter_input_array", "(", "INPUT_POST", ",", "$", "this", "->", "configuration", "[", "'subjects'", "]", "[", "$", "this", "->", "name", "]", "[", "'CRUD'", "]", "[", "'inputFields'", "]", ")", ")", ";", "if", "(", "$", "input", ")", "{", "//extract primary key value", "$", "primaryKeyValue", "=", "$", "this", "->", "extractPrimaryKeyValue", "(", "$", "input", ",", "'a'", ")", ";", "try", "{", "//ORM insert", "$", "this", "->", "delete", "(", "$", "primaryKeyValue", ")", ";", "$", "this", "->", "messages", "->", "save", "(", "'cookies'", ",", "'success'", ",", "sprintf", "(", "$", "this", "->", "translations", "[", "$", "this", "->", "name", "]", "[", "'CRUD'", "]", "[", "'delete-success'", "]", ",", "$", "this", "->", "translations", "[", "$", "this", "->", "name", "]", "[", "'singular'", "]", ")", ")", ";", "}", "catch", "(", "\\", "PDOException", "$", "exception", ")", "{", "$", "this", "->", "messages", "->", "save", "(", "'cookies'", ",", "'danger'", ",", "$", "this", "->", "handleError", "(", "$", "exception", ")", ")", ";", "$", "redirectAction", "=", "'deleteForm/'", ".", "$", "this", "->", "extractPrimaryKeyValue", "(", "$", "input", ",", "'s'", ")", ";", "}", "}", "//redirect", "$", "redirectAction", "=", "$", "redirectAction", "?", "$", "redirectAction", ":", "'list'", ";", "$", "this", "->", "httpResponse", "=", "$", "this", "->", "httpResponse", "->", "withHeader", "(", "'Location'", ",", "$", "redirectAction", ")", ";", "}" ]
Delete record action @param string $redirectAction
[ "Delete", "record", "action" ]
a43ad7868098ff1e7bda6819547ea64f9a853732
https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Traits/CRUD.php#L258-L279
train
vukbgit/PHPCraft.Subject
src/Traits/CRUD.php
CRUD.execDeleteBulk
protected function execDeleteBulk() { //get values $primaryKeyValues = $_POST['primaryKeyValues']; // database translations $this->loadTranslations('database', sprintf('private/global/locales/%s/database.ini', LANGUAGE)); $deletedNumber = 0; foreach($primaryKeyValues as $recordPrimaryKeyValues) { try{ $this->delete($recordPrimaryKeyValues); $deletedNumber++; } catch(\PDOException $exception) { $this->messages->save('cookies', 'danger', $this->handleError($exception)); } } //success message if($deletedNumber) { $this->messages->save('cookies','success',sprintf($this->translations[$this->name]['CRUD']['delete-bulk-success'], $deletedNumber, $this->translations[$this->name]['plural'])); } //redirection to list action is performed by javascript into jquery post() success function }
php
protected function execDeleteBulk() { //get values $primaryKeyValues = $_POST['primaryKeyValues']; // database translations $this->loadTranslations('database', sprintf('private/global/locales/%s/database.ini', LANGUAGE)); $deletedNumber = 0; foreach($primaryKeyValues as $recordPrimaryKeyValues) { try{ $this->delete($recordPrimaryKeyValues); $deletedNumber++; } catch(\PDOException $exception) { $this->messages->save('cookies', 'danger', $this->handleError($exception)); } } //success message if($deletedNumber) { $this->messages->save('cookies','success',sprintf($this->translations[$this->name]['CRUD']['delete-bulk-success'], $deletedNumber, $this->translations[$this->name]['plural'])); } //redirection to list action is performed by javascript into jquery post() success function }
[ "protected", "function", "execDeleteBulk", "(", ")", "{", "//get values", "$", "primaryKeyValues", "=", "$", "_POST", "[", "'primaryKeyValues'", "]", ";", "// database translations", "$", "this", "->", "loadTranslations", "(", "'database'", ",", "sprintf", "(", "'private/global/locales/%s/database.ini'", ",", "LANGUAGE", ")", ")", ";", "$", "deletedNumber", "=", "0", ";", "foreach", "(", "$", "primaryKeyValues", "as", "$", "recordPrimaryKeyValues", ")", "{", "try", "{", "$", "this", "->", "delete", "(", "$", "recordPrimaryKeyValues", ")", ";", "$", "deletedNumber", "++", ";", "}", "catch", "(", "\\", "PDOException", "$", "exception", ")", "{", "$", "this", "->", "messages", "->", "save", "(", "'cookies'", ",", "'danger'", ",", "$", "this", "->", "handleError", "(", "$", "exception", ")", ")", ";", "}", "}", "//success message", "if", "(", "$", "deletedNumber", ")", "{", "$", "this", "->", "messages", "->", "save", "(", "'cookies'", ",", "'success'", ",", "sprintf", "(", "$", "this", "->", "translations", "[", "$", "this", "->", "name", "]", "[", "'CRUD'", "]", "[", "'delete-bulk-success'", "]", ",", "$", "deletedNumber", ",", "$", "this", "->", "translations", "[", "$", "this", "->", "name", "]", "[", "'plural'", "]", ")", ")", ";", "}", "//redirection to list action is performed by javascript into jquery post() success function", "}" ]
deletes multiple record
[ "deletes", "multiple", "record" ]
a43ad7868098ff1e7bda6819547ea64f9a853732
https://github.com/vukbgit/PHPCraft.Subject/blob/a43ad7868098ff1e7bda6819547ea64f9a853732/src/Traits/CRUD.php#L284-L304
train
as3io/As3ModlrBundle
DependencyInjection/ServiceLoader/SearchClients.php
SearchClients.createElasticClient
private function createElasticClient($clientName, ContainerBuilder $container) { // Storage metadata $smfName = sprintf('%s.metadata', $clientName); $definition = new Definition( Utility::getLibraryClass('Search\Elastic\StorageMetadataFactory') ); $definition->setPublic(false); $container->setDefinition($smfName, $definition); // Client return new Definition( Utility::getLibraryClass('Search\Elastic\Client'), [new Reference($smfName)] ); }
php
private function createElasticClient($clientName, ContainerBuilder $container) { // Storage metadata $smfName = sprintf('%s.metadata', $clientName); $definition = new Definition( Utility::getLibraryClass('Search\Elastic\StorageMetadataFactory') ); $definition->setPublic(false); $container->setDefinition($smfName, $definition); // Client return new Definition( Utility::getLibraryClass('Search\Elastic\Client'), [new Reference($smfName)] ); }
[ "private", "function", "createElasticClient", "(", "$", "clientName", ",", "ContainerBuilder", "$", "container", ")", "{", "// Storage metadata", "$", "smfName", "=", "sprintf", "(", "'%s.metadata'", ",", "$", "clientName", ")", ";", "$", "definition", "=", "new", "Definition", "(", "Utility", "::", "getLibraryClass", "(", "'Search\\Elastic\\StorageMetadataFactory'", ")", ")", ";", "$", "definition", "->", "setPublic", "(", "false", ")", ";", "$", "container", "->", "setDefinition", "(", "$", "smfName", ",", "$", "definition", ")", ";", "// Client", "return", "new", "Definition", "(", "Utility", "::", "getLibraryClass", "(", "'Search\\Elastic\\Client'", ")", ",", "[", "new", "Reference", "(", "$", "smfName", ")", "]", ")", ";", "}" ]
Creates the Elastic search client service definition. Will also load support services. @param string $clientName @param ContainerBuilder $container @return Definition
[ "Creates", "the", "Elastic", "search", "client", "service", "definition", ".", "Will", "also", "load", "support", "services", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/ServiceLoader/SearchClients.php#L25-L40
train
humplus/template
src/Template.php
Template.compiled
protected function compiled($template) { $template = ltrim($template, '/'); if (strrchr($template, '.') == $this->extension) $template = substr($template, 0, -strlen($this->extension)); $file = $this->dir . DIRECTORY_SEPARATOR . $template . $this->extension; if (!is_file($file)) throw new \RuntimeException("template not found:$file!"); $modified = filemtime($file); $compiled = $this->temp . DIRECTORY_SEPARATOR . $template . ".{$modified}.php"; if (!$this->debug && is_file($compiled) && filemtime($compiled) >= $modified) return $compiled; $content = self::compile(file_get_contents($file), $this->left, $this->right); self::writeFile($compiled, $content, $this->temp); return $compiled; }
php
protected function compiled($template) { $template = ltrim($template, '/'); if (strrchr($template, '.') == $this->extension) $template = substr($template, 0, -strlen($this->extension)); $file = $this->dir . DIRECTORY_SEPARATOR . $template . $this->extension; if (!is_file($file)) throw new \RuntimeException("template not found:$file!"); $modified = filemtime($file); $compiled = $this->temp . DIRECTORY_SEPARATOR . $template . ".{$modified}.php"; if (!$this->debug && is_file($compiled) && filemtime($compiled) >= $modified) return $compiled; $content = self::compile(file_get_contents($file), $this->left, $this->right); self::writeFile($compiled, $content, $this->temp); return $compiled; }
[ "protected", "function", "compiled", "(", "$", "template", ")", "{", "$", "template", "=", "ltrim", "(", "$", "template", ",", "'/'", ")", ";", "if", "(", "strrchr", "(", "$", "template", ",", "'.'", ")", "==", "$", "this", "->", "extension", ")", "$", "template", "=", "substr", "(", "$", "template", ",", "0", ",", "-", "strlen", "(", "$", "this", "->", "extension", ")", ")", ";", "$", "file", "=", "$", "this", "->", "dir", ".", "DIRECTORY_SEPARATOR", ".", "$", "template", ".", "$", "this", "->", "extension", ";", "if", "(", "!", "is_file", "(", "$", "file", ")", ")", "throw", "new", "\\", "RuntimeException", "(", "\"template not found:$file!\"", ")", ";", "$", "modified", "=", "filemtime", "(", "$", "file", ")", ";", "$", "compiled", "=", "$", "this", "->", "temp", ".", "DIRECTORY_SEPARATOR", ".", "$", "template", ".", "\".{$modified}.php\"", ";", "if", "(", "!", "$", "this", "->", "debug", "&&", "is_file", "(", "$", "compiled", ")", "&&", "filemtime", "(", "$", "compiled", ")", ">=", "$", "modified", ")", "return", "$", "compiled", ";", "$", "content", "=", "self", "::", "compile", "(", "file_get_contents", "(", "$", "file", ")", ",", "$", "this", "->", "left", ",", "$", "this", "->", "right", ")", ";", "self", "::", "writeFile", "(", "$", "compiled", ",", "$", "content", ",", "$", "this", "->", "temp", ")", ";", "return", "$", "compiled", ";", "}" ]
Fetch Compiled Template @param $template @return string @throws \Exception
[ "Fetch", "Compiled", "Template" ]
f94a7f3f2ee0fc874a233c9a2526f26728d40833
https://github.com/humplus/template/blob/f94a7f3f2ee0fc874a233c9a2526f26728d40833/src/Template.php#L145-L163
train
humplus/template
src/Template.php
Template.initWidgetParameters
protected static function initWidgetParameters($widget, array $parameters) { $param = var_export($parameters, true); $param = preg_replace("/'\\$(.*)',/isU", "\$\\1,", $param); $param = str_replace('\\\'', '\'', $param); return "<?php \$this->widget->setParameters($param);?>\n"; }
php
protected static function initWidgetParameters($widget, array $parameters) { $param = var_export($parameters, true); $param = preg_replace("/'\\$(.*)',/isU", "\$\\1,", $param); $param = str_replace('\\\'', '\'', $param); return "<?php \$this->widget->setParameters($param);?>\n"; }
[ "protected", "static", "function", "initWidgetParameters", "(", "$", "widget", ",", "array", "$", "parameters", ")", "{", "$", "param", "=", "var_export", "(", "$", "parameters", ",", "true", ")", ";", "$", "param", "=", "preg_replace", "(", "\"/'\\\\$(.*)',/isU\"", ",", "\"\\$\\\\1,\"", ",", "$", "param", ")", ";", "$", "param", "=", "str_replace", "(", "'\\\\\\''", ",", "'\\''", ",", "$", "param", ")", ";", "return", "\"<?php \\$this->widget->setParameters($param);?>\\n\"", ";", "}" ]
Set Widget Parameters @param string $widget @param array $parameters @return string
[ "Set", "Widget", "Parameters" ]
f94a7f3f2ee0fc874a233c9a2526f26728d40833
https://github.com/humplus/template/blob/f94a7f3f2ee0fc874a233c9a2526f26728d40833/src/Template.php#L345-L352
train
humplus/template
src/Template.php
Template.writeFile
protected static function writeFile($target, $content, $tmp) { $dir = dirname($target); if (!is_dir($dir)) mkdir($dir, 644, true); $file = tempnam($tmp, 'hum'); if (!($fd = fopen($file, 'w'))) throw new \RuntimeException("create template tmp file failed:$file!"); fwrite($fd, $content); fclose($fd); if (file_exists($target)) unlink($target); $ret = rename($file, $target); if ($ret) chmod($target, 644); else throw new \RuntimeException("create template failed:$target!"); return $ret; }
php
protected static function writeFile($target, $content, $tmp) { $dir = dirname($target); if (!is_dir($dir)) mkdir($dir, 644, true); $file = tempnam($tmp, 'hum'); if (!($fd = fopen($file, 'w'))) throw new \RuntimeException("create template tmp file failed:$file!"); fwrite($fd, $content); fclose($fd); if (file_exists($target)) unlink($target); $ret = rename($file, $target); if ($ret) chmod($target, 644); else throw new \RuntimeException("create template failed:$target!"); return $ret; }
[ "protected", "static", "function", "writeFile", "(", "$", "target", ",", "$", "content", ",", "$", "tmp", ")", "{", "$", "dir", "=", "dirname", "(", "$", "target", ")", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "mkdir", "(", "$", "dir", ",", "644", ",", "true", ")", ";", "$", "file", "=", "tempnam", "(", "$", "tmp", ",", "'hum'", ")", ";", "if", "(", "!", "(", "$", "fd", "=", "fopen", "(", "$", "file", ",", "'w'", ")", ")", ")", "throw", "new", "\\", "RuntimeException", "(", "\"create template tmp file failed:$file!\"", ")", ";", "fwrite", "(", "$", "fd", ",", "$", "content", ")", ";", "fclose", "(", "$", "fd", ")", ";", "if", "(", "file_exists", "(", "$", "target", ")", ")", "unlink", "(", "$", "target", ")", ";", "$", "ret", "=", "rename", "(", "$", "file", ",", "$", "target", ")", ";", "if", "(", "$", "ret", ")", "chmod", "(", "$", "target", ",", "644", ")", ";", "else", "throw", "new", "\\", "RuntimeException", "(", "\"create template failed:$target!\"", ")", ";", "return", "$", "ret", ";", "}" ]
Write Compiled File @param string $target @param string $content @param string $tmp @return string bool
[ "Write", "Compiled", "File" ]
f94a7f3f2ee0fc874a233c9a2526f26728d40833
https://github.com/humplus/template/blob/f94a7f3f2ee0fc874a233c9a2526f26728d40833/src/Template.php#L387-L406
train
enikeishik/ufoframework
src/Ufo/Core/App.php
App.execute
public function execute(): void { $path = ''; try { $path = $this->getPath(); if ($this->config->cache) { try { $this->setCache(); } catch (StorageNotSupportedException $e) { $this->cache = null; } catch (StorageConnectException $e) { $this->cache = null; } } if (null !== $this->cache && !$this->cache->expired($path, $this->config->cacheTtlWholePage)) { $result = $this->getCacheResult($this->cache->get($path, '')); } else { $result = $this->compose($this->parse($path)); } } catch (BadPathException $e) { $result = $this->getError(500, 'Bad path'); } catch (RouteStorageNotSetException $e) { $result = $this->getError(500, 'Route storage not set'); } catch (RouteStorageEmptyException $e) { $result = $this->getError(500, 'Route storage empty'); } catch (DbConnectException $e) { if (null !== $this->cache && $this->cache->has($path)) { // @codeCoverageIgnoreStart // passed in local tests, but skipped in travis $result = $this->getCacheResult($this->cache->get($path, '')); // @codeCoverageIgnoreEnd } else { $result = $this->getError(500, 'DataBase connection error'); } } catch (SectionNotExistsException $e) { $result = $this->getError(404, 'Section not exists'); } catch (SectionDisabledException $e) { $result = $this->getError(403, 'Section disabled'); } catch (ModuleDisabledException $e) { $result = $this->getError(403, 'Section module disabled'); } catch (ModuleParameterConflictException $e) { $result = $this->getError(404, 'Module parameter conflict with another'); } catch (ModuleParameterFormatException $e) { $result = $this->getError(404, 'Module parameter bad format'); } catch (ModuleParameterUnknownException $e) { $result = $this->getError(404, 'Module parameter unknown'); } catch (\Throwable $e) { $result = $this->getError(500, 'Unexpected exception: ' . $e->getMessage()); } $this->sendHeaders($result->getHeaders()); $this->render($result->getView()); }
php
public function execute(): void { $path = ''; try { $path = $this->getPath(); if ($this->config->cache) { try { $this->setCache(); } catch (StorageNotSupportedException $e) { $this->cache = null; } catch (StorageConnectException $e) { $this->cache = null; } } if (null !== $this->cache && !$this->cache->expired($path, $this->config->cacheTtlWholePage)) { $result = $this->getCacheResult($this->cache->get($path, '')); } else { $result = $this->compose($this->parse($path)); } } catch (BadPathException $e) { $result = $this->getError(500, 'Bad path'); } catch (RouteStorageNotSetException $e) { $result = $this->getError(500, 'Route storage not set'); } catch (RouteStorageEmptyException $e) { $result = $this->getError(500, 'Route storage empty'); } catch (DbConnectException $e) { if (null !== $this->cache && $this->cache->has($path)) { // @codeCoverageIgnoreStart // passed in local tests, but skipped in travis $result = $this->getCacheResult($this->cache->get($path, '')); // @codeCoverageIgnoreEnd } else { $result = $this->getError(500, 'DataBase connection error'); } } catch (SectionNotExistsException $e) { $result = $this->getError(404, 'Section not exists'); } catch (SectionDisabledException $e) { $result = $this->getError(403, 'Section disabled'); } catch (ModuleDisabledException $e) { $result = $this->getError(403, 'Section module disabled'); } catch (ModuleParameterConflictException $e) { $result = $this->getError(404, 'Module parameter conflict with another'); } catch (ModuleParameterFormatException $e) { $result = $this->getError(404, 'Module parameter bad format'); } catch (ModuleParameterUnknownException $e) { $result = $this->getError(404, 'Module parameter unknown'); } catch (\Throwable $e) { $result = $this->getError(500, 'Unexpected exception: ' . $e->getMessage()); } $this->sendHeaders($result->getHeaders()); $this->render($result->getView()); }
[ "public", "function", "execute", "(", ")", ":", "void", "{", "$", "path", "=", "''", ";", "try", "{", "$", "path", "=", "$", "this", "->", "getPath", "(", ")", ";", "if", "(", "$", "this", "->", "config", "->", "cache", ")", "{", "try", "{", "$", "this", "->", "setCache", "(", ")", ";", "}", "catch", "(", "StorageNotSupportedException", "$", "e", ")", "{", "$", "this", "->", "cache", "=", "null", ";", "}", "catch", "(", "StorageConnectException", "$", "e", ")", "{", "$", "this", "->", "cache", "=", "null", ";", "}", "}", "if", "(", "null", "!==", "$", "this", "->", "cache", "&&", "!", "$", "this", "->", "cache", "->", "expired", "(", "$", "path", ",", "$", "this", "->", "config", "->", "cacheTtlWholePage", ")", ")", "{", "$", "result", "=", "$", "this", "->", "getCacheResult", "(", "$", "this", "->", "cache", "->", "get", "(", "$", "path", ",", "''", ")", ")", ";", "}", "else", "{", "$", "result", "=", "$", "this", "->", "compose", "(", "$", "this", "->", "parse", "(", "$", "path", ")", ")", ";", "}", "}", "catch", "(", "BadPathException", "$", "e", ")", "{", "$", "result", "=", "$", "this", "->", "getError", "(", "500", ",", "'Bad path'", ")", ";", "}", "catch", "(", "RouteStorageNotSetException", "$", "e", ")", "{", "$", "result", "=", "$", "this", "->", "getError", "(", "500", ",", "'Route storage not set'", ")", ";", "}", "catch", "(", "RouteStorageEmptyException", "$", "e", ")", "{", "$", "result", "=", "$", "this", "->", "getError", "(", "500", ",", "'Route storage empty'", ")", ";", "}", "catch", "(", "DbConnectException", "$", "e", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "cache", "&&", "$", "this", "->", "cache", "->", "has", "(", "$", "path", ")", ")", "{", "// @codeCoverageIgnoreStart", "// passed in local tests, but skipped in travis", "$", "result", "=", "$", "this", "->", "getCacheResult", "(", "$", "this", "->", "cache", "->", "get", "(", "$", "path", ",", "''", ")", ")", ";", "// @codeCoverageIgnoreEnd", "}", "else", "{", "$", "result", "=", "$", "this", "->", "getError", "(", "500", ",", "'DataBase connection error'", ")", ";", "}", "}", "catch", "(", "SectionNotExistsException", "$", "e", ")", "{", "$", "result", "=", "$", "this", "->", "getError", "(", "404", ",", "'Section not exists'", ")", ";", "}", "catch", "(", "SectionDisabledException", "$", "e", ")", "{", "$", "result", "=", "$", "this", "->", "getError", "(", "403", ",", "'Section disabled'", ")", ";", "}", "catch", "(", "ModuleDisabledException", "$", "e", ")", "{", "$", "result", "=", "$", "this", "->", "getError", "(", "403", ",", "'Section module disabled'", ")", ";", "}", "catch", "(", "ModuleParameterConflictException", "$", "e", ")", "{", "$", "result", "=", "$", "this", "->", "getError", "(", "404", ",", "'Module parameter conflict with another'", ")", ";", "}", "catch", "(", "ModuleParameterFormatException", "$", "e", ")", "{", "$", "result", "=", "$", "this", "->", "getError", "(", "404", ",", "'Module parameter bad format'", ")", ";", "}", "catch", "(", "ModuleParameterUnknownException", "$", "e", ")", "{", "$", "result", "=", "$", "this", "->", "getError", "(", "404", ",", "'Module parameter unknown'", ")", ";", "}", "catch", "(", "\\", "Throwable", "$", "e", ")", "{", "$", "result", "=", "$", "this", "->", "getError", "(", "500", ",", "'Unexpected exception: '", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "$", "this", "->", "sendHeaders", "(", "$", "result", "->", "getHeaders", "(", ")", ")", ";", "$", "this", "->", "render", "(", "$", "result", "->", "getView", "(", ")", ")", ";", "}" ]
Application main workflow. @return void
[ "Application", "main", "workflow", "." ]
fb44461bcb0506dbc3257724a2281f756594f62f
https://github.com/enikeishik/ufoframework/blob/fb44461bcb0506dbc3257724a2281f756594f62f/src/Ufo/Core/App.php#L86-L155
train
black-lamp/blcms-payment
backend/controllers/DefaultController.php
DefaultController.actionSave
public function actionSave($id = null, $languageId = null) { if (empty($languageId)) { $languageId = Language::getCurrent()->id; } if (!empty($id)) { $model = PaymentMethod::findOne($id); if (empty($model)) throw new NotFoundHttpException(); $modelTranslation = PaymentMethodTranslation::find() ->where(['payment_method_id' => $model->id, 'language_id' => $languageId])->one(); if (empty($modelTranslation)) { $modelTranslation = new PaymentMethodTranslation(); } } else { $model = new PaymentMethod(); $modelTranslation = new PaymentMethodTranslation(); } if (\Yii::$app->request->isPost) { if ($model->load(\Yii::$app->request->post())) { $imageModel = new PaymentImageModel(); $imageModel->imageFile = UploadedFile::getInstance($model, 'image'); if (!empty($imageModel->imageFile)) { $uploadedImageName = $imageModel->upload(); $model->image = $uploadedImageName; } } if ($modelTranslation->load(Yii::$app->request->post())) { if ($modelTranslation->validate()) { $model->save(); $modelTranslation->payment_method_id = $model->id; $modelTranslation->language_id = $languageId; $modelTranslation->save(); return $this->redirect(['save', 'id' => $model->id, 'languageId' => $languageId]); } } } return $this->render('save', [ 'model' => $model, 'modelTranslation' => $modelTranslation, 'selectedLanguage' => Language::findOne($languageId) ]); }
php
public function actionSave($id = null, $languageId = null) { if (empty($languageId)) { $languageId = Language::getCurrent()->id; } if (!empty($id)) { $model = PaymentMethod::findOne($id); if (empty($model)) throw new NotFoundHttpException(); $modelTranslation = PaymentMethodTranslation::find() ->where(['payment_method_id' => $model->id, 'language_id' => $languageId])->one(); if (empty($modelTranslation)) { $modelTranslation = new PaymentMethodTranslation(); } } else { $model = new PaymentMethod(); $modelTranslation = new PaymentMethodTranslation(); } if (\Yii::$app->request->isPost) { if ($model->load(\Yii::$app->request->post())) { $imageModel = new PaymentImageModel(); $imageModel->imageFile = UploadedFile::getInstance($model, 'image'); if (!empty($imageModel->imageFile)) { $uploadedImageName = $imageModel->upload(); $model->image = $uploadedImageName; } } if ($modelTranslation->load(Yii::$app->request->post())) { if ($modelTranslation->validate()) { $model->save(); $modelTranslation->payment_method_id = $model->id; $modelTranslation->language_id = $languageId; $modelTranslation->save(); return $this->redirect(['save', 'id' => $model->id, 'languageId' => $languageId]); } } } return $this->render('save', [ 'model' => $model, 'modelTranslation' => $modelTranslation, 'selectedLanguage' => Language::findOne($languageId) ]); }
[ "public", "function", "actionSave", "(", "$", "id", "=", "null", ",", "$", "languageId", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "languageId", ")", ")", "{", "$", "languageId", "=", "Language", "::", "getCurrent", "(", ")", "->", "id", ";", "}", "if", "(", "!", "empty", "(", "$", "id", ")", ")", "{", "$", "model", "=", "PaymentMethod", "::", "findOne", "(", "$", "id", ")", ";", "if", "(", "empty", "(", "$", "model", ")", ")", "throw", "new", "NotFoundHttpException", "(", ")", ";", "$", "modelTranslation", "=", "PaymentMethodTranslation", "::", "find", "(", ")", "->", "where", "(", "[", "'payment_method_id'", "=>", "$", "model", "->", "id", ",", "'language_id'", "=>", "$", "languageId", "]", ")", "->", "one", "(", ")", ";", "if", "(", "empty", "(", "$", "modelTranslation", ")", ")", "{", "$", "modelTranslation", "=", "new", "PaymentMethodTranslation", "(", ")", ";", "}", "}", "else", "{", "$", "model", "=", "new", "PaymentMethod", "(", ")", ";", "$", "modelTranslation", "=", "new", "PaymentMethodTranslation", "(", ")", ";", "}", "if", "(", "\\", "Yii", "::", "$", "app", "->", "request", "->", "isPost", ")", "{", "if", "(", "$", "model", "->", "load", "(", "\\", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ")", ")", "{", "$", "imageModel", "=", "new", "PaymentImageModel", "(", ")", ";", "$", "imageModel", "->", "imageFile", "=", "UploadedFile", "::", "getInstance", "(", "$", "model", ",", "'image'", ")", ";", "if", "(", "!", "empty", "(", "$", "imageModel", "->", "imageFile", ")", ")", "{", "$", "uploadedImageName", "=", "$", "imageModel", "->", "upload", "(", ")", ";", "$", "model", "->", "image", "=", "$", "uploadedImageName", ";", "}", "}", "if", "(", "$", "modelTranslation", "->", "load", "(", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ")", ")", "{", "if", "(", "$", "modelTranslation", "->", "validate", "(", ")", ")", "{", "$", "model", "->", "save", "(", ")", ";", "$", "modelTranslation", "->", "payment_method_id", "=", "$", "model", "->", "id", ";", "$", "modelTranslation", "->", "language_id", "=", "$", "languageId", ";", "$", "modelTranslation", "->", "save", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "[", "'save'", ",", "'id'", "=>", "$", "model", "->", "id", ",", "'languageId'", "=>", "$", "languageId", "]", ")", ";", "}", "}", "}", "return", "$", "this", "->", "render", "(", "'save'", ",", "[", "'model'", "=>", "$", "model", ",", "'modelTranslation'", "=>", "$", "modelTranslation", ",", "'selectedLanguage'", "=>", "Language", "::", "findOne", "(", "$", "languageId", ")", "]", ")", ";", "}" ]
Creates a new PaymentMethod model. If creation is successful, the browser will be redirected to the 'view' page. @param integer $id @param integer $languageId @return mixed @throws Exception
[ "Creates", "a", "new", "PaymentMethod", "model", ".", "If", "creation", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "view", "page", "." ]
6d139e0bb5a4e7733382cc6fe083173551905b92
https://github.com/black-lamp/blcms-payment/blob/6d139e0bb5a4e7733382cc6fe083173551905b92/backend/controllers/DefaultController.php#L74-L122
train
black-lamp/blcms-payment
backend/controllers/DefaultController.php
DefaultController.actionDelete
public function actionDelete($id) { if (($model = PaymentMethod::findOne($id)) !== null) { $model->delete(); return $this->redirect(['index']); } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
php
public function actionDelete($id) { if (($model = PaymentMethod::findOne($id)) !== null) { $model->delete(); return $this->redirect(['index']); } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
[ "public", "function", "actionDelete", "(", "$", "id", ")", "{", "if", "(", "(", "$", "model", "=", "PaymentMethod", "::", "findOne", "(", "$", "id", ")", ")", "!==", "null", ")", "{", "$", "model", "->", "delete", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "[", "'index'", "]", ")", ";", "}", "else", "{", "throw", "new", "NotFoundHttpException", "(", "'The requested page does not exist.'", ")", ";", "}", "}" ]
Deletes an existing PaymentMethod model. If deletion is successful, the browser will be redirected to the 'index' page. @param integer $id @return mixed @throws NotFoundHttpException
[ "Deletes", "an", "existing", "PaymentMethod", "model", ".", "If", "deletion", "is", "successful", "the", "browser", "will", "be", "redirected", "to", "the", "index", "page", "." ]
6d139e0bb5a4e7733382cc6fe083173551905b92
https://github.com/black-lamp/blcms-payment/blob/6d139e0bb5a4e7733382cc6fe083173551905b92/backend/controllers/DefaultController.php#L131-L139
train
black-lamp/blcms-payment
backend/controllers/DefaultController.php
DefaultController.actionDeleteImage
public function actionDeleteImage($id) { if (!empty($id)) { $paymentMethod = PaymentMethod::findOne($id); $isDeleted = \Yii::$app->shop_imagable->delete('payment', $paymentMethod->image); if ($isDeleted) { $paymentMethod->image = NULL; $paymentMethod->save(); return $this->redirect(Yii::$app->request->referrer); } else throw new Exception('Deleting failed.'); } else throw new NotFoundHttpException(); }
php
public function actionDeleteImage($id) { if (!empty($id)) { $paymentMethod = PaymentMethod::findOne($id); $isDeleted = \Yii::$app->shop_imagable->delete('payment', $paymentMethod->image); if ($isDeleted) { $paymentMethod->image = NULL; $paymentMethod->save(); return $this->redirect(Yii::$app->request->referrer); } else throw new Exception('Deleting failed.'); } else throw new NotFoundHttpException(); }
[ "public", "function", "actionDeleteImage", "(", "$", "id", ")", "{", "if", "(", "!", "empty", "(", "$", "id", ")", ")", "{", "$", "paymentMethod", "=", "PaymentMethod", "::", "findOne", "(", "$", "id", ")", ";", "$", "isDeleted", "=", "\\", "Yii", "::", "$", "app", "->", "shop_imagable", "->", "delete", "(", "'payment'", ",", "$", "paymentMethod", "->", "image", ")", ";", "if", "(", "$", "isDeleted", ")", "{", "$", "paymentMethod", "->", "image", "=", "NULL", ";", "$", "paymentMethod", "->", "save", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "Yii", "::", "$", "app", "->", "request", "->", "referrer", ")", ";", "}", "else", "throw", "new", "Exception", "(", "'Deleting failed.'", ")", ";", "}", "else", "throw", "new", "NotFoundHttpException", "(", ")", ";", "}" ]
Deletes image from Payment method model. @param integer $id @return mixed @throws NotFoundHttpException @throws Exception
[ "Deletes", "image", "from", "Payment", "method", "model", "." ]
6d139e0bb5a4e7733382cc6fe083173551905b92
https://github.com/black-lamp/blcms-payment/blob/6d139e0bb5a4e7733382cc6fe083173551905b92/backend/controllers/DefaultController.php#L149-L163
train
rzajac/phptools
src/Helper/Obj.php
Obj.get
public static function get($obj, $propName, $default = null) { if (!is_object($obj)) { return $default; } try { return $obj->$propName; } catch (\Exception $e) { } return $default; }
php
public static function get($obj, $propName, $default = null) { if (!is_object($obj)) { return $default; } try { return $obj->$propName; } catch (\Exception $e) { } return $default; }
[ "public", "static", "function", "get", "(", "$", "obj", ",", "$", "propName", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "is_object", "(", "$", "obj", ")", ")", "{", "return", "$", "default", ";", "}", "try", "{", "return", "$", "obj", "->", "$", "propName", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "}", "return", "$", "default", ";", "}" ]
Get object property value or default if it does not exist. This handles only public properties. @param object $obj The object. @param string $propName The public property name. @param mixed $default The default value to return if property name doesn't exist. @return mixed
[ "Get", "object", "property", "value", "or", "default", "if", "it", "does", "not", "exist", "." ]
3cbece7645942d244603c14ba897d8a676ee3088
https://github.com/rzajac/phptools/blob/3cbece7645942d244603c14ba897d8a676ee3088/src/Helper/Obj.php#L38-L50
train
rzajac/phptools
src/Helper/Obj.php
Obj.getRfl
public static function getRfl($obj, $propName, $default = null) { if (!is_object($obj)) { return $default; } try { $prop = new \ReflectionProperty($obj, $propName); } catch (\Exception $e) { return $default; } if ($prop->isPublic()) { return $obj->$propName; } else { $prop->setAccessible(true); return $prop->getValue($obj); } }
php
public static function getRfl($obj, $propName, $default = null) { if (!is_object($obj)) { return $default; } try { $prop = new \ReflectionProperty($obj, $propName); } catch (\Exception $e) { return $default; } if ($prop->isPublic()) { return $obj->$propName; } else { $prop->setAccessible(true); return $prop->getValue($obj); } }
[ "public", "static", "function", "getRfl", "(", "$", "obj", ",", "$", "propName", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "is_object", "(", "$", "obj", ")", ")", "{", "return", "$", "default", ";", "}", "try", "{", "$", "prop", "=", "new", "\\", "ReflectionProperty", "(", "$", "obj", ",", "$", "propName", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "$", "default", ";", "}", "if", "(", "$", "prop", "->", "isPublic", "(", ")", ")", "{", "return", "$", "obj", "->", "$", "propName", ";", "}", "else", "{", "$", "prop", "->", "setAccessible", "(", "true", ")", ";", "return", "$", "prop", "->", "getValue", "(", "$", "obj", ")", ";", "}", "}" ]
Get object property value using reflection. This method is slower then Obj::get. @param object $obj The object. @param string $propName The property name. @param mixed $default The default value to return if property name doesn't exist. @return mixed|null
[ "Get", "object", "property", "value", "using", "reflection", "." ]
3cbece7645942d244603c14ba897d8a676ee3088
https://github.com/rzajac/phptools/blob/3cbece7645942d244603c14ba897d8a676ee3088/src/Helper/Obj.php#L63-L82
train
prolic/HumusMvc
src/HumusMvc/Db/MultiDbManager.php
MultiDbManager.getDefaultDb
public function getDefaultDb($justPickOne = true) { if (null !== $this->defaultDb) { return $this->defaultDb; } if ($justPickOne) { return reset($this->dbs); // Return first db in db pool } return null; }
php
public function getDefaultDb($justPickOne = true) { if (null !== $this->defaultDb) { return $this->defaultDb; } if ($justPickOne) { return reset($this->dbs); // Return first db in db pool } return null; }
[ "public", "function", "getDefaultDb", "(", "$", "justPickOne", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "defaultDb", ")", "{", "return", "$", "this", "->", "defaultDb", ";", "}", "if", "(", "$", "justPickOne", ")", "{", "return", "reset", "(", "$", "this", "->", "dbs", ")", ";", "// Return first db in db pool", "}", "return", "null", ";", "}" ]
Get the default db connection @param boolean $justPickOne If true, a random (the first one in the stack) connection is returned if no default was set. If false, null is returned if no default was set. @return null|Zend_Db_Adapter_Abstract
[ "Get", "the", "default", "db", "connection" ]
09e8c6422d84b57745cc643047e10761be2a21a7
https://github.com/prolic/HumusMvc/blob/09e8c6422d84b57745cc643047e10761be2a21a7/src/HumusMvc/Db/MultiDbManager.php#L60-L71
train
prolic/HumusMvc
src/HumusMvc/Db/MultiDbManager.php
MultiDbManager.getDb
public function getDb($db = null) { if ($db === null) { return $this->getDefaultDb(); } if (isset($this->dbs[$db])) { return $this->dbs[$db]; } throw new Exception\InvalidArgumentException( 'A DB adapter was tried to retrieve, but was not configured' ); }
php
public function getDb($db = null) { if ($db === null) { return $this->getDefaultDb(); } if (isset($this->dbs[$db])) { return $this->dbs[$db]; } throw new Exception\InvalidArgumentException( 'A DB adapter was tried to retrieve, but was not configured' ); }
[ "public", "function", "getDb", "(", "$", "db", "=", "null", ")", "{", "if", "(", "$", "db", "===", "null", ")", "{", "return", "$", "this", "->", "getDefaultDb", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "dbs", "[", "$", "db", "]", ")", ")", "{", "return", "$", "this", "->", "dbs", "[", "$", "db", "]", ";", "}", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'A DB adapter was tried to retrieve, but was not configured'", ")", ";", "}" ]
Retrieve the specified database connection @param null|string|Zend_Db_Adapter_Abstract $db The adapter to retrieve. Null to retrieve the default connection @return Zend_Db_Adapter_Abstract @throws Exception\InvalidArgumentException if the given parameter could not be found
[ "Retrieve", "the", "specified", "database", "connection" ]
09e8c6422d84b57745cc643047e10761be2a21a7
https://github.com/prolic/HumusMvc/blob/09e8c6422d84b57745cc643047e10761be2a21a7/src/HumusMvc/Db/MultiDbManager.php#L81-L94
train
beMang/phpgone
core/Helpers/Session.php
Session.updateAttr
public function updateAttr($key, $value) { if (isset($_SESSION[$key])) { $_SESSION[$key] = $value; return true; } else { return false; } }
php
public function updateAttr($key, $value) { if (isset($_SESSION[$key])) { $_SESSION[$key] = $value; return true; } else { return false; } }
[ "public", "function", "updateAttr", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "_SESSION", "[", "$", "key", "]", ")", ")", "{", "$", "_SESSION", "[", "$", "key", "]", "=", "$", "value", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Modifie un attribut de la session @param string $key Clé de l'attribut à modifier @param string $value Valeur de l'attribut à modifier @return bool succès de l'opération
[ "Modifie", "un", "attribut", "de", "la", "session" ]
6da468283880b7f5b28dc3735f8f13c97382710b
https://github.com/beMang/phpgone/blob/6da468283880b7f5b28dc3735f8f13c97382710b/core/Helpers/Session.php#L30-L38
train
balintsera/evista-perform
src/ValueObject/SpecialFormFieldValidatorFactory.php
SpecialFormFieldValidatorFactory.create
public static function create(FormField $field, $submittedData) { switch ($field->getType()) { case 'email': $object = new SpecialEmailValidator($field, $submittedData); break; default: throw FormFieldException::noSuchType($field->getType()); break; } return $object; }
php
public static function create(FormField $field, $submittedData) { switch ($field->getType()) { case 'email': $object = new SpecialEmailValidator($field, $submittedData); break; default: throw FormFieldException::noSuchType($field->getType()); break; } return $object; }
[ "public", "static", "function", "create", "(", "FormField", "$", "field", ",", "$", "submittedData", ")", "{", "switch", "(", "$", "field", "->", "getType", "(", ")", ")", "{", "case", "'email'", ":", "$", "object", "=", "new", "SpecialEmailValidator", "(", "$", "field", ",", "$", "submittedData", ")", ";", "break", ";", "default", ":", "throw", "FormFieldException", "::", "noSuchType", "(", "$", "field", "->", "getType", "(", ")", ")", ";", "break", ";", "}", "return", "$", "object", ";", "}" ]
Factory method to create an appropriate type @param FormField $field @param $submittedData @return SpecialEmailValidator @throws FormFieldException
[ "Factory", "method", "to", "create", "an", "appropriate", "type" ]
2b8723852ebe824ed721f30293e1e0d2c14f4b21
https://github.com/balintsera/evista-perform/blob/2b8723852ebe824ed721f30293e1e0d2c14f4b21/src/ValueObject/SpecialFormFieldValidatorFactory.php#L24-L36
train
lasallecms/lasallecms-l5-mailgun-pkg
src/Processing/MapMailgunPostVariables.php
MapMailgunPostVariables.mapInboundPostVarsToEmail_messagesFields
public function mapInboundPostVarsToEmail_messagesFields() { $data = []; $data['user_id'] = $this->getUserIdByMappedEmailAddress(); $data['from_email_address'] = trim($this->request->input('sender')); $data['from_name'] = $this->genericWashText($this->request ->input('from')); $data['to_email_address'] = $this->setToEmailAddressField(); $data['to_name'] = $this->setToField(); $data['subject'] = $this->genericWashText($this->request->input('subject')); $data['body'] = $this->setBodyField(); $data['message_header'] = json_decode($this->request->input('message-headers')); $data['recipient'] = $this->request->input('recipient'); return $data; }
php
public function mapInboundPostVarsToEmail_messagesFields() { $data = []; $data['user_id'] = $this->getUserIdByMappedEmailAddress(); $data['from_email_address'] = trim($this->request->input('sender')); $data['from_name'] = $this->genericWashText($this->request ->input('from')); $data['to_email_address'] = $this->setToEmailAddressField(); $data['to_name'] = $this->setToField(); $data['subject'] = $this->genericWashText($this->request->input('subject')); $data['body'] = $this->setBodyField(); $data['message_header'] = json_decode($this->request->input('message-headers')); $data['recipient'] = $this->request->input('recipient'); return $data; }
[ "public", "function", "mapInboundPostVarsToEmail_messagesFields", "(", ")", "{", "$", "data", "=", "[", "]", ";", "$", "data", "[", "'user_id'", "]", "=", "$", "this", "->", "getUserIdByMappedEmailAddress", "(", ")", ";", "$", "data", "[", "'from_email_address'", "]", "=", "trim", "(", "$", "this", "->", "request", "->", "input", "(", "'sender'", ")", ")", ";", "$", "data", "[", "'from_name'", "]", "=", "$", "this", "->", "genericWashText", "(", "$", "this", "->", "request", "->", "input", "(", "'from'", ")", ")", ";", "$", "data", "[", "'to_email_address'", "]", "=", "$", "this", "->", "setToEmailAddressField", "(", ")", ";", "$", "data", "[", "'to_name'", "]", "=", "$", "this", "->", "setToField", "(", ")", ";", "$", "data", "[", "'subject'", "]", "=", "$", "this", "->", "genericWashText", "(", "$", "this", "->", "request", "->", "input", "(", "'subject'", ")", ")", ";", "$", "data", "[", "'body'", "]", "=", "$", "this", "->", "setBodyField", "(", ")", ";", "$", "data", "[", "'message_header'", "]", "=", "json_decode", "(", "$", "this", "->", "request", "->", "input", "(", "'message-headers'", ")", ")", ";", "$", "data", "[", "'recipient'", "]", "=", "$", "this", "->", "request", "->", "input", "(", "'recipient'", ")", ";", "return", "$", "data", ";", "}" ]
Map the non-attachment vars from the inbound email webhook to the email_messages fields @return array
[ "Map", "the", "non", "-", "attachment", "vars", "from", "the", "inbound", "email", "webhook", "to", "the", "email_messages", "fields" ]
f6c1fb92211b2537db87a1f03c126dc46691ee5e
https://github.com/lasallecms/lasallecms-l5-mailgun-pkg/blob/f6c1fb92211b2537db87a1f03c126dc46691ee5e/src/Processing/MapMailgunPostVariables.php#L106-L122
train
lasallecms/lasallecms-l5-mailgun-pkg
src/Processing/MapMailgunPostVariables.php
MapMailgunPostVariables.setBodyField
public function setBodyField() { if ($this->request->input('stripped-html')) { return $this->request->input('stripped-html'); } return $this->request->input('body-plain'); }
php
public function setBodyField() { if ($this->request->input('stripped-html')) { return $this->request->input('stripped-html'); } return $this->request->input('body-plain'); }
[ "public", "function", "setBodyField", "(", ")", "{", "if", "(", "$", "this", "->", "request", "->", "input", "(", "'stripped-html'", ")", ")", "{", "return", "$", "this", "->", "request", "->", "input", "(", "'stripped-html'", ")", ";", "}", "return", "$", "this", "->", "request", "->", "input", "(", "'body-plain'", ")", ";", "}" ]
Set the email's body field @return mixed
[ "Set", "the", "email", "s", "body", "field" ]
f6c1fb92211b2537db87a1f03c126dc46691ee5e
https://github.com/lasallecms/lasallecms-l5-mailgun-pkg/blob/f6c1fb92211b2537db87a1f03c126dc46691ee5e/src/Processing/MapMailgunPostVariables.php#L190-L197
train
ScaraMVC/Framework
src/Scara/Http/Request.php
Request.cast
public function cast($request) { if (is_array($request) || is_object($request)) { foreach ($request as $key => $value) { if (is_array($value)) { $this->cast($value); } else { $this->$key = $value; } } } }
php
public function cast($request) { if (is_array($request) || is_object($request)) { foreach ($request as $key => $value) { if (is_array($value)) { $this->cast($value); } else { $this->$key = $value; } } } }
[ "public", "function", "cast", "(", "$", "request", ")", "{", "if", "(", "is_array", "(", "$", "request", ")", "||", "is_object", "(", "$", "request", ")", ")", "{", "foreach", "(", "$", "request", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "this", "->", "cast", "(", "$", "value", ")", ";", "}", "else", "{", "$", "this", "->", "$", "key", "=", "$", "value", ";", "}", "}", "}", "}" ]
Casts the request array into new Request object. @param array $request - The request object
[ "Casts", "the", "request", "array", "into", "new", "Request", "object", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Http/Request.php#L46-L57
train
ScaraMVC/Framework
src/Scara/Http/Request.php
Request.setRequest
public function setRequest($request = []) { if (!empty($request)) { if (is_array($request)) { foreach ((array) $request as $item) { foreach ($item as $key => $value) { if (empty($value)) { $request['empty'] = 'true'; } else { $request['empty'] = 'false'; } } break; } $this->_request = $request; return $this; } else { throw new \Exception('Initial request object must be an instance of an array!'); } } else { throw new \Exception('An empty request object was given!'); } }
php
public function setRequest($request = []) { if (!empty($request)) { if (is_array($request)) { foreach ((array) $request as $item) { foreach ($item as $key => $value) { if (empty($value)) { $request['empty'] = 'true'; } else { $request['empty'] = 'false'; } } break; } $this->_request = $request; return $this; } else { throw new \Exception('Initial request object must be an instance of an array!'); } } else { throw new \Exception('An empty request object was given!'); } }
[ "public", "function", "setRequest", "(", "$", "request", "=", "[", "]", ")", "{", "if", "(", "!", "empty", "(", "$", "request", ")", ")", "{", "if", "(", "is_array", "(", "$", "request", ")", ")", "{", "foreach", "(", "(", "array", ")", "$", "request", "as", "$", "item", ")", "{", "foreach", "(", "$", "item", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "$", "request", "[", "'empty'", "]", "=", "'true'", ";", "}", "else", "{", "$", "request", "[", "'empty'", "]", "=", "'false'", ";", "}", "}", "break", ";", "}", "$", "this", "->", "_request", "=", "$", "request", ";", "return", "$", "this", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Initial request object must be an instance of an array!'", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'An empty request object was given!'", ")", ";", "}", "}" ]
Sets the request. @param array $request - The request object @throws \Exception @return Request
[ "Sets", "the", "request", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Http/Request.php#L78-L101
train
cubicmushroom/valueobjects
src/DateTime/DateTime.php
DateTime.sameValueAs
public function sameValueAs(ValueObjectInterface $date_time) { if (false === Util::classEquals($this, $date_time)) { return false; } return $this->getDate()->sameValueAs($date_time->getDate()) && $this->getTime()->sameValueAs($date_time->getTime()); }
php
public function sameValueAs(ValueObjectInterface $date_time) { if (false === Util::classEquals($this, $date_time)) { return false; } return $this->getDate()->sameValueAs($date_time->getDate()) && $this->getTime()->sameValueAs($date_time->getTime()); }
[ "public", "function", "sameValueAs", "(", "ValueObjectInterface", "$", "date_time", ")", "{", "if", "(", "false", "===", "Util", "::", "classEquals", "(", "$", "this", ",", "$", "date_time", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "getDate", "(", ")", "->", "sameValueAs", "(", "$", "date_time", "->", "getDate", "(", ")", ")", "&&", "$", "this", "->", "getTime", "(", ")", "->", "sameValueAs", "(", "$", "date_time", "->", "getTime", "(", ")", ")", ";", "}" ]
Tells whether two DateTime are equal by comparing their values @param ValueObjectInterface $date_time @return bool
[ "Tells", "whether", "two", "DateTime", "are", "equal", "by", "comparing", "their", "values" ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/DateTime/DateTime.php#L86-L93
train
cubicmushroom/valueobjects
src/DateTime/DateTime.php
DateTime.toNativeDateTime
public function toNativeDateTime() { $year = $this->getDate()->getYear()->toNative(); $month = $this->getDate()->getMonth()->getNumericValue(); $day = $this->getDate()->getDay()->toNative(); $hour = $this->getTime()->getHour()->toNative(); $minute = $this->getTime()->getMinute()->toNative(); $second = $this->getTime()->getSecond()->toNative(); $dateTime = new \DateTime(); $dateTime->setDate($year, $month, $day); $dateTime->setTime($hour, $minute, $second); return $dateTime; }
php
public function toNativeDateTime() { $year = $this->getDate()->getYear()->toNative(); $month = $this->getDate()->getMonth()->getNumericValue(); $day = $this->getDate()->getDay()->toNative(); $hour = $this->getTime()->getHour()->toNative(); $minute = $this->getTime()->getMinute()->toNative(); $second = $this->getTime()->getSecond()->toNative(); $dateTime = new \DateTime(); $dateTime->setDate($year, $month, $day); $dateTime->setTime($hour, $minute, $second); return $dateTime; }
[ "public", "function", "toNativeDateTime", "(", ")", "{", "$", "year", "=", "$", "this", "->", "getDate", "(", ")", "->", "getYear", "(", ")", "->", "toNative", "(", ")", ";", "$", "month", "=", "$", "this", "->", "getDate", "(", ")", "->", "getMonth", "(", ")", "->", "getNumericValue", "(", ")", ";", "$", "day", "=", "$", "this", "->", "getDate", "(", ")", "->", "getDay", "(", ")", "->", "toNative", "(", ")", ";", "$", "hour", "=", "$", "this", "->", "getTime", "(", ")", "->", "getHour", "(", ")", "->", "toNative", "(", ")", ";", "$", "minute", "=", "$", "this", "->", "getTime", "(", ")", "->", "getMinute", "(", ")", "->", "toNative", "(", ")", ";", "$", "second", "=", "$", "this", "->", "getTime", "(", ")", "->", "getSecond", "(", ")", "->", "toNative", "(", ")", ";", "$", "dateTime", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "dateTime", "->", "setDate", "(", "$", "year", ",", "$", "month", ",", "$", "day", ")", ";", "$", "dateTime", "->", "setTime", "(", "$", "hour", ",", "$", "minute", ",", "$", "second", ")", ";", "return", "$", "dateTime", ";", "}" ]
Returns a native PHP \DateTime version of the current DateTime. @return \DateTime
[ "Returns", "a", "native", "PHP", "\\", "DateTime", "version", "of", "the", "current", "DateTime", "." ]
4554239ab75d65eeb9773219aa5b07e9fbfabb92
https://github.com/cubicmushroom/valueobjects/blob/4554239ab75d65eeb9773219aa5b07e9fbfabb92/src/DateTime/DateTime.php#L120-L134
train
KeyboardCowboy/drush-denver
Denver.class.php
Denver.setEnvironments
public function setEnvironments($env) { $envs = (explode('+', $env)); while (!empty($envs)) { $_env = array_shift($envs); if (!$this->setEnvironment($_env)) { $msg = dt("Unable to locate an environment definition for '@env'.", ['@env' => $_env]); if (empty($envs)) { drush_log($msg, 'warning'); return FALSE; } else { drush_log($msg, 'warning'); if (!drush_confirm(dt("Do you want to process the other environments?"))) { return drush_user_abort(dt("Aborting.")); } } } } return TRUE; }
php
public function setEnvironments($env) { $envs = (explode('+', $env)); while (!empty($envs)) { $_env = array_shift($envs); if (!$this->setEnvironment($_env)) { $msg = dt("Unable to locate an environment definition for '@env'.", ['@env' => $_env]); if (empty($envs)) { drush_log($msg, 'warning'); return FALSE; } else { drush_log($msg, 'warning'); if (!drush_confirm(dt("Do you want to process the other environments?"))) { return drush_user_abort(dt("Aborting.")); } } } } return TRUE; }
[ "public", "function", "setEnvironments", "(", "$", "env", ")", "{", "$", "envs", "=", "(", "explode", "(", "'+'", ",", "$", "env", ")", ")", ";", "while", "(", "!", "empty", "(", "$", "envs", ")", ")", "{", "$", "_env", "=", "array_shift", "(", "$", "envs", ")", ";", "if", "(", "!", "$", "this", "->", "setEnvironment", "(", "$", "_env", ")", ")", "{", "$", "msg", "=", "dt", "(", "\"Unable to locate an environment definition for '@env'.\"", ",", "[", "'@env'", "=>", "$", "_env", "]", ")", ";", "if", "(", "empty", "(", "$", "envs", ")", ")", "{", "drush_log", "(", "$", "msg", ",", "'warning'", ")", ";", "return", "FALSE", ";", "}", "else", "{", "drush_log", "(", "$", "msg", ",", "'warning'", ")", ";", "if", "(", "!", "drush_confirm", "(", "dt", "(", "\"Do you want to process the other environments?\"", ")", ")", ")", "{", "return", "drush_user_abort", "(", "dt", "(", "\"Aborting.\"", ")", ")", ";", "}", "}", "}", "}", "return", "TRUE", ";", "}" ]
Load the desired environments. @param string $env The environment argument. May be composite (env1+env2). @return bool Whether the environments were loaded.
[ "Load", "the", "desired", "environments", "." ]
37608c6bda0d1ad59a99e0ea007dc164995b2669
https://github.com/KeyboardCowboy/drush-denver/blob/37608c6bda0d1ad59a99e0ea007dc164995b2669/Denver.class.php#L99-L119
train
KeyboardCowboy/drush-denver
Denver.class.php
Denver.setEnvironment
private function setEnvironment($env) { if (isset($this->environments[$env])) { $this->loadEnvironment($env); return TRUE; } else { return FALSE; } }
php
private function setEnvironment($env) { if (isset($this->environments[$env])) { $this->loadEnvironment($env); return TRUE; } else { return FALSE; } }
[ "private", "function", "setEnvironment", "(", "$", "env", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "environments", "[", "$", "env", "]", ")", ")", "{", "$", "this", "->", "loadEnvironment", "(", "$", "env", ")", ";", "return", "TRUE", ";", "}", "else", "{", "return", "FALSE", ";", "}", "}" ]
Load an individual environment definition. @param string $env The single env def name. @return bool Whether the environment was loaded.
[ "Load", "an", "individual", "environment", "definition", "." ]
37608c6bda0d1ad59a99e0ea007dc164995b2669
https://github.com/KeyboardCowboy/drush-denver/blob/37608c6bda0d1ad59a99e0ea007dc164995b2669/Denver.class.php#L130-L138
train
KeyboardCowboy/drush-denver
Denver.class.php
Denver.exec
public function exec($groups = '') { $_groups = !empty($groups) ? explode(',', $groups) : array(); // Print a message that the build is starting. $names = implode('+', array_keys($this->loadedEnvs)); drush_print(); drush_print($this->formatHeading(dt("--- CONFIGURING @name ENVIRONMENT ---", array('@name' => strtoupper($names))), '')); foreach ($this->exec as $type => $options) { if (!empty($options) && (empty($_groups) || in_array($type, $_groups))) { // Print a nice heading. $heading = $this->formatHeading($type); drush_print(); drush_print("{$heading}"); switch ($type) { case 'modules'; $this->execModules($options); break; case 'variables': $this->execVariables($options); break; case 'permissions': $this->execPermissions($options); break; case 'commands': $this->execCommands($options); break; default: drush_set_error('INVALID_ENV_GROUP', dt("I'm not sure what to do with '!group'.", ['!group' => $type])); break; } } } drush_print(); if (drush_get_error()) { drush_set_error('DENVER_ENV_SETUP_FAILED', dt("The environment may not have been configured the way you wanted. Check the logs for more details.")); drush_print(dt("Use the --groups option to run only certain sections of an environment definition.")); } else { return drush_log(dt("Environment setup complete!"), 'success'); } }
php
public function exec($groups = '') { $_groups = !empty($groups) ? explode(',', $groups) : array(); // Print a message that the build is starting. $names = implode('+', array_keys($this->loadedEnvs)); drush_print(); drush_print($this->formatHeading(dt("--- CONFIGURING @name ENVIRONMENT ---", array('@name' => strtoupper($names))), '')); foreach ($this->exec as $type => $options) { if (!empty($options) && (empty($_groups) || in_array($type, $_groups))) { // Print a nice heading. $heading = $this->formatHeading($type); drush_print(); drush_print("{$heading}"); switch ($type) { case 'modules'; $this->execModules($options); break; case 'variables': $this->execVariables($options); break; case 'permissions': $this->execPermissions($options); break; case 'commands': $this->execCommands($options); break; default: drush_set_error('INVALID_ENV_GROUP', dt("I'm not sure what to do with '!group'.", ['!group' => $type])); break; } } } drush_print(); if (drush_get_error()) { drush_set_error('DENVER_ENV_SETUP_FAILED', dt("The environment may not have been configured the way you wanted. Check the logs for more details.")); drush_print(dt("Use the --groups option to run only certain sections of an environment definition.")); } else { return drush_log(dt("Environment setup complete!"), 'success'); } }
[ "public", "function", "exec", "(", "$", "groups", "=", "''", ")", "{", "$", "_groups", "=", "!", "empty", "(", "$", "groups", ")", "?", "explode", "(", "','", ",", "$", "groups", ")", ":", "array", "(", ")", ";", "// Print a message that the build is starting.", "$", "names", "=", "implode", "(", "'+'", ",", "array_keys", "(", "$", "this", "->", "loadedEnvs", ")", ")", ";", "drush_print", "(", ")", ";", "drush_print", "(", "$", "this", "->", "formatHeading", "(", "dt", "(", "\"--- CONFIGURING @name ENVIRONMENT ---\"", ",", "array", "(", "'@name'", "=>", "strtoupper", "(", "$", "names", ")", ")", ")", ",", "''", ")", ")", ";", "foreach", "(", "$", "this", "->", "exec", "as", "$", "type", "=>", "$", "options", ")", "{", "if", "(", "!", "empty", "(", "$", "options", ")", "&&", "(", "empty", "(", "$", "_groups", ")", "||", "in_array", "(", "$", "type", ",", "$", "_groups", ")", ")", ")", "{", "// Print a nice heading.", "$", "heading", "=", "$", "this", "->", "formatHeading", "(", "$", "type", ")", ";", "drush_print", "(", ")", ";", "drush_print", "(", "\"{$heading}\"", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "'modules'", ";", "$", "this", "->", "execModules", "(", "$", "options", ")", ";", "break", ";", "case", "'variables'", ":", "$", "this", "->", "execVariables", "(", "$", "options", ")", ";", "break", ";", "case", "'permissions'", ":", "$", "this", "->", "execPermissions", "(", "$", "options", ")", ";", "break", ";", "case", "'commands'", ":", "$", "this", "->", "execCommands", "(", "$", "options", ")", ";", "break", ";", "default", ":", "drush_set_error", "(", "'INVALID_ENV_GROUP'", ",", "dt", "(", "\"I'm not sure what to do with '!group'.\"", ",", "[", "'!group'", "=>", "$", "type", "]", ")", ")", ";", "break", ";", "}", "}", "}", "drush_print", "(", ")", ";", "if", "(", "drush_get_error", "(", ")", ")", "{", "drush_set_error", "(", "'DENVER_ENV_SETUP_FAILED'", ",", "dt", "(", "\"The environment may not have been configured the way you wanted. Check the logs for more details.\"", ")", ")", ";", "drush_print", "(", "dt", "(", "\"Use the --groups option to run only certain sections of an environment definition.\"", ")", ")", ";", "}", "else", "{", "return", "drush_log", "(", "dt", "(", "\"Environment setup complete!\"", ")", ",", "'success'", ")", ";", "}", "}" ]
Apply the settings. @param string $groups The groups option as passed in from drush_get_option().
[ "Apply", "the", "settings", "." ]
37608c6bda0d1ad59a99e0ea007dc164995b2669
https://github.com/KeyboardCowboy/drush-denver/blob/37608c6bda0d1ad59a99e0ea007dc164995b2669/Denver.class.php#L156-L203
train
KeyboardCowboy/drush-denver
Denver.class.php
Denver.printSummary
public function printSummary() { drush_print(); // Print env files used for this definition. drush_print($this->formatHeading('Environment Definitions Found')); foreach ($this->loadedEnvs as $filename) { drush_print("{$filename}", 1); } drush_print(); drush_print($this->formatHeading(dt("CONFIGURATION SUMMARY"))); // We want to make sure they are printed in the same order as they will run. foreach ($this->getActiveDefinition() as $group => $options) { // Print a nice heading. $heading = $this->formatHeading($group); switch (strtolower($group)) { case 'modules': $this->printModuleSummary($options, $heading); break; case 'variables': $this->printVariableSummary($options, $heading); break; case 'permissions': $this->printPermissionSummary($options, $heading); break; case 'commands': $this->printCommandSummary($options, $heading); break; default: drush_print($this->formatHeading($group)); drush_log(dt("I'm not sure what to do with '@group'.", ['@group' => $group]), 'warning'); break; } } }
php
public function printSummary() { drush_print(); // Print env files used for this definition. drush_print($this->formatHeading('Environment Definitions Found')); foreach ($this->loadedEnvs as $filename) { drush_print("{$filename}", 1); } drush_print(); drush_print($this->formatHeading(dt("CONFIGURATION SUMMARY"))); // We want to make sure they are printed in the same order as they will run. foreach ($this->getActiveDefinition() as $group => $options) { // Print a nice heading. $heading = $this->formatHeading($group); switch (strtolower($group)) { case 'modules': $this->printModuleSummary($options, $heading); break; case 'variables': $this->printVariableSummary($options, $heading); break; case 'permissions': $this->printPermissionSummary($options, $heading); break; case 'commands': $this->printCommandSummary($options, $heading); break; default: drush_print($this->formatHeading($group)); drush_log(dt("I'm not sure what to do with '@group'.", ['@group' => $group]), 'warning'); break; } } }
[ "public", "function", "printSummary", "(", ")", "{", "drush_print", "(", ")", ";", "// Print env files used for this definition.", "drush_print", "(", "$", "this", "->", "formatHeading", "(", "'Environment Definitions Found'", ")", ")", ";", "foreach", "(", "$", "this", "->", "loadedEnvs", "as", "$", "filename", ")", "{", "drush_print", "(", "\"{$filename}\"", ",", "1", ")", ";", "}", "drush_print", "(", ")", ";", "drush_print", "(", "$", "this", "->", "formatHeading", "(", "dt", "(", "\"CONFIGURATION SUMMARY\"", ")", ")", ")", ";", "// We want to make sure they are printed in the same order as they will run.", "foreach", "(", "$", "this", "->", "getActiveDefinition", "(", ")", "as", "$", "group", "=>", "$", "options", ")", "{", "// Print a nice heading.", "$", "heading", "=", "$", "this", "->", "formatHeading", "(", "$", "group", ")", ";", "switch", "(", "strtolower", "(", "$", "group", ")", ")", "{", "case", "'modules'", ":", "$", "this", "->", "printModuleSummary", "(", "$", "options", ",", "$", "heading", ")", ";", "break", ";", "case", "'variables'", ":", "$", "this", "->", "printVariableSummary", "(", "$", "options", ",", "$", "heading", ")", ";", "break", ";", "case", "'permissions'", ":", "$", "this", "->", "printPermissionSummary", "(", "$", "options", ",", "$", "heading", ")", ";", "break", ";", "case", "'commands'", ":", "$", "this", "->", "printCommandSummary", "(", "$", "options", ",", "$", "heading", ")", ";", "break", ";", "default", ":", "drush_print", "(", "$", "this", "->", "formatHeading", "(", "$", "group", ")", ")", ";", "drush_log", "(", "dt", "(", "\"I'm not sure what to do with '@group'.\"", ",", "[", "'@group'", "=>", "$", "group", "]", ")", ",", "'warning'", ")", ";", "break", ";", "}", "}", "}" ]
Print a summary of the environment definitions.
[ "Print", "a", "summary", "of", "the", "environment", "definitions", "." ]
37608c6bda0d1ad59a99e0ea007dc164995b2669
https://github.com/KeyboardCowboy/drush-denver/blob/37608c6bda0d1ad59a99e0ea007dc164995b2669/Denver.class.php#L208-L248
train
KeyboardCowboy/drush-denver
Denver.class.php
Denver.printModuleSummary
private function printModuleSummary($options, $heading = '') { // Print module info. if (!empty($options)) { drush_print("{$heading}"); $values = []; foreach ($options as $status => $modules) { $key = dt("!action", ['!action' => ucwords($status)]); $value = implode(', ', $modules); $values[$key] = $value; } drush_print_format([$values], 'key-value-list'); } }
php
private function printModuleSummary($options, $heading = '') { // Print module info. if (!empty($options)) { drush_print("{$heading}"); $values = []; foreach ($options as $status => $modules) { $key = dt("!action", ['!action' => ucwords($status)]); $value = implode(', ', $modules); $values[$key] = $value; } drush_print_format([$values], 'key-value-list'); } }
[ "private", "function", "printModuleSummary", "(", "$", "options", ",", "$", "heading", "=", "''", ")", "{", "// Print module info.", "if", "(", "!", "empty", "(", "$", "options", ")", ")", "{", "drush_print", "(", "\"{$heading}\"", ")", ";", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "options", "as", "$", "status", "=>", "$", "modules", ")", "{", "$", "key", "=", "dt", "(", "\"!action\"", ",", "[", "'!action'", "=>", "ucwords", "(", "$", "status", ")", "]", ")", ";", "$", "value", "=", "implode", "(", "', '", ",", "$", "modules", ")", ";", "$", "values", "[", "$", "key", "]", "=", "$", "value", ";", "}", "drush_print_format", "(", "[", "$", "values", "]", ",", "'key-value-list'", ")", ";", "}", "}" ]
Print a summary of the module section. @param array $options The array of module information from the yaml file.
[ "Print", "a", "summary", "of", "the", "module", "section", "." ]
37608c6bda0d1ad59a99e0ea007dc164995b2669
https://github.com/KeyboardCowboy/drush-denver/blob/37608c6bda0d1ad59a99e0ea007dc164995b2669/Denver.class.php#L256-L270
train
KeyboardCowboy/drush-denver
Denver.class.php
Denver.printPermissionSummary
private function printPermissionSummary($options, $heading = '') { // Print permission info. if (!empty($options)) { drush_print("{$heading}"); foreach ($options as $role => $perms) { foreach ($options[$role] as &$grant) { $grant = ($grant == 0) ? dt('revoke') : dt('grant'); } drush_print($role, 1); drush_print_format([$options[$role]], 'key-value-list'); } } }
php
private function printPermissionSummary($options, $heading = '') { // Print permission info. if (!empty($options)) { drush_print("{$heading}"); foreach ($options as $role => $perms) { foreach ($options[$role] as &$grant) { $grant = ($grant == 0) ? dt('revoke') : dt('grant'); } drush_print($role, 1); drush_print_format([$options[$role]], 'key-value-list'); } } }
[ "private", "function", "printPermissionSummary", "(", "$", "options", ",", "$", "heading", "=", "''", ")", "{", "// Print permission info.", "if", "(", "!", "empty", "(", "$", "options", ")", ")", "{", "drush_print", "(", "\"{$heading}\"", ")", ";", "foreach", "(", "$", "options", "as", "$", "role", "=>", "$", "perms", ")", "{", "foreach", "(", "$", "options", "[", "$", "role", "]", "as", "&", "$", "grant", ")", "{", "$", "grant", "=", "(", "$", "grant", "==", "0", ")", "?", "dt", "(", "'revoke'", ")", ":", "dt", "(", "'grant'", ")", ";", "}", "drush_print", "(", "$", "role", ",", "1", ")", ";", "drush_print_format", "(", "[", "$", "options", "[", "$", "role", "]", "]", ",", "'key-value-list'", ")", ";", "}", "}", "}" ]
Print a summary of the permission section. @param array $options The array of permission information from the yaml file.
[ "Print", "a", "summary", "of", "the", "permission", "section", "." ]
37608c6bda0d1ad59a99e0ea007dc164995b2669
https://github.com/KeyboardCowboy/drush-denver/blob/37608c6bda0d1ad59a99e0ea007dc164995b2669/Denver.class.php#L293-L307
train
KeyboardCowboy/drush-denver
Denver.class.php
Denver.printCommandSummary
private function printCommandSummary($options, $heading = '') { // Print command info. if (!empty($options)) { drush_print("{$heading}"); foreach ($options as $command => $info) { drush_print($this->formatCommand($info), 1); } drush_print(); } }
php
private function printCommandSummary($options, $heading = '') { // Print command info. if (!empty($options)) { drush_print("{$heading}"); foreach ($options as $command => $info) { drush_print($this->formatCommand($info), 1); } drush_print(); } }
[ "private", "function", "printCommandSummary", "(", "$", "options", ",", "$", "heading", "=", "''", ")", "{", "// Print command info.", "if", "(", "!", "empty", "(", "$", "options", ")", ")", "{", "drush_print", "(", "\"{$heading}\"", ")", ";", "foreach", "(", "$", "options", "as", "$", "command", "=>", "$", "info", ")", "{", "drush_print", "(", "$", "this", "->", "formatCommand", "(", "$", "info", ")", ",", "1", ")", ";", "}", "drush_print", "(", ")", ";", "}", "}" ]
Print a summary of the command section. @param array $options The array of command information from the yaml file.
[ "Print", "a", "summary", "of", "the", "command", "section", "." ]
37608c6bda0d1ad59a99e0ea007dc164995b2669
https://github.com/KeyboardCowboy/drush-denver/blob/37608c6bda0d1ad59a99e0ea007dc164995b2669/Denver.class.php#L315-L325
train
KeyboardCowboy/drush-denver
Denver.class.php
Denver.execVariables
private function execVariables(array $options) { foreach ($options as $variable => $value) { if ($value === '[DELETE]') { variable_del($variable); drush_print(dt("'@var' was deleted.", ['@var' => $variable])); } else { variable_set($variable, $value); if (is_scalar($value)) { drush_print(dt("'@var' set to @val.", [ '@var' => $variable, '@val' => $value, ])); } else { drush_print(dt("'@var' has been set.", ['@var' => $variable])); } } } }
php
private function execVariables(array $options) { foreach ($options as $variable => $value) { if ($value === '[DELETE]') { variable_del($variable); drush_print(dt("'@var' was deleted.", ['@var' => $variable])); } else { variable_set($variable, $value); if (is_scalar($value)) { drush_print(dt("'@var' set to @val.", [ '@var' => $variable, '@val' => $value, ])); } else { drush_print(dt("'@var' has been set.", ['@var' => $variable])); } } } }
[ "private", "function", "execVariables", "(", "array", "$", "options", ")", "{", "foreach", "(", "$", "options", "as", "$", "variable", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "===", "'[DELETE]'", ")", "{", "variable_del", "(", "$", "variable", ")", ";", "drush_print", "(", "dt", "(", "\"'@var' was deleted.\"", ",", "[", "'@var'", "=>", "$", "variable", "]", ")", ")", ";", "}", "else", "{", "variable_set", "(", "$", "variable", ",", "$", "value", ")", ";", "if", "(", "is_scalar", "(", "$", "value", ")", ")", "{", "drush_print", "(", "dt", "(", "\"'@var' set to @val.\"", ",", "[", "'@var'", "=>", "$", "variable", ",", "'@val'", "=>", "$", "value", ",", "]", ")", ")", ";", "}", "else", "{", "drush_print", "(", "dt", "(", "\"'@var' has been set.\"", ",", "[", "'@var'", "=>", "$", "variable", "]", ")", ")", ";", "}", "}", "}", "}" ]
Set system variables. @todo How does this work in Drupal 8? @param array $options The variables and their values.
[ "Set", "system", "variables", "." ]
37608c6bda0d1ad59a99e0ea007dc164995b2669
https://github.com/KeyboardCowboy/drush-denver/blob/37608c6bda0d1ad59a99e0ea007dc164995b2669/Denver.class.php#L371-L391
train
KeyboardCowboy/drush-denver
Denver.class.php
Denver.formatHeading
public function formatHeading($text, $line_ending = ":") { $green = "\033[1;32;40m\033[1m%s{$line_ending}\033[0m"; $heading = sprintf($green, ucwords($text)); return $heading; }
php
public function formatHeading($text, $line_ending = ":") { $green = "\033[1;32;40m\033[1m%s{$line_ending}\033[0m"; $heading = sprintf($green, ucwords($text)); return $heading; }
[ "public", "function", "formatHeading", "(", "$", "text", ",", "$", "line_ending", "=", "\":\"", ")", "{", "$", "green", "=", "\"\\033[1;32;40m\\033[1m%s{$line_ending}\\033[0m\"", ";", "$", "heading", "=", "sprintf", "(", "$", "green", ",", "ucwords", "(", "$", "text", ")", ")", ";", "return", "$", "heading", ";", "}" ]
Format a nice, readable heading for the user. @param string $text The raw heading text. @param string $line_ending A string to end the heading with. @return string The formatted heading text.
[ "Format", "a", "nice", "readable", "heading", "for", "the", "user", "." ]
37608c6bda0d1ad59a99e0ea007dc164995b2669
https://github.com/KeyboardCowboy/drush-denver/blob/37608c6bda0d1ad59a99e0ea007dc164995b2669/Denver.class.php#L484-L488
train
KeyboardCowboy/drush-denver
Denver.class.php
Denver.formatCommand
public function formatCommand($info) { // Create the base. $parts = ["drush"]; $parts[] = $info['alias']; // Check for a '--yes' options and set it early for common formatting. if (isset($info['options']['yes'])) { $parts[] = '-y'; unset($info['options']['yes']); } // Add the command name. $parts[] = $info['name']; // Add arguments. if (!empty($info['args'])) { $parts[] = implode(' ', $info['args']); } // Add options. if (!empty($info['options'])) { // Skip the config option. unset($info['options']['config']); foreach ($info['options'] as $option => $value) { $part = "--{$option}"; if ($value !== TRUE && $value !== 1) { $part .= "={$value}"; } $parts[] = $part; } } return implode(' ', $parts); }
php
public function formatCommand($info) { // Create the base. $parts = ["drush"]; $parts[] = $info['alias']; // Check for a '--yes' options and set it early for common formatting. if (isset($info['options']['yes'])) { $parts[] = '-y'; unset($info['options']['yes']); } // Add the command name. $parts[] = $info['name']; // Add arguments. if (!empty($info['args'])) { $parts[] = implode(' ', $info['args']); } // Add options. if (!empty($info['options'])) { // Skip the config option. unset($info['options']['config']); foreach ($info['options'] as $option => $value) { $part = "--{$option}"; if ($value !== TRUE && $value !== 1) { $part .= "={$value}"; } $parts[] = $part; } } return implode(' ', $parts); }
[ "public", "function", "formatCommand", "(", "$", "info", ")", "{", "// Create the base.", "$", "parts", "=", "[", "\"drush\"", "]", ";", "$", "parts", "[", "]", "=", "$", "info", "[", "'alias'", "]", ";", "// Check for a '--yes' options and set it early for common formatting.", "if", "(", "isset", "(", "$", "info", "[", "'options'", "]", "[", "'yes'", "]", ")", ")", "{", "$", "parts", "[", "]", "=", "'-y'", ";", "unset", "(", "$", "info", "[", "'options'", "]", "[", "'yes'", "]", ")", ";", "}", "// Add the command name.", "$", "parts", "[", "]", "=", "$", "info", "[", "'name'", "]", ";", "// Add arguments.", "if", "(", "!", "empty", "(", "$", "info", "[", "'args'", "]", ")", ")", "{", "$", "parts", "[", "]", "=", "implode", "(", "' '", ",", "$", "info", "[", "'args'", "]", ")", ";", "}", "// Add options.", "if", "(", "!", "empty", "(", "$", "info", "[", "'options'", "]", ")", ")", "{", "// Skip the config option.", "unset", "(", "$", "info", "[", "'options'", "]", "[", "'config'", "]", ")", ";", "foreach", "(", "$", "info", "[", "'options'", "]", "as", "$", "option", "=>", "$", "value", ")", "{", "$", "part", "=", "\"--{$option}\"", ";", "if", "(", "$", "value", "!==", "TRUE", "&&", "$", "value", "!==", "1", ")", "{", "$", "part", ".=", "\"={$value}\"", ";", "}", "$", "parts", "[", "]", "=", "$", "part", ";", "}", "}", "return", "implode", "(", "' '", ",", "$", "parts", ")", ";", "}" ]
Format a command as a single line. @param array|null $info The command settings. @return string The formatted command.
[ "Format", "a", "command", "as", "a", "single", "line", "." ]
37608c6bda0d1ad59a99e0ea007dc164995b2669
https://github.com/KeyboardCowboy/drush-denver/blob/37608c6bda0d1ad59a99e0ea007dc164995b2669/Denver.class.php#L499-L534
train
KeyboardCowboy/drush-denver
Denver.class.php
Denver.loadEnvironment
private function loadEnvironment($env) { $this->exec = array_merge_recursive_distinct($this->exec, $this->environments[$env]); $this->loadedEnvs[$env] = $this->exec['filename']; unset($this->exec['filename']); }
php
private function loadEnvironment($env) { $this->exec = array_merge_recursive_distinct($this->exec, $this->environments[$env]); $this->loadedEnvs[$env] = $this->exec['filename']; unset($this->exec['filename']); }
[ "private", "function", "loadEnvironment", "(", "$", "env", ")", "{", "$", "this", "->", "exec", "=", "array_merge_recursive_distinct", "(", "$", "this", "->", "exec", ",", "$", "this", "->", "environments", "[", "$", "env", "]", ")", ";", "$", "this", "->", "loadedEnvs", "[", "$", "env", "]", "=", "$", "this", "->", "exec", "[", "'filename'", "]", ";", "unset", "(", "$", "this", "->", "exec", "[", "'filename'", "]", ")", ";", "}" ]
Load in an environment definition. @param string $env An environment name.
[ "Load", "in", "an", "environment", "definition", "." ]
37608c6bda0d1ad59a99e0ea007dc164995b2669
https://github.com/KeyboardCowboy/drush-denver/blob/37608c6bda0d1ad59a99e0ea007dc164995b2669/Denver.class.php#L542-L546
train
KeyboardCowboy/drush-denver
Denver.class.php
Denver.loadConfig
private function loadConfig() { drush_log(dt('Loading config paths.'), 'debug'); $config_paths = [$this->getSiteDir()]; // Find directories to scan for environment config files. // system, 'home.drush', 'drupal', 'custom' foreach ($this->contexts as $context) { if ($files = _drush_config_file($context, 'env')) { if (is_array($files)) { foreach ($files as $file) { $config_paths[] = dirname($file); } } else { $config_paths[] = dirname($files); } } } // Remove any empty values. $config_paths = array_filter($config_paths); // Flip the config list for proper hierarchy. $this->configPaths = array_reverse($config_paths); drush_log(dt('Loaded config paths.'), 'debug'); }
php
private function loadConfig() { drush_log(dt('Loading config paths.'), 'debug'); $config_paths = [$this->getSiteDir()]; // Find directories to scan for environment config files. // system, 'home.drush', 'drupal', 'custom' foreach ($this->contexts as $context) { if ($files = _drush_config_file($context, 'env')) { if (is_array($files)) { foreach ($files as $file) { $config_paths[] = dirname($file); } } else { $config_paths[] = dirname($files); } } } // Remove any empty values. $config_paths = array_filter($config_paths); // Flip the config list for proper hierarchy. $this->configPaths = array_reverse($config_paths); drush_log(dt('Loaded config paths.'), 'debug'); }
[ "private", "function", "loadConfig", "(", ")", "{", "drush_log", "(", "dt", "(", "'Loading config paths.'", ")", ",", "'debug'", ")", ";", "$", "config_paths", "=", "[", "$", "this", "->", "getSiteDir", "(", ")", "]", ";", "// Find directories to scan for environment config files.", "// system, 'home.drush', 'drupal', 'custom'", "foreach", "(", "$", "this", "->", "contexts", "as", "$", "context", ")", "{", "if", "(", "$", "files", "=", "_drush_config_file", "(", "$", "context", ",", "'env'", ")", ")", "{", "if", "(", "is_array", "(", "$", "files", ")", ")", "{", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "config_paths", "[", "]", "=", "dirname", "(", "$", "file", ")", ";", "}", "}", "else", "{", "$", "config_paths", "[", "]", "=", "dirname", "(", "$", "files", ")", ";", "}", "}", "}", "// Remove any empty values.", "$", "config_paths", "=", "array_filter", "(", "$", "config_paths", ")", ";", "// Flip the config list for proper hierarchy.", "$", "this", "->", "configPaths", "=", "array_reverse", "(", "$", "config_paths", ")", ";", "drush_log", "(", "dt", "(", "'Loaded config paths.'", ")", ",", "'debug'", ")", ";", "}" ]
Find the config paths to search for env definitions.
[ "Find", "the", "config", "paths", "to", "search", "for", "env", "definitions", "." ]
37608c6bda0d1ad59a99e0ea007dc164995b2669
https://github.com/KeyboardCowboy/drush-denver/blob/37608c6bda0d1ad59a99e0ea007dc164995b2669/Denver.class.php#L551-L576
train
KeyboardCowboy/drush-denver
Denver.class.php
Denver.getSiteDir
public function getSiteDir() { if (!drush_has_boostrapped(DRUSH_BOOTSTRAP_DRUPAL_SITE)) { return FALSE; } // Check for aliases. $site_name = drush_sitealias_bootstrapped_site_name(); $alias = drush_sitealias_get_record("@{$site_name}"); if (floatval(DRUSH_VERSION) > 6.2) { $site_path = drush_sitealias_local_site_path($alias); } else { $supposed_path = drush_sitealias_local_site_path($alias); $hostname = drush_sitealias_uri_to_site_dir($alias['uri']); $site_root = drush_get_context('DRUSH_SELECTED_DRUPAL_ROOT'); if (file_exists($site_root . '/sites/sites.php')) { $sites = []; include $site_root . '/sites/sites.php'; // If we found a match in sites.php and the supposed path is sites/default // then replace 'default' with the matching directory. if (isset($sites[$hostname]) && substr($supposed_path, -8) == '/default') { $site_path = str_replace('/default', "/{$sites[$hostname]}", $supposed_path); } else { $site_path = $supposed_path; } } else { $site_path = $supposed_path; } } // If the site dir is 'default', switch to 'all'. if (substr($site_path, -8) == '/default') { $site_path = str_replace('/default', '/all', $site_path); } return $site_path . '/drush'; }
php
public function getSiteDir() { if (!drush_has_boostrapped(DRUSH_BOOTSTRAP_DRUPAL_SITE)) { return FALSE; } // Check for aliases. $site_name = drush_sitealias_bootstrapped_site_name(); $alias = drush_sitealias_get_record("@{$site_name}"); if (floatval(DRUSH_VERSION) > 6.2) { $site_path = drush_sitealias_local_site_path($alias); } else { $supposed_path = drush_sitealias_local_site_path($alias); $hostname = drush_sitealias_uri_to_site_dir($alias['uri']); $site_root = drush_get_context('DRUSH_SELECTED_DRUPAL_ROOT'); if (file_exists($site_root . '/sites/sites.php')) { $sites = []; include $site_root . '/sites/sites.php'; // If we found a match in sites.php and the supposed path is sites/default // then replace 'default' with the matching directory. if (isset($sites[$hostname]) && substr($supposed_path, -8) == '/default') { $site_path = str_replace('/default', "/{$sites[$hostname]}", $supposed_path); } else { $site_path = $supposed_path; } } else { $site_path = $supposed_path; } } // If the site dir is 'default', switch to 'all'. if (substr($site_path, -8) == '/default') { $site_path = str_replace('/default', '/all', $site_path); } return $site_path . '/drush'; }
[ "public", "function", "getSiteDir", "(", ")", "{", "if", "(", "!", "drush_has_boostrapped", "(", "DRUSH_BOOTSTRAP_DRUPAL_SITE", ")", ")", "{", "return", "FALSE", ";", "}", "// Check for aliases.", "$", "site_name", "=", "drush_sitealias_bootstrapped_site_name", "(", ")", ";", "$", "alias", "=", "drush_sitealias_get_record", "(", "\"@{$site_name}\"", ")", ";", "if", "(", "floatval", "(", "DRUSH_VERSION", ")", ">", "6.2", ")", "{", "$", "site_path", "=", "drush_sitealias_local_site_path", "(", "$", "alias", ")", ";", "}", "else", "{", "$", "supposed_path", "=", "drush_sitealias_local_site_path", "(", "$", "alias", ")", ";", "$", "hostname", "=", "drush_sitealias_uri_to_site_dir", "(", "$", "alias", "[", "'uri'", "]", ")", ";", "$", "site_root", "=", "drush_get_context", "(", "'DRUSH_SELECTED_DRUPAL_ROOT'", ")", ";", "if", "(", "file_exists", "(", "$", "site_root", ".", "'/sites/sites.php'", ")", ")", "{", "$", "sites", "=", "[", "]", ";", "include", "$", "site_root", ".", "'/sites/sites.php'", ";", "// If we found a match in sites.php and the supposed path is sites/default", "// then replace 'default' with the matching directory.", "if", "(", "isset", "(", "$", "sites", "[", "$", "hostname", "]", ")", "&&", "substr", "(", "$", "supposed_path", ",", "-", "8", ")", "==", "'/default'", ")", "{", "$", "site_path", "=", "str_replace", "(", "'/default'", ",", "\"/{$sites[$hostname]}\"", ",", "$", "supposed_path", ")", ";", "}", "else", "{", "$", "site_path", "=", "$", "supposed_path", ";", "}", "}", "else", "{", "$", "site_path", "=", "$", "supposed_path", ";", "}", "}", "// If the site dir is 'default', switch to 'all'.", "if", "(", "substr", "(", "$", "site_path", ",", "-", "8", ")", "==", "'/default'", ")", "{", "$", "site_path", "=", "str_replace", "(", "'/default'", ",", "'/all'", ",", "$", "site_path", ")", ";", "}", "return", "$", "site_path", ".", "'/drush'", ";", "}" ]
Get this site's appropriate drush directory for env vars. Optionally, the directory can be created by passing in the --make option. @return string The directory path.
[ "Get", "this", "site", "s", "appropriate", "drush", "directory", "for", "env", "vars", "." ]
37608c6bda0d1ad59a99e0ea007dc164995b2669
https://github.com/KeyboardCowboy/drush-denver/blob/37608c6bda0d1ad59a99e0ea007dc164995b2669/Denver.class.php#L586-L628
train
KeyboardCowboy/drush-denver
Denver.class.php
Denver.findEnvironments
private function findEnvironments() { drush_log(dt('Loading environment files.'), 'debug'); foreach ($this->configPaths as $path) { drush_log(dt("Scanning !path.", ['!path' => $path]), 'debug'); foreach (drush_scan_directory($path, '/env\.drushrc\.y(a)?ml/') as $file) { $this->loadEnvFile($file); } } drush_log(dt('Loaded environment files.'), 'debug'); }
php
private function findEnvironments() { drush_log(dt('Loading environment files.'), 'debug'); foreach ($this->configPaths as $path) { drush_log(dt("Scanning !path.", ['!path' => $path]), 'debug'); foreach (drush_scan_directory($path, '/env\.drushrc\.y(a)?ml/') as $file) { $this->loadEnvFile($file); } } drush_log(dt('Loaded environment files.'), 'debug'); }
[ "private", "function", "findEnvironments", "(", ")", "{", "drush_log", "(", "dt", "(", "'Loading environment files.'", ")", ",", "'debug'", ")", ";", "foreach", "(", "$", "this", "->", "configPaths", "as", "$", "path", ")", "{", "drush_log", "(", "dt", "(", "\"Scanning !path.\"", ",", "[", "'!path'", "=>", "$", "path", "]", ")", ",", "'debug'", ")", ";", "foreach", "(", "drush_scan_directory", "(", "$", "path", ",", "'/env\\.drushrc\\.y(a)?ml/'", ")", "as", "$", "file", ")", "{", "$", "this", "->", "loadEnvFile", "(", "$", "file", ")", ";", "}", "}", "drush_log", "(", "dt", "(", "'Loaded environment files.'", ")", ",", "'debug'", ")", ";", "}" ]
Find and load environment definitions.
[ "Find", "and", "load", "environment", "definitions", "." ]
37608c6bda0d1ad59a99e0ea007dc164995b2669
https://github.com/KeyboardCowboy/drush-denver/blob/37608c6bda0d1ad59a99e0ea007dc164995b2669/Denver.class.php#L633-L644
train
KeyboardCowboy/drush-denver
Denver.class.php
Denver.loadEnvFile
protected function loadEnvFile($file) { list($name, ,) = explode('.', $file->name); $this->environments[$name] = $this->extractEnv($file->filename); $this->environments[$name]['filename'] = $this->parseFilename($file->filename); }
php
protected function loadEnvFile($file) { list($name, ,) = explode('.', $file->name); $this->environments[$name] = $this->extractEnv($file->filename); $this->environments[$name]['filename'] = $this->parseFilename($file->filename); }
[ "protected", "function", "loadEnvFile", "(", "$", "file", ")", "{", "list", "(", "$", "name", ",", ",", ")", "=", "explode", "(", "'.'", ",", "$", "file", "->", "name", ")", ";", "$", "this", "->", "environments", "[", "$", "name", "]", "=", "$", "this", "->", "extractEnv", "(", "$", "file", "->", "filename", ")", ";", "$", "this", "->", "environments", "[", "$", "name", "]", "[", "'filename'", "]", "=", "$", "this", "->", "parseFilename", "(", "$", "file", "->", "filename", ")", ";", "}" ]
Extract the contents of an environment definition file. @param object $file A file object.
[ "Extract", "the", "contents", "of", "an", "environment", "definition", "file", "." ]
37608c6bda0d1ad59a99e0ea007dc164995b2669
https://github.com/KeyboardCowboy/drush-denver/blob/37608c6bda0d1ad59a99e0ea007dc164995b2669/Denver.class.php#L652-L656
train
KeyboardCowboy/drush-denver
Denver.class.php
Denver.parseFilename
private function parseFilename($filename) { if (defined('DRUPAL_ROOT') && stripos($filename, DRUPAL_ROOT) === 0) { return substr($filename, strpos($filename, DRUPAL_ROOT) + strlen(DRUPAL_ROOT) + 1); } else { return $filename; } }
php
private function parseFilename($filename) { if (defined('DRUPAL_ROOT') && stripos($filename, DRUPAL_ROOT) === 0) { return substr($filename, strpos($filename, DRUPAL_ROOT) + strlen(DRUPAL_ROOT) + 1); } else { return $filename; } }
[ "private", "function", "parseFilename", "(", "$", "filename", ")", "{", "if", "(", "defined", "(", "'DRUPAL_ROOT'", ")", "&&", "stripos", "(", "$", "filename", ",", "DRUPAL_ROOT", ")", "===", "0", ")", "{", "return", "substr", "(", "$", "filename", ",", "strpos", "(", "$", "filename", ",", "DRUPAL_ROOT", ")", "+", "strlen", "(", "DRUPAL_ROOT", ")", "+", "1", ")", ";", "}", "else", "{", "return", "$", "filename", ";", "}", "}" ]
Resolve the proper filename for an environment file. @param string $filename The filename. @return string The resolved filename.
[ "Resolve", "the", "proper", "filename", "for", "an", "environment", "file", "." ]
37608c6bda0d1ad59a99e0ea007dc164995b2669
https://github.com/KeyboardCowboy/drush-denver/blob/37608c6bda0d1ad59a99e0ea007dc164995b2669/Denver.class.php#L778-L785
train
PageBoost/hipchat-php-v2
src/PageBoost/HipChatV2/Resources/Users.php
Users.update
public function update($name, $email, $mention_name, $timezone = 'UTC', $is_group_admin = false, $title = '', $password = null) { $queryParams = array( 'name' => $name, 'title' => $title, 'mention_name' => $mention_name, 'is_group_admin' => $is_group_admin, 'timezone' => $timezone, 'email' => $email, ); if ($password != null) { $queryParams['password'] = $password; } $user_id = $this->getId(); $response = $this->request->put('user/'.$user_id.'', $queryParams); return $this->request->returnResponseObject($response); }
php
public function update($name, $email, $mention_name, $timezone = 'UTC', $is_group_admin = false, $title = '', $password = null) { $queryParams = array( 'name' => $name, 'title' => $title, 'mention_name' => $mention_name, 'is_group_admin' => $is_group_admin, 'timezone' => $timezone, 'email' => $email, ); if ($password != null) { $queryParams['password'] = $password; } $user_id = $this->getId(); $response = $this->request->put('user/'.$user_id.'', $queryParams); return $this->request->returnResponseObject($response); }
[ "public", "function", "update", "(", "$", "name", ",", "$", "email", ",", "$", "mention_name", ",", "$", "timezone", "=", "'UTC'", ",", "$", "is_group_admin", "=", "false", ",", "$", "title", "=", "''", ",", "$", "password", "=", "null", ")", "{", "$", "queryParams", "=", "array", "(", "'name'", "=>", "$", "name", ",", "'title'", "=>", "$", "title", ",", "'mention_name'", "=>", "$", "mention_name", ",", "'is_group_admin'", "=>", "$", "is_group_admin", ",", "'timezone'", "=>", "$", "timezone", ",", "'email'", "=>", "$", "email", ",", ")", ";", "if", "(", "$", "password", "!=", "null", ")", "{", "$", "queryParams", "[", "'password'", "]", "=", "$", "password", ";", "}", "$", "user_id", "=", "$", "this", "->", "getId", "(", ")", ";", "$", "response", "=", "$", "this", "->", "request", "->", "put", "(", "'user/'", ".", "$", "user_id", ".", "''", ",", "$", "queryParams", ")", ";", "return", "$", "this", "->", "request", "->", "returnResponseObject", "(", "$", "response", ")", ";", "}" ]
Update user All values are required except password one which is optional! @param string $name @param string $email @param string $mention_name @param string $timezone @param bool $is_group_admin @param string $title @param null $password @return
[ "Update", "user", "All", "values", "are", "required", "except", "password", "one", "which", "is", "optional!" ]
47625e17fba273b7cc916268d972b4ca8cc48c0c
https://github.com/PageBoost/hipchat-php-v2/blob/47625e17fba273b7cc916268d972b4ca8cc48c0c/src/PageBoost/HipChatV2/Resources/Users.php#L103-L121
train
Retentio/Boomgo
src/Boomgo/Builder/MapBuilder.php
MapBuilder.buildMap
protected function buildMap(array $metadata) { $className = $this->getMapClassName(); $map = new $className($metadata['class']); foreach ($metadata['definitions'] as $metadataDefinition) { $definition = $this->buildDefinition($metadataDefinition); $map->addDefinition($definition); } return $map; }
php
protected function buildMap(array $metadata) { $className = $this->getMapClassName(); $map = new $className($metadata['class']); foreach ($metadata['definitions'] as $metadataDefinition) { $definition = $this->buildDefinition($metadataDefinition); $map->addDefinition($definition); } return $map; }
[ "protected", "function", "buildMap", "(", "array", "$", "metadata", ")", "{", "$", "className", "=", "$", "this", "->", "getMapClassName", "(", ")", ";", "$", "map", "=", "new", "$", "className", "(", "$", "metadata", "[", "'class'", "]", ")", ";", "foreach", "(", "$", "metadata", "[", "'definitions'", "]", "as", "$", "metadataDefinition", ")", "{", "$", "definition", "=", "$", "this", "->", "buildDefinition", "(", "$", "metadataDefinition", ")", ";", "$", "map", "->", "addDefinition", "(", "$", "definition", ")", ";", "}", "return", "$", "map", ";", "}" ]
Build a Map @param array $metadata @return Map
[ "Build", "a", "Map" ]
95cc53777425dd76cd0034046fa4f9e72c04d73a
https://github.com/Retentio/Boomgo/blob/95cc53777425dd76cd0034046fa4f9e72c04d73a/src/Boomgo/Builder/MapBuilder.php#L172-L183
train
Retentio/Boomgo
src/Boomgo/Builder/MapBuilder.php
MapBuilder.buildDefinition
protected function buildDefinition(array $metadata) { if (!isset($metadata['attribute']) && !isset($metadata['key'])) { throw new \RuntimeException('Invalid metadata should provide an attribute or a key'); } // @TODO Rethink this hacky method cause I hate annotation ? if (!isset($metadata['key'])) { $metadata['key'] = $this->formatter->toMongoKey($metadata['attribute']); } elseif (!isset($metadata['attribute'])) { $metadata['attribute'] = $this->formatter->toPhpAttribute($metadata['key']); } $metadata['accessor'] = $this->formatter->getPhpAccessor($metadata['attribute']); $metadata['mutator'] = $this->formatter->getPhpMutator($metadata['attribute']); $className = $this->getDefinitionClassName(); $definition = new $className($metadata); return $definition; }
php
protected function buildDefinition(array $metadata) { if (!isset($metadata['attribute']) && !isset($metadata['key'])) { throw new \RuntimeException('Invalid metadata should provide an attribute or a key'); } // @TODO Rethink this hacky method cause I hate annotation ? if (!isset($metadata['key'])) { $metadata['key'] = $this->formatter->toMongoKey($metadata['attribute']); } elseif (!isset($metadata['attribute'])) { $metadata['attribute'] = $this->formatter->toPhpAttribute($metadata['key']); } $metadata['accessor'] = $this->formatter->getPhpAccessor($metadata['attribute']); $metadata['mutator'] = $this->formatter->getPhpMutator($metadata['attribute']); $className = $this->getDefinitionClassName(); $definition = new $className($metadata); return $definition; }
[ "protected", "function", "buildDefinition", "(", "array", "$", "metadata", ")", "{", "if", "(", "!", "isset", "(", "$", "metadata", "[", "'attribute'", "]", ")", "&&", "!", "isset", "(", "$", "metadata", "[", "'key'", "]", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Invalid metadata should provide an attribute or a key'", ")", ";", "}", "// @TODO Rethink this hacky method cause I hate annotation ?", "if", "(", "!", "isset", "(", "$", "metadata", "[", "'key'", "]", ")", ")", "{", "$", "metadata", "[", "'key'", "]", "=", "$", "this", "->", "formatter", "->", "toMongoKey", "(", "$", "metadata", "[", "'attribute'", "]", ")", ";", "}", "elseif", "(", "!", "isset", "(", "$", "metadata", "[", "'attribute'", "]", ")", ")", "{", "$", "metadata", "[", "'attribute'", "]", "=", "$", "this", "->", "formatter", "->", "toPhpAttribute", "(", "$", "metadata", "[", "'key'", "]", ")", ";", "}", "$", "metadata", "[", "'accessor'", "]", "=", "$", "this", "->", "formatter", "->", "getPhpAccessor", "(", "$", "metadata", "[", "'attribute'", "]", ")", ";", "$", "metadata", "[", "'mutator'", "]", "=", "$", "this", "->", "formatter", "->", "getPhpMutator", "(", "$", "metadata", "[", "'attribute'", "]", ")", ";", "$", "className", "=", "$", "this", "->", "getDefinitionClassName", "(", ")", ";", "$", "definition", "=", "new", "$", "className", "(", "$", "metadata", ")", ";", "return", "$", "definition", ";", "}" ]
Build a Definition @param array $metadata @return Definition
[ "Build", "a", "Definition" ]
95cc53777425dd76cd0034046fa4f9e72c04d73a
https://github.com/Retentio/Boomgo/blob/95cc53777425dd76cd0034046fa4f9e72c04d73a/src/Boomgo/Builder/MapBuilder.php#L192-L212
train
eureka-framework/component-cache
src/Cache/CacheWrapperFile.php
CacheWrapperFile.clearExpired
protected function clearExpired() { if (empty($this->cache)) { $file = $this->directory . 'Cache.dat'; //~ Retrieve Cache information. if (file_exists($file)) { $content = file_get_contents($file); if (!empty($content)) { $this->cache = unserialize($content); } else { $this->cache = array(); } } } // Clean all caches have expired. foreach ($this->cache as $pKey => $time) { if ($time < time()) { $this->remove($pKey); } } return true; }
php
protected function clearExpired() { if (empty($this->cache)) { $file = $this->directory . 'Cache.dat'; //~ Retrieve Cache information. if (file_exists($file)) { $content = file_get_contents($file); if (!empty($content)) { $this->cache = unserialize($content); } else { $this->cache = array(); } } } // Clean all caches have expired. foreach ($this->cache as $pKey => $time) { if ($time < time()) { $this->remove($pKey); } } return true; }
[ "protected", "function", "clearExpired", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "cache", ")", ")", "{", "$", "file", "=", "$", "this", "->", "directory", ".", "'Cache.dat'", ";", "//~ Retrieve Cache information.", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "$", "content", "=", "file_get_contents", "(", "$", "file", ")", ";", "if", "(", "!", "empty", "(", "$", "content", ")", ")", "{", "$", "this", "->", "cache", "=", "unserialize", "(", "$", "content", ")", ";", "}", "else", "{", "$", "this", "->", "cache", "=", "array", "(", ")", ";", "}", "}", "}", "// Clean all caches have expired.", "foreach", "(", "$", "this", "->", "cache", "as", "$", "pKey", "=>", "$", "time", ")", "{", "if", "(", "$", "time", "<", "time", "(", ")", ")", "{", "$", "this", "->", "remove", "(", "$", "pKey", ")", ";", "}", "}", "return", "true", ";", "}" ]
Clean Cache have expired. @return boolean
[ "Clean", "Cache", "have", "expired", "." ]
c110441ac7bb20edd2ecd8162f4302596d875785
https://github.com/eureka-framework/component-cache/blob/c110441ac7bb20edd2ecd8162f4302596d875785/src/Cache/CacheWrapperFile.php#L63-L87
train
eureka-framework/component-cache
src/Cache/CacheWrapperFile.php
CacheWrapperFile.get
public function get($key) { if (!$this->has($key)) { return null; } $file = $this->directory . substr(md5($this->prefix() . $key), 0, 10) . '.dat'; return unserialize(file_get_contents($file)); }
php
public function get($key) { if (!$this->has($key)) { return null; } $file = $this->directory . substr(md5($this->prefix() . $key), 0, 10) . '.dat'; return unserialize(file_get_contents($file)); }
[ "public", "function", "get", "(", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "return", "null", ";", "}", "$", "file", "=", "$", "this", "->", "directory", ".", "substr", "(", "md5", "(", "$", "this", "->", "prefix", "(", ")", ".", "$", "key", ")", ",", "0", ",", "10", ")", ".", "'.dat'", ";", "return", "unserialize", "(", "file_get_contents", "(", "$", "file", ")", ")", ";", "}" ]
Gets a value in the Cache for the specified key. @param string $key The key name @return mixed Cache content (null if the key does not exist).
[ "Gets", "a", "value", "in", "the", "Cache", "for", "the", "specified", "key", "." ]
c110441ac7bb20edd2ecd8162f4302596d875785
https://github.com/eureka-framework/component-cache/blob/c110441ac7bb20edd2ecd8162f4302596d875785/src/Cache/CacheWrapperFile.php#L95-L104
train
eureka-framework/component-cache
src/Cache/CacheWrapperFile.php
CacheWrapperFile.set
public function set($key, $value, $lifeTime = 900) { //~ Check if enabled if (!$this->isEnabled()) { return false; } //~ Clear expired Cache files $this->clearExpired(); $pKey = $this->prefix() . $key; $file = $this->directory . substr(md5($pKey), 0, 10) . '.dat'; if ((bool) file_put_contents($file, serialize($value))) { $this->cache[$pKey] = time() + $lifeTime; $this->save(); return true; } else { return false; } }
php
public function set($key, $value, $lifeTime = 900) { //~ Check if enabled if (!$this->isEnabled()) { return false; } //~ Clear expired Cache files $this->clearExpired(); $pKey = $this->prefix() . $key; $file = $this->directory . substr(md5($pKey), 0, 10) . '.dat'; if ((bool) file_put_contents($file, serialize($value))) { $this->cache[$pKey] = time() + $lifeTime; $this->save(); return true; } else { return false; } }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "lifeTime", "=", "900", ")", "{", "//~ Check if enabled", "if", "(", "!", "$", "this", "->", "isEnabled", "(", ")", ")", "{", "return", "false", ";", "}", "//~ Clear expired Cache files", "$", "this", "->", "clearExpired", "(", ")", ";", "$", "pKey", "=", "$", "this", "->", "prefix", "(", ")", ".", "$", "key", ";", "$", "file", "=", "$", "this", "->", "directory", ".", "substr", "(", "md5", "(", "$", "pKey", ")", ",", "0", ",", "10", ")", ".", "'.dat'", ";", "if", "(", "(", "bool", ")", "file_put_contents", "(", "$", "file", ",", "serialize", "(", "$", "value", ")", ")", ")", "{", "$", "this", "->", "cache", "[", "$", "pKey", "]", "=", "time", "(", ")", "+", "$", "lifeTime", ";", "$", "this", "->", "save", "(", ")", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Sets a value in the Cache for the specified key. @param string $key The key name @param mixed $value The content to put in Cache @param integer $lifeTime Time to keep the content in Cache in seconds @return boolean
[ "Sets", "a", "value", "in", "the", "Cache", "for", "the", "specified", "key", "." ]
c110441ac7bb20edd2ecd8162f4302596d875785
https://github.com/eureka-framework/component-cache/blob/c110441ac7bb20edd2ecd8162f4302596d875785/src/Cache/CacheWrapperFile.php#L171-L191
train
mikebarlow/result
src/Result.php
Result.success
public static function success($code = '', $message = '', $errors = [], $extras = []) { return self::loadResult(self::SUCCESS, $code, $message, $errors, $extras); }
php
public static function success($code = '', $message = '', $errors = [], $extras = []) { return self::loadResult(self::SUCCESS, $code, $message, $errors, $extras); }
[ "public", "static", "function", "success", "(", "$", "code", "=", "''", ",", "$", "message", "=", "''", ",", "$", "errors", "=", "[", "]", ",", "$", "extras", "=", "[", "]", ")", "{", "return", "self", "::", "loadResult", "(", "self", "::", "SUCCESS", ",", "$", "code", ",", "$", "message", ",", "$", "errors", ",", "$", "extras", ")", ";", "}" ]
initiate a success result @param string $code @param string $message @param array $errors @param array $extras @return Result $Result
[ "initiate", "a", "success", "result" ]
412efe97c32434b986be7373b936b643748ace64
https://github.com/mikebarlow/result/blob/412efe97c32434b986be7373b936b643748ace64/src/Result.php#L39-L42
train
mikebarlow/result
src/Result.php
Result.fail
public static function fail($code = '', $message = '', $errors = [], $extras = []) { return self::loadResult(self::FAIL, $code, $message, $errors, $extras); }
php
public static function fail($code = '', $message = '', $errors = [], $extras = []) { return self::loadResult(self::FAIL, $code, $message, $errors, $extras); }
[ "public", "static", "function", "fail", "(", "$", "code", "=", "''", ",", "$", "message", "=", "''", ",", "$", "errors", "=", "[", "]", ",", "$", "extras", "=", "[", "]", ")", "{", "return", "self", "::", "loadResult", "(", "self", "::", "FAIL", ",", "$", "code", ",", "$", "message", ",", "$", "errors", ",", "$", "extras", ")", ";", "}" ]
initiate a fail result @param string $code @param string $message @param array $errors @param array $extras @return Result $Result
[ "initiate", "a", "fail", "result" ]
412efe97c32434b986be7373b936b643748ace64
https://github.com/mikebarlow/result/blob/412efe97c32434b986be7373b936b643748ace64/src/Result.php#L53-L56
train
mikebarlow/result
src/Result.php
Result.loadResult
protected static function loadResult($status, $code, $message, $errors, $extras) { $Result = new static($status); if (! empty($code)) { $Result->setCode($code); } if (! empty($message)) { $Result->setMessage($message); } if (! empty($errors)) { $Result->setErrors($errors); } if (! empty($extras)) { $Result->setExtras($extras); } return $Result; }
php
protected static function loadResult($status, $code, $message, $errors, $extras) { $Result = new static($status); if (! empty($code)) { $Result->setCode($code); } if (! empty($message)) { $Result->setMessage($message); } if (! empty($errors)) { $Result->setErrors($errors); } if (! empty($extras)) { $Result->setExtras($extras); } return $Result; }
[ "protected", "static", "function", "loadResult", "(", "$", "status", ",", "$", "code", ",", "$", "message", ",", "$", "errors", ",", "$", "extras", ")", "{", "$", "Result", "=", "new", "static", "(", "$", "status", ")", ";", "if", "(", "!", "empty", "(", "$", "code", ")", ")", "{", "$", "Result", "->", "setCode", "(", "$", "code", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "message", ")", ")", "{", "$", "Result", "->", "setMessage", "(", "$", "message", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "errors", ")", ")", "{", "$", "Result", "->", "setErrors", "(", "$", "errors", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "extras", ")", ")", "{", "$", "Result", "->", "setExtras", "(", "$", "extras", ")", ";", "}", "return", "$", "Result", ";", "}" ]
load up the result object @param bool $status @param string $code @param string $message @param array $errors @param array $extras @return Result $Result
[ "load", "up", "the", "result", "object" ]
412efe97c32434b986be7373b936b643748ace64
https://github.com/mikebarlow/result/blob/412efe97c32434b986be7373b936b643748ace64/src/Result.php#L68-L89
train
mikebarlow/result
src/Result.php
Result.addError
public function addError($error) { if (is_array($error)) { $this->errors += $error; } else { $this->errors[] = $error; } return $this; }
php
public function addError($error) { if (is_array($error)) { $this->errors += $error; } else { $this->errors[] = $error; } return $this; }
[ "public", "function", "addError", "(", "$", "error", ")", "{", "if", "(", "is_array", "(", "$", "error", ")", ")", "{", "$", "this", "->", "errors", "+=", "$", "error", ";", "}", "else", "{", "$", "this", "->", "errors", "[", "]", "=", "$", "error", ";", "}", "return", "$", "this", ";", "}" ]
add an error message to the list @param mixed $error @return Result $this
[ "add", "an", "error", "message", "to", "the", "list" ]
412efe97c32434b986be7373b936b643748ace64
https://github.com/mikebarlow/result/blob/412efe97c32434b986be7373b936b643748ace64/src/Result.php#L197-L206
train
mikebarlow/result
src/Result.php
Result.getExtra
public function getExtra($key) { if (array_key_exists($key, $this->extras)) { return $this->extras[$key]; } return false; }
php
public function getExtra($key) { if (array_key_exists($key, $this->extras)) { return $this->extras[$key]; } return false; }
[ "public", "function", "getExtra", "(", "$", "key", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "extras", ")", ")", "{", "return", "$", "this", "->", "extras", "[", "$", "key", "]", ";", "}", "return", "false", ";", "}" ]
get individual extra items @param string $key @return mixed
[ "get", "individual", "extra", "items" ]
412efe97c32434b986be7373b936b643748ace64
https://github.com/mikebarlow/result/blob/412efe97c32434b986be7373b936b643748ace64/src/Result.php#L224-L231
train
linpax/microphp-framework
src/form/Form.php
Form.label
public function label(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); return Html::label($model->getLabel($property), $element['id'], $options); }
php
public function label(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); return Html::label($model->getLabel($property), $element['id'], $options); }
[ "public", "function", "label", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "return", "Html", "::", "label", "(", "$", "model", "->", "getLabel", "(", "$", "property", ")", ",", "$", "element", "[", "'id'", "]", ",", "$", "options", ")", ";", "}" ]
Render label tag @access public @param IFormModel $model model @param string $property model property @param array $options attributes array @return string
[ "Render", "label", "tag" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L32-L37
train
linpax/microphp-framework
src/form/Form.php
Form.getField
protected function getField(IFormModel $model, $property) { $cl = get_class($model); $smallName = substr($cl, strrpos($cl, '\\') + 1); return [ 'id' => $smallName.'_'.$property, 'name' => $smallName.'['.$property.']', 'value' => property_exists($model, $property) ? $model->$property : null ]; }
php
protected function getField(IFormModel $model, $property) { $cl = get_class($model); $smallName = substr($cl, strrpos($cl, '\\') + 1); return [ 'id' => $smallName.'_'.$property, 'name' => $smallName.'['.$property.']', 'value' => property_exists($model, $property) ? $model->$property : null ]; }
[ "protected", "function", "getField", "(", "IFormModel", "$", "model", ",", "$", "property", ")", "{", "$", "cl", "=", "get_class", "(", "$", "model", ")", ";", "$", "smallName", "=", "substr", "(", "$", "cl", ",", "strrpos", "(", "$", "cl", ",", "'\\\\'", ")", "+", "1", ")", ";", "return", "[", "'id'", "=>", "$", "smallName", ".", "'_'", ".", "$", "property", ",", "'name'", "=>", "$", "smallName", ".", "'['", ".", "$", "property", ".", "']'", ",", "'value'", "=>", "property_exists", "(", "$", "model", ",", "$", "property", ")", "?", "$", "model", "->", "$", "property", ":", "null", "]", ";", "}" ]
Get model field data @access private @param IFormModel $model model @param string $property model property @return array
[ "Get", "model", "field", "data" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L49-L59
train
linpax/microphp-framework
src/form/Form.php
Form.hiddenField
public function hiddenField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); return Html::hiddenField($element['name'], $element['value'], $options); }
php
public function hiddenField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); return Html::hiddenField($element['name'], $element['value'], $options); }
[ "public", "function", "hiddenField", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "return", "Html", "::", "hiddenField", "(", "$", "element", "[", "'name'", "]", ",", "$", "element", "[", "'value'", "]", ",", "$", "options", ")", ";", "}" ]
Render hidden field tag @access public @param IFormModel $model model @param string $property model property @param array $options attributes array @return string
[ "Render", "hidden", "field", "tag" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L72-L77
train
linpax/microphp-framework
src/form/Form.php
Form.getBlock
protected function getBlock($name, array &$options) { $block = []; /** @noinspection ReferenceMismatchInspection */ if (array_key_exists($name, $options)) { $block = $options[$name]; unset($options[$name]); } return $block; }
php
protected function getBlock($name, array &$options) { $block = []; /** @noinspection ReferenceMismatchInspection */ if (array_key_exists($name, $options)) { $block = $options[$name]; unset($options[$name]); } return $block; }
[ "protected", "function", "getBlock", "(", "$", "name", ",", "array", "&", "$", "options", ")", "{", "$", "block", "=", "[", "]", ";", "/** @noinspection ReferenceMismatchInspection */", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "options", ")", ")", "{", "$", "block", "=", "$", "options", "[", "$", "name", "]", ";", "unset", "(", "$", "options", "[", "$", "name", "]", ")", ";", "}", "return", "$", "block", ";", "}" ]
Get block from options @access protected @param string $name Block name @param array $options Options array @return array
[ "Get", "block", "from", "options" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L151-L162
train
linpax/microphp-framework
src/form/Form.php
Form.fileFieldRow
public function fileFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->fileField($model, $property, $options). Html::closeTag('div'); }
php
public function fileFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->fileField($model, $property, $options). Html::closeTag('div'); }
[ "public", "function", "fileFieldRow", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "openTag", "(", "'div'", ",", "$", "this", "->", "getBlock", "(", "'block'", ",", "$", "options", ")", ")", ".", "Html", "::", "label", "(", "$", "model", "->", "getLabel", "(", "$", "property", ")", ",", "$", "element", "[", "'id'", "]", ",", "$", "this", "->", "getBlock", "(", "'label'", ",", "$", "options", ")", ")", ".", "$", "this", "->", "fileField", "(", "$", "model", ",", "$", "property", ",", "$", "options", ")", ".", "Html", "::", "closeTag", "(", "'div'", ")", ";", "}" ]
Render file field row @access public @param IFormModel $model model @param string $property model property @param array $options attribute array @return string
[ "Render", "file", "field", "row" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L194-L203
train
linpax/microphp-framework
src/form/Form.php
Form.imageFieldRow
public function imageFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->imageField($model, $property, $options). Html::closeTag('div'); }
php
public function imageFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->imageField($model, $property, $options). Html::closeTag('div'); }
[ "public", "function", "imageFieldRow", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "openTag", "(", "'div'", ",", "$", "this", "->", "getBlock", "(", "'block'", ",", "$", "options", ")", ")", ".", "Html", "::", "label", "(", "$", "model", "->", "getLabel", "(", "$", "property", ")", ",", "$", "element", "[", "'id'", "]", ",", "$", "this", "->", "getBlock", "(", "'label'", ",", "$", "options", ")", ")", ".", "$", "this", "->", "imageField", "(", "$", "model", ",", "$", "property", ",", "$", "options", ")", ".", "Html", "::", "closeTag", "(", "'div'", ")", ";", "}" ]
Render image field row @access public @param IFormModel $model model @param string $property model property @param array $options attribute array @return string
[ "Render", "image", "field", "row" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L235-L244
train
linpax/microphp-framework
src/form/Form.php
Form.imageField
public function imageField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; $image = !empty($options['image']) ? $options['image'] : []; return Html::imageField($element['name'], $element['value'], $image, $options); }
php
public function imageField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; $image = !empty($options['image']) ? $options['image'] : []; return Html::imageField($element['name'], $element['value'], $image, $options); }
[ "public", "function", "imageField", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "$", "image", "=", "!", "empty", "(", "$", "options", "[", "'image'", "]", ")", "?", "$", "options", "[", "'image'", "]", ":", "[", "]", ";", "return", "Html", "::", "imageField", "(", "$", "element", "[", "'name'", "]", ",", "$", "element", "[", "'value'", "]", ",", "$", "image", ",", "$", "options", ")", ";", "}" ]
Render image field tag @access public @param IFormModel $model model @param string $property model property @param array $options attributes array @return string
[ "Render", "image", "field", "tag" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L257-L264
train
linpax/microphp-framework
src/form/Form.php
Form.passwordFieldRow
public function passwordFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->passwordField($model, $property, $options). Html::closeTag('div'); }
php
public function passwordFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->passwordField($model, $property, $options). Html::closeTag('div'); }
[ "public", "function", "passwordFieldRow", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "openTag", "(", "'div'", ",", "$", "this", "->", "getBlock", "(", "'block'", ",", "$", "options", ")", ")", ".", "Html", "::", "label", "(", "$", "model", "->", "getLabel", "(", "$", "property", ")", ",", "$", "element", "[", "'id'", "]", ",", "$", "this", "->", "getBlock", "(", "'label'", ",", "$", "options", ")", ")", ".", "$", "this", "->", "passwordField", "(", "$", "model", ",", "$", "property", ",", "$", "options", ")", ".", "Html", "::", "closeTag", "(", "'div'", ")", ";", "}" ]
Render password field row @access public @param IFormModel $model model @param string $property model property @param array $options attribute array @return string
[ "Render", "password", "field", "row" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L277-L286
train
linpax/microphp-framework
src/form/Form.php
Form.textAreaFieldRow
public function textAreaFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->textAreaField($model, $property, $options). Html::closeTag('div'); }
php
public function textAreaFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->textAreaField($model, $property, $options). Html::closeTag('div'); }
[ "public", "function", "textAreaFieldRow", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "openTag", "(", "'div'", ",", "$", "this", "->", "getBlock", "(", "'block'", ",", "$", "options", ")", ")", ".", "Html", "::", "label", "(", "$", "model", "->", "getLabel", "(", "$", "property", ")", ",", "$", "element", "[", "'id'", "]", ",", "$", "this", "->", "getBlock", "(", "'label'", ",", "$", "options", ")", ")", ".", "$", "this", "->", "textAreaField", "(", "$", "model", ",", "$", "property", ",", "$", "options", ")", ".", "Html", "::", "closeTag", "(", "'div'", ")", ";", "}" ]
Render textArea field row @access public @param IFormModel $model model @param string $property model property @param array $options attribute array @return string
[ "Render", "textArea", "field", "row" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L318-L327
train
linpax/microphp-framework
src/form/Form.php
Form.textAreaField
public function textAreaField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::textArea($element['name'], $element['value'], $options); }
php
public function textAreaField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::textArea($element['name'], $element['value'], $options); }
[ "public", "function", "textAreaField", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "textArea", "(", "$", "element", "[", "'name'", "]", ",", "$", "element", "[", "'value'", "]", ",", "$", "options", ")", ";", "}" ]
Render textarea tag @access public @param IFormModel $model model @param string $property model property @param array $options attributes array @return string
[ "Render", "textarea", "tag" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L340-L346
train
linpax/microphp-framework
src/form/Form.php
Form.checkboxFieldRow
public function checkboxFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->checkBoxField($model, $property, $options). Html::closeTag('div'); }
php
public function checkboxFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->checkBoxField($model, $property, $options). Html::closeTag('div'); }
[ "public", "function", "checkboxFieldRow", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "openTag", "(", "'div'", ",", "$", "this", "->", "getBlock", "(", "'block'", ",", "$", "options", ")", ")", ".", "Html", "::", "label", "(", "$", "model", "->", "getLabel", "(", "$", "property", ")", ",", "$", "element", "[", "'id'", "]", ",", "$", "this", "->", "getBlock", "(", "'label'", ",", "$", "options", ")", ")", ".", "$", "this", "->", "checkBoxField", "(", "$", "model", ",", "$", "property", ",", "$", "options", ")", ".", "Html", "::", "closeTag", "(", "'div'", ")", ";", "}" ]
Render checkbox field row @access public @param IFormModel $model model @param string $property model property @param array $options attribute array @return string
[ "Render", "checkbox", "field", "row" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L359-L368
train
linpax/microphp-framework
src/form/Form.php
Form.listBoxFieldRow
public function listBoxFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->listBoxField($model, $property, $options). Html::closeTag('div'); }
php
public function listBoxFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->listBoxField($model, $property, $options). Html::closeTag('div'); }
[ "public", "function", "listBoxFieldRow", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "openTag", "(", "'div'", ",", "$", "this", "->", "getBlock", "(", "'block'", ",", "$", "options", ")", ")", ".", "Html", "::", "label", "(", "$", "model", "->", "getLabel", "(", "$", "property", ")", ",", "$", "element", "[", "'id'", "]", ",", "$", "this", "->", "getBlock", "(", "'label'", ",", "$", "options", ")", ")", ".", "$", "this", "->", "listBoxField", "(", "$", "model", ",", "$", "property", ",", "$", "options", ")", ".", "Html", "::", "closeTag", "(", "'div'", ")", ";", "}" ]
Render listBox field row @access public @param IFormModel $model model @param string $property model property @param array $options attribute array @return string
[ "Render", "listBox", "field", "row" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L402-L411
train
linpax/microphp-framework
src/form/Form.php
Form.listBoxField
public function listBoxField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; $options['selected'] = $element['value']; if (empty($options['size'])) { $options['size'] = 3; } return Html::listBox($element['name'], $this->getBlock('elements', $options), $options); }
php
public function listBoxField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; $options['selected'] = $element['value']; if (empty($options['size'])) { $options['size'] = 3; } return Html::listBox($element['name'], $this->getBlock('elements', $options), $options); }
[ "public", "function", "listBoxField", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "$", "options", "[", "'selected'", "]", "=", "$", "element", "[", "'value'", "]", ";", "if", "(", "empty", "(", "$", "options", "[", "'size'", "]", ")", ")", "{", "$", "options", "[", "'size'", "]", "=", "3", ";", "}", "return", "Html", "::", "listBox", "(", "$", "element", "[", "'name'", "]", ",", "$", "this", "->", "getBlock", "(", "'elements'", ",", "$", "options", ")", ",", "$", "options", ")", ";", "}" ]
Render list box tag @access public @param IFormModel $model model @param string $property model property @param array $options attributes array @return string
[ "Render", "list", "box", "tag" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L424-L435
train
linpax/microphp-framework
src/form/Form.php
Form.dropDownListField
public function dropDownListField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; if (!empty($element['value'])) { $options['selected'] = $element['value']; } return Html::dropDownList($element['name'], $this->getBlock('elements', $options), $options); }
php
public function dropDownListField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; if (!empty($element['value'])) { $options['selected'] = $element['value']; } return Html::dropDownList($element['name'], $this->getBlock('elements', $options), $options); }
[ "public", "function", "dropDownListField", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "if", "(", "!", "empty", "(", "$", "element", "[", "'value'", "]", ")", ")", "{", "$", "options", "[", "'selected'", "]", "=", "$", "element", "[", "'value'", "]", ";", "}", "return", "Html", "::", "dropDownList", "(", "$", "element", "[", "'name'", "]", ",", "$", "this", "->", "getBlock", "(", "'elements'", ",", "$", "options", ")", ",", "$", "options", ")", ";", "}" ]
Render drop down list tag @access public @param IFormModel $model model @param string $property model property @param array $options attribute array @return string
[ "Render", "drop", "down", "list", "tag" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L470-L480
train
linpax/microphp-framework
src/form/Form.php
Form.checkBoxListField
public function checkBoxListField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $checkboxes = !empty($options['checkboxes']) ? $options['checkboxes'] : []; $format = !empty($options['format']) ? $options['format'] : '<p>%check% %text%</p>'; return Html::checkBoxList($element['name'], $checkboxes, $format, $element['value']); }
php
public function checkBoxListField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $checkboxes = !empty($options['checkboxes']) ? $options['checkboxes'] : []; $format = !empty($options['format']) ? $options['format'] : '<p>%check% %text%</p>'; return Html::checkBoxList($element['name'], $checkboxes, $format, $element['value']); }
[ "public", "function", "checkBoxListField", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "checkboxes", "=", "!", "empty", "(", "$", "options", "[", "'checkboxes'", "]", ")", "?", "$", "options", "[", "'checkboxes'", "]", ":", "[", "]", ";", "$", "format", "=", "!", "empty", "(", "$", "options", "[", "'format'", "]", ")", "?", "$", "options", "[", "'format'", "]", ":", "'<p>%check% %text%</p>'", ";", "return", "Html", "::", "checkBoxList", "(", "$", "element", "[", "'name'", "]", ",", "$", "checkboxes", ",", "$", "format", ",", "$", "element", "[", "'value'", "]", ")", ";", "}" ]
Render check box list tag @access public @param IFormModel $model model @param string $property property model @param array $options options array @return string
[ "Render", "check", "box", "list", "tag" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L515-L522
train
linpax/microphp-framework
src/form/Form.php
Form.radioButtonListField
public function radioButtonListField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $radios = !empty($options['radios']) ? $options['radios'] : []; $format = !empty($options['format']) ? $options['format'] : '<p>%radio% %text%</p>'; return Html::radioButtonList($element['name'], $radios, $format, $element['value']); }
php
public function radioButtonListField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $radios = !empty($options['radios']) ? $options['radios'] : []; $format = !empty($options['format']) ? $options['format'] : '<p>%radio% %text%</p>'; return Html::radioButtonList($element['name'], $radios, $format, $element['value']); }
[ "public", "function", "radioButtonListField", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "radios", "=", "!", "empty", "(", "$", "options", "[", "'radios'", "]", ")", "?", "$", "options", "[", "'radios'", "]", ":", "[", "]", ";", "$", "format", "=", "!", "empty", "(", "$", "options", "[", "'format'", "]", ")", "?", "$", "options", "[", "'format'", "]", ":", "'<p>%radio% %text%</p>'", ";", "return", "Html", "::", "radioButtonList", "(", "$", "element", "[", "'name'", "]", ",", "$", "radios", ",", "$", "format", ",", "$", "element", "[", "'value'", "]", ")", ";", "}" ]
Render radio button list tag @access public @param IFormModel $model model @param string $property model property @param array $options options array @return string
[ "Render", "radio", "button", "list", "tag" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L557-L564
train
linpax/microphp-framework
src/form/Form.php
Form.colorFieldRow
public function colorFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->colorField($model, $property, $options). Html::closeTag('div'); }
php
public function colorFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->colorField($model, $property, $options). Html::closeTag('div'); }
[ "public", "function", "colorFieldRow", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "openTag", "(", "'div'", ",", "$", "this", "->", "getBlock", "(", "'block'", ",", "$", "options", ")", ")", ".", "Html", "::", "label", "(", "$", "model", "->", "getLabel", "(", "$", "property", ")", ",", "$", "element", "[", "'id'", "]", ",", "$", "this", "->", "getBlock", "(", "'label'", ",", "$", "options", ")", ")", ".", "$", "this", "->", "colorField", "(", "$", "model", ",", "$", "property", ",", "$", "options", ")", ".", "Html", "::", "closeTag", "(", "'div'", ")", ";", "}" ]
Render color field row @access public @param IFormModel $model model @param string $property model property @param array $options attribute array @return string
[ "Render", "color", "field", "row" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L579-L588
train
linpax/microphp-framework
src/form/Form.php
Form.dateTimeFieldRow
public function dateTimeFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->dateTimeField($model, $property, $options). Html::closeTag('div'); }
php
public function dateTimeFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->dateTimeField($model, $property, $options). Html::closeTag('div'); }
[ "public", "function", "dateTimeFieldRow", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "openTag", "(", "'div'", ",", "$", "this", "->", "getBlock", "(", "'block'", ",", "$", "options", ")", ")", ".", "Html", "::", "label", "(", "$", "model", "->", "getLabel", "(", "$", "property", ")", ",", "$", "element", "[", "'id'", "]", ",", "$", "this", "->", "getBlock", "(", "'label'", ",", "$", "options", ")", ")", ".", "$", "this", "->", "dateTimeField", "(", "$", "model", ",", "$", "property", ",", "$", "options", ")", ".", "Html", "::", "closeTag", "(", "'div'", ")", ";", "}" ]
Render datetime field row @access public @param IFormModel $model model @param string $property model property @param array $options attribute array @return string
[ "Render", "datetime", "field", "row" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L661-L670
train
linpax/microphp-framework
src/form/Form.php
Form.dateTimeField
public function dateTimeField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::datetimeField($element['name'], $element['value'], $options); }
php
public function dateTimeField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::datetimeField($element['name'], $element['value'], $options); }
[ "public", "function", "dateTimeField", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "datetimeField", "(", "$", "element", "[", "'name'", "]", ",", "$", "element", "[", "'value'", "]", ",", "$", "options", ")", ";", "}" ]
Render datetime field tag @access public @param IFormModel $model model @param string $property model property @param array $options attributes array @return string
[ "Render", "datetime", "field", "tag" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L683-L689
train
linpax/microphp-framework
src/form/Form.php
Form.dateTimeLocalFieldRow
public function dateTimeLocalFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->dateTimeLocalField($model, $property, $options). Html::closeTag('div'); }
php
public function dateTimeLocalFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->dateTimeLocalField($model, $property, $options). Html::closeTag('div'); }
[ "public", "function", "dateTimeLocalFieldRow", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "openTag", "(", "'div'", ",", "$", "this", "->", "getBlock", "(", "'block'", ",", "$", "options", ")", ")", ".", "Html", "::", "label", "(", "$", "model", "->", "getLabel", "(", "$", "property", ")", ",", "$", "element", "[", "'id'", "]", ",", "$", "this", "->", "getBlock", "(", "'label'", ",", "$", "options", ")", ")", ".", "$", "this", "->", "dateTimeLocalField", "(", "$", "model", ",", "$", "property", ",", "$", "options", ")", ".", "Html", "::", "closeTag", "(", "'div'", ")", ";", "}" ]
Render datetime-local field row @access public @param IFormModel $model model @param string $property model property @param array $options attribute array @return string
[ "Render", "datetime", "-", "local", "field", "row" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L702-L711
train
linpax/microphp-framework
src/form/Form.php
Form.dateTimeLocalField
public function dateTimeLocalField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::datetimeLocalField($element['name'], $element['value'], $options); }
php
public function dateTimeLocalField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::datetimeLocalField($element['name'], $element['value'], $options); }
[ "public", "function", "dateTimeLocalField", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "datetimeLocalField", "(", "$", "element", "[", "'name'", "]", ",", "$", "element", "[", "'value'", "]", ",", "$", "options", ")", ";", "}" ]
Render datetime-local field tag @access public @param IFormModel $model model @param string $property model property @param array $options attributes array @return string
[ "Render", "datetime", "-", "local", "field", "tag" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L724-L730
train
linpax/microphp-framework
src/form/Form.php
Form.emailFieldRow
public function emailFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->emailField($model, $property, $options). Html::closeTag('div'); }
php
public function emailFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->emailField($model, $property, $options). Html::closeTag('div'); }
[ "public", "function", "emailFieldRow", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "openTag", "(", "'div'", ",", "$", "this", "->", "getBlock", "(", "'block'", ",", "$", "options", ")", ")", ".", "Html", "::", "label", "(", "$", "model", "->", "getLabel", "(", "$", "property", ")", ",", "$", "element", "[", "'id'", "]", ",", "$", "this", "->", "getBlock", "(", "'label'", ",", "$", "options", ")", ")", ".", "$", "this", "->", "emailField", "(", "$", "model", ",", "$", "property", ",", "$", "options", ")", ".", "Html", "::", "closeTag", "(", "'div'", ")", ";", "}" ]
Render email field row @access public @param IFormModel $model model @param string $property model property @param array $options attribute array @return string
[ "Render", "email", "field", "row" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L743-L752
train
linpax/microphp-framework
src/form/Form.php
Form.rangeFieldRow
public function rangeFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->rangeField($model, $property, $options). Html::closeTag('div'); }
php
public function rangeFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->rangeField($model, $property, $options). Html::closeTag('div'); }
[ "public", "function", "rangeFieldRow", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "openTag", "(", "'div'", ",", "$", "this", "->", "getBlock", "(", "'block'", ",", "$", "options", ")", ")", ".", "Html", "::", "label", "(", "$", "model", "->", "getLabel", "(", "$", "property", ")", ",", "$", "element", "[", "'id'", "]", ",", "$", "this", "->", "getBlock", "(", "'label'", ",", "$", "options", ")", ")", ".", "$", "this", "->", "rangeField", "(", "$", "model", ",", "$", "property", ",", "$", "options", ")", ".", "Html", "::", "closeTag", "(", "'div'", ")", ";", "}" ]
Render range field row @access public @param IFormModel $model model @param string $property model property @param array $options attribute array @return string
[ "Render", "range", "field", "row" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L825-L834
train
linpax/microphp-framework
src/form/Form.php
Form.searchFieldRow
public function searchFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->searchField($model, $property, $options). Html::closeTag('div'); }
php
public function searchFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->searchField($model, $property, $options). Html::closeTag('div'); }
[ "public", "function", "searchFieldRow", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "openTag", "(", "'div'", ",", "$", "this", "->", "getBlock", "(", "'block'", ",", "$", "options", ")", ")", ".", "Html", "::", "label", "(", "$", "model", "->", "getLabel", "(", "$", "property", ")", ",", "$", "element", "[", "'id'", "]", ",", "$", "this", "->", "getBlock", "(", "'label'", ",", "$", "options", ")", ")", ".", "$", "this", "->", "searchField", "(", "$", "model", ",", "$", "property", ",", "$", "options", ")", ".", "Html", "::", "closeTag", "(", "'div'", ")", ";", "}" ]
Render search field row @access public @param IFormModel $model model @param string $property model property @param array $options attribute array @return string
[ "Render", "search", "field", "row" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L866-L875
train
linpax/microphp-framework
src/form/Form.php
Form.telFieldRow
public function telFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->telField($model, $property, $options). Html::closeTag('div'); }
php
public function telFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->telField($model, $property, $options). Html::closeTag('div'); }
[ "public", "function", "telFieldRow", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "openTag", "(", "'div'", ",", "$", "this", "->", "getBlock", "(", "'block'", ",", "$", "options", ")", ")", ".", "Html", "::", "label", "(", "$", "model", "->", "getLabel", "(", "$", "property", ")", ",", "$", "element", "[", "'id'", "]", ",", "$", "this", "->", "getBlock", "(", "'label'", ",", "$", "options", ")", ")", ".", "$", "this", "->", "telField", "(", "$", "model", ",", "$", "property", ",", "$", "options", ")", ".", "Html", "::", "closeTag", "(", "'div'", ")", ";", "}" ]
Render telephone field row @access public @param IFormModel $model model @param string $property model property @param array $options attribute array @return string
[ "Render", "telephone", "field", "row" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L907-L916
train
linpax/microphp-framework
src/form/Form.php
Form.telField
public function telField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::telField($element['name'], $element['value'], $options); }
php
public function telField(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::telField($element['name'], $element['value'], $options); }
[ "public", "function", "telField", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "telField", "(", "$", "element", "[", "'name'", "]", ",", "$", "element", "[", "'value'", "]", ",", "$", "options", ")", ";", "}" ]
Render telephone tag @access public @param IFormModel $model model @param string $property model property @param array $options attributes array @return string
[ "Render", "telephone", "tag" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L929-L935
train
linpax/microphp-framework
src/form/Form.php
Form.timeFieldRow
public function timeFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->timeField($model, $property, $options). Html::closeTag('div'); }
php
public function timeFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->timeField($model, $property, $options). Html::closeTag('div'); }
[ "public", "function", "timeFieldRow", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "openTag", "(", "'div'", ",", "$", "this", "->", "getBlock", "(", "'block'", ",", "$", "options", ")", ")", ".", "Html", "::", "label", "(", "$", "model", "->", "getLabel", "(", "$", "property", ")", ",", "$", "element", "[", "'id'", "]", ",", "$", "this", "->", "getBlock", "(", "'label'", ",", "$", "options", ")", ")", ".", "$", "this", "->", "timeField", "(", "$", "model", ",", "$", "property", ",", "$", "options", ")", ".", "Html", "::", "closeTag", "(", "'div'", ")", ";", "}" ]
Render time field row @access public @param IFormModel $model model @param string $property model property @param array $options attribute array @return string
[ "Render", "time", "field", "row" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L948-L957
train
linpax/microphp-framework
src/form/Form.php
Form.urlFieldRow
public function urlFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->urlField($model, $property, $options). Html::closeTag('div'); }
php
public function urlFieldRow(IFormModel $model, $property, array $options = []) { $element = $this->getField($model, $property); $options['id'] = $element['id']; return Html::openTag('div', $this->getBlock('block', $options)). Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)). $this->urlField($model, $property, $options). Html::closeTag('div'); }
[ "public", "function", "urlFieldRow", "(", "IFormModel", "$", "model", ",", "$", "property", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "element", "=", "$", "this", "->", "getField", "(", "$", "model", ",", "$", "property", ")", ";", "$", "options", "[", "'id'", "]", "=", "$", "element", "[", "'id'", "]", ";", "return", "Html", "::", "openTag", "(", "'div'", ",", "$", "this", "->", "getBlock", "(", "'block'", ",", "$", "options", ")", ")", ".", "Html", "::", "label", "(", "$", "model", "->", "getLabel", "(", "$", "property", ")", ",", "$", "element", "[", "'id'", "]", ",", "$", "this", "->", "getBlock", "(", "'label'", ",", "$", "options", ")", ")", ".", "$", "this", "->", "urlField", "(", "$", "model", ",", "$", "property", ",", "$", "options", ")", ".", "Html", "::", "closeTag", "(", "'div'", ")", ";", "}" ]
Render url field row @access public @param IFormModel $model model @param string $property model property @param array $options attribute array @return string
[ "Render", "url", "field", "row" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/form/Form.php#L989-L998
train