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
phpMv/ubiquity
src/Ubiquity/controllers/auth/AuthControllerOverrideTrait.php
AuthControllerOverrideTrait.rememberMe
protected function rememberMe($connected){ $id= $this->toCookie($connected); if(isset($id)){ UCookie::set($this->_getUserSessionKey(),$id); } }
php
protected function rememberMe($connected){ $id= $this->toCookie($connected); if(isset($id)){ UCookie::set($this->_getUserSessionKey(),$id); } }
[ "protected", "function", "rememberMe", "(", "$", "connected", ")", "{", "$", "id", "=", "$", "this", "->", "toCookie", "(", "$", "connected", ")", ";", "if", "(", "isset", "(", "$", "id", ")", ")", "{", "UCookie", "::", "set", "(", "$", "this", "->", "_getUserSessionKey", "(", ")", ",", "$", "id", ")", ";", "}", "}" ]
Saves the connected user identifier in a cookie @param object $connected
[ "Saves", "the", "connected", "user", "identifier", "in", "a", "cookie" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/auth/AuthControllerOverrideTrait.php#L84-L89
train
phpMv/ubiquity
src/Ubiquity/utils/base/UFileSystem.php
UFileSystem.safeMkdir
public static function safeMkdir($dir, $mode = 0777, $recursive = true) { if (! \is_dir ( $dir )) return \mkdir ( $dir, $mode, $recursive ); return true; }
php
public static function safeMkdir($dir, $mode = 0777, $recursive = true) { if (! \is_dir ( $dir )) return \mkdir ( $dir, $mode, $recursive ); return true; }
[ "public", "static", "function", "safeMkdir", "(", "$", "dir", ",", "$", "mode", "=", "0777", ",", "$", "recursive", "=", "true", ")", "{", "if", "(", "!", "\\", "is_dir", "(", "$", "dir", ")", ")", "return", "\\", "mkdir", "(", "$", "dir", ",", "$", "mode", ",", "$", "recursive", ")", ";", "return", "true", ";", "}" ]
Tests the existance and eventually creates a directory @param string $dir @param int $mode @param boolean $recursive @return boolean
[ "Tests", "the", "existance", "and", "eventually", "creates", "a", "directory" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/base/UFileSystem.php#L68-L72
train
phpMv/ubiquity
src/Ubiquity/utils/base/UFileSystem.php
UFileSystem.cleanPathname
public static function cleanPathname($path) { if (UString::isNotNull ( $path )) { if (\DS === "/") $path = \str_replace ( "\\", \DS, $path ); else $path = \str_replace ( "/", \DS, $path ); $path = \str_replace ( \DS . \DS, \DS, $path ); if (! UString::endswith ( $path, \DS )) { $path = $path . \DS; } } return $path; }
php
public static function cleanPathname($path) { if (UString::isNotNull ( $path )) { if (\DS === "/") $path = \str_replace ( "\\", \DS, $path ); else $path = \str_replace ( "/", \DS, $path ); $path = \str_replace ( \DS . \DS, \DS, $path ); if (! UString::endswith ( $path, \DS )) { $path = $path . \DS; } } return $path; }
[ "public", "static", "function", "cleanPathname", "(", "$", "path", ")", "{", "if", "(", "UString", "::", "isNotNull", "(", "$", "path", ")", ")", "{", "if", "(", "\\", "DS", "===", "\"/\"", ")", "$", "path", "=", "\\", "str_replace", "(", "\"\\\\\"", ",", "\\", "DS", ",", "$", "path", ")", ";", "else", "$", "path", "=", "\\", "str_replace", "(", "\"/\"", ",", "\\", "DS", ",", "$", "path", ")", ";", "$", "path", "=", "\\", "str_replace", "(", "\\", "DS", ".", "\\", "DS", ",", "\\", "DS", ",", "$", "path", ")", ";", "if", "(", "!", "UString", "::", "endswith", "(", "$", "path", ",", "\\", "DS", ")", ")", "{", "$", "path", "=", "$", "path", ".", "\\", "DS", ";", "}", "}", "return", "$", "path", ";", "}" ]
Cleans a directory path by removing double backslashes or slashes and using DIRECTORY_SEPARATOR @param string $path @return string
[ "Cleans", "a", "directory", "path", "by", "removing", "double", "backslashes", "or", "slashes", "and", "using", "DIRECTORY_SEPARATOR" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/base/UFileSystem.php#L80-L92
train
phpMv/ubiquity
src/Ubiquity/utils/base/UFileSystem.php
UFileSystem.cleanFilePathname
public static function cleanFilePathname($path) { if (UString::isNotNull ( $path )) { if (\DS === "/") $path = \str_replace ( "\\", \DS, $path ); else $path = \str_replace ( "/", \DS, $path ); $path = \str_replace ( \DS . \DS, \DS, $path ); } return $path; }
php
public static function cleanFilePathname($path) { if (UString::isNotNull ( $path )) { if (\DS === "/") $path = \str_replace ( "\\", \DS, $path ); else $path = \str_replace ( "/", \DS, $path ); $path = \str_replace ( \DS . \DS, \DS, $path ); } return $path; }
[ "public", "static", "function", "cleanFilePathname", "(", "$", "path", ")", "{", "if", "(", "UString", "::", "isNotNull", "(", "$", "path", ")", ")", "{", "if", "(", "\\", "DS", "===", "\"/\"", ")", "$", "path", "=", "\\", "str_replace", "(", "\"\\\\\"", ",", "\\", "DS", ",", "$", "path", ")", ";", "else", "$", "path", "=", "\\", "str_replace", "(", "\"/\"", ",", "\\", "DS", ",", "$", "path", ")", ";", "$", "path", "=", "\\", "str_replace", "(", "\\", "DS", ".", "\\", "DS", ",", "\\", "DS", ",", "$", "path", ")", ";", "}", "return", "$", "path", ";", "}" ]
Cleans a file path by removing double backslashes or slashes and using DIRECTORY_SEPARATOR @param string $path @return string
[ "Cleans", "a", "file", "path", "by", "removing", "double", "backslashes", "or", "slashes", "and", "using", "DIRECTORY_SEPARATOR" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/base/UFileSystem.php#L100-L109
train
phpMv/ubiquity
src/Ubiquity/utils/base/UFileSystem.php
UFileSystem.getLines
public static function getLines($filename, $reverse = false, $maxLines = null, $lineCallback = null) { if (file_exists ( $filename )) { if ($reverse && isset ( $maxLines )) { $result = [ ]; $fl = fopen ( $filename, "r" ); for($x_pos = 0, $ln = 0, $lines = [ ]; fseek ( $fl, $x_pos, SEEK_END ) !== - 1; $x_pos --) { $char = fgetc ( $fl ); if ($char === "\n") { if (is_callable ( $lineCallback )) { $lineCallback ( $result, $lines [$ln] ); } else { $result [] = $lines [$ln]; } if (isset ( $maxLines ) && sizeof ( $result ) >= $maxLines) { fclose ( $fl ); return $result; } $ln ++; continue; } $lines [$ln] = $char . ((array_key_exists ( $ln, $lines )) ? $lines [$ln] : ''); } fclose ( $fl ); return $result; } else { return self::getLinesByLine ( $filename, $reverse, $maxLines, $lineCallback ); } } return [ ]; }
php
public static function getLines($filename, $reverse = false, $maxLines = null, $lineCallback = null) { if (file_exists ( $filename )) { if ($reverse && isset ( $maxLines )) { $result = [ ]; $fl = fopen ( $filename, "r" ); for($x_pos = 0, $ln = 0, $lines = [ ]; fseek ( $fl, $x_pos, SEEK_END ) !== - 1; $x_pos --) { $char = fgetc ( $fl ); if ($char === "\n") { if (is_callable ( $lineCallback )) { $lineCallback ( $result, $lines [$ln] ); } else { $result [] = $lines [$ln]; } if (isset ( $maxLines ) && sizeof ( $result ) >= $maxLines) { fclose ( $fl ); return $result; } $ln ++; continue; } $lines [$ln] = $char . ((array_key_exists ( $ln, $lines )) ? $lines [$ln] : ''); } fclose ( $fl ); return $result; } else { return self::getLinesByLine ( $filename, $reverse, $maxLines, $lineCallback ); } } return [ ]; }
[ "public", "static", "function", "getLines", "(", "$", "filename", ",", "$", "reverse", "=", "false", ",", "$", "maxLines", "=", "null", ",", "$", "lineCallback", "=", "null", ")", "{", "if", "(", "file_exists", "(", "$", "filename", ")", ")", "{", "if", "(", "$", "reverse", "&&", "isset", "(", "$", "maxLines", ")", ")", "{", "$", "result", "=", "[", "]", ";", "$", "fl", "=", "fopen", "(", "$", "filename", ",", "\"r\"", ")", ";", "for", "(", "$", "x_pos", "=", "0", ",", "$", "ln", "=", "0", ",", "$", "lines", "=", "[", "]", ";", "fseek", "(", "$", "fl", ",", "$", "x_pos", ",", "SEEK_END", ")", "!==", "-", "1", ";", "$", "x_pos", "--", ")", "{", "$", "char", "=", "fgetc", "(", "$", "fl", ")", ";", "if", "(", "$", "char", "===", "\"\\n\"", ")", "{", "if", "(", "is_callable", "(", "$", "lineCallback", ")", ")", "{", "$", "lineCallback", "(", "$", "result", ",", "$", "lines", "[", "$", "ln", "]", ")", ";", "}", "else", "{", "$", "result", "[", "]", "=", "$", "lines", "[", "$", "ln", "]", ";", "}", "if", "(", "isset", "(", "$", "maxLines", ")", "&&", "sizeof", "(", "$", "result", ")", ">=", "$", "maxLines", ")", "{", "fclose", "(", "$", "fl", ")", ";", "return", "$", "result", ";", "}", "$", "ln", "++", ";", "continue", ";", "}", "$", "lines", "[", "$", "ln", "]", "=", "$", "char", ".", "(", "(", "array_key_exists", "(", "$", "ln", ",", "$", "lines", ")", ")", "?", "$", "lines", "[", "$", "ln", "]", ":", "''", ")", ";", "}", "fclose", "(", "$", "fl", ")", ";", "return", "$", "result", ";", "}", "else", "{", "return", "self", "::", "getLinesByLine", "(", "$", "filename", ",", "$", "reverse", ",", "$", "maxLines", ",", "$", "lineCallback", ")", ";", "}", "}", "return", "[", "]", ";", "}" ]
Returns the lines of a file in an array @param string $filename @param boolean $reverse @param null|int $maxLines @param callback $lineCallback @return array
[ "Returns", "the", "lines", "of", "a", "file", "in", "an", "array" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/base/UFileSystem.php#L181-L210
train
phpMv/ubiquity
src/Ubiquity/controllers/di/DiManager.php
DiManager.init
public static function init(&$config) { $controllers = CacheManager::getControllers (); foreach ( $controllers as $controller ) { CacheManager::$cache->remove( self::getControllerCacheKey ( $controller )); $parser = new DiControllerParser (); $parser->parse ( $controller, $config ); $injections = $parser->getInjections (); if (sizeof ( $injections ) > 0) { self::store ( $controller, $parser->__toString () ); } } }
php
public static function init(&$config) { $controllers = CacheManager::getControllers (); foreach ( $controllers as $controller ) { CacheManager::$cache->remove( self::getControllerCacheKey ( $controller )); $parser = new DiControllerParser (); $parser->parse ( $controller, $config ); $injections = $parser->getInjections (); if (sizeof ( $injections ) > 0) { self::store ( $controller, $parser->__toString () ); } } }
[ "public", "static", "function", "init", "(", "&", "$", "config", ")", "{", "$", "controllers", "=", "CacheManager", "::", "getControllers", "(", ")", ";", "foreach", "(", "$", "controllers", "as", "$", "controller", ")", "{", "CacheManager", "::", "$", "cache", "->", "remove", "(", "self", "::", "getControllerCacheKey", "(", "$", "controller", ")", ")", ";", "$", "parser", "=", "new", "DiControllerParser", "(", ")", ";", "$", "parser", "->", "parse", "(", "$", "controller", ",", "$", "config", ")", ";", "$", "injections", "=", "$", "parser", "->", "getInjections", "(", ")", ";", "if", "(", "sizeof", "(", "$", "injections", ")", ">", "0", ")", "{", "self", "::", "store", "(", "$", "controller", ",", "$", "parser", "->", "__toString", "(", ")", ")", ";", "}", "}", "}" ]
Initialize dependency injection cache To use in dev only! @param array $config
[ "Initialize", "dependency", "injection", "cache", "To", "use", "in", "dev", "only!" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/di/DiManager.php#L26-L37
train
phpMv/ubiquity
src/Ubiquity/utils/base/UArray.php
UArray.save
public static function save($array, $filename) { $content = "<?php\nreturn " . self::asPhpArray ( $array, "array", 1, true ) . ";"; return UFileSystem::save ( $filename, $content ); }
php
public static function save($array, $filename) { $content = "<?php\nreturn " . self::asPhpArray ( $array, "array", 1, true ) . ";"; return UFileSystem::save ( $filename, $content ); }
[ "public", "static", "function", "save", "(", "$", "array", ",", "$", "filename", ")", "{", "$", "content", "=", "\"<?php\\nreturn \"", ".", "self", "::", "asPhpArray", "(", "$", "array", ",", "\"array\"", ",", "1", ",", "true", ")", ".", "\";\"", ";", "return", "UFileSystem", "::", "save", "(", "$", "filename", ",", "$", "content", ")", ";", "}" ]
Save a php array to the disk. @param array $array The array to save @param string $filename The path of the file to save in @return int
[ "Save", "a", "php", "array", "to", "the", "disk", "." ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/base/UArray.php#L90-L93
train
phpMv/ubiquity
src/Ubiquity/controllers/Router.php
Router.getRoute
public static function getRoute($path, $cachedResponse = true) { $path = self::slashPath ( $path ); if (isset ( self::$routes [$path] )) { return self::getRoute_ ( self::$routes [$path], $path, [ $path ], $cachedResponse ); } foreach ( self::$routes as $routePath => $routeDetails ) { if (preg_match ( "@^" . $routePath . "$@s", $path, $matches )) { if (($r = self::getRoute_ ( $routeDetails, $routePath, $matches, $cachedResponse )) !== false) { return $r; } } } Logger::warn ( "Router", "No route found for {$path}", "getRoute" ); return false; }
php
public static function getRoute($path, $cachedResponse = true) { $path = self::slashPath ( $path ); if (isset ( self::$routes [$path] )) { return self::getRoute_ ( self::$routes [$path], $path, [ $path ], $cachedResponse ); } foreach ( self::$routes as $routePath => $routeDetails ) { if (preg_match ( "@^" . $routePath . "$@s", $path, $matches )) { if (($r = self::getRoute_ ( $routeDetails, $routePath, $matches, $cachedResponse )) !== false) { return $r; } } } Logger::warn ( "Router", "No route found for {$path}", "getRoute" ); return false; }
[ "public", "static", "function", "getRoute", "(", "$", "path", ",", "$", "cachedResponse", "=", "true", ")", "{", "$", "path", "=", "self", "::", "slashPath", "(", "$", "path", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "routes", "[", "$", "path", "]", ")", ")", "{", "return", "self", "::", "getRoute_", "(", "self", "::", "$", "routes", "[", "$", "path", "]", ",", "$", "path", ",", "[", "$", "path", "]", ",", "$", "cachedResponse", ")", ";", "}", "foreach", "(", "self", "::", "$", "routes", "as", "$", "routePath", "=>", "$", "routeDetails", ")", "{", "if", "(", "preg_match", "(", "\"@^\"", ".", "$", "routePath", ".", "\"$@s\"", ",", "$", "path", ",", "$", "matches", ")", ")", "{", "if", "(", "(", "$", "r", "=", "self", "::", "getRoute_", "(", "$", "routeDetails", ",", "$", "routePath", ",", "$", "matches", ",", "$", "cachedResponse", ")", ")", "!==", "false", ")", "{", "return", "$", "r", ";", "}", "}", "}", "Logger", "::", "warn", "(", "\"Router\"", ",", "\"No route found for {$path}\"", ",", "\"getRoute\"", ")", ";", "return", "false", ";", "}" ]
Returns the route corresponding to a path @param string $path The route path @param boolean $cachedResponse @return boolean|mixed[]|string
[ "Returns", "the", "route", "corresponding", "to", "a", "path" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/Router.php#L114-L128
train
phpMv/ubiquity
src/Ubiquity/controllers/Router.php
Router.url
public static function url($name, $parameters = []) { return URequest::getUrl ( self::getRouteByName ( $name, $parameters, false ) ); }
php
public static function url($name, $parameters = []) { return URequest::getUrl ( self::getRouteByName ( $name, $parameters, false ) ); }
[ "public", "static", "function", "url", "(", "$", "name", ",", "$", "parameters", "=", "[", "]", ")", "{", "return", "URequest", "::", "getUrl", "(", "self", "::", "getRouteByName", "(", "$", "name", ",", "$", "parameters", ",", "false", ")", ")", ";", "}" ]
Returns the generated url from a route @param string $name the route name @param array $parameters default: [] @return string the generated url (http://myApp/path/to/route)
[ "Returns", "the", "generated", "url", "from", "a", "route" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/Router.php#L170-L172
train
phpMv/ubiquity
src/Ubiquity/controllers/Router.php
Router.slashPath
public static function slashPath($path) { if (UString::startswith ( $path, "/" ) === false) $path = "/" . $path; if (! UString::endswith ( $path, "/" )) $path = $path . "/"; return $path; }
php
public static function slashPath($path) { if (UString::startswith ( $path, "/" ) === false) $path = "/" . $path; if (! UString::endswith ( $path, "/" )) $path = $path . "/"; return $path; }
[ "public", "static", "function", "slashPath", "(", "$", "path", ")", "{", "if", "(", "UString", "::", "startswith", "(", "$", "path", ",", "\"/\"", ")", "===", "false", ")", "$", "path", "=", "\"/\"", ".", "$", "path", ";", "if", "(", "!", "UString", "::", "endswith", "(", "$", "path", ",", "\"/\"", ")", ")", "$", "path", "=", "$", "path", ".", "\"/\"", ";", "return", "$", "path", ";", "}" ]
Adds a slash before and after a path @param string $path The path to modify @return string The path with slashes
[ "Adds", "a", "slash", "before", "and", "after", "a", "path" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/Router.php#L201-L207
train
phpMv/ubiquity
src/Ubiquity/contents/validation/ValidatorsManager.php
ValidatorsManager.validate
public static function validate($instance, $group = "") { $class = get_class ( $instance ); $cache = self::getClassCacheValidators ( $class, $group ); if ($cache !== false) { return self::validateFromCache_ ( $instance, $cache ); } $members = self::fetch ( $class ); if ($group !== "") { $members = self::getGroupArrayValidators ( $members, $group ); } return self::validate_ ( $instance, $members ); }
php
public static function validate($instance, $group = "") { $class = get_class ( $instance ); $cache = self::getClassCacheValidators ( $class, $group ); if ($cache !== false) { return self::validateFromCache_ ( $instance, $cache ); } $members = self::fetch ( $class ); if ($group !== "") { $members = self::getGroupArrayValidators ( $members, $group ); } return self::validate_ ( $instance, $members ); }
[ "public", "static", "function", "validate", "(", "$", "instance", ",", "$", "group", "=", "\"\"", ")", "{", "$", "class", "=", "get_class", "(", "$", "instance", ")", ";", "$", "cache", "=", "self", "::", "getClassCacheValidators", "(", "$", "class", ",", "$", "group", ")", ";", "if", "(", "$", "cache", "!==", "false", ")", "{", "return", "self", "::", "validateFromCache_", "(", "$", "instance", ",", "$", "cache", ")", ";", "}", "$", "members", "=", "self", "::", "fetch", "(", "$", "class", ")", ";", "if", "(", "$", "group", "!==", "\"\"", ")", "{", "$", "members", "=", "self", "::", "getGroupArrayValidators", "(", "$", "members", ",", "$", "group", ")", ";", "}", "return", "self", "::", "validate_", "(", "$", "instance", ",", "$", "members", ")", ";", "}" ]
Validates an instance @param object $instance @param string $group @return \Ubiquity\contents\validation\validators\ConstraintViolation[]
[ "Validates", "an", "instance" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/contents/validation/ValidatorsManager.php#L134-L145
train
phpMv/ubiquity
src/Ubiquity/contents/validation/ValidatorsManager.php
ValidatorsManager.validateInstances
public static function validateInstances($instances, $group = "") { if (sizeof ( $instances ) > 0) { $instance = current ( $instances ); $class = get_class ( $instance ); $cache = self::getClassCacheValidators ( $class, $group ); if ($cache === false) { $members = self::fetch ( $class ); self::initInstancesValidators ( $instance, $members, $group ); $cache = self::$instanceValidators [$class]; } return self::validateInstances_ ( $instances, $cache ); } return [ ]; }
php
public static function validateInstances($instances, $group = "") { if (sizeof ( $instances ) > 0) { $instance = current ( $instances ); $class = get_class ( $instance ); $cache = self::getClassCacheValidators ( $class, $group ); if ($cache === false) { $members = self::fetch ( $class ); self::initInstancesValidators ( $instance, $members, $group ); $cache = self::$instanceValidators [$class]; } return self::validateInstances_ ( $instances, $cache ); } return [ ]; }
[ "public", "static", "function", "validateInstances", "(", "$", "instances", ",", "$", "group", "=", "\"\"", ")", "{", "if", "(", "sizeof", "(", "$", "instances", ")", ">", "0", ")", "{", "$", "instance", "=", "current", "(", "$", "instances", ")", ";", "$", "class", "=", "get_class", "(", "$", "instance", ")", ";", "$", "cache", "=", "self", "::", "getClassCacheValidators", "(", "$", "class", ",", "$", "group", ")", ";", "if", "(", "$", "cache", "===", "false", ")", "{", "$", "members", "=", "self", "::", "fetch", "(", "$", "class", ")", ";", "self", "::", "initInstancesValidators", "(", "$", "instance", ",", "$", "members", ",", "$", "group", ")", ";", "$", "cache", "=", "self", "::", "$", "instanceValidators", "[", "$", "class", "]", ";", "}", "return", "self", "::", "validateInstances_", "(", "$", "instances", ",", "$", "cache", ")", ";", "}", "return", "[", "]", ";", "}" ]
Validates an array of objects @param array $instances @param string $group @return \Ubiquity\contents\validation\validators\ConstraintViolation[]
[ "Validates", "an", "array", "of", "objects" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/contents/validation/ValidatorsManager.php#L154-L167
train
phpMv/ubiquity
src/Ubiquity/cache/traits/ModelsCacheTrait.php
ModelsCacheTrait.getModels
public static function getModels(&$config, $silent = false) { $result = [ ]; $files = self::getModelsFiles ( $config, $silent ); foreach ( $files as $file ) { $result [] = ClassUtils::getClassFullNameFromFile ( $file ); } return $result; }
php
public static function getModels(&$config, $silent = false) { $result = [ ]; $files = self::getModelsFiles ( $config, $silent ); foreach ( $files as $file ) { $result [] = ClassUtils::getClassFullNameFromFile ( $file ); } return $result; }
[ "public", "static", "function", "getModels", "(", "&", "$", "config", ",", "$", "silent", "=", "false", ")", "{", "$", "result", "=", "[", "]", ";", "$", "files", "=", "self", "::", "getModelsFiles", "(", "$", "config", ",", "$", "silent", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "result", "[", "]", "=", "ClassUtils", "::", "getClassFullNameFromFile", "(", "$", "file", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns an array of the models class names @param array $config @param boolean $silent @return string[]
[ "Returns", "an", "array", "of", "the", "models", "class", "names" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/cache/traits/ModelsCacheTrait.php#L86-L93
train
phpMv/ubiquity
src/Ubiquity/controllers/crud/CRUDController.php
CRUDController.refresh_
public function refresh_() { $model = $this->model; if (isset ( $_POST ["s"] )) { $instances = $this->search ( $model, $_POST ["s"] ); } else { $page = URequest::post ( "p", 1 ); $instances = $this->getInstances ( $totalCount, $page ); } if (! isset ( $totalCount )) { $totalCount = DAO::count ( $model, $this->_getAdminData ()->_getInstancesFilter ( $model ) ); } $recordsPerPage = $this->_getModelViewer ()->recordsPerPage ( $model, $totalCount ); $grpByFields = $this->_getModelViewer ()->getGroupByFields (); if (isset ( $recordsPerPage )) { if (! is_array ( $grpByFields )) { UResponse::asJSON (); $responseFormatter = new ResponseFormatter (); print_r ( $responseFormatter->getJSONDatas ( $instances ) ); } else { $this->_renderDataTableForRefresh ( $instances, $model, $totalCount ); } } else { $this->jquery->execAtLast ( '$("#search-query-content").html("' . $_POST ["s"] . '");$("#search-query").show();$("#table-details").html("");' ); $this->_renderDataTableForRefresh ( $instances, $model, $totalCount ); } }
php
public function refresh_() { $model = $this->model; if (isset ( $_POST ["s"] )) { $instances = $this->search ( $model, $_POST ["s"] ); } else { $page = URequest::post ( "p", 1 ); $instances = $this->getInstances ( $totalCount, $page ); } if (! isset ( $totalCount )) { $totalCount = DAO::count ( $model, $this->_getAdminData ()->_getInstancesFilter ( $model ) ); } $recordsPerPage = $this->_getModelViewer ()->recordsPerPage ( $model, $totalCount ); $grpByFields = $this->_getModelViewer ()->getGroupByFields (); if (isset ( $recordsPerPage )) { if (! is_array ( $grpByFields )) { UResponse::asJSON (); $responseFormatter = new ResponseFormatter (); print_r ( $responseFormatter->getJSONDatas ( $instances ) ); } else { $this->_renderDataTableForRefresh ( $instances, $model, $totalCount ); } } else { $this->jquery->execAtLast ( '$("#search-query-content").html("' . $_POST ["s"] . '");$("#search-query").show();$("#table-details").html("");' ); $this->_renderDataTableForRefresh ( $instances, $model, $totalCount ); } }
[ "public", "function", "refresh_", "(", ")", "{", "$", "model", "=", "$", "this", "->", "model", ";", "if", "(", "isset", "(", "$", "_POST", "[", "\"s\"", "]", ")", ")", "{", "$", "instances", "=", "$", "this", "->", "search", "(", "$", "model", ",", "$", "_POST", "[", "\"s\"", "]", ")", ";", "}", "else", "{", "$", "page", "=", "URequest", "::", "post", "(", "\"p\"", ",", "1", ")", ";", "$", "instances", "=", "$", "this", "->", "getInstances", "(", "$", "totalCount", ",", "$", "page", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "totalCount", ")", ")", "{", "$", "totalCount", "=", "DAO", "::", "count", "(", "$", "model", ",", "$", "this", "->", "_getAdminData", "(", ")", "->", "_getInstancesFilter", "(", "$", "model", ")", ")", ";", "}", "$", "recordsPerPage", "=", "$", "this", "->", "_getModelViewer", "(", ")", "->", "recordsPerPage", "(", "$", "model", ",", "$", "totalCount", ")", ";", "$", "grpByFields", "=", "$", "this", "->", "_getModelViewer", "(", ")", "->", "getGroupByFields", "(", ")", ";", "if", "(", "isset", "(", "$", "recordsPerPage", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "grpByFields", ")", ")", "{", "UResponse", "::", "asJSON", "(", ")", ";", "$", "responseFormatter", "=", "new", "ResponseFormatter", "(", ")", ";", "print_r", "(", "$", "responseFormatter", "->", "getJSONDatas", "(", "$", "instances", ")", ")", ";", "}", "else", "{", "$", "this", "->", "_renderDataTableForRefresh", "(", "$", "instances", ",", "$", "model", ",", "$", "totalCount", ")", ";", "}", "}", "else", "{", "$", "this", "->", "jquery", "->", "execAtLast", "(", "'$(\"#search-query-content\").html(\"'", ".", "$", "_POST", "[", "\"s\"", "]", ".", "'\");$(\"#search-query\").show();$(\"#table-details\").html(\"\");'", ")", ";", "$", "this", "->", "_renderDataTableForRefresh", "(", "$", "instances", ",", "$", "model", ",", "$", "totalCount", ")", ";", "}", "}" ]
Refreshes the area corresponding to the DataTable
[ "Refreshes", "the", "area", "corresponding", "to", "the", "DataTable" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/crud/CRUDController.php#L73-L98
train
phpMv/ubiquity
src/Ubiquity/controllers/crud/CRUDController.php
CRUDController.edit
public function edit($modal = "no", $ids = "") { if (URequest::isAjax ()) { $instance = $this->getModelInstance ( $ids, false ); $instance->_new = false; $this->_edit ( $instance, $modal ); } else { $this->jquery->execAtLast ( "$('._edit[data-ajax={$ids}]').trigger('click');" ); $this->index (); } }
php
public function edit($modal = "no", $ids = "") { if (URequest::isAjax ()) { $instance = $this->getModelInstance ( $ids, false ); $instance->_new = false; $this->_edit ( $instance, $modal ); } else { $this->jquery->execAtLast ( "$('._edit[data-ajax={$ids}]').trigger('click');" ); $this->index (); } }
[ "public", "function", "edit", "(", "$", "modal", "=", "\"no\"", ",", "$", "ids", "=", "\"\"", ")", "{", "if", "(", "URequest", "::", "isAjax", "(", ")", ")", "{", "$", "instance", "=", "$", "this", "->", "getModelInstance", "(", "$", "ids", ",", "false", ")", ";", "$", "instance", "->", "_new", "=", "false", ";", "$", "this", "->", "_edit", "(", "$", "instance", ",", "$", "modal", ")", ";", "}", "else", "{", "$", "this", "->", "jquery", "->", "execAtLast", "(", "\"$('._edit[data-ajax={$ids}]').trigger('click');\"", ")", ";", "$", "this", "->", "index", "(", ")", ";", "}", "}" ]
Edits an instance @param string $modal Accept "no" or "modal" for a modal dialog @param string $ids the primary value(s)
[ "Edits", "an", "instance" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/crud/CRUDController.php#L106-L115
train
phpMv/ubiquity
src/Ubiquity/controllers/crud/CRUDController.php
CRUDController.newModel
public function newModel($modal = "no") { if (URequest::isAjax ()) { $model = $this->model; $instance = new $model (); $instance->_new = true; $this->_edit ( $instance, $modal ); } else { $this->jquery->execAtLast ( "$('.ui.button._new').trigger('click');" ); $this->index (); } }
php
public function newModel($modal = "no") { if (URequest::isAjax ()) { $model = $this->model; $instance = new $model (); $instance->_new = true; $this->_edit ( $instance, $modal ); } else { $this->jquery->execAtLast ( "$('.ui.button._new').trigger('click');" ); $this->index (); } }
[ "public", "function", "newModel", "(", "$", "modal", "=", "\"no\"", ")", "{", "if", "(", "URequest", "::", "isAjax", "(", ")", ")", "{", "$", "model", "=", "$", "this", "->", "model", ";", "$", "instance", "=", "new", "$", "model", "(", ")", ";", "$", "instance", "->", "_new", "=", "true", ";", "$", "this", "->", "_edit", "(", "$", "instance", ",", "$", "modal", ")", ";", "}", "else", "{", "$", "this", "->", "jquery", "->", "execAtLast", "(", "\"$('.ui.button._new').trigger('click');\"", ")", ";", "$", "this", "->", "index", "(", ")", ";", "}", "}" ]
Adds a new instance and edits it @param string $modal Accept "no" or "modal" for a modal dialog
[ "Adds", "a", "new", "instance", "and", "edits", "it" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/crud/CRUDController.php#L122-L132
train
phpMv/ubiquity
src/Ubiquity/controllers/crud/CRUDController.php
CRUDController.display
public function display($modal = "no", $ids = "") { if (URequest::isAjax ()) { $instance = $this->getModelInstance ( $ids ); $key = OrmUtils::getFirstKeyValue ( $instance ); $this->jquery->execOn ( "click", "._close", '$("#table-details").html("");$("#dataTable").show();' ); $this->jquery->getOnClick ( "._edit", $this->_getBaseRoute () . "/edit/" . $modal . "/" . $key, "#frm-add-update" ); $this->jquery->getOnClick ( "._delete", $this->_getBaseRoute () . "/delete/" . $key, "#table-messages" ); $this->_getModelViewer ()->getModelDataElement ( $instance, $this->model, $modal ); $this->jquery->renderView ( $this->_getFiles ()->getViewDisplay (), [ "classname" => $this->model,"instance" => $instance,"pk" => $key ] ); } else { $this->jquery->execAtLast ( "$('._display[data-ajax={$ids}]').trigger('click');" ); $this->index (); } }
php
public function display($modal = "no", $ids = "") { if (URequest::isAjax ()) { $instance = $this->getModelInstance ( $ids ); $key = OrmUtils::getFirstKeyValue ( $instance ); $this->jquery->execOn ( "click", "._close", '$("#table-details").html("");$("#dataTable").show();' ); $this->jquery->getOnClick ( "._edit", $this->_getBaseRoute () . "/edit/" . $modal . "/" . $key, "#frm-add-update" ); $this->jquery->getOnClick ( "._delete", $this->_getBaseRoute () . "/delete/" . $key, "#table-messages" ); $this->_getModelViewer ()->getModelDataElement ( $instance, $this->model, $modal ); $this->jquery->renderView ( $this->_getFiles ()->getViewDisplay (), [ "classname" => $this->model,"instance" => $instance,"pk" => $key ] ); } else { $this->jquery->execAtLast ( "$('._display[data-ajax={$ids}]').trigger('click');" ); $this->index (); } }
[ "public", "function", "display", "(", "$", "modal", "=", "\"no\"", ",", "$", "ids", "=", "\"\"", ")", "{", "if", "(", "URequest", "::", "isAjax", "(", ")", ")", "{", "$", "instance", "=", "$", "this", "->", "getModelInstance", "(", "$", "ids", ")", ";", "$", "key", "=", "OrmUtils", "::", "getFirstKeyValue", "(", "$", "instance", ")", ";", "$", "this", "->", "jquery", "->", "execOn", "(", "\"click\"", ",", "\"._close\"", ",", "'$(\"#table-details\").html(\"\");$(\"#dataTable\").show();'", ")", ";", "$", "this", "->", "jquery", "->", "getOnClick", "(", "\"._edit\"", ",", "$", "this", "->", "_getBaseRoute", "(", ")", ".", "\"/edit/\"", ".", "$", "modal", ".", "\"/\"", ".", "$", "key", ",", "\"#frm-add-update\"", ")", ";", "$", "this", "->", "jquery", "->", "getOnClick", "(", "\"._delete\"", ",", "$", "this", "->", "_getBaseRoute", "(", ")", ".", "\"/delete/\"", ".", "$", "key", ",", "\"#table-messages\"", ")", ";", "$", "this", "->", "_getModelViewer", "(", ")", "->", "getModelDataElement", "(", "$", "instance", ",", "$", "this", "->", "model", ",", "$", "modal", ")", ";", "$", "this", "->", "jquery", "->", "renderView", "(", "$", "this", "->", "_getFiles", "(", ")", "->", "getViewDisplay", "(", ")", ",", "[", "\"classname\"", "=>", "$", "this", "->", "model", ",", "\"instance\"", "=>", "$", "instance", ",", "\"pk\"", "=>", "$", "key", "]", ")", ";", "}", "else", "{", "$", "this", "->", "jquery", "->", "execAtLast", "(", "\"$('._display[data-ajax={$ids}]').trigger('click');\"", ")", ";", "$", "this", "->", "index", "(", ")", ";", "}", "}" ]
Displays an instance @param string $modal @param string $ids
[ "Displays", "an", "instance" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/crud/CRUDController.php#L152-L166
train
phpMv/ubiquity
src/Ubiquity/controllers/crud/CRUDController.php
CRUDController.delete
public function delete($ids) { if (URequest::isAjax ()) { $instance = $this->getModelInstance ( $ids ); $instanceString = $this->getInstanceToString ( $instance ); if (sizeof ( $_POST ) > 0) { try { if (DAO::remove ( $instance )) { $message = new CRUDMessage ( "Deletion of `<b>" . $instanceString . "</b>`", "Deletion", "info", "info circle", 4000 ); $message = $this->_getEvents ()->onSuccessDeleteMessage ( $message, $instance ); $this->jquery->exec ( "$('._element[data-ajax={$ids}]').remove();", true ); } else { $message = new CRUDMessage ( "Can not delete `" . $instanceString . "`", "Deletion", "warning", "warning circle" ); $message = $this->_getEvents ()->onErrorDeleteMessage ( $message, $instance ); } } catch ( \Exception $e ) { $message = new CRUDMessage ( "Exception : can not delete `" . $instanceString . "`", "Exception", "warning", "warning" ); $message = $this->_getEvents ()->onErrorDeleteMessage ( $message, $instance ); } $message = $this->_showSimpleMessage ( $message ); } else { $message = new CRUDMessage ( "Do you confirm the deletion of `<b>" . $instanceString . "</b>`?", "Remove confirmation", "error", "question circle" ); $message = $this->_getEvents ()->onConfDeleteMessage ( $message, $instance ); $message = $this->_showConfMessage ( $message, $this->_getBaseRoute () . "/delete/{$ids}", "#table-messages", $ids ); } echo $message; echo $this->jquery->compile ( $this->view ); } else { $this->jquery->execAtLast ( "$('._delete[data-ajax={$ids}]').trigger('click');" ); $this->index (); } }
php
public function delete($ids) { if (URequest::isAjax ()) { $instance = $this->getModelInstance ( $ids ); $instanceString = $this->getInstanceToString ( $instance ); if (sizeof ( $_POST ) > 0) { try { if (DAO::remove ( $instance )) { $message = new CRUDMessage ( "Deletion of `<b>" . $instanceString . "</b>`", "Deletion", "info", "info circle", 4000 ); $message = $this->_getEvents ()->onSuccessDeleteMessage ( $message, $instance ); $this->jquery->exec ( "$('._element[data-ajax={$ids}]').remove();", true ); } else { $message = new CRUDMessage ( "Can not delete `" . $instanceString . "`", "Deletion", "warning", "warning circle" ); $message = $this->_getEvents ()->onErrorDeleteMessage ( $message, $instance ); } } catch ( \Exception $e ) { $message = new CRUDMessage ( "Exception : can not delete `" . $instanceString . "`", "Exception", "warning", "warning" ); $message = $this->_getEvents ()->onErrorDeleteMessage ( $message, $instance ); } $message = $this->_showSimpleMessage ( $message ); } else { $message = new CRUDMessage ( "Do you confirm the deletion of `<b>" . $instanceString . "</b>`?", "Remove confirmation", "error", "question circle" ); $message = $this->_getEvents ()->onConfDeleteMessage ( $message, $instance ); $message = $this->_showConfMessage ( $message, $this->_getBaseRoute () . "/delete/{$ids}", "#table-messages", $ids ); } echo $message; echo $this->jquery->compile ( $this->view ); } else { $this->jquery->execAtLast ( "$('._delete[data-ajax={$ids}]').trigger('click');" ); $this->index (); } }
[ "public", "function", "delete", "(", "$", "ids", ")", "{", "if", "(", "URequest", "::", "isAjax", "(", ")", ")", "{", "$", "instance", "=", "$", "this", "->", "getModelInstance", "(", "$", "ids", ")", ";", "$", "instanceString", "=", "$", "this", "->", "getInstanceToString", "(", "$", "instance", ")", ";", "if", "(", "sizeof", "(", "$", "_POST", ")", ">", "0", ")", "{", "try", "{", "if", "(", "DAO", "::", "remove", "(", "$", "instance", ")", ")", "{", "$", "message", "=", "new", "CRUDMessage", "(", "\"Deletion of `<b>\"", ".", "$", "instanceString", ".", "\"</b>`\"", ",", "\"Deletion\"", ",", "\"info\"", ",", "\"info circle\"", ",", "4000", ")", ";", "$", "message", "=", "$", "this", "->", "_getEvents", "(", ")", "->", "onSuccessDeleteMessage", "(", "$", "message", ",", "$", "instance", ")", ";", "$", "this", "->", "jquery", "->", "exec", "(", "\"$('._element[data-ajax={$ids}]').remove();\"", ",", "true", ")", ";", "}", "else", "{", "$", "message", "=", "new", "CRUDMessage", "(", "\"Can not delete `\"", ".", "$", "instanceString", ".", "\"`\"", ",", "\"Deletion\"", ",", "\"warning\"", ",", "\"warning circle\"", ")", ";", "$", "message", "=", "$", "this", "->", "_getEvents", "(", ")", "->", "onErrorDeleteMessage", "(", "$", "message", ",", "$", "instance", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "message", "=", "new", "CRUDMessage", "(", "\"Exception : can not delete `\"", ".", "$", "instanceString", ".", "\"`\"", ",", "\"Exception\"", ",", "\"warning\"", ",", "\"warning\"", ")", ";", "$", "message", "=", "$", "this", "->", "_getEvents", "(", ")", "->", "onErrorDeleteMessage", "(", "$", "message", ",", "$", "instance", ")", ";", "}", "$", "message", "=", "$", "this", "->", "_showSimpleMessage", "(", "$", "message", ")", ";", "}", "else", "{", "$", "message", "=", "new", "CRUDMessage", "(", "\"Do you confirm the deletion of `<b>\"", ".", "$", "instanceString", ".", "\"</b>`?\"", ",", "\"Remove confirmation\"", ",", "\"error\"", ",", "\"question circle\"", ")", ";", "$", "message", "=", "$", "this", "->", "_getEvents", "(", ")", "->", "onConfDeleteMessage", "(", "$", "message", ",", "$", "instance", ")", ";", "$", "message", "=", "$", "this", "->", "_showConfMessage", "(", "$", "message", ",", "$", "this", "->", "_getBaseRoute", "(", ")", ".", "\"/delete/{$ids}\"", ",", "\"#table-messages\"", ",", "$", "ids", ")", ";", "}", "echo", "$", "message", ";", "echo", "$", "this", "->", "jquery", "->", "compile", "(", "$", "this", "->", "view", ")", ";", "}", "else", "{", "$", "this", "->", "jquery", "->", "execAtLast", "(", "\"$('._delete[data-ajax={$ids}]').trigger('click');\"", ")", ";", "$", "this", "->", "index", "(", ")", ";", "}", "}" ]
Deletes an instance @param mixed $ids
[ "Deletes", "an", "instance" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/crud/CRUDController.php#L173-L203
train
phpMv/ubiquity
src/Ubiquity/controllers/crud/CRUDController.php
CRUDController.update
public function update() { $message = new CRUDMessage ( "Modifications were successfully saved", "Updating" ); $instance = $_SESSION ["instance"] ?? null; if (isset ( $instance )) { $isNew = $instance->_new; try { $updated = CRUDHelper::update ( $instance, $_POST ); if ($updated) { $message->setType ( "success" )->setIcon ( "check circle outline" ); $message = $this->_getEvents ()->onSuccessUpdateMessage ( $message, $instance ); $this->refreshInstance ( $instance, $isNew ); } else { $message->setMessage ( "An error has occurred. Can not save changes." )->setType ( "error" )->setIcon ( "warning circle" ); $message = $this->_getEvents ()->onErrorUpdateMessage ( $message, $instance ); } } catch ( \Exception $e ) { $instanceString = $this->getInstanceToString ( $instance ); $message = new CRUDMessage ( "Exception : can not update `" . $instanceString . "`", "Exception", "warning", "warning" ); $message = $this->_getEvents ()->onErrorUpdateMessage ( $message, $instance ); } echo $this->_showSimpleMessage ( $message, "updateMsg" ); echo $this->jquery->compile ( $this->view ); return $instance; } else { throw new \Exception ( '$_SESSION["instance"] is null' ); } }
php
public function update() { $message = new CRUDMessage ( "Modifications were successfully saved", "Updating" ); $instance = $_SESSION ["instance"] ?? null; if (isset ( $instance )) { $isNew = $instance->_new; try { $updated = CRUDHelper::update ( $instance, $_POST ); if ($updated) { $message->setType ( "success" )->setIcon ( "check circle outline" ); $message = $this->_getEvents ()->onSuccessUpdateMessage ( $message, $instance ); $this->refreshInstance ( $instance, $isNew ); } else { $message->setMessage ( "An error has occurred. Can not save changes." )->setType ( "error" )->setIcon ( "warning circle" ); $message = $this->_getEvents ()->onErrorUpdateMessage ( $message, $instance ); } } catch ( \Exception $e ) { $instanceString = $this->getInstanceToString ( $instance ); $message = new CRUDMessage ( "Exception : can not update `" . $instanceString . "`", "Exception", "warning", "warning" ); $message = $this->_getEvents ()->onErrorUpdateMessage ( $message, $instance ); } echo $this->_showSimpleMessage ( $message, "updateMsg" ); echo $this->jquery->compile ( $this->view ); return $instance; } else { throw new \Exception ( '$_SESSION["instance"] is null' ); } }
[ "public", "function", "update", "(", ")", "{", "$", "message", "=", "new", "CRUDMessage", "(", "\"Modifications were successfully saved\"", ",", "\"Updating\"", ")", ";", "$", "instance", "=", "$", "_SESSION", "[", "\"instance\"", "]", "??", "null", ";", "if", "(", "isset", "(", "$", "instance", ")", ")", "{", "$", "isNew", "=", "$", "instance", "->", "_new", ";", "try", "{", "$", "updated", "=", "CRUDHelper", "::", "update", "(", "$", "instance", ",", "$", "_POST", ")", ";", "if", "(", "$", "updated", ")", "{", "$", "message", "->", "setType", "(", "\"success\"", ")", "->", "setIcon", "(", "\"check circle outline\"", ")", ";", "$", "message", "=", "$", "this", "->", "_getEvents", "(", ")", "->", "onSuccessUpdateMessage", "(", "$", "message", ",", "$", "instance", ")", ";", "$", "this", "->", "refreshInstance", "(", "$", "instance", ",", "$", "isNew", ")", ";", "}", "else", "{", "$", "message", "->", "setMessage", "(", "\"An error has occurred. Can not save changes.\"", ")", "->", "setType", "(", "\"error\"", ")", "->", "setIcon", "(", "\"warning circle\"", ")", ";", "$", "message", "=", "$", "this", "->", "_getEvents", "(", ")", "->", "onErrorUpdateMessage", "(", "$", "message", ",", "$", "instance", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "instanceString", "=", "$", "this", "->", "getInstanceToString", "(", "$", "instance", ")", ";", "$", "message", "=", "new", "CRUDMessage", "(", "\"Exception : can not update `\"", ".", "$", "instanceString", ".", "\"`\"", ",", "\"Exception\"", ",", "\"warning\"", ",", "\"warning\"", ")", ";", "$", "message", "=", "$", "this", "->", "_getEvents", "(", ")", "->", "onErrorUpdateMessage", "(", "$", "message", ",", "$", "instance", ")", ";", "}", "echo", "$", "this", "->", "_showSimpleMessage", "(", "$", "message", ",", "\"updateMsg\"", ")", ";", "echo", "$", "this", "->", "jquery", "->", "compile", "(", "$", "this", "->", "view", ")", ";", "return", "$", "instance", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'$_SESSION[\"instance\"] is null'", ")", ";", "}", "}" ]
Updates an instance from the data posted in a form @return object The updated instance
[ "Updates", "an", "instance", "from", "the", "data", "posted", "in", "a", "form" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/crud/CRUDController.php#L217-L243
train
phpMv/ubiquity
src/Ubiquity/controllers/crud/CRUDController.php
CRUDController.showDetail
public function showDetail($ids) { if (URequest::isAjax ()) { $instance = $this->getModelInstance ( $ids ); $viewer = $this->_getModelViewer (); $hasElements = false; $model = $this->model; $fkInstances = CRUDHelper::getFKIntances ( $instance, $model ); $semantic = $this->jquery->semantic (); $grid = $semantic->htmlGrid ( "detail" ); if (sizeof ( $fkInstances ) > 0) { $wide = intval ( 16 / sizeof ( $fkInstances ) ); if ($wide < 4) $wide = 4; foreach ( $fkInstances as $member => $fkInstanceArray ) { $element = $viewer->getFkMemberElementDetails ( $member, $fkInstanceArray ["objectFK"], $fkInstanceArray ["fkClass"], $fkInstanceArray ["fkTable"] ); if (isset ( $element )) { $grid->addCol ( $wide )->setContent ( $element ); $hasElements = true; } } if ($hasElements) { echo $grid; $url = $this->_getFiles ()->getDetailClickURL ( $this->model ); if (UString::isNotNull ( $url )) { $this->detailClick ( $url ); } } echo $this->jquery->compile ( $this->view ); } } else { $this->jquery->execAtLast ( "$('tr[data-ajax={$ids}]').trigger('click');" ); $this->index (); } }
php
public function showDetail($ids) { if (URequest::isAjax ()) { $instance = $this->getModelInstance ( $ids ); $viewer = $this->_getModelViewer (); $hasElements = false; $model = $this->model; $fkInstances = CRUDHelper::getFKIntances ( $instance, $model ); $semantic = $this->jquery->semantic (); $grid = $semantic->htmlGrid ( "detail" ); if (sizeof ( $fkInstances ) > 0) { $wide = intval ( 16 / sizeof ( $fkInstances ) ); if ($wide < 4) $wide = 4; foreach ( $fkInstances as $member => $fkInstanceArray ) { $element = $viewer->getFkMemberElementDetails ( $member, $fkInstanceArray ["objectFK"], $fkInstanceArray ["fkClass"], $fkInstanceArray ["fkTable"] ); if (isset ( $element )) { $grid->addCol ( $wide )->setContent ( $element ); $hasElements = true; } } if ($hasElements) { echo $grid; $url = $this->_getFiles ()->getDetailClickURL ( $this->model ); if (UString::isNotNull ( $url )) { $this->detailClick ( $url ); } } echo $this->jquery->compile ( $this->view ); } } else { $this->jquery->execAtLast ( "$('tr[data-ajax={$ids}]').trigger('click');" ); $this->index (); } }
[ "public", "function", "showDetail", "(", "$", "ids", ")", "{", "if", "(", "URequest", "::", "isAjax", "(", ")", ")", "{", "$", "instance", "=", "$", "this", "->", "getModelInstance", "(", "$", "ids", ")", ";", "$", "viewer", "=", "$", "this", "->", "_getModelViewer", "(", ")", ";", "$", "hasElements", "=", "false", ";", "$", "model", "=", "$", "this", "->", "model", ";", "$", "fkInstances", "=", "CRUDHelper", "::", "getFKIntances", "(", "$", "instance", ",", "$", "model", ")", ";", "$", "semantic", "=", "$", "this", "->", "jquery", "->", "semantic", "(", ")", ";", "$", "grid", "=", "$", "semantic", "->", "htmlGrid", "(", "\"detail\"", ")", ";", "if", "(", "sizeof", "(", "$", "fkInstances", ")", ">", "0", ")", "{", "$", "wide", "=", "intval", "(", "16", "/", "sizeof", "(", "$", "fkInstances", ")", ")", ";", "if", "(", "$", "wide", "<", "4", ")", "$", "wide", "=", "4", ";", "foreach", "(", "$", "fkInstances", "as", "$", "member", "=>", "$", "fkInstanceArray", ")", "{", "$", "element", "=", "$", "viewer", "->", "getFkMemberElementDetails", "(", "$", "member", ",", "$", "fkInstanceArray", "[", "\"objectFK\"", "]", ",", "$", "fkInstanceArray", "[", "\"fkClass\"", "]", ",", "$", "fkInstanceArray", "[", "\"fkTable\"", "]", ")", ";", "if", "(", "isset", "(", "$", "element", ")", ")", "{", "$", "grid", "->", "addCol", "(", "$", "wide", ")", "->", "setContent", "(", "$", "element", ")", ";", "$", "hasElements", "=", "true", ";", "}", "}", "if", "(", "$", "hasElements", ")", "{", "echo", "$", "grid", ";", "$", "url", "=", "$", "this", "->", "_getFiles", "(", ")", "->", "getDetailClickURL", "(", "$", "this", "->", "model", ")", ";", "if", "(", "UString", "::", "isNotNull", "(", "$", "url", ")", ")", "{", "$", "this", "->", "detailClick", "(", "$", "url", ")", ";", "}", "}", "echo", "$", "this", "->", "jquery", "->", "compile", "(", "$", "this", "->", "view", ")", ";", "}", "}", "else", "{", "$", "this", "->", "jquery", "->", "execAtLast", "(", "\"$('tr[data-ajax={$ids}]').trigger('click');\"", ")", ";", "$", "this", "->", "index", "(", ")", ";", "}", "}" ]
Shows associated members with foreign keys @param mixed $ids
[ "Shows", "associated", "members", "with", "foreign", "keys" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/crud/CRUDController.php#L250-L283
train
phpMv/ubiquity
src/Ubiquity/controllers/rest/ResponseFormatter.php
ResponseFormatter.getDatas
public function getDatas($objects, &$classname = null) { $objects = \array_map ( function ($o) use (&$classname) { return $this->cleanRestObject ( $o, $classname ); }, $objects ); return \array_values ( $objects ); }
php
public function getDatas($objects, &$classname = null) { $objects = \array_map ( function ($o) use (&$classname) { return $this->cleanRestObject ( $o, $classname ); }, $objects ); return \array_values ( $objects ); }
[ "public", "function", "getDatas", "(", "$", "objects", ",", "&", "$", "classname", "=", "null", ")", "{", "$", "objects", "=", "\\", "array_map", "(", "function", "(", "$", "o", ")", "use", "(", "&", "$", "classname", ")", "{", "return", "$", "this", "->", "cleanRestObject", "(", "$", "o", ",", "$", "classname", ")", ";", "}", ",", "$", "objects", ")", ";", "return", "\\", "array_values", "(", "$", "objects", ")", ";", "}" ]
Returns an array of datas from an array of objects @param array $objects @param string $classname @return array
[ "Returns", "an", "array", "of", "datas", "from", "an", "array", "of", "objects" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/rest/ResponseFormatter.php#L37-L42
train
phpMv/ubiquity
src/Ubiquity/orm/DAO.php
DAO.connect
public static function connect($dbType, $dbName, $serverName = '127.0.0.1', $port = '3306', $user = 'root', $password = '', $options = [], $cache = false) { self::$db = new Database ( $dbType, $dbName, $serverName, $port, $user, $password, $options, $cache ); try { self::$db->connect (); } catch ( \Exception $e ) { Logger::error ( "DAO", $e->getMessage () ); throw new DAOException ( $e->getMessage (), $e->getCode (), $e->getPrevious () ); } }
php
public static function connect($dbType, $dbName, $serverName = '127.0.0.1', $port = '3306', $user = 'root', $password = '', $options = [], $cache = false) { self::$db = new Database ( $dbType, $dbName, $serverName, $port, $user, $password, $options, $cache ); try { self::$db->connect (); } catch ( \Exception $e ) { Logger::error ( "DAO", $e->getMessage () ); throw new DAOException ( $e->getMessage (), $e->getCode (), $e->getPrevious () ); } }
[ "public", "static", "function", "connect", "(", "$", "dbType", ",", "$", "dbName", ",", "$", "serverName", "=", "'127.0.0.1'", ",", "$", "port", "=", "'3306'", ",", "$", "user", "=", "'root'", ",", "$", "password", "=", "''", ",", "$", "options", "=", "[", "]", ",", "$", "cache", "=", "false", ")", "{", "self", "::", "$", "db", "=", "new", "Database", "(", "$", "dbType", ",", "$", "dbName", ",", "$", "serverName", ",", "$", "port", ",", "$", "user", ",", "$", "password", ",", "$", "options", ",", "$", "cache", ")", ";", "try", "{", "self", "::", "$", "db", "->", "connect", "(", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "Logger", "::", "error", "(", "\"DAO\"", ",", "$", "e", "->", "getMessage", "(", ")", ")", ";", "throw", "new", "DAOException", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", "->", "getPrevious", "(", ")", ")", ";", "}", "}" ]
Establishes the connection to the database using the past parameters @param string $dbType @param string $dbName @param string $serverName @param string $port @param string $user @param string $password @param array $options @param boolean $cache
[ "Establishes", "the", "connection", "to", "the", "database", "using", "the", "past", "parameters" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/orm/DAO.php#L228-L236
train
phpMv/ubiquity
src/Ubiquity/orm/DAO.php
DAO.isConnected
public static function isConnected() { return self::$db !== null && (self::$db instanceof Database) && self::$db->isConnected (); }
php
public static function isConnected() { return self::$db !== null && (self::$db instanceof Database) && self::$db->isConnected (); }
[ "public", "static", "function", "isConnected", "(", ")", "{", "return", "self", "::", "$", "db", "!==", "null", "&&", "(", "self", "::", "$", "db", "instanceof", "Database", ")", "&&", "self", "::", "$", "db", "->", "isConnected", "(", ")", ";", "}" ]
Returns true if the connection to the database is established @return boolean
[ "Returns", "true", "if", "the", "connection", "to", "the", "database", "is", "established" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/orm/DAO.php#L255-L257
train
phpMv/ubiquity
src/Ubiquity/cache/ClassUtils.php
ClassUtils.getNamespaceFromParts
public static function getNamespaceFromParts($parts) { $resultArray = [ ]; if (! \is_array ( $parts )) { $parts = [ $parts ]; } foreach ( $parts as $part ) { $resultArray = \array_merge ( $resultArray, \explode ( "\\", $part ) ); } $resultArray = \array_diff ( $resultArray, [ "" ] ); return \implode ( "\\", $resultArray ); }
php
public static function getNamespaceFromParts($parts) { $resultArray = [ ]; if (! \is_array ( $parts )) { $parts = [ $parts ]; } foreach ( $parts as $part ) { $resultArray = \array_merge ( $resultArray, \explode ( "\\", $part ) ); } $resultArray = \array_diff ( $resultArray, [ "" ] ); return \implode ( "\\", $resultArray ); }
[ "public", "static", "function", "getNamespaceFromParts", "(", "$", "parts", ")", "{", "$", "resultArray", "=", "[", "]", ";", "if", "(", "!", "\\", "is_array", "(", "$", "parts", ")", ")", "{", "$", "parts", "=", "[", "$", "parts", "]", ";", "}", "foreach", "(", "$", "parts", "as", "$", "part", ")", "{", "$", "resultArray", "=", "\\", "array_merge", "(", "$", "resultArray", ",", "\\", "explode", "(", "\"\\\\\"", ",", "$", "part", ")", ")", ";", "}", "$", "resultArray", "=", "\\", "array_diff", "(", "$", "resultArray", ",", "[", "\"\"", "]", ")", ";", "return", "\\", "implode", "(", "\"\\\\\"", ",", "$", "resultArray", ")", ";", "}" ]
Returns a cleanly namespace @param array|string $parts @return string
[ "Returns", "a", "cleanly", "namespace" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/cache/ClassUtils.php#L89-L99
train
phpMv/ubiquity
src/Ubiquity/cache/ClassUtils.php
ClassUtils.getClassNameWithNS
public static function getClassNameWithNS($defaultNS, $name) { if (\strpos ( $name, "\\" ) === false) { $name = $defaultNS . "\\" . $name; } return $name; }
php
public static function getClassNameWithNS($defaultNS, $name) { if (\strpos ( $name, "\\" ) === false) { $name = $defaultNS . "\\" . $name; } return $name; }
[ "public", "static", "function", "getClassNameWithNS", "(", "$", "defaultNS", ",", "$", "name", ")", "{", "if", "(", "\\", "strpos", "(", "$", "name", ",", "\"\\\\\"", ")", "===", "false", ")", "{", "$", "name", "=", "$", "defaultNS", ".", "\"\\\\\"", ".", "$", "name", ";", "}", "return", "$", "name", ";", "}" ]
Returns the complete name of a class @param string $defaultNS @param string $name @return string
[ "Returns", "the", "complete", "name", "of", "a", "class" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/cache/ClassUtils.php#L145-L150
train
phpMv/ubiquity
src/Ubiquity/utils/http/UResponse.php
UResponse.setContentType
public static function setContentType($contentType, $encoding = null) { $value = $contentType; if (isset ( $encoding )) $value .= ' ;charset=' . $encoding; self::header ( 'Content-Type', $value ); }
php
public static function setContentType($contentType, $encoding = null) { $value = $contentType; if (isset ( $encoding )) $value .= ' ;charset=' . $encoding; self::header ( 'Content-Type', $value ); }
[ "public", "static", "function", "setContentType", "(", "$", "contentType", ",", "$", "encoding", "=", "null", ")", "{", "$", "value", "=", "$", "contentType", ";", "if", "(", "isset", "(", "$", "encoding", ")", ")", "$", "value", ".=", "' ;charset='", ".", "$", "encoding", ";", "self", "::", "header", "(", "'Content-Type'", ",", "$", "value", ")", ";", "}" ]
Sets header content-type @param string $contentType @param string $encoding
[ "Sets", "header", "content", "-", "type" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/http/UResponse.php#L52-L57
train
phpMv/ubiquity
src/Ubiquity/utils/http/USession.php
USession.addOrRemoveValueFromArray
public static function addOrRemoveValueFromArray($arrayKey, $value, $add = null) { $array = self::getArray ( $arrayKey ); $_SESSION [$arrayKey] = $array; $search = array_search ( $value, $array ); if ($search === FALSE && $add) { $_SESSION [$arrayKey] [] = $value; return true; } else if ($add !== true) { unset ( $_SESSION [$arrayKey] [$search] ); $_SESSION [$arrayKey] = array_values ( $_SESSION [$arrayKey] ); return false; } }
php
public static function addOrRemoveValueFromArray($arrayKey, $value, $add = null) { $array = self::getArray ( $arrayKey ); $_SESSION [$arrayKey] = $array; $search = array_search ( $value, $array ); if ($search === FALSE && $add) { $_SESSION [$arrayKey] [] = $value; return true; } else if ($add !== true) { unset ( $_SESSION [$arrayKey] [$search] ); $_SESSION [$arrayKey] = array_values ( $_SESSION [$arrayKey] ); return false; } }
[ "public", "static", "function", "addOrRemoveValueFromArray", "(", "$", "arrayKey", ",", "$", "value", ",", "$", "add", "=", "null", ")", "{", "$", "array", "=", "self", "::", "getArray", "(", "$", "arrayKey", ")", ";", "$", "_SESSION", "[", "$", "arrayKey", "]", "=", "$", "array", ";", "$", "search", "=", "array_search", "(", "$", "value", ",", "$", "array", ")", ";", "if", "(", "$", "search", "===", "FALSE", "&&", "$", "add", ")", "{", "$", "_SESSION", "[", "$", "arrayKey", "]", "[", "]", "=", "$", "value", ";", "return", "true", ";", "}", "else", "if", "(", "$", "add", "!==", "true", ")", "{", "unset", "(", "$", "_SESSION", "[", "$", "arrayKey", "]", "[", "$", "search", "]", ")", ";", "$", "_SESSION", "[", "$", "arrayKey", "]", "=", "array_values", "(", "$", "_SESSION", "[", "$", "arrayKey", "]", ")", ";", "return", "false", ";", "}", "}" ]
Adds or removes a value from an array in session @param string $arrayKey the key of the array to add or remove in @param mixed $value the value to add @param boolean|null $add If true, adds otherwise removes @return boolean
[ "Adds", "or", "removes", "a", "value", "from", "an", "array", "in", "session" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/http/USession.php#L47-L59
train
phpMv/ubiquity
src/Ubiquity/utils/http/USession.php
USession.setBoolean
public static function setBoolean($key, $value) { $_SESSION [$key] = UString::isBooleanTrue ( $value ); return $_SESSION [$key]; }
php
public static function setBoolean($key, $value) { $_SESSION [$key] = UString::isBooleanTrue ( $value ); return $_SESSION [$key]; }
[ "public", "static", "function", "setBoolean", "(", "$", "key", ",", "$", "value", ")", "{", "$", "_SESSION", "[", "$", "key", "]", "=", "UString", "::", "isBooleanTrue", "(", "$", "value", ")", ";", "return", "$", "_SESSION", "[", "$", "key", "]", ";", "}" ]
Sets a boolean value at key position in session @param string $key the key to add or set in @param mixed $value the value to set @return boolean
[ "Sets", "a", "boolean", "value", "at", "key", "position", "in", "session" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/http/USession.php#L96-L99
train
phpMv/ubiquity
src/Ubiquity/utils/http/USession.php
USession.getBoolean
public static function getBoolean($key) { self::start (); $ret = false; if (isset ( $_SESSION [$key] )) { $ret = UString::isBooleanTrue ( $_SESSION [$key] ); } return $ret; }
php
public static function getBoolean($key) { self::start (); $ret = false; if (isset ( $_SESSION [$key] )) { $ret = UString::isBooleanTrue ( $_SESSION [$key] ); } return $ret; }
[ "public", "static", "function", "getBoolean", "(", "$", "key", ")", "{", "self", "::", "start", "(", ")", ";", "$", "ret", "=", "false", ";", "if", "(", "isset", "(", "$", "_SESSION", "[", "$", "key", "]", ")", ")", "{", "$", "ret", "=", "UString", "::", "isBooleanTrue", "(", "$", "_SESSION", "[", "$", "key", "]", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Returns a boolean stored at the key position in session @param string $key the key to add or set @return boolean
[ "Returns", "a", "boolean", "stored", "at", "the", "key", "position", "in", "session" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/http/USession.php#L108-L115
train
phpMv/ubiquity
src/Ubiquity/utils/http/USession.php
USession.inc
public static function inc($key, $inc = 1) { return self::set ( $key, self::get ( $key, 0 ) + $inc ); }
php
public static function inc($key, $inc = 1) { return self::set ( $key, self::get ( $key, 0 ) + $inc ); }
[ "public", "static", "function", "inc", "(", "$", "key", ",", "$", "inc", "=", "1", ")", "{", "return", "self", "::", "set", "(", "$", "key", ",", "self", "::", "get", "(", "$", "key", ",", "0", ")", "+", "$", "inc", ")", ";", "}" ]
Increment the value at the key index in session @param string $key @param number $inc @return number
[ "Increment", "the", "value", "at", "the", "key", "index", "in", "session" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/http/USession.php#L216-L218
train
phpMv/ubiquity
src/Ubiquity/utils/http/USession.php
USession.dec
public static function dec($key, $dec = 1) { return self::set ( $key, self::get ( $key, 0 ) - $dec ); }
php
public static function dec($key, $dec = 1) { return self::set ( $key, self::get ( $key, 0 ) - $dec ); }
[ "public", "static", "function", "dec", "(", "$", "key", ",", "$", "dec", "=", "1", ")", "{", "return", "self", "::", "set", "(", "$", "key", ",", "self", "::", "get", "(", "$", "key", ",", "0", ")", "-", "$", "dec", ")", ";", "}" ]
Decrement the value at the key index in session @param string $key @param number $dec @return number
[ "Decrement", "the", "value", "at", "the", "key", "index", "in", "session" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/http/USession.php#L227-L229
train
phpMv/ubiquity
src/Ubiquity/utils/http/USession.php
USession.concat
public static function concat($key, $str, $default = NULL) { return self::set ( $key, self::get ( $key, $default ) . $str ); }
php
public static function concat($key, $str, $default = NULL) { return self::set ( $key, self::get ( $key, $default ) . $str ); }
[ "public", "static", "function", "concat", "(", "$", "key", ",", "$", "str", ",", "$", "default", "=", "NULL", ")", "{", "return", "self", "::", "set", "(", "$", "key", ",", "self", "::", "get", "(", "$", "key", ",", "$", "default", ")", ".", "$", "str", ")", ";", "}" ]
Adds a string at the end of the value at the key index in session @param string $key @param string $str @return string
[ "Adds", "a", "string", "at", "the", "end", "of", "the", "value", "at", "the", "key", "index", "in", "session" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/http/USession.php#L238-L240
train
phpMv/ubiquity
src/Ubiquity/utils/http/USession.php
USession.apply
public static function apply($key, $callback, $default = NULL) { $value = self::get ( $key, $default ); if (is_string ( $callback ) && function_exists ( $callback )) { $value = call_user_func ( $callback, $value ); } elseif (is_callable ( $callback )) { $value = $callback ( $value ); } else { return $value; } return self::set ( $key, $value ); }
php
public static function apply($key, $callback, $default = NULL) { $value = self::get ( $key, $default ); if (is_string ( $callback ) && function_exists ( $callback )) { $value = call_user_func ( $callback, $value ); } elseif (is_callable ( $callback )) { $value = $callback ( $value ); } else { return $value; } return self::set ( $key, $value ); }
[ "public", "static", "function", "apply", "(", "$", "key", ",", "$", "callback", ",", "$", "default", "=", "NULL", ")", "{", "$", "value", "=", "self", "::", "get", "(", "$", "key", ",", "$", "default", ")", ";", "if", "(", "is_string", "(", "$", "callback", ")", "&&", "function_exists", "(", "$", "callback", ")", ")", "{", "$", "value", "=", "call_user_func", "(", "$", "callback", ",", "$", "value", ")", ";", "}", "elseif", "(", "is_callable", "(", "$", "callback", ")", ")", "{", "$", "value", "=", "$", "callback", "(", "$", "value", ")", ";", "}", "else", "{", "return", "$", "value", ";", "}", "return", "self", "::", "set", "(", "$", "key", ",", "$", "value", ")", ";", "}" ]
Applies a callback function to the value at the key index in session @param string $key @param string|callable $callback @return mixed
[ "Applies", "a", "callback", "function", "to", "the", "value", "at", "the", "key", "index", "in", "session" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/http/USession.php#L249-L259
train
phpMv/ubiquity
src/Ubiquity/utils/http/USession.php
USession.Walk
public static function Walk($callback, $userData = null) { self::start (); array_walk ( $_SESSION, $callback, $userData ); return $_SESSION; }
php
public static function Walk($callback, $userData = null) { self::start (); array_walk ( $_SESSION, $callback, $userData ); return $_SESSION; }
[ "public", "static", "function", "Walk", "(", "$", "callback", ",", "$", "userData", "=", "null", ")", "{", "self", "::", "start", "(", ")", ";", "array_walk", "(", "$", "_SESSION", ",", "$", "callback", ",", "$", "userData", ")", ";", "return", "$", "_SESSION", ";", "}" ]
Apply a user supplied function to every member of Session array @param callable $callback @param mixed $userData @return array
[ "Apply", "a", "user", "supplied", "function", "to", "every", "member", "of", "Session", "array" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/http/USession.php#L268-L272
train
phpMv/ubiquity
src/Ubiquity/utils/http/USession.php
USession.start
public static function start($name = null) { if (! self::isStarted ()) { if (isset ( $name ) && $name !== "") { self::$name = $name; } if (isset ( self::$name )) { \session_name ( self::$name ); } \session_start (); } }
php
public static function start($name = null) { if (! self::isStarted ()) { if (isset ( $name ) && $name !== "") { self::$name = $name; } if (isset ( self::$name )) { \session_name ( self::$name ); } \session_start (); } }
[ "public", "static", "function", "start", "(", "$", "name", "=", "null", ")", "{", "if", "(", "!", "self", "::", "isStarted", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "name", ")", "&&", "$", "name", "!==", "\"\"", ")", "{", "self", "::", "$", "name", "=", "$", "name", ";", "}", "if", "(", "isset", "(", "self", "::", "$", "name", ")", ")", "{", "\\", "session_name", "(", "self", "::", "$", "name", ")", ";", "}", "\\", "session_start", "(", ")", ";", "}", "}" ]
Start new or resume existing session @param string|null $name the name of the session
[ "Start", "new", "or", "resume", "existing", "session" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/http/USession.php#L302-L312
train
phpMv/ubiquity
src/Ubiquity/utils/http/USession.php
USession.init
public static function init($key, $value) { if (! isset ( $_SESSION [$key] )) { $_SESSION [$key] = $value; } return $_SESSION [$key]; }
php
public static function init($key, $value) { if (! isset ( $_SESSION [$key] )) { $_SESSION [$key] = $value; } return $_SESSION [$key]; }
[ "public", "static", "function", "init", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "_SESSION", "[", "$", "key", "]", ")", ")", "{", "$", "_SESSION", "[", "$", "key", "]", "=", "$", "value", ";", "}", "return", "$", "_SESSION", "[", "$", "key", "]", ";", "}" ]
Initialize the key in Session if key does not exists @param string $key @param mixed $value @return mixed
[ "Initialize", "the", "key", "in", "Session", "if", "key", "does", "not", "exists" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/http/USession.php#L342-L347
train
phpMv/ubiquity
src/Ubiquity/utils/http/USession.php
USession.terminate
public static function terminate() { if (! self::isStarted ()) return; self::start (); $_SESSION = array (); if (\ini_get ( "session.use_cookies" )) { $params = \session_get_cookie_params (); \setcookie ( \session_name (), '', \time () - 42000, $params ["path"], $params ["domain"], $params ["secure"], $params ["httponly"] ); } \session_destroy (); }
php
public static function terminate() { if (! self::isStarted ()) return; self::start (); $_SESSION = array (); if (\ini_get ( "session.use_cookies" )) { $params = \session_get_cookie_params (); \setcookie ( \session_name (), '', \time () - 42000, $params ["path"], $params ["domain"], $params ["secure"], $params ["httponly"] ); } \session_destroy (); }
[ "public", "static", "function", "terminate", "(", ")", "{", "if", "(", "!", "self", "::", "isStarted", "(", ")", ")", "return", ";", "self", "::", "start", "(", ")", ";", "$", "_SESSION", "=", "array", "(", ")", ";", "if", "(", "\\", "ini_get", "(", "\"session.use_cookies\"", ")", ")", "{", "$", "params", "=", "\\", "session_get_cookie_params", "(", ")", ";", "\\", "setcookie", "(", "\\", "session_name", "(", ")", ",", "''", ",", "\\", "time", "(", ")", "-", "42000", ",", "$", "params", "[", "\"path\"", "]", ",", "$", "params", "[", "\"domain\"", "]", ",", "$", "params", "[", "\"secure\"", "]", ",", "$", "params", "[", "\"httponly\"", "]", ")", ";", "}", "\\", "session_destroy", "(", ")", ";", "}" ]
Terminates the active session
[ "Terminates", "the", "active", "session" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/http/USession.php#L352-L363
train
phpMv/ubiquity
src/Ubiquity/controllers/rest/api/jsonapi/JsonApiResponseFormatter.php
JsonApiResponseFormatter.addPageLinks
protected function addPageLinks(&$r, $classname, $pages) { $pageSize = $pages ['pageSize']; unset ( $pages ['pageSize'] ); foreach ( $pages as $page => $number ) { $r ['links'] [$page] = $this->getLink ( $this->pageLink, [ "baseRoute" => $this->baseRoute,'classname' => $classname,'pageNumber' => $number,'pageSize' => $pageSize ] ); } }
php
protected function addPageLinks(&$r, $classname, $pages) { $pageSize = $pages ['pageSize']; unset ( $pages ['pageSize'] ); foreach ( $pages as $page => $number ) { $r ['links'] [$page] = $this->getLink ( $this->pageLink, [ "baseRoute" => $this->baseRoute,'classname' => $classname,'pageNumber' => $number,'pageSize' => $pageSize ] ); } }
[ "protected", "function", "addPageLinks", "(", "&", "$", "r", ",", "$", "classname", ",", "$", "pages", ")", "{", "$", "pageSize", "=", "$", "pages", "[", "'pageSize'", "]", ";", "unset", "(", "$", "pages", "[", "'pageSize'", "]", ")", ";", "foreach", "(", "$", "pages", "as", "$", "page", "=>", "$", "number", ")", "{", "$", "r", "[", "'links'", "]", "[", "$", "page", "]", "=", "$", "this", "->", "getLink", "(", "$", "this", "->", "pageLink", ",", "[", "\"baseRoute\"", "=>", "$", "this", "->", "baseRoute", ",", "'classname'", "=>", "$", "classname", ",", "'pageNumber'", "=>", "$", "number", ",", "'pageSize'", "=>", "$", "pageSize", "]", ")", ";", "}", "}" ]
Adds page links @param array $r @param string $classname @param array $pages
[ "Adds", "page", "links" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/rest/api/jsonapi/JsonApiResponseFormatter.php#L82-L88
train
phpMv/ubiquity
src/Ubiquity/controllers/crud/CRUDControllerUtilitiesTrait.php
CRUDControllerUtilitiesTrait._deleteMultiple
protected function _deleteMultiple($data, $action, $target, $condition) { if (URequest::isPost ()) { if (is_callable ( $condition )) { $condition = $condition ( $data ); } $rep = DAO::deleteAll ( $this->model, $condition ); if ($rep) { $message = new CRUDMessage ( "Deleting {count} objects", "Deletion", "info", "info circle", 4000 ); $message = $this->_getEvents ()->onSuccessDeleteMultipleMessage ( $message, $rep ); $message->parseContent ( [ "count" => $rep ] ); } if (isset ( $message )) { $this->_showSimpleMessage ( $message, "delete-all" ); } $this->index (); } else { $message = new CRUDMessage ( "Do you confirm the deletion of this objects?", "Remove confirmation", "error" ); $this->_getEvents ()->onConfDeleteMultipleMessage ( $message, $data ); $message = $this->_showConfMessage ( $message, $this->_getBaseRoute () . "/{$action}/{$data}", $target, $data, [ "jqueryDone" => "replaceWith" ] ); echo $message; echo $this->jquery->compile ( $this->view ); } }
php
protected function _deleteMultiple($data, $action, $target, $condition) { if (URequest::isPost ()) { if (is_callable ( $condition )) { $condition = $condition ( $data ); } $rep = DAO::deleteAll ( $this->model, $condition ); if ($rep) { $message = new CRUDMessage ( "Deleting {count} objects", "Deletion", "info", "info circle", 4000 ); $message = $this->_getEvents ()->onSuccessDeleteMultipleMessage ( $message, $rep ); $message->parseContent ( [ "count" => $rep ] ); } if (isset ( $message )) { $this->_showSimpleMessage ( $message, "delete-all" ); } $this->index (); } else { $message = new CRUDMessage ( "Do you confirm the deletion of this objects?", "Remove confirmation", "error" ); $this->_getEvents ()->onConfDeleteMultipleMessage ( $message, $data ); $message = $this->_showConfMessage ( $message, $this->_getBaseRoute () . "/{$action}/{$data}", $target, $data, [ "jqueryDone" => "replaceWith" ] ); echo $message; echo $this->jquery->compile ( $this->view ); } }
[ "protected", "function", "_deleteMultiple", "(", "$", "data", ",", "$", "action", ",", "$", "target", ",", "$", "condition", ")", "{", "if", "(", "URequest", "::", "isPost", "(", ")", ")", "{", "if", "(", "is_callable", "(", "$", "condition", ")", ")", "{", "$", "condition", "=", "$", "condition", "(", "$", "data", ")", ";", "}", "$", "rep", "=", "DAO", "::", "deleteAll", "(", "$", "this", "->", "model", ",", "$", "condition", ")", ";", "if", "(", "$", "rep", ")", "{", "$", "message", "=", "new", "CRUDMessage", "(", "\"Deleting {count} objects\"", ",", "\"Deletion\"", ",", "\"info\"", ",", "\"info circle\"", ",", "4000", ")", ";", "$", "message", "=", "$", "this", "->", "_getEvents", "(", ")", "->", "onSuccessDeleteMultipleMessage", "(", "$", "message", ",", "$", "rep", ")", ";", "$", "message", "->", "parseContent", "(", "[", "\"count\"", "=>", "$", "rep", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "message", ")", ")", "{", "$", "this", "->", "_showSimpleMessage", "(", "$", "message", ",", "\"delete-all\"", ")", ";", "}", "$", "this", "->", "index", "(", ")", ";", "}", "else", "{", "$", "message", "=", "new", "CRUDMessage", "(", "\"Do you confirm the deletion of this objects?\"", ",", "\"Remove confirmation\"", ",", "\"error\"", ")", ";", "$", "this", "->", "_getEvents", "(", ")", "->", "onConfDeleteMultipleMessage", "(", "$", "message", ",", "$", "data", ")", ";", "$", "message", "=", "$", "this", "->", "_showConfMessage", "(", "$", "message", ",", "$", "this", "->", "_getBaseRoute", "(", ")", ".", "\"/{$action}/{$data}\"", ",", "$", "target", ",", "$", "data", ",", "[", "\"jqueryDone\"", "=>", "\"replaceWith\"", "]", ")", ";", "echo", "$", "message", ";", "echo", "$", "this", "->", "jquery", "->", "compile", "(", "$", "this", "->", "view", ")", ";", "}", "}" ]
Helper to delete multiple objects @param mixed $data @param string $action @param string $target the css selector for refreshing @param callable|string $condition the callback for generating the SQL where (for deletion) with the parameter data, or a simple string
[ "Helper", "to", "delete", "multiple", "objects" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/crud/CRUDControllerUtilitiesTrait.php#L135-L157
train
phpMv/ubiquity
src/Ubiquity/contents/validation/ValidatorsManagerInitTrait.php
ValidatorsManagerInitTrait.initModelsValidators
public static function initModelsValidators(&$config) { $models = CacheManager::getModels ( $config, true ); foreach ( $models as $model ) { self::initClassValidators ( $model ); } }
php
public static function initModelsValidators(&$config) { $models = CacheManager::getModels ( $config, true ); foreach ( $models as $model ) { self::initClassValidators ( $model ); } }
[ "public", "static", "function", "initModelsValidators", "(", "&", "$", "config", ")", "{", "$", "models", "=", "CacheManager", "::", "getModels", "(", "$", "config", ",", "true", ")", ";", "foreach", "(", "$", "models", "as", "$", "model", ")", "{", "self", "::", "initClassValidators", "(", "$", "model", ")", ";", "}", "}" ]
Parses models and save validators in cache to use in dev only @param array $config
[ "Parses", "models", "and", "save", "validators", "in", "cache", "to", "use", "in", "dev", "only" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/contents/validation/ValidatorsManagerInitTrait.php#L21-L26
train
phpMv/ubiquity
src/Ubiquity/controllers/admin/viewers/ModelViewer.php
ModelViewer.getForm
public function getForm($identifier, $instance) { $form = $this->jquery->semantic ()->dataForm ( $identifier, $instance ); $form->setLibraryId ( "frmEdit" ); $className = \get_class ( $instance ); $fields = $this->controller->_getAdminData ()->getFormFieldNames ( $className, $instance ); $relFields = OrmUtils::getFieldsInRelations_ ( $className ); $this->setFormFields_ ( $fields, $relFields ); array_unshift ( $fields, "_message" ); $form->setFields ( $fields ); $fieldTypes = OrmUtils::getFieldTypes ( $className ); $this->setFormFieldsComponent ( $form, $fieldTypes ); $this->relationMembersInForm ( $form, $instance, $className, $fields, $relFields ); OrmUtils::setFieldToMemberNames ( $fields, $relFields ); $form->setCaptions ( $this->getFormCaptions ( $fields, $className, $instance ) ); $message = $this->getFormTitle ( $form, $instance ); $form->setCaption ( "_message", $message ["subMessage"] ); $form->fieldAsMessage ( "_message", [ "icon" => $message ["icon"] ] ); $instance->_message = $message ["message"]; $form->setSubmitParams ( $this->controller->_getBaseRoute () . "/update", "#frm-add-update" ); $form->onGenerateField ( [ $this,'onGenerateFormField' ] ); return $form; }
php
public function getForm($identifier, $instance) { $form = $this->jquery->semantic ()->dataForm ( $identifier, $instance ); $form->setLibraryId ( "frmEdit" ); $className = \get_class ( $instance ); $fields = $this->controller->_getAdminData ()->getFormFieldNames ( $className, $instance ); $relFields = OrmUtils::getFieldsInRelations_ ( $className ); $this->setFormFields_ ( $fields, $relFields ); array_unshift ( $fields, "_message" ); $form->setFields ( $fields ); $fieldTypes = OrmUtils::getFieldTypes ( $className ); $this->setFormFieldsComponent ( $form, $fieldTypes ); $this->relationMembersInForm ( $form, $instance, $className, $fields, $relFields ); OrmUtils::setFieldToMemberNames ( $fields, $relFields ); $form->setCaptions ( $this->getFormCaptions ( $fields, $className, $instance ) ); $message = $this->getFormTitle ( $form, $instance ); $form->setCaption ( "_message", $message ["subMessage"] ); $form->fieldAsMessage ( "_message", [ "icon" => $message ["icon"] ] ); $instance->_message = $message ["message"]; $form->setSubmitParams ( $this->controller->_getBaseRoute () . "/update", "#frm-add-update" ); $form->onGenerateField ( [ $this,'onGenerateFormField' ] ); return $form; }
[ "public", "function", "getForm", "(", "$", "identifier", ",", "$", "instance", ")", "{", "$", "form", "=", "$", "this", "->", "jquery", "->", "semantic", "(", ")", "->", "dataForm", "(", "$", "identifier", ",", "$", "instance", ")", ";", "$", "form", "->", "setLibraryId", "(", "\"frmEdit\"", ")", ";", "$", "className", "=", "\\", "get_class", "(", "$", "instance", ")", ";", "$", "fields", "=", "$", "this", "->", "controller", "->", "_getAdminData", "(", ")", "->", "getFormFieldNames", "(", "$", "className", ",", "$", "instance", ")", ";", "$", "relFields", "=", "OrmUtils", "::", "getFieldsInRelations_", "(", "$", "className", ")", ";", "$", "this", "->", "setFormFields_", "(", "$", "fields", ",", "$", "relFields", ")", ";", "array_unshift", "(", "$", "fields", ",", "\"_message\"", ")", ";", "$", "form", "->", "setFields", "(", "$", "fields", ")", ";", "$", "fieldTypes", "=", "OrmUtils", "::", "getFieldTypes", "(", "$", "className", ")", ";", "$", "this", "->", "setFormFieldsComponent", "(", "$", "form", ",", "$", "fieldTypes", ")", ";", "$", "this", "->", "relationMembersInForm", "(", "$", "form", ",", "$", "instance", ",", "$", "className", ",", "$", "fields", ",", "$", "relFields", ")", ";", "OrmUtils", "::", "setFieldToMemberNames", "(", "$", "fields", ",", "$", "relFields", ")", ";", "$", "form", "->", "setCaptions", "(", "$", "this", "->", "getFormCaptions", "(", "$", "fields", ",", "$", "className", ",", "$", "instance", ")", ")", ";", "$", "message", "=", "$", "this", "->", "getFormTitle", "(", "$", "form", ",", "$", "instance", ")", ";", "$", "form", "->", "setCaption", "(", "\"_message\"", ",", "$", "message", "[", "\"subMessage\"", "]", ")", ";", "$", "form", "->", "fieldAsMessage", "(", "\"_message\"", ",", "[", "\"icon\"", "=>", "$", "message", "[", "\"icon\"", "]", "]", ")", ";", "$", "instance", "->", "_message", "=", "$", "message", "[", "\"message\"", "]", ";", "$", "form", "->", "setSubmitParams", "(", "$", "this", "->", "controller", "->", "_getBaseRoute", "(", ")", ".", "\"/update\"", ",", "\"#frm-add-update\"", ")", ";", "$", "form", "->", "onGenerateField", "(", "[", "$", "this", ",", "'onGenerateFormField'", "]", ")", ";", "return", "$", "form", ";", "}" ]
Returns the form for adding or modifying an object @param string $identifier @param object $instance the object to add or modify @return \Ajax\semantic\widgets\dataform\DataForm
[ "Returns", "the", "form", "for", "adding", "or", "modifying", "an", "object" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/admin/viewers/ModelViewer.php#L60-L83
train
phpMv/ubiquity
src/Ubiquity/controllers/admin/viewers/ModelViewer.php
ModelViewer.getFormTitle
protected function getFormTitle($form, $instance) { $type = ($instance->_new) ? "new" : "edit"; $messageInfos = [ "new" => [ "icon" => HtmlIconGroups::corner ( "table", "plus", "big" ),"subMessage" => "New object creation" ],"edit" => [ "icon" => HtmlIconGroups::corner ( "table", "edit", "big" ),"subMessage" => "Editing an existing object" ] ]; $message = $messageInfos [$type]; $message ["message"] = \get_class ( $instance ); return $message; }
php
protected function getFormTitle($form, $instance) { $type = ($instance->_new) ? "new" : "edit"; $messageInfos = [ "new" => [ "icon" => HtmlIconGroups::corner ( "table", "plus", "big" ),"subMessage" => "New object creation" ],"edit" => [ "icon" => HtmlIconGroups::corner ( "table", "edit", "big" ),"subMessage" => "Editing an existing object" ] ]; $message = $messageInfos [$type]; $message ["message"] = \get_class ( $instance ); return $message; }
[ "protected", "function", "getFormTitle", "(", "$", "form", ",", "$", "instance", ")", "{", "$", "type", "=", "(", "$", "instance", "->", "_new", ")", "?", "\"new\"", ":", "\"edit\"", ";", "$", "messageInfos", "=", "[", "\"new\"", "=>", "[", "\"icon\"", "=>", "HtmlIconGroups", "::", "corner", "(", "\"table\"", ",", "\"plus\"", ",", "\"big\"", ")", ",", "\"subMessage\"", "=>", "\"New object creation\"", "]", ",", "\"edit\"", "=>", "[", "\"icon\"", "=>", "HtmlIconGroups", "::", "corner", "(", "\"table\"", ",", "\"edit\"", ",", "\"big\"", ")", ",", "\"subMessage\"", "=>", "\"Editing an existing object\"", "]", "]", ";", "$", "message", "=", "$", "messageInfos", "[", "$", "type", "]", ";", "$", "message", "[", "\"message\"", "]", "=", "\\", "get_class", "(", "$", "instance", ")", ";", "return", "$", "message", ";", "}" ]
Returns an associative array defining form message title with keys "icon","message","subMessage" @param DataForm $form @param object $instance @return array the message title
[ "Returns", "an", "associative", "array", "defining", "form", "message", "title", "with", "keys", "icon", "message", "subMessage" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/admin/viewers/ModelViewer.php#L164-L170
train
phpMv/ubiquity
src/Ubiquity/controllers/admin/viewers/ModelViewer.php
ModelViewer.getModelDataElement
public function getModelDataElement($instance, $model, $modal) { $semantic = $this->jquery->semantic (); $fields = $this->controller->_getAdminData ()->getElementFieldNames ( $model ); $dataElement = $semantic->dataElement ( "de", $instance ); $pk = OrmUtils::getFirstKeyValue ( $instance ); $dataElement->getInstanceViewer ()->setIdentifierFunction ( function () use ($pk) { return $pk; } ); $dataElement->setFields ( $fields ); $dataElement->setCaptions ( $this->getElementCaptions ( $fields, $model, $instance ) ); $fkInstances = CRUDHelper::getFKIntances ( $instance, $model ); foreach ( $fkInstances as $member => $fkInstanceArray ) { if (array_search ( $member, $fields ) !== false) { $dataElement->setValueFunction ( $member, function () use ($fkInstanceArray, $member) { return $this->getFkMemberElement ( $member, $fkInstanceArray ["objectFK"], $fkInstanceArray ["fkClass"], $fkInstanceArray ["fkTable"] ); } ); } } $this->addEditMemberFonctionality ( "dataElement" ); return $dataElement; }
php
public function getModelDataElement($instance, $model, $modal) { $semantic = $this->jquery->semantic (); $fields = $this->controller->_getAdminData ()->getElementFieldNames ( $model ); $dataElement = $semantic->dataElement ( "de", $instance ); $pk = OrmUtils::getFirstKeyValue ( $instance ); $dataElement->getInstanceViewer ()->setIdentifierFunction ( function () use ($pk) { return $pk; } ); $dataElement->setFields ( $fields ); $dataElement->setCaptions ( $this->getElementCaptions ( $fields, $model, $instance ) ); $fkInstances = CRUDHelper::getFKIntances ( $instance, $model ); foreach ( $fkInstances as $member => $fkInstanceArray ) { if (array_search ( $member, $fields ) !== false) { $dataElement->setValueFunction ( $member, function () use ($fkInstanceArray, $member) { return $this->getFkMemberElement ( $member, $fkInstanceArray ["objectFK"], $fkInstanceArray ["fkClass"], $fkInstanceArray ["fkTable"] ); } ); } } $this->addEditMemberFonctionality ( "dataElement" ); return $dataElement; }
[ "public", "function", "getModelDataElement", "(", "$", "instance", ",", "$", "model", ",", "$", "modal", ")", "{", "$", "semantic", "=", "$", "this", "->", "jquery", "->", "semantic", "(", ")", ";", "$", "fields", "=", "$", "this", "->", "controller", "->", "_getAdminData", "(", ")", "->", "getElementFieldNames", "(", "$", "model", ")", ";", "$", "dataElement", "=", "$", "semantic", "->", "dataElement", "(", "\"de\"", ",", "$", "instance", ")", ";", "$", "pk", "=", "OrmUtils", "::", "getFirstKeyValue", "(", "$", "instance", ")", ";", "$", "dataElement", "->", "getInstanceViewer", "(", ")", "->", "setIdentifierFunction", "(", "function", "(", ")", "use", "(", "$", "pk", ")", "{", "return", "$", "pk", ";", "}", ")", ";", "$", "dataElement", "->", "setFields", "(", "$", "fields", ")", ";", "$", "dataElement", "->", "setCaptions", "(", "$", "this", "->", "getElementCaptions", "(", "$", "fields", ",", "$", "model", ",", "$", "instance", ")", ")", ";", "$", "fkInstances", "=", "CRUDHelper", "::", "getFKIntances", "(", "$", "instance", ",", "$", "model", ")", ";", "foreach", "(", "$", "fkInstances", "as", "$", "member", "=>", "$", "fkInstanceArray", ")", "{", "if", "(", "array_search", "(", "$", "member", ",", "$", "fields", ")", "!==", "false", ")", "{", "$", "dataElement", "->", "setValueFunction", "(", "$", "member", ",", "function", "(", ")", "use", "(", "$", "fkInstanceArray", ",", "$", "member", ")", "{", "return", "$", "this", "->", "getFkMemberElement", "(", "$", "member", ",", "$", "fkInstanceArray", "[", "\"objectFK\"", "]", ",", "$", "fkInstanceArray", "[", "\"fkClass\"", "]", ",", "$", "fkInstanceArray", "[", "\"fkTable\"", "]", ")", ";", "}", ")", ";", "}", "}", "$", "this", "->", "addEditMemberFonctionality", "(", "\"dataElement\"", ")", ";", "return", "$", "dataElement", ";", "}" ]
Returns a DataElement object for displaying the instance Used in the display method of the CrudController in display route @param object $instance @param string $model The model class name (long name) @param boolean $modal @return \Ajax\semantic\widgets\dataelement\DataElement
[ "Returns", "a", "DataElement", "object", "for", "displaying", "the", "instance", "Used", "in", "the", "display", "method", "of", "the", "CrudController", "in", "display", "route" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/admin/viewers/ModelViewer.php#L233-L255
train
phpMv/ubiquity
src/Ubiquity/controllers/admin/viewers/ModelViewer.php
ModelViewer.getModelDataTable
public function getModelDataTable($instances, $model, $totalCount, $page = 1) { $adminRoute = $this->controller->_getBaseRoute (); $files = $this->controller->_getFiles (); $dataTable = $this->getDataTableInstance ( $instances, $model, $totalCount, $page ); $attributes = $this->controller->_getAdminData ()->getFieldNames ( $model ); $this->setDataTableAttributes ( $dataTable, $attributes, $model, $instances ); $dataTable->setCaptions ( $this->getCaptions ( $attributes, $model ) ); $dataTable->addClass ( "small very compact" ); $lbl = new HtmlLabel ( "search-query", "<span id='search-query-content'></span>" ); $icon = $lbl->addIcon ( "delete", false ); $lbl->wrap ( "<span>", "</span>" ); $lbl->setProperty ( "style", "display: none;" ); $icon->getOnClick ( $adminRoute . $files->getRouteRefreshTable (), "#lv", [ "jqueryDone" => "replaceWith","hasLoader" => "internal" ] ); $dataTable->addItemInToolbar ( $lbl ); $dataTable->addSearchInToolbar (); $dataTable->setToolbarPosition ( PositionInTable::FOOTER ); $dataTable->getToolbar ()->setSecondary (); return $dataTable; }
php
public function getModelDataTable($instances, $model, $totalCount, $page = 1) { $adminRoute = $this->controller->_getBaseRoute (); $files = $this->controller->_getFiles (); $dataTable = $this->getDataTableInstance ( $instances, $model, $totalCount, $page ); $attributes = $this->controller->_getAdminData ()->getFieldNames ( $model ); $this->setDataTableAttributes ( $dataTable, $attributes, $model, $instances ); $dataTable->setCaptions ( $this->getCaptions ( $attributes, $model ) ); $dataTable->addClass ( "small very compact" ); $lbl = new HtmlLabel ( "search-query", "<span id='search-query-content'></span>" ); $icon = $lbl->addIcon ( "delete", false ); $lbl->wrap ( "<span>", "</span>" ); $lbl->setProperty ( "style", "display: none;" ); $icon->getOnClick ( $adminRoute . $files->getRouteRefreshTable (), "#lv", [ "jqueryDone" => "replaceWith","hasLoader" => "internal" ] ); $dataTable->addItemInToolbar ( $lbl ); $dataTable->addSearchInToolbar (); $dataTable->setToolbarPosition ( PositionInTable::FOOTER ); $dataTable->getToolbar ()->setSecondary (); return $dataTable; }
[ "public", "function", "getModelDataTable", "(", "$", "instances", ",", "$", "model", ",", "$", "totalCount", ",", "$", "page", "=", "1", ")", "{", "$", "adminRoute", "=", "$", "this", "->", "controller", "->", "_getBaseRoute", "(", ")", ";", "$", "files", "=", "$", "this", "->", "controller", "->", "_getFiles", "(", ")", ";", "$", "dataTable", "=", "$", "this", "->", "getDataTableInstance", "(", "$", "instances", ",", "$", "model", ",", "$", "totalCount", ",", "$", "page", ")", ";", "$", "attributes", "=", "$", "this", "->", "controller", "->", "_getAdminData", "(", ")", "->", "getFieldNames", "(", "$", "model", ")", ";", "$", "this", "->", "setDataTableAttributes", "(", "$", "dataTable", ",", "$", "attributes", ",", "$", "model", ",", "$", "instances", ")", ";", "$", "dataTable", "->", "setCaptions", "(", "$", "this", "->", "getCaptions", "(", "$", "attributes", ",", "$", "model", ")", ")", ";", "$", "dataTable", "->", "addClass", "(", "\"small very compact\"", ")", ";", "$", "lbl", "=", "new", "HtmlLabel", "(", "\"search-query\"", ",", "\"<span id='search-query-content'></span>\"", ")", ";", "$", "icon", "=", "$", "lbl", "->", "addIcon", "(", "\"delete\"", ",", "false", ")", ";", "$", "lbl", "->", "wrap", "(", "\"<span>\"", ",", "\"</span>\"", ")", ";", "$", "lbl", "->", "setProperty", "(", "\"style\"", ",", "\"display: none;\"", ")", ";", "$", "icon", "->", "getOnClick", "(", "$", "adminRoute", ".", "$", "files", "->", "getRouteRefreshTable", "(", ")", ",", "\"#lv\"", ",", "[", "\"jqueryDone\"", "=>", "\"replaceWith\"", ",", "\"hasLoader\"", "=>", "\"internal\"", "]", ")", ";", "$", "dataTable", "->", "addItemInToolbar", "(", "$", "lbl", ")", ";", "$", "dataTable", "->", "addSearchInToolbar", "(", ")", ";", "$", "dataTable", "->", "setToolbarPosition", "(", "PositionInTable", "::", "FOOTER", ")", ";", "$", "dataTable", "->", "getToolbar", "(", ")", "->", "setSecondary", "(", ")", ";", "return", "$", "dataTable", ";", "}" ]
Returns the dataTable responsible for displaying instances of the model @param array $instances objects to display @param string $model model class name (long name) @return DataTable
[ "Returns", "the", "dataTable", "responsible", "for", "displaying", "instances", "of", "the", "model" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/admin/viewers/ModelViewer.php#L275-L295
train
phpMv/ubiquity
src/Ubiquity/controllers/admin/viewers/ModelViewer.php
ModelViewer.getDataTableInstance
protected function getDataTableInstance($instances, $model, $totalCount, $page = 1): DataTable { $semantic = $this->jquery->semantic (); $recordsPerPage = $this->recordsPerPage ( $model, $totalCount ); if (is_numeric ( $recordsPerPage )) { $grpByFields = $this->getGroupByFields (); if (is_array ( $grpByFields )) { $dataTable = $semantic->dataTable ( "lv", $model, $instances ); $dataTable->setGroupByFields ( $grpByFields ); } else { $dataTable = $semantic->jsonDataTable ( "lv", $model, $instances ); } $dataTable->paginate ( $page, $totalCount, $recordsPerPage, 5 ); $dataTable->onActiveRowChange ( '$("#table-details").html("");' ); $dataTable->onSearchTerminate ( '$("#search-query-content").html(data);$("#search-query").show();$("#table-details").html("");' ); } else { $dataTable = $semantic->dataTable ( "lv", $model, $instances ); } return $dataTable; }
php
protected function getDataTableInstance($instances, $model, $totalCount, $page = 1): DataTable { $semantic = $this->jquery->semantic (); $recordsPerPage = $this->recordsPerPage ( $model, $totalCount ); if (is_numeric ( $recordsPerPage )) { $grpByFields = $this->getGroupByFields (); if (is_array ( $grpByFields )) { $dataTable = $semantic->dataTable ( "lv", $model, $instances ); $dataTable->setGroupByFields ( $grpByFields ); } else { $dataTable = $semantic->jsonDataTable ( "lv", $model, $instances ); } $dataTable->paginate ( $page, $totalCount, $recordsPerPage, 5 ); $dataTable->onActiveRowChange ( '$("#table-details").html("");' ); $dataTable->onSearchTerminate ( '$("#search-query-content").html(data);$("#search-query").show();$("#table-details").html("");' ); } else { $dataTable = $semantic->dataTable ( "lv", $model, $instances ); } return $dataTable; }
[ "protected", "function", "getDataTableInstance", "(", "$", "instances", ",", "$", "model", ",", "$", "totalCount", ",", "$", "page", "=", "1", ")", ":", "DataTable", "{", "$", "semantic", "=", "$", "this", "->", "jquery", "->", "semantic", "(", ")", ";", "$", "recordsPerPage", "=", "$", "this", "->", "recordsPerPage", "(", "$", "model", ",", "$", "totalCount", ")", ";", "if", "(", "is_numeric", "(", "$", "recordsPerPage", ")", ")", "{", "$", "grpByFields", "=", "$", "this", "->", "getGroupByFields", "(", ")", ";", "if", "(", "is_array", "(", "$", "grpByFields", ")", ")", "{", "$", "dataTable", "=", "$", "semantic", "->", "dataTable", "(", "\"lv\"", ",", "$", "model", ",", "$", "instances", ")", ";", "$", "dataTable", "->", "setGroupByFields", "(", "$", "grpByFields", ")", ";", "}", "else", "{", "$", "dataTable", "=", "$", "semantic", "->", "jsonDataTable", "(", "\"lv\"", ",", "$", "model", ",", "$", "instances", ")", ";", "}", "$", "dataTable", "->", "paginate", "(", "$", "page", ",", "$", "totalCount", ",", "$", "recordsPerPage", ",", "5", ")", ";", "$", "dataTable", "->", "onActiveRowChange", "(", "'$(\"#table-details\").html(\"\");'", ")", ";", "$", "dataTable", "->", "onSearchTerminate", "(", "'$(\"#search-query-content\").html(data);$(\"#search-query\").show();$(\"#table-details\").html(\"\");'", ")", ";", "}", "else", "{", "$", "dataTable", "=", "$", "semantic", "->", "dataTable", "(", "\"lv\"", ",", "$", "model", ",", "$", "instances", ")", ";", "}", "return", "$", "dataTable", ";", "}" ]
Returns the dataTable instance for dispaying a list of object @param array $instances @param string $model @param number $totalCount @param number $page @return DataTable
[ "Returns", "the", "dataTable", "instance", "for", "dispaying", "a", "list", "of", "object" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/controllers/admin/viewers/ModelViewer.php#L376-L394
train
phpMv/ubiquity
src/Ubiquity/themes/ThemesManager.php
ThemesManager.setActiveTheme
public static function setActiveTheme($activeTheme) { self::$activeTheme = $activeTheme ?? ''; $engineInstance = Startup::$templateEngine; if ($engineInstance instanceof Twig) { $engineInstance->setTheme ( $activeTheme, self::THEMES_FOLDER ); } else { throw new ThemesException ( 'Template engine must be an instance of Twig for themes activation!' ); } }
php
public static function setActiveTheme($activeTheme) { self::$activeTheme = $activeTheme ?? ''; $engineInstance = Startup::$templateEngine; if ($engineInstance instanceof Twig) { $engineInstance->setTheme ( $activeTheme, self::THEMES_FOLDER ); } else { throw new ThemesException ( 'Template engine must be an instance of Twig for themes activation!' ); } }
[ "public", "static", "function", "setActiveTheme", "(", "$", "activeTheme", ")", "{", "self", "::", "$", "activeTheme", "=", "$", "activeTheme", "??", "''", ";", "$", "engineInstance", "=", "Startup", "::", "$", "templateEngine", ";", "if", "(", "$", "engineInstance", "instanceof", "Twig", ")", "{", "$", "engineInstance", "->", "setTheme", "(", "$", "activeTheme", ",", "self", "::", "THEMES_FOLDER", ")", ";", "}", "else", "{", "throw", "new", "ThemesException", "(", "'Template engine must be an instance of Twig for themes activation!'", ")", ";", "}", "}" ]
Sets the activeTheme @param string $activeTheme @throws ThemesException
[ "Sets", "the", "activeTheme" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/themes/ThemesManager.php#L37-L45
train
phpMv/ubiquity
src/Ubiquity/themes/ThemesManager.php
ThemesManager.getAvailableThemes
public static function getAvailableThemes() { $path = \ROOT . \DS . 'views' . \DS . self::THEMES_FOLDER . \DS . '*'; $dirs = \glob ( $path, GLOB_ONLYDIR | GLOB_NOSORT ); $result = [ ]; foreach ( $dirs as $dir ) { $result [] = basename ( $dir ); } return $result; }
php
public static function getAvailableThemes() { $path = \ROOT . \DS . 'views' . \DS . self::THEMES_FOLDER . \DS . '*'; $dirs = \glob ( $path, GLOB_ONLYDIR | GLOB_NOSORT ); $result = [ ]; foreach ( $dirs as $dir ) { $result [] = basename ( $dir ); } return $result; }
[ "public", "static", "function", "getAvailableThemes", "(", ")", "{", "$", "path", "=", "\\", "ROOT", ".", "\\", "DS", ".", "'views'", ".", "\\", "DS", ".", "self", "::", "THEMES_FOLDER", ".", "\\", "DS", ".", "'*'", ";", "$", "dirs", "=", "\\", "glob", "(", "$", "path", ",", "GLOB_ONLYDIR", "|", "GLOB_NOSORT", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "dirs", "as", "$", "dir", ")", "{", "$", "result", "[", "]", "=", "basename", "(", "$", "dir", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns the names of available themes. @return string[]
[ "Returns", "the", "names", "of", "available", "themes", "." ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/themes/ThemesManager.php#L69-L77
train
phpMv/ubiquity
src/Ubiquity/utils/http/URequest.php
URequest.getDatas
public static function getDatas() { $method = \strtolower ( $_SERVER ['REQUEST_METHOD'] ); switch ($method) { case 'post' : if (self::getContentType () == 'application/x-www-form-urlencoded') { return $_POST; } break; case 'get' : return $_GET; default : return self::getInput (); } return self::getInput (); }
php
public static function getDatas() { $method = \strtolower ( $_SERVER ['REQUEST_METHOD'] ); switch ($method) { case 'post' : if (self::getContentType () == 'application/x-www-form-urlencoded') { return $_POST; } break; case 'get' : return $_GET; default : return self::getInput (); } return self::getInput (); }
[ "public", "static", "function", "getDatas", "(", ")", "{", "$", "method", "=", "\\", "strtolower", "(", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", ")", ";", "switch", "(", "$", "method", ")", "{", "case", "'post'", ":", "if", "(", "self", "::", "getContentType", "(", ")", "==", "'application/x-www-form-urlencoded'", ")", "{", "return", "$", "_POST", ";", "}", "break", ";", "case", "'get'", ":", "return", "$", "_GET", ";", "default", ":", "return", "self", "::", "getInput", "(", ")", ";", "}", "return", "self", "::", "getInput", "(", ")", ";", "}" ]
Returns the query data, regardless of the method @return array
[ "Returns", "the", "query", "data", "regardless", "of", "the", "method" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/http/URequest.php#L82-L96
train
phpMv/ubiquity
src/Ubiquity/utils/http/URequest.php
URequest.getBoolean
public static function getBoolean($key) { $ret = false; if (isset ( $_REQUEST [$key] )) { $ret = UString::isBooleanTrue ( $_REQUEST [$key] ); } return $ret; }
php
public static function getBoolean($key) { $ret = false; if (isset ( $_REQUEST [$key] )) { $ret = UString::isBooleanTrue ( $_REQUEST [$key] ); } return $ret; }
[ "public", "static", "function", "getBoolean", "(", "$", "key", ")", "{", "$", "ret", "=", "false", ";", "if", "(", "isset", "(", "$", "_REQUEST", "[", "$", "key", "]", ")", ")", "{", "$", "ret", "=", "UString", "::", "isBooleanTrue", "(", "$", "_REQUEST", "[", "$", "key", "]", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Returns a boolean at the key position in request @param string $key the key to add or set @return boolean
[ "Returns", "a", "boolean", "at", "the", "key", "position", "in", "request" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/http/URequest.php#L210-L216
train
phpMv/ubiquity
src/Ubiquity/utils/http/URequest.php
URequest.getOrigin
public static function getOrigin() { $headers = getallheaders (); if (isset ( $headers ['Origin'] )) { return $headers ['Origin']; } if (isset ( $_SERVER ['HTTP_ORIGIN'] )) { return $_SERVER ['HTTP_ORIGIN']; } else if (isset ( $_SERVER ['HTTP_REFERER'] )) { return $_SERVER ['HTTP_REFERER']; } else { return $_SERVER ['REMOTE_ADDR']; } }
php
public static function getOrigin() { $headers = getallheaders (); if (isset ( $headers ['Origin'] )) { return $headers ['Origin']; } if (isset ( $_SERVER ['HTTP_ORIGIN'] )) { return $_SERVER ['HTTP_ORIGIN']; } else if (isset ( $_SERVER ['HTTP_REFERER'] )) { return $_SERVER ['HTTP_REFERER']; } else { return $_SERVER ['REMOTE_ADDR']; } }
[ "public", "static", "function", "getOrigin", "(", ")", "{", "$", "headers", "=", "getallheaders", "(", ")", ";", "if", "(", "isset", "(", "$", "headers", "[", "'Origin'", "]", ")", ")", "{", "return", "$", "headers", "[", "'Origin'", "]", ";", "}", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_ORIGIN'", "]", ")", ")", "{", "return", "$", "_SERVER", "[", "'HTTP_ORIGIN'", "]", ";", "}", "else", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTP_REFERER'", "]", ")", ")", "{", "return", "$", "_SERVER", "[", "'HTTP_REFERER'", "]", ";", "}", "else", "{", "return", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ";", "}", "}" ]
Returns the request origin @return string
[ "Returns", "the", "request", "origin" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/http/URequest.php#L256-L268
train
phpMv/ubiquity
src/Ubiquity/cache/system/PhpFastCacheDriver.php
PhpFastCacheDriver.fetch
public function fetch($key) { $result = $this->cacheInstance->getItem ( $this->getRealKey ( $key ) )->get (); return eval ( $result ); }
php
public function fetch($key) { $result = $this->cacheInstance->getItem ( $this->getRealKey ( $key ) )->get (); return eval ( $result ); }
[ "public", "function", "fetch", "(", "$", "key", ")", "{", "$", "result", "=", "$", "this", "->", "cacheInstance", "->", "getItem", "(", "$", "this", "->", "getRealKey", "(", "$", "key", ")", ")", "->", "get", "(", ")", ";", "return", "eval", "(", "$", "result", ")", ";", "}" ]
Fetches data stored for the given key. @param string $key cache key @return mixed the cached data
[ "Fetches", "data", "stored", "for", "the", "given", "key", "." ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/cache/system/PhpFastCacheDriver.php#L76-L79
train
phpMv/ubiquity
src/Ubiquity/utils/http/UCookie.php
UCookie.set
public static function set($name, $value, $duration = 60*60*24, $path = "/", $secure = false, $httpOnly = false) { \setcookie ( $name, $value, \time () + $duration, $path, $secure, $httpOnly ); }
php
public static function set($name, $value, $duration = 60*60*24, $path = "/", $secure = false, $httpOnly = false) { \setcookie ( $name, $value, \time () + $duration, $path, $secure, $httpOnly ); }
[ "public", "static", "function", "set", "(", "$", "name", ",", "$", "value", ",", "$", "duration", "=", "60", "*", "60", "*", "24", ",", "$", "path", "=", "\"/\"", ",", "$", "secure", "=", "false", ",", "$", "httpOnly", "=", "false", ")", "{", "\\", "setcookie", "(", "$", "name", ",", "$", "value", ",", "\\", "time", "(", ")", "+", "$", "duration", ",", "$", "path", ",", "$", "secure", ",", "$", "httpOnly", ")", ";", "}" ]
Sends a cookie @param string $name the name of the cookie @param string $value The value of the cookie. @param int $duration default : 1 day @param string $path default : / the cookie will be available within the entire domain @param boolean $secure Indicates that the cookie should only be transmitted over asecure HTTPS @param boolean $httpOnly When true the cookie will be made accessible only through the HTTPprotocol @return boolean
[ "Sends", "a", "cookie" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/http/UCookie.php#L33-L35
train
phpMv/ubiquity
src/Ubiquity/utils/http/UCookie.php
UCookie.deleteAll
public static function deleteAll($path = "/") { foreach ( $_COOKIE as $name => $value ) { self::delete ( $name, $path ); } }
php
public static function deleteAll($path = "/") { foreach ( $_COOKIE as $name => $value ) { self::delete ( $name, $path ); } }
[ "public", "static", "function", "deleteAll", "(", "$", "path", "=", "\"/\"", ")", "{", "foreach", "(", "$", "_COOKIE", "as", "$", "name", "=>", "$", "value", ")", "{", "self", "::", "delete", "(", "$", "name", ",", "$", "path", ")", ";", "}", "}" ]
Deletes all cookies
[ "Deletes", "all", "cookies" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/http/UCookie.php#L64-L68
train
phpMv/ubiquity
src/Ubiquity/utils/http/UCookie.php
UCookie.setRaw
public static function setRaw($name, $value, $duration = 60*60*24, $path = "/", $secure = false, $httpOnly = false) { return \setrawcookie ( $name, $value, \time () + $duration, $path, $secure, $httpOnly ); }
php
public static function setRaw($name, $value, $duration = 60*60*24, $path = "/", $secure = false, $httpOnly = false) { return \setrawcookie ( $name, $value, \time () + $duration, $path, $secure, $httpOnly ); }
[ "public", "static", "function", "setRaw", "(", "$", "name", ",", "$", "value", ",", "$", "duration", "=", "60", "*", "60", "*", "24", ",", "$", "path", "=", "\"/\"", ",", "$", "secure", "=", "false", ",", "$", "httpOnly", "=", "false", ")", "{", "return", "\\", "setrawcookie", "(", "$", "name", ",", "$", "value", ",", "\\", "time", "(", ")", "+", "$", "duration", ",", "$", "path", ",", "$", "secure", ",", "$", "httpOnly", ")", ";", "}" ]
Sends a raw cookie without urlencoding the cookie value @param string $name the name of the cookie @param string $value The value of the cookie. @param int $duration default : 1 day @param string $path default : / the cookie will be available within the entire domain @param boolean $secure Indicates that the cookie should only be transmitted over asecure HTTPS @param boolean $httpOnly When true the cookie will be made accessible only through the HTTPprotocol @return boolean @since Ubiquity 2.0.11
[ "Sends", "a", "raw", "cookie", "without", "urlencoding", "the", "cookie", "value" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/http/UCookie.php#L99-L101
train
phpMv/ubiquity
src/Ubiquity/utils/base/UString.php
UString.pluralize
public static function pluralize($count, $zero, $one, $other) { $result = $other; if ($count === 0) { $result = $zero; } elseif ($count === 1) { $result = $one; } return \str_replace ( '{count}', $count, $result ); }
php
public static function pluralize($count, $zero, $one, $other) { $result = $other; if ($count === 0) { $result = $zero; } elseif ($count === 1) { $result = $one; } return \str_replace ( '{count}', $count, $result ); }
[ "public", "static", "function", "pluralize", "(", "$", "count", ",", "$", "zero", ",", "$", "one", ",", "$", "other", ")", "{", "$", "result", "=", "$", "other", ";", "if", "(", "$", "count", "===", "0", ")", "{", "$", "result", "=", "$", "zero", ";", "}", "elseif", "(", "$", "count", "===", "1", ")", "{", "$", "result", "=", "$", "one", ";", "}", "return", "\\", "str_replace", "(", "'{count}'", ",", "$", "count", ",", "$", "result", ")", ";", "}" ]
Pluralize an expression @param int $count the count of elements @param string $zero value to return if count==0, can contains {count} mask @param string $one value to return if count==1, can contains {count} mask @param string $other value to return if count>1, can contains {count} mask @return string the pluralized expression
[ "Pluralize", "an", "expression" ]
284fccf0b4af5da817e31a958b5b67844c459b10
https://github.com/phpMv/ubiquity/blob/284fccf0b4af5da817e31a958b5b67844c459b10/src/Ubiquity/utils/base/UString.php#L70-L78
train
Nexmo/nexmo-php
src/Client.php
Client.get
public function get($url, array $params = []) { $queryString = '?' . http_build_query($params); $url = $url . $queryString; $request = new Request( $url, 'GET' ); return $this->send($request); }
php
public function get($url, array $params = []) { $queryString = '?' . http_build_query($params); $url = $url . $queryString; $request = new Request( $url, 'GET' ); return $this->send($request); }
[ "public", "function", "get", "(", "$", "url", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "queryString", "=", "'?'", ".", "http_build_query", "(", "$", "params", ")", ";", "$", "url", "=", "$", "url", ".", "$", "queryString", ";", "$", "request", "=", "new", "Request", "(", "$", "url", ",", "'GET'", ")", ";", "return", "$", "this", "->", "send", "(", "$", "request", ")", ";", "}" ]
Takes a URL and a key=>value array to generate a GET PSR-7 request object @param string $url The URL to make a request to @param array $params Key=>Value array of data to use as the query string @return \Psr\Http\Message\ResponseInterface
[ "Takes", "a", "URL", "and", "a", "key", "=", ">", "value", "array", "to", "generate", "a", "GET", "PSR", "-", "7", "request", "object" ]
81e5839d544481b1e942c6d41d9b3b3cfadfd76a
https://github.com/Nexmo/nexmo-php/blob/81e5839d544481b1e942c6d41d9b3b3cfadfd76a/src/Client.php#L273-L285
train
Nexmo/nexmo-php
src/Verify/Verification.php
Verification.check
public function check($code, $ip = null) { try { $this->useClient()->check($this, $code, $ip); return true; } catch(RequestException $e) { if($e->getCode() == 16 || $e->getCode() == 17){ return false; } throw $e; } }
php
public function check($code, $ip = null) { try { $this->useClient()->check($this, $code, $ip); return true; } catch(RequestException $e) { if($e->getCode() == 16 || $e->getCode() == 17){ return false; } throw $e; } }
[ "public", "function", "check", "(", "$", "code", ",", "$", "ip", "=", "null", ")", "{", "try", "{", "$", "this", "->", "useClient", "(", ")", "->", "check", "(", "$", "this", ",", "$", "code", ",", "$", "ip", ")", ";", "return", "true", ";", "}", "catch", "(", "RequestException", "$", "e", ")", "{", "if", "(", "$", "e", "->", "getCode", "(", ")", "==", "16", "||", "$", "e", "->", "getCode", "(", ")", "==", "17", ")", "{", "return", "false", ";", "}", "throw", "$", "e", ";", "}", "}" ]
Check if the code is correct. Unlike the method it proxies, an invalid code does not throw an exception. @uses \Nexmo\Verify\Client::check() @param string $code Numeric code provided by the user. @param null|string $ip IP address to be used for the verification. @return bool Code is valid. @throws RequestException
[ "Check", "if", "the", "code", "is", "correct", ".", "Unlike", "the", "method", "it", "proxies", "an", "invalid", "code", "does", "not", "throw", "an", "exception", "." ]
81e5839d544481b1e942c6d41d9b3b3cfadfd76a
https://github.com/Nexmo/nexmo-php/blob/81e5839d544481b1e942c6d41d9b3b3cfadfd76a/src/Verify/Verification.php#L90-L102
train
Nexmo/nexmo-php
src/Verify/Verification.php
Verification.getChecks
public function getChecks() { $checks = $this->proxyArrayAccess('checks'); if(!$checks){ return []; } foreach($checks as $i => $check) { $checks[$i] = new Check($check); } return $checks; }
php
public function getChecks() { $checks = $this->proxyArrayAccess('checks'); if(!$checks){ return []; } foreach($checks as $i => $check) { $checks[$i] = new Check($check); } return $checks; }
[ "public", "function", "getChecks", "(", ")", "{", "$", "checks", "=", "$", "this", "->", "proxyArrayAccess", "(", "'checks'", ")", ";", "if", "(", "!", "$", "checks", ")", "{", "return", "[", "]", ";", "}", "foreach", "(", "$", "checks", "as", "$", "i", "=>", "$", "check", ")", "{", "$", "checks", "[", "$", "i", "]", "=", "new", "Check", "(", "$", "check", ")", ";", "}", "return", "$", "checks", ";", "}" ]
Get an array of verification checks, if available. Will return an empty array if no check have been made, or if the data is not available. Only available after a searching for a verification. @see \Nexmo\Verify\Client::search(); However still @uses \Nexmo\Verify\Verification::proxyArrayAccess() @return \Nexmo\Verify\Check[]|\Nexmo\Verify\Check
[ "Get", "an", "array", "of", "verification", "checks", "if", "available", ".", "Will", "return", "an", "empty", "array", "if", "no", "check", "have", "been", "made", "or", "if", "the", "data", "is", "not", "available", "." ]
81e5839d544481b1e942c6d41d9b3b3cfadfd76a
https://github.com/Nexmo/nexmo-php/blob/81e5839d544481b1e942c6d41d9b3b3cfadfd76a/src/Verify/Verification.php#L380-L392
train
Nexmo/nexmo-php
src/Call/Call.php
Call.lazyLoad
protected function lazyLoad() { if(!empty($this->data)){ return true; } if(isset($this->id)){ $this->get($this); return true; } return false; }
php
protected function lazyLoad() { if(!empty($this->data)){ return true; } if(isset($this->id)){ $this->get($this); return true; } return false; }
[ "protected", "function", "lazyLoad", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "data", ")", ")", "{", "return", "true", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "id", ")", ")", "{", "$", "this", "->", "get", "(", "$", "this", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Returns true if the resource data is loaded. Will attempt to load the data if it's not already. @return bool
[ "Returns", "true", "if", "the", "resource", "data", "is", "loaded", "." ]
81e5839d544481b1e942c6d41d9b3b3cfadfd76a
https://github.com/Nexmo/nexmo-php/blob/81e5839d544481b1e942c6d41d9b3b3cfadfd76a/src/Call/Call.php#L231-L243
train
ruflin/Elastica
lib/Elastica/Cluster/Health/Index.php
Index.getShards
public function getShards(): array { $shards = []; foreach ($this->_data['shards'] as $shardNumber => $shard) { $shards[] = new Shard($shardNumber, $shard); } return $shards; }
php
public function getShards(): array { $shards = []; foreach ($this->_data['shards'] as $shardNumber => $shard) { $shards[] = new Shard($shardNumber, $shard); } return $shards; }
[ "public", "function", "getShards", "(", ")", ":", "array", "{", "$", "shards", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "_data", "[", "'shards'", "]", "as", "$", "shardNumber", "=>", "$", "shard", ")", "{", "$", "shards", "[", "]", "=", "new", "Shard", "(", "$", "shardNumber", ",", "$", "shard", ")", ";", "}", "return", "$", "shards", ";", "}" ]
Gets the health of the shards in this index. @return Shard[]
[ "Gets", "the", "health", "of", "the", "shards", "in", "this", "index", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Cluster/Health/Index.php#L129-L137
train
ruflin/Elastica
lib/Elastica/Query/FunctionScore.php
FunctionScore.addFunction
public function addFunction( string $functionType, $functionParams, AbstractQuery $filter = null, float $weight = null ): self { $function = [ $functionType => $functionParams, ]; if (null !== $filter) { $function['filter'] = $filter; } if (null !== $weight) { $function['weight'] = $weight; } $this->_functions[] = $function; return $this; }
php
public function addFunction( string $functionType, $functionParams, AbstractQuery $filter = null, float $weight = null ): self { $function = [ $functionType => $functionParams, ]; if (null !== $filter) { $function['filter'] = $filter; } if (null !== $weight) { $function['weight'] = $weight; } $this->_functions[] = $function; return $this; }
[ "public", "function", "addFunction", "(", "string", "$", "functionType", ",", "$", "functionParams", ",", "AbstractQuery", "$", "filter", "=", "null", ",", "float", "$", "weight", "=", "null", ")", ":", "self", "{", "$", "function", "=", "[", "$", "functionType", "=>", "$", "functionParams", ",", "]", ";", "if", "(", "null", "!==", "$", "filter", ")", "{", "$", "function", "[", "'filter'", "]", "=", "$", "filter", ";", "}", "if", "(", "null", "!==", "$", "weight", ")", "{", "$", "function", "[", "'weight'", "]", "=", "$", "weight", ";", "}", "$", "this", "->", "_functions", "[", "]", "=", "$", "function", ";", "return", "$", "this", ";", "}" ]
Add a function to the function_score query. @param string $functionType valid values are DECAY_* constants and script_score @param array|float|AbstractScript $functionParams the body of the function. See documentation for proper syntax. @param AbstractQuery $filter filter to apply to the function @param float $weight function weight @return $this
[ "Add", "a", "function", "to", "the", "function_score", "query", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Query/FunctionScore.php#L75-L96
train
ruflin/Elastica
lib/Elastica/Query/FunctionScore.php
FunctionScore.addScriptScoreFunction
public function addScriptScoreFunction(AbstractScript $script, AbstractQuery $filter = null, float $weight = null) { return $this->addFunction('script_score', $script, $filter, $weight); }
php
public function addScriptScoreFunction(AbstractScript $script, AbstractQuery $filter = null, float $weight = null) { return $this->addFunction('script_score', $script, $filter, $weight); }
[ "public", "function", "addScriptScoreFunction", "(", "AbstractScript", "$", "script", ",", "AbstractQuery", "$", "filter", "=", "null", ",", "float", "$", "weight", "=", "null", ")", "{", "return", "$", "this", "->", "addFunction", "(", "'script_score'", ",", "$", "script", ",", "$", "filter", ",", "$", "weight", ")", ";", "}" ]
Add a script_score function to the query. @param AbstractScript $script a Script object @param AbstractQuery $filter an optional filter to apply to the function @param float $weight the weight of the function @return $this
[ "Add", "a", "script_score", "function", "to", "the", "query", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Query/FunctionScore.php#L107-L110
train
ruflin/Elastica
lib/Elastica/Query/FunctionScore.php
FunctionScore.addDecayFunction
public function addDecayFunction( string $function, string $field, string $origin, string $scale, string $offset = null, float $decay = null, float $weight = null, AbstractQuery $filter = null, string $multiValueMode = null ) { $functionParams = [ $field => [ 'origin' => $origin, 'scale' => $scale, ], ]; if (null !== $offset) { $functionParams[$field]['offset'] = $offset; } if (null !== $decay) { $functionParams[$field]['decay'] = $decay; } if (null !== $multiValueMode) { $functionParams['multi_value_mode'] = $multiValueMode; } return $this->addFunction($function, $functionParams, $filter, $weight); }
php
public function addDecayFunction( string $function, string $field, string $origin, string $scale, string $offset = null, float $decay = null, float $weight = null, AbstractQuery $filter = null, string $multiValueMode = null ) { $functionParams = [ $field => [ 'origin' => $origin, 'scale' => $scale, ], ]; if (null !== $offset) { $functionParams[$field]['offset'] = $offset; } if (null !== $decay) { $functionParams[$field]['decay'] = $decay; } if (null !== $multiValueMode) { $functionParams['multi_value_mode'] = $multiValueMode; } return $this->addFunction($function, $functionParams, $filter, $weight); }
[ "public", "function", "addDecayFunction", "(", "string", "$", "function", ",", "string", "$", "field", ",", "string", "$", "origin", ",", "string", "$", "scale", ",", "string", "$", "offset", "=", "null", ",", "float", "$", "decay", "=", "null", ",", "float", "$", "weight", "=", "null", ",", "AbstractQuery", "$", "filter", "=", "null", ",", "string", "$", "multiValueMode", "=", "null", ")", "{", "$", "functionParams", "=", "[", "$", "field", "=>", "[", "'origin'", "=>", "$", "origin", ",", "'scale'", "=>", "$", "scale", ",", "]", ",", "]", ";", "if", "(", "null", "!==", "$", "offset", ")", "{", "$", "functionParams", "[", "$", "field", "]", "[", "'offset'", "]", "=", "$", "offset", ";", "}", "if", "(", "null", "!==", "$", "decay", ")", "{", "$", "functionParams", "[", "$", "field", "]", "[", "'decay'", "]", "=", "$", "decay", ";", "}", "if", "(", "null", "!==", "$", "multiValueMode", ")", "{", "$", "functionParams", "[", "'multi_value_mode'", "]", "=", "$", "multiValueMode", ";", "}", "return", "$", "this", "->", "addFunction", "(", "$", "function", ",", "$", "functionParams", ",", "$", "filter", ",", "$", "weight", ")", ";", "}" ]
Add a decay function to the query. @param string $function see DECAY_* constants for valid options @param string $field the document field on which to perform the decay function @param string $origin the origin value for this decay function @param string $scale a scale to define the rate of decay for this function @param string $offset If defined, this function will only be computed for documents with a distance from the origin greater than this value @param float $decay optionally defines how documents are scored at the distance given by the $scale parameter @param float $weight optional factor by which to multiply the score at the value provided by the $scale parameter @param AbstractQuery $filter a filter associated with this function @param string $multiValueMode see MULTI_VALUE_MODE_* constants for valid options @return $this
[ "Add", "a", "decay", "function", "to", "the", "query", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Query/FunctionScore.php#L127-L156
train
ruflin/Elastica
lib/Elastica/Query/FunctionScore.php
FunctionScore.addRandomScoreFunction
public function addRandomScoreFunction( int $seed, AbstractQuery $filter = null, float $weight = null, string $field = null ): self { $functionParams = [ 'seed' => $seed, ]; if (null !== $field) { $functionParams['field'] = $field; } return $this->addFunction('random_score', $functionParams, $filter, $weight); }
php
public function addRandomScoreFunction( int $seed, AbstractQuery $filter = null, float $weight = null, string $field = null ): self { $functionParams = [ 'seed' => $seed, ]; if (null !== $field) { $functionParams['field'] = $field; } return $this->addFunction('random_score', $functionParams, $filter, $weight); }
[ "public", "function", "addRandomScoreFunction", "(", "int", "$", "seed", ",", "AbstractQuery", "$", "filter", "=", "null", ",", "float", "$", "weight", "=", "null", ",", "string", "$", "field", "=", "null", ")", ":", "self", "{", "$", "functionParams", "=", "[", "'seed'", "=>", "$", "seed", ",", "]", ";", "if", "(", "null", "!==", "$", "field", ")", "{", "$", "functionParams", "[", "'field'", "]", "=", "$", "field", ";", "}", "return", "$", "this", "->", "addFunction", "(", "'random_score'", ",", "$", "functionParams", ",", "$", "filter", ",", "$", "weight", ")", ";", "}" ]
Add a random_score function to the query. @param int $seed the seed value @param AbstractQuery $filter a filter associated with this function @param float $weight an optional boost value associated with this function @param string $field the field to be used for random number generation @return $this
[ "Add", "a", "random_score", "function", "to", "the", "query", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Query/FunctionScore.php#L216-L231
train
ruflin/Elastica
lib/Elastica/Query/FunctionScore.php
FunctionScore.setRandomScore
public function setRandomScore(int $seed = null): self { $seedParam = new \stdClass(); if (null !== $seed) { $seedParam->seed = $seed; } return $this->setParam('random_score', $seedParam); }
php
public function setRandomScore(int $seed = null): self { $seedParam = new \stdClass(); if (null !== $seed) { $seedParam->seed = $seed; } return $this->setParam('random_score', $seedParam); }
[ "public", "function", "setRandomScore", "(", "int", "$", "seed", "=", "null", ")", ":", "self", "{", "$", "seedParam", "=", "new", "\\", "stdClass", "(", ")", ";", "if", "(", "null", "!==", "$", "seed", ")", "{", "$", "seedParam", "->", "seed", "=", "$", "seed", ";", "}", "return", "$", "this", "->", "setParam", "(", "'random_score'", ",", "$", "seedParam", ")", ";", "}" ]
If set, this query will return results in random order. @param int $seed set a seed value to return results in the same random order for consistent pagination @return $this
[ "If", "set", "this", "query", "will", "return", "results", "in", "random", "order", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Query/FunctionScore.php#L276-L284
train
ruflin/Elastica
lib/Elastica/Suggest/Phrase.php
Phrase.setHighlight
public function setHighlight(string $preTag, string $postTag): Phrase { return $this->setParam('highlight', [ 'pre_tag' => $preTag, 'post_tag' => $postTag, ]); }
php
public function setHighlight(string $preTag, string $postTag): Phrase { return $this->setParam('highlight', [ 'pre_tag' => $preTag, 'post_tag' => $postTag, ]); }
[ "public", "function", "setHighlight", "(", "string", "$", "preTag", ",", "string", "$", "postTag", ")", ":", "Phrase", "{", "return", "$", "this", "->", "setParam", "(", "'highlight'", ",", "[", "'pre_tag'", "=>", "$", "preTag", ",", "'post_tag'", "=>", "$", "postTag", ",", "]", ")", ";", "}" ]
Set suggestion highlighting. @param string $preTag @param string $postTag @return $this
[ "Set", "suggestion", "highlighting", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Suggest/Phrase.php#L97-L103
train
ruflin/Elastica
lib/Elastica/Scroll.php
Scroll.next
public function next() { if ($this->currentPage < $this->totalPages) { $this->_saveOptions(); $this->_search->setOption(Search::OPTION_SCROLL, $this->expiryTime); $this->_search->setOption(Search::OPTION_SCROLL_ID, $this->_nextScrollId); $this->_setScrollId($this->_search->search()); $this->_revertOptions(); } else { // If there are no pages left, we do not need to query ES. $this->clear(); } }
php
public function next() { if ($this->currentPage < $this->totalPages) { $this->_saveOptions(); $this->_search->setOption(Search::OPTION_SCROLL, $this->expiryTime); $this->_search->setOption(Search::OPTION_SCROLL_ID, $this->_nextScrollId); $this->_setScrollId($this->_search->search()); $this->_revertOptions(); } else { // If there are no pages left, we do not need to query ES. $this->clear(); } }
[ "public", "function", "next", "(", ")", "{", "if", "(", "$", "this", "->", "currentPage", "<", "$", "this", "->", "totalPages", ")", "{", "$", "this", "->", "_saveOptions", "(", ")", ";", "$", "this", "->", "_search", "->", "setOption", "(", "Search", "::", "OPTION_SCROLL", ",", "$", "this", "->", "expiryTime", ")", ";", "$", "this", "->", "_search", "->", "setOption", "(", "Search", "::", "OPTION_SCROLL_ID", ",", "$", "this", "->", "_nextScrollId", ")", ";", "$", "this", "->", "_setScrollId", "(", "$", "this", "->", "_search", "->", "search", "(", ")", ")", ";", "$", "this", "->", "_revertOptions", "(", ")", ";", "}", "else", "{", "// If there are no pages left, we do not need to query ES.", "$", "this", "->", "clear", "(", ")", ";", "}", "}" ]
Next scroll search. @see http://php.net/manual/en/iterator.next.php
[ "Next", "scroll", "search", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Scroll.php#L74-L89
train
ruflin/Elastica
lib/Elastica/Scroll.php
Scroll.rewind
public function rewind() { // reset state $this->_options = [null, null]; $this->currentPage = 0; // initial search $this->_saveOptions(); $this->_search->setOption(Search::OPTION_SCROLL, $this->expiryTime); $this->_search->setOption(Search::OPTION_SCROLL_ID, null); $this->_setScrollId($this->_search->search()); $this->_revertOptions(); }
php
public function rewind() { // reset state $this->_options = [null, null]; $this->currentPage = 0; // initial search $this->_saveOptions(); $this->_search->setOption(Search::OPTION_SCROLL, $this->expiryTime); $this->_search->setOption(Search::OPTION_SCROLL_ID, null); $this->_setScrollId($this->_search->search()); $this->_revertOptions(); }
[ "public", "function", "rewind", "(", ")", "{", "// reset state", "$", "this", "->", "_options", "=", "[", "null", ",", "null", "]", ";", "$", "this", "->", "currentPage", "=", "0", ";", "// initial search", "$", "this", "->", "_saveOptions", "(", ")", ";", "$", "this", "->", "_search", "->", "setOption", "(", "Search", "::", "OPTION_SCROLL", ",", "$", "this", "->", "expiryTime", ")", ";", "$", "this", "->", "_search", "->", "setOption", "(", "Search", "::", "OPTION_SCROLL_ID", ",", "null", ")", ";", "$", "this", "->", "_setScrollId", "(", "$", "this", "->", "_search", "->", "search", "(", ")", ")", ";", "$", "this", "->", "_revertOptions", "(", ")", ";", "}" ]
Initial scroll search. @see http://php.net/manual/en/iterator.rewind.php
[ "Initial", "scroll", "search", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Scroll.php#L120-L134
train
ruflin/Elastica
lib/Elastica/Scroll.php
Scroll.clear
public function clear() { if (null !== $this->_nextScrollId) { $this->_search->getClient()->request( '_search/scroll', Request::DELETE, [Search::OPTION_SCROLL_ID => [$this->_nextScrollId]] ); // Reset scroll ID so valid() returns false. $this->_nextScrollId = null; $this->_currentResultSet = null; } }
php
public function clear() { if (null !== $this->_nextScrollId) { $this->_search->getClient()->request( '_search/scroll', Request::DELETE, [Search::OPTION_SCROLL_ID => [$this->_nextScrollId]] ); // Reset scroll ID so valid() returns false. $this->_nextScrollId = null; $this->_currentResultSet = null; } }
[ "public", "function", "clear", "(", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "_nextScrollId", ")", "{", "$", "this", "->", "_search", "->", "getClient", "(", ")", "->", "request", "(", "'_search/scroll'", ",", "Request", "::", "DELETE", ",", "[", "Search", "::", "OPTION_SCROLL_ID", "=>", "[", "$", "this", "->", "_nextScrollId", "]", "]", ")", ";", "// Reset scroll ID so valid() returns false.", "$", "this", "->", "_nextScrollId", "=", "null", ";", "$", "this", "->", "_currentResultSet", "=", "null", ";", "}", "}" ]
Cleares the search context on ES and marks this Scroll instance as finished.
[ "Cleares", "the", "search", "context", "on", "ES", "and", "marks", "this", "Scroll", "instance", "as", "finished", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Scroll.php#L139-L152
train
ruflin/Elastica
lib/Elastica/Scroll.php
Scroll._setScrollId
protected function _setScrollId(ResultSet $resultSet) { if (0 === $this->currentPage) { $this->totalPages = $resultSet->count() > 0 ? \ceil($resultSet->getTotalHits() / $resultSet->count()) : 0; } $this->_currentResultSet = $resultSet; ++$this->currentPage; $this->_nextScrollId = $resultSet->getResponse()->isOk() && $resultSet->count() > 0 ? $resultSet->getResponse()->getScrollId() : null; }
php
protected function _setScrollId(ResultSet $resultSet) { if (0 === $this->currentPage) { $this->totalPages = $resultSet->count() > 0 ? \ceil($resultSet->getTotalHits() / $resultSet->count()) : 0; } $this->_currentResultSet = $resultSet; ++$this->currentPage; $this->_nextScrollId = $resultSet->getResponse()->isOk() && $resultSet->count() > 0 ? $resultSet->getResponse()->getScrollId() : null; }
[ "protected", "function", "_setScrollId", "(", "ResultSet", "$", "resultSet", ")", "{", "if", "(", "0", "===", "$", "this", "->", "currentPage", ")", "{", "$", "this", "->", "totalPages", "=", "$", "resultSet", "->", "count", "(", ")", ">", "0", "?", "\\", "ceil", "(", "$", "resultSet", "->", "getTotalHits", "(", ")", "/", "$", "resultSet", "->", "count", "(", ")", ")", ":", "0", ";", "}", "$", "this", "->", "_currentResultSet", "=", "$", "resultSet", ";", "++", "$", "this", "->", "currentPage", ";", "$", "this", "->", "_nextScrollId", "=", "$", "resultSet", "->", "getResponse", "(", ")", "->", "isOk", "(", ")", "&&", "$", "resultSet", "->", "count", "(", ")", ">", "0", "?", "$", "resultSet", "->", "getResponse", "(", ")", "->", "getScrollId", "(", ")", ":", "null", ";", "}" ]
Prepares Scroll for next request. @param ResultSet $resultSet
[ "Prepares", "Scroll", "for", "next", "request", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Scroll.php#L159-L168
train
ruflin/Elastica
lib/Elastica/Scroll.php
Scroll._saveOptions
protected function _saveOptions() { if ($this->_search->hasOption(Search::OPTION_SCROLL)) { $this->_options[0] = $this->_search->getOption(Search::OPTION_SCROLL); } if ($this->_search->hasOption(Search::OPTION_SCROLL_ID)) { $this->_options[1] = $this->_search->getOption(Search::OPTION_SCROLL_ID); } }
php
protected function _saveOptions() { if ($this->_search->hasOption(Search::OPTION_SCROLL)) { $this->_options[0] = $this->_search->getOption(Search::OPTION_SCROLL); } if ($this->_search->hasOption(Search::OPTION_SCROLL_ID)) { $this->_options[1] = $this->_search->getOption(Search::OPTION_SCROLL_ID); } }
[ "protected", "function", "_saveOptions", "(", ")", "{", "if", "(", "$", "this", "->", "_search", "->", "hasOption", "(", "Search", "::", "OPTION_SCROLL", ")", ")", "{", "$", "this", "->", "_options", "[", "0", "]", "=", "$", "this", "->", "_search", "->", "getOption", "(", "Search", "::", "OPTION_SCROLL", ")", ";", "}", "if", "(", "$", "this", "->", "_search", "->", "hasOption", "(", "Search", "::", "OPTION_SCROLL_ID", ")", ")", "{", "$", "this", "->", "_options", "[", "1", "]", "=", "$", "this", "->", "_search", "->", "getOption", "(", "Search", "::", "OPTION_SCROLL_ID", ")", ";", "}", "}" ]
Save all search options manipulated by Scroll.
[ "Save", "all", "search", "options", "manipulated", "by", "Scroll", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Scroll.php#L173-L182
train
ruflin/Elastica
lib/Elastica/Scroll.php
Scroll._revertOptions
protected function _revertOptions() { $this->_search->setOption(Search::OPTION_SCROLL, $this->_options[0]); $this->_search->setOption(Search::OPTION_SCROLL_ID, $this->_options[1]); }
php
protected function _revertOptions() { $this->_search->setOption(Search::OPTION_SCROLL, $this->_options[0]); $this->_search->setOption(Search::OPTION_SCROLL_ID, $this->_options[1]); }
[ "protected", "function", "_revertOptions", "(", ")", "{", "$", "this", "->", "_search", "->", "setOption", "(", "Search", "::", "OPTION_SCROLL", ",", "$", "this", "->", "_options", "[", "0", "]", ")", ";", "$", "this", "->", "_search", "->", "setOption", "(", "Search", "::", "OPTION_SCROLL_ID", ",", "$", "this", "->", "_options", "[", "1", "]", ")", ";", "}" ]
Revert search options to previously saved state.
[ "Revert", "search", "options", "to", "previously", "saved", "state", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Scroll.php#L187-L191
train
ruflin/Elastica
lib/Elastica/Search.php
Search.addIndex
public function addIndex($index) { if ($index instanceof Index) { $index = $index->getName(); } if (!\is_scalar($index)) { throw new InvalidException('Invalid param type'); } $this->_indices[] = (string) $index; return $this; }
php
public function addIndex($index) { if ($index instanceof Index) { $index = $index->getName(); } if (!\is_scalar($index)) { throw new InvalidException('Invalid param type'); } $this->_indices[] = (string) $index; return $this; }
[ "public", "function", "addIndex", "(", "$", "index", ")", "{", "if", "(", "$", "index", "instanceof", "Index", ")", "{", "$", "index", "=", "$", "index", "->", "getName", "(", ")", ";", "}", "if", "(", "!", "\\", "is_scalar", "(", "$", "index", ")", ")", "{", "throw", "new", "InvalidException", "(", "'Invalid param type'", ")", ";", "}", "$", "this", "->", "_indices", "[", "]", "=", "(", "string", ")", "$", "index", ";", "return", "$", "this", ";", "}" ]
Adds a index to the list. @param \Elastica\Index|string $index Index object or string @throws \Elastica\Exception\InvalidException @return $this
[ "Adds", "a", "index", "to", "the", "list", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Search.php#L99-L112
train
ruflin/Elastica
lib/Elastica/Search.php
Search.addType
public function addType($type) { if ($type instanceof Type) { $type = $type->getName(); } if (!\is_string($type)) { throw new InvalidException('Invalid type type'); } $this->_types[] = $type; return $this; }
php
public function addType($type) { if ($type instanceof Type) { $type = $type->getName(); } if (!\is_string($type)) { throw new InvalidException('Invalid type type'); } $this->_types[] = $type; return $this; }
[ "public", "function", "addType", "(", "$", "type", ")", "{", "if", "(", "$", "type", "instanceof", "Type", ")", "{", "$", "type", "=", "$", "type", "->", "getName", "(", ")", ";", "}", "if", "(", "!", "\\", "is_string", "(", "$", "type", ")", ")", "{", "throw", "new", "InvalidException", "(", "'Invalid type type'", ")", ";", "}", "$", "this", "->", "_types", "[", "]", "=", "$", "type", ";", "return", "$", "this", ";", "}" ]
Adds a type to the current search. @param \Elastica\Type|string $type Type name or object @throws \Elastica\Exception\InvalidException @return $this
[ "Adds", "a", "type", "to", "the", "current", "search", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Search.php#L139-L152
train
ruflin/Elastica
lib/Elastica/Search.php
Search.getPath
public function getPath() { if (isset($this->_options[self::OPTION_SCROLL_ID])) { return '_search/scroll'; } $indices = $this->getIndices(); $path = ''; $types = $this->getTypes(); if (empty($indices)) { if (!empty($types)) { $path .= '_all'; } } else { $path .= \implode(',', $indices); } if (!empty($types)) { $path .= '/'.\implode(',', $types); } // Add full path based on indices and types -> could be all return $path.'/_search'; }
php
public function getPath() { if (isset($this->_options[self::OPTION_SCROLL_ID])) { return '_search/scroll'; } $indices = $this->getIndices(); $path = ''; $types = $this->getTypes(); if (empty($indices)) { if (!empty($types)) { $path .= '_all'; } } else { $path .= \implode(',', $indices); } if (!empty($types)) { $path .= '/'.\implode(',', $types); } // Add full path based on indices and types -> could be all return $path.'/_search'; }
[ "public", "function", "getPath", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_options", "[", "self", "::", "OPTION_SCROLL_ID", "]", ")", ")", "{", "return", "'_search/scroll'", ";", "}", "$", "indices", "=", "$", "this", "->", "getIndices", "(", ")", ";", "$", "path", "=", "''", ";", "$", "types", "=", "$", "this", "->", "getTypes", "(", ")", ";", "if", "(", "empty", "(", "$", "indices", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "types", ")", ")", "{", "$", "path", ".=", "'_all'", ";", "}", "}", "else", "{", "$", "path", ".=", "\\", "implode", "(", "','", ",", "$", "indices", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "types", ")", ")", "{", "$", "path", ".=", "'/'", ".", "\\", "implode", "(", "','", ",", "$", "types", ")", ";", "}", "// Add full path based on indices and types -> could be all", "return", "$", "path", ".", "'/_search'", ";", "}" ]
Combines indices and types to the search request path. @return string Search path
[ "Combines", "indices", "and", "types", "to", "the", "search", "request", "path", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Search.php#L407-L432
train
ruflin/Elastica
lib/Elastica/Search.php
Search.search
public function search($query = '', $options = null) { $this->setOptionsAndQuery($options, $query); $query = $this->getQuery(); $path = $this->getPath(); $params = $this->getOptions(); // Send scroll_id via raw HTTP body to handle cases of very large (> 4kb) ids. if ('_search/scroll' == $path) { $data = [self::OPTION_SCROLL_ID => $params[self::OPTION_SCROLL_ID]]; unset($params[self::OPTION_SCROLL_ID]); } else { $data = $query->toArray(); } $response = $this->getClient()->request( $path, Request::GET, $data, $params ); return $this->_builder->buildResultSet($response, $query); }
php
public function search($query = '', $options = null) { $this->setOptionsAndQuery($options, $query); $query = $this->getQuery(); $path = $this->getPath(); $params = $this->getOptions(); // Send scroll_id via raw HTTP body to handle cases of very large (> 4kb) ids. if ('_search/scroll' == $path) { $data = [self::OPTION_SCROLL_ID => $params[self::OPTION_SCROLL_ID]]; unset($params[self::OPTION_SCROLL_ID]); } else { $data = $query->toArray(); } $response = $this->getClient()->request( $path, Request::GET, $data, $params ); return $this->_builder->buildResultSet($response, $query); }
[ "public", "function", "search", "(", "$", "query", "=", "''", ",", "$", "options", "=", "null", ")", "{", "$", "this", "->", "setOptionsAndQuery", "(", "$", "options", ",", "$", "query", ")", ";", "$", "query", "=", "$", "this", "->", "getQuery", "(", ")", ";", "$", "path", "=", "$", "this", "->", "getPath", "(", ")", ";", "$", "params", "=", "$", "this", "->", "getOptions", "(", ")", ";", "// Send scroll_id via raw HTTP body to handle cases of very large (> 4kb) ids.", "if", "(", "'_search/scroll'", "==", "$", "path", ")", "{", "$", "data", "=", "[", "self", "::", "OPTION_SCROLL_ID", "=>", "$", "params", "[", "self", "::", "OPTION_SCROLL_ID", "]", "]", ";", "unset", "(", "$", "params", "[", "self", "::", "OPTION_SCROLL_ID", "]", ")", ";", "}", "else", "{", "$", "data", "=", "$", "query", "->", "toArray", "(", ")", ";", "}", "$", "response", "=", "$", "this", "->", "getClient", "(", ")", "->", "request", "(", "$", "path", ",", "Request", "::", "GET", ",", "$", "data", ",", "$", "params", ")", ";", "return", "$", "this", "->", "_builder", "->", "buildResultSet", "(", "$", "response", ",", "$", "query", ")", ";", "}" ]
Search in the set indices, types. @param mixed $query @param int|array $options OPTIONAL Limit or associative array of options (option=>value) @throws \Elastica\Exception\InvalidException @return \Elastica\ResultSet
[ "Search", "in", "the", "set", "indices", "types", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Search.php#L444-L469
train
ruflin/Elastica
lib/Elastica/Query/Ids.php
Ids.setIds
public function setIds($ids): self { if (\is_array($ids)) { $this->_params['values'] = $ids; } else { $this->_params['values'] = [$ids]; } return $this; }
php
public function setIds($ids): self { if (\is_array($ids)) { $this->_params['values'] = $ids; } else { $this->_params['values'] = [$ids]; } return $this; }
[ "public", "function", "setIds", "(", "$", "ids", ")", ":", "self", "{", "if", "(", "\\", "is_array", "(", "$", "ids", ")", ")", "{", "$", "this", "->", "_params", "[", "'values'", "]", "=", "$", "ids", ";", "}", "else", "{", "$", "this", "->", "_params", "[", "'values'", "]", "=", "[", "$", "ids", "]", ";", "}", "return", "$", "this", ";", "}" ]
Sets the ids to filter. @param array|string $ids List of ids @return $this
[ "Sets", "the", "ids", "to", "filter", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Query/Ids.php#L47-L56
train
ruflin/Elastica
lib/Elastica/Status.php
Status.getIndicesWithAlias
public function getIndicesWithAlias($alias) { $endpoint = new Get(); $endpoint->setName($alias); $response = null; try { $response = $this->_client->requestEndpoint($endpoint); } catch (ResponseException $e) { // 404 means the index alias doesn't exist which means no indexes have it. if (404 === $e->getResponse()->getStatus()) { return []; } // If we don't have a 404 then this is still unexpected so rethrow the exception. throw $e; } $indices = []; foreach ($response->getData() as $name => $unused) { $indices[] = new Index($this->_client, $name); } return $indices; }
php
public function getIndicesWithAlias($alias) { $endpoint = new Get(); $endpoint->setName($alias); $response = null; try { $response = $this->_client->requestEndpoint($endpoint); } catch (ResponseException $e) { // 404 means the index alias doesn't exist which means no indexes have it. if (404 === $e->getResponse()->getStatus()) { return []; } // If we don't have a 404 then this is still unexpected so rethrow the exception. throw $e; } $indices = []; foreach ($response->getData() as $name => $unused) { $indices[] = new Index($this->_client, $name); } return $indices; }
[ "public", "function", "getIndicesWithAlias", "(", "$", "alias", ")", "{", "$", "endpoint", "=", "new", "Get", "(", ")", ";", "$", "endpoint", "->", "setName", "(", "$", "alias", ")", ";", "$", "response", "=", "null", ";", "try", "{", "$", "response", "=", "$", "this", "->", "_client", "->", "requestEndpoint", "(", "$", "endpoint", ")", ";", "}", "catch", "(", "ResponseException", "$", "e", ")", "{", "// 404 means the index alias doesn't exist which means no indexes have it.", "if", "(", "404", "===", "$", "e", "->", "getResponse", "(", ")", "->", "getStatus", "(", ")", ")", "{", "return", "[", "]", ";", "}", "// If we don't have a 404 then this is still unexpected so rethrow the exception.", "throw", "$", "e", ";", "}", "$", "indices", "=", "[", "]", ";", "foreach", "(", "$", "response", "->", "getData", "(", ")", "as", "$", "name", "=>", "$", "unused", ")", "{", "$", "indices", "[", "]", "=", "new", "Index", "(", "$", "this", "->", "_client", ",", "$", "name", ")", ";", "}", "return", "$", "indices", ";", "}" ]
Returns an array with all indices that the given alias name points to. @param string $alias Alias name @return array|\Elastica\Index[] List of Elastica\Index
[ "Returns", "an", "array", "with", "all", "indices", "that", "the", "given", "alias", "name", "points", "to", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Status.php#L106-L129
train
ruflin/Elastica
lib/Elastica/Exception/ResponseException.php
ResponseException.getElasticsearchException
public function getElasticsearchException(): ElasticsearchException { $response = $this->getResponse(); return new ElasticsearchException($response->getStatus(), $response->getErrorMessage()); }
php
public function getElasticsearchException(): ElasticsearchException { $response = $this->getResponse(); return new ElasticsearchException($response->getStatus(), $response->getErrorMessage()); }
[ "public", "function", "getElasticsearchException", "(", ")", ":", "ElasticsearchException", "{", "$", "response", "=", "$", "this", "->", "getResponse", "(", ")", ";", "return", "new", "ElasticsearchException", "(", "$", "response", "->", "getStatus", "(", ")", ",", "$", "response", "->", "getErrorMessage", "(", ")", ")", ";", "}" ]
Returns elasticsearch exception. @return ElasticsearchException
[ "Returns", "elasticsearch", "exception", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Exception/ResponseException.php#L63-L68
train
ruflin/Elastica
lib/Elastica/Type/AbstractType.php
AbstractType.create
public function create(bool $recreate = false) { $this->getIndex()->create($this->_indexParams, $recreate); $mapping = new Mapping($this->getType()); $mapping->setProperties($this->_mapping); $mapping->setSource(['enabled' => $this->_source]); $mapping->send(); }
php
public function create(bool $recreate = false) { $this->getIndex()->create($this->_indexParams, $recreate); $mapping = new Mapping($this->getType()); $mapping->setProperties($this->_mapping); $mapping->setSource(['enabled' => $this->_source]); $mapping->send(); }
[ "public", "function", "create", "(", "bool", "$", "recreate", "=", "false", ")", "{", "$", "this", "->", "getIndex", "(", ")", "->", "create", "(", "$", "this", "->", "_indexParams", ",", "$", "recreate", ")", ";", "$", "mapping", "=", "new", "Mapping", "(", "$", "this", "->", "getType", "(", ")", ")", ";", "$", "mapping", "->", "setProperties", "(", "$", "this", "->", "_mapping", ")", ";", "$", "mapping", "->", "setSource", "(", "[", "'enabled'", "=>", "$", "this", "->", "_source", "]", ")", ";", "$", "mapping", "->", "send", "(", ")", ";", "}" ]
Creates the index and sets the mapping for this type. @param bool $recreate OPTIONAL Recreates the index if true (default = false)
[ "Creates", "the", "index", "and", "sets", "the", "mapping", "for", "this", "type", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Type/AbstractType.php#L128-L136
train
ruflin/Elastica
lib/Elastica/Type/AbstractType.php
AbstractType.search
public function search($query = '', $options = null): ResultSet { return $this->getType()->search($query, $options = null); }
php
public function search($query = '', $options = null): ResultSet { return $this->getType()->search($query, $options = null); }
[ "public", "function", "search", "(", "$", "query", "=", "''", ",", "$", "options", "=", "null", ")", ":", "ResultSet", "{", "return", "$", "this", "->", "getType", "(", ")", "->", "search", "(", "$", "query", ",", "$", "options", "=", "null", ")", ";", "}" ]
Search on the type. @param string|array|Query $query Array with all query data inside or a Elastica\Query object @param int|array $options @return ResultSet with all results inside @see \Elastica\SearchableInterface::search
[ "Search", "on", "the", "type", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Type/AbstractType.php#L159-L162
train
ruflin/Elastica
lib/Elastica/Aggregation/Percentiles.php
Percentiles.setHdr
public function setHdr(string $key, float $value): self { $compression = [$key => $value]; return $this->setParam('hdr', $compression); }
php
public function setHdr(string $key, float $value): self { $compression = [$key => $value]; return $this->setParam('hdr', $compression); }
[ "public", "function", "setHdr", "(", "string", "$", "key", ",", "float", "$", "value", ")", ":", "self", "{", "$", "compression", "=", "[", "$", "key", "=>", "$", "value", "]", ";", "return", "$", "this", "->", "setParam", "(", "'hdr'", ",", "$", "compression", ")", ";", "}" ]
Set hdr parameter. @param string $key @param float $value @return $this
[ "Set", "hdr", "parameter", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Aggregation/Percentiles.php#L47-L52
train
ruflin/Elastica
lib/Elastica/Query/SpanTerm.php
SpanTerm.setTerm
public function setTerm(string $key, $value, float $boost = 1.0): self { return $this->setRawTerm([$key => ['value' => $value, 'boost' => $boost]]); }
php
public function setTerm(string $key, $value, float $boost = 1.0): self { return $this->setRawTerm([$key => ['value' => $value, 'boost' => $boost]]); }
[ "public", "function", "setTerm", "(", "string", "$", "key", ",", "$", "value", ",", "float", "$", "boost", "=", "1.0", ")", ":", "self", "{", "return", "$", "this", "->", "setRawTerm", "(", "[", "$", "key", "=>", "[", "'value'", "=>", "$", "value", ",", "'boost'", "=>", "$", "boost", "]", "]", ")", ";", "}" ]
Adds a term to the term query. @param string $key Key to query @param string|array $value Values(s) for the query. Boost can be set with array @param float $boost OPTIONAL Boost value (default = 1.0) @return $this
[ "Adds", "a", "term", "to", "the", "term", "query", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Query/SpanTerm.php#L47-L50
train
ruflin/Elastica
lib/Elastica/ResultSet.php
ResultSet.getAggregation
public function getAggregation($name) { $data = $this->_response->getData(); if (isset($data['aggregations']) && isset($data['aggregations'][$name])) { return $data['aggregations'][$name]; } throw new InvalidException("This result set does not contain an aggregation named {$name}."); }
php
public function getAggregation($name) { $data = $this->_response->getData(); if (isset($data['aggregations']) && isset($data['aggregations'][$name])) { return $data['aggregations'][$name]; } throw new InvalidException("This result set does not contain an aggregation named {$name}."); }
[ "public", "function", "getAggregation", "(", "$", "name", ")", "{", "$", "data", "=", "$", "this", "->", "_response", "->", "getData", "(", ")", ";", "if", "(", "isset", "(", "$", "data", "[", "'aggregations'", "]", ")", "&&", "isset", "(", "$", "data", "[", "'aggregations'", "]", "[", "$", "name", "]", ")", ")", "{", "return", "$", "data", "[", "'aggregations'", "]", "[", "$", "name", "]", ";", "}", "throw", "new", "InvalidException", "(", "\"This result set does not contain an aggregation named {$name}.\"", ")", ";", "}" ]
Retrieve a specific aggregation from this result set. @param string $name the name of the desired aggregation @throws Exception\InvalidException if an aggregation by the given name cannot be found @return array
[ "Retrieve", "a", "specific", "aggregation", "from", "this", "result", "set", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/ResultSet.php#L141-L149
train
ruflin/Elastica
lib/Elastica/Query/Prefix.php
Prefix.setPrefix
public function setPrefix(string $key, $value, float $boost = 1.0): self { return $this->setRawPrefix([$key => ['value' => $value, 'boost' => $boost]]); }
php
public function setPrefix(string $key, $value, float $boost = 1.0): self { return $this->setRawPrefix([$key => ['value' => $value, 'boost' => $boost]]); }
[ "public", "function", "setPrefix", "(", "string", "$", "key", ",", "$", "value", ",", "float", "$", "boost", "=", "1.0", ")", ":", "self", "{", "return", "$", "this", "->", "setRawPrefix", "(", "[", "$", "key", "=>", "[", "'value'", "=>", "$", "value", ",", "'boost'", "=>", "$", "boost", "]", "]", ")", ";", "}" ]
Adds a prefix to the prefix query. @param string $key Key to query @param string|array $value Values(s) for the query. Boost can be set with array @param float $boost OPTIONAL Boost value (default = 1.0) @return $this
[ "Adds", "a", "prefix", "to", "the", "prefix", "query", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Query/Prefix.php#L44-L47
train
ruflin/Elastica
lib/Elastica/QueryBuilder/DSL/Aggregation.php
Aggregation.sum_bucket
public function sum_bucket(string $name, string $bucketsPath = null): SumBucket { return new SumBucket($name, $bucketsPath); }
php
public function sum_bucket(string $name, string $bucketsPath = null): SumBucket { return new SumBucket($name, $bucketsPath); }
[ "public", "function", "sum_bucket", "(", "string", "$", "name", ",", "string", "$", "bucketsPath", "=", "null", ")", ":", "SumBucket", "{", "return", "new", "SumBucket", "(", "$", "name", ",", "$", "bucketsPath", ")", ";", "}" ]
sum bucket aggregation. @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-sum-bucket-aggregation.html @param string $name @param string|null $bucketsPath @return SumBucket
[ "sum", "bucket", "aggregation", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/QueryBuilder/DSL/Aggregation.php#L110-L113
train
ruflin/Elastica
lib/Elastica/QueryBuilder/DSL/Aggregation.php
Aggregation.avg_bucket
public function avg_bucket(string $name, string $bucketsPath = null): AvgBucket { return new AvgBucket($name, $bucketsPath); }
php
public function avg_bucket(string $name, string $bucketsPath = null): AvgBucket { return new AvgBucket($name, $bucketsPath); }
[ "public", "function", "avg_bucket", "(", "string", "$", "name", ",", "string", "$", "bucketsPath", "=", "null", ")", ":", "AvgBucket", "{", "return", "new", "AvgBucket", "(", "$", "name", ",", "$", "bucketsPath", ")", ";", "}" ]
avg bucket aggregation. @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-avg-bucket-aggregation.html @param string $name @param string|null $bucketsPath @return AvgBucket
[ "avg", "bucket", "aggregation", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/QueryBuilder/DSL/Aggregation.php#L139-L142
train
ruflin/Elastica
lib/Elastica/QueryBuilder/DSL/Aggregation.php
Aggregation.percentiles
public function percentiles(string $name, string $field = null): Percentiles { return new Percentiles($name, $field); }
php
public function percentiles(string $name, string $field = null): Percentiles { return new Percentiles($name, $field); }
[ "public", "function", "percentiles", "(", "string", "$", "name", ",", "string", "$", "field", "=", "null", ")", ":", "Percentiles", "{", "return", "new", "Percentiles", "(", "$", "name", ",", "$", "field", ")", ";", "}" ]
percentiles aggregation. @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-percentile-aggregation.html @param string $name the name of this aggregation @param string $field the field on which to perform this aggregation @return Percentiles
[ "percentiles", "aggregation", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/QueryBuilder/DSL/Aggregation.php#L197-L200
train
ruflin/Elastica
lib/Elastica/QueryBuilder/DSL/Aggregation.php
Aggregation.scripted_metric
public function scripted_metric( string $name, string $initScript = null, string $mapScript = null, string $combineScript = null, string $reduceScript = null ): ScriptedMetric { return new ScriptedMetric($name, $initScript, $mapScript, $combineScript, $reduceScript); }
php
public function scripted_metric( string $name, string $initScript = null, string $mapScript = null, string $combineScript = null, string $reduceScript = null ): ScriptedMetric { return new ScriptedMetric($name, $initScript, $mapScript, $combineScript, $reduceScript); }
[ "public", "function", "scripted_metric", "(", "string", "$", "name", ",", "string", "$", "initScript", "=", "null", ",", "string", "$", "mapScript", "=", "null", ",", "string", "$", "combineScript", "=", "null", ",", "string", "$", "reduceScript", "=", "null", ")", ":", "ScriptedMetric", "{", "return", "new", "ScriptedMetric", "(", "$", "name", ",", "$", "initScript", ",", "$", "mapScript", ",", "$", "combineScript", ",", "$", "reduceScript", ")", ";", "}" ]
scripted metric aggregation. @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-scripted-metric-aggregation.html @param string $name @param string|null $initScript @param string|null $mapScript @param string|null $combineScript @param string|null $reduceScript @return ScriptedMetric
[ "scripted", "metric", "aggregation", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/QueryBuilder/DSL/Aggregation.php#L267-L275
train
ruflin/Elastica
lib/Elastica/QueryBuilder/DSL/Aggregation.php
Aggregation.filter
public function filter(string $name, AbstractQuery $filter = null): Filter { return new Filter($name, $filter); }
php
public function filter(string $name, AbstractQuery $filter = null): Filter { return new Filter($name, $filter); }
[ "public", "function", "filter", "(", "string", "$", "name", ",", "AbstractQuery", "$", "filter", "=", "null", ")", ":", "Filter", "{", "return", "new", "Filter", "(", "$", "name", ",", "$", "filter", ")", ";", "}" ]
filter aggregation. @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filter-aggregation.html @param string $name @param AbstractQuery $filter @return Filter
[ "filter", "aggregation", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/QueryBuilder/DSL/Aggregation.php#L301-L304
train
ruflin/Elastica
lib/Elastica/QueryBuilder/DSL/Aggregation.php
Aggregation.reverse_nested
public function reverse_nested(string $name, string $path = null): ReverseNested { return new ReverseNested($name, $path); }
php
public function reverse_nested(string $name, string $path = null): ReverseNested { return new ReverseNested($name, $path); }
[ "public", "function", "reverse_nested", "(", "string", "$", "name", ",", "string", "$", "path", "=", "null", ")", ":", "ReverseNested", "{", "return", "new", "ReverseNested", "(", "$", "name", ",", "$", "path", ")", ";", "}" ]
reverse nested aggregation. @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html @param string $name The name of this aggregation @param string $path Optional path to the nested object for this aggregation. Defaults to the root of the main document. @return ReverseNested
[ "reverse", "nested", "aggregation", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/QueryBuilder/DSL/Aggregation.php#L360-L363
train
ruflin/Elastica
lib/Elastica/QueryBuilder/DSL/Aggregation.php
Aggregation.histogram
public function histogram(string $name, string $field, $interval): Histogram { return new Histogram($name, $field, $interval); }
php
public function histogram(string $name, string $field, $interval): Histogram { return new Histogram($name, $field, $interval); }
[ "public", "function", "histogram", "(", "string", "$", "name", ",", "string", "$", "field", ",", "$", "interval", ")", ":", "Histogram", "{", "return", "new", "Histogram", "(", "$", "name", ",", "$", "field", ",", "$", "interval", ")", ";", "}" ]
histogram aggregation. @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-histogram-aggregation.html @param string $name the name of this aggregation @param string $field the name of the field on which to perform the aggregation @param int $interval the interval by which documents will be bucketed @return Histogram
[ "histogram", "aggregation", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/QueryBuilder/DSL/Aggregation.php#L459-L462
train
ruflin/Elastica
lib/Elastica/QueryBuilder/DSL/Aggregation.php
Aggregation.date_histogram
public function date_histogram(string $name, string $field, $interval): DateHistogram { return new DateHistogram($name, $field, $interval); }
php
public function date_histogram(string $name, string $field, $interval): DateHistogram { return new DateHistogram($name, $field, $interval); }
[ "public", "function", "date_histogram", "(", "string", "$", "name", ",", "string", "$", "field", ",", "$", "interval", ")", ":", "DateHistogram", "{", "return", "new", "DateHistogram", "(", "$", "name", ",", "$", "field", ",", "$", "interval", ")", ";", "}" ]
date histogram aggregation. @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html @param string $name the name of this aggregation @param string $field the name of the field on which to perform the aggregation @param int|string $interval the interval by which documents will be bucketed @return DateHistogram
[ "date", "histogram", "aggregation", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/QueryBuilder/DSL/Aggregation.php#L475-L478
train
ruflin/Elastica
lib/Elastica/QueryBuilder/DSL/Aggregation.php
Aggregation.geo_distance
public function geo_distance(string $name, string $field, $origin): GeoDistance { return new GeoDistance($name, $field, $origin); }
php
public function geo_distance(string $name, string $field, $origin): GeoDistance { return new GeoDistance($name, $field, $origin); }
[ "public", "function", "geo_distance", "(", "string", "$", "name", ",", "string", "$", "field", ",", "$", "origin", ")", ":", "GeoDistance", "{", "return", "new", "GeoDistance", "(", "$", "name", ",", "$", "field", ",", "$", "origin", ")", ";", "}" ]
geo distance aggregation. @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geodistance-aggregation.html @param string $name the name if this aggregation @param string $field the field on which to perform this aggregation @param string|array $origin the point from which distances will be calculated @return GeoDistance
[ "geo", "distance", "aggregation", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/QueryBuilder/DSL/Aggregation.php#L491-L494
train
ruflin/Elastica
lib/Elastica/QueryBuilder/DSL/Aggregation.php
Aggregation.bucket_script
public function bucket_script(string $name, array $bucketsPath = null, string $script = null): BucketScript { return new BucketScript($name, $bucketsPath, $script); }
php
public function bucket_script(string $name, array $bucketsPath = null, string $script = null): BucketScript { return new BucketScript($name, $bucketsPath, $script); }
[ "public", "function", "bucket_script", "(", "string", "$", "name", ",", "array", "$", "bucketsPath", "=", "null", ",", "string", "$", "script", "=", "null", ")", ":", "BucketScript", "{", "return", "new", "BucketScript", "(", "$", "name", ",", "$", "bucketsPath", ",", "$", "script", ")", ";", "}" ]
bucket script aggregation. @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-bucket-script-aggregation.html @param string $name @param array|null $bucketsPath @param string|null $script @return BucketScript
[ "bucket", "script", "aggregation", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/QueryBuilder/DSL/Aggregation.php#L522-L525
train
ruflin/Elastica
lib/Elastica/QueryBuilder/DSL/Aggregation.php
Aggregation.serial_diff
public function serial_diff(string $name, string $bucketsPath = null): SerialDiff { return new SerialDiff($name, $bucketsPath); }
php
public function serial_diff(string $name, string $bucketsPath = null): SerialDiff { return new SerialDiff($name, $bucketsPath); }
[ "public", "function", "serial_diff", "(", "string", "$", "name", ",", "string", "$", "bucketsPath", "=", "null", ")", ":", "SerialDiff", "{", "return", "new", "SerialDiff", "(", "$", "name", ",", "$", "bucketsPath", ")", ";", "}" ]
serial diff aggregation. @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-serialdiff-aggregation.html @param string $name @param string|null $bucketsPath @return SerialDiff
[ "serial", "diff", "aggregation", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/QueryBuilder/DSL/Aggregation.php#L537-L540
train
ruflin/Elastica
lib/Elastica/Query/MoreLikeThis.php
MoreLikeThis.setAnalyzer
public function setAnalyzer(string $analyzer): self { $analyzer = \trim($analyzer); return $this->setParam('analyzer', $analyzer); }
php
public function setAnalyzer(string $analyzer): self { $analyzer = \trim($analyzer); return $this->setParam('analyzer', $analyzer); }
[ "public", "function", "setAnalyzer", "(", "string", "$", "analyzer", ")", ":", "self", "{", "$", "analyzer", "=", "\\", "trim", "(", "$", "analyzer", ")", ";", "return", "$", "this", "->", "setParam", "(", "'analyzer'", ",", "$", "analyzer", ")", ";", "}" ]
Set analyzer. @param string $analyzer @return $this
[ "Set", "analyzer", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Query/MoreLikeThis.php#L141-L146
train
ruflin/Elastica
lib/Elastica/Transport/Http.php
Http._setupCurl
protected function _setupCurl($curlConnection) { if ($this->getConnection()->hasConfig('curl')) { foreach ($this->getConnection()->getConfig('curl') as $key => $param) { \curl_setopt($curlConnection, $key, $param); } } }
php
protected function _setupCurl($curlConnection) { if ($this->getConnection()->hasConfig('curl')) { foreach ($this->getConnection()->getConfig('curl') as $key => $param) { \curl_setopt($curlConnection, $key, $param); } } }
[ "protected", "function", "_setupCurl", "(", "$", "curlConnection", ")", "{", "if", "(", "$", "this", "->", "getConnection", "(", ")", "->", "hasConfig", "(", "'curl'", ")", ")", "{", "foreach", "(", "$", "this", "->", "getConnection", "(", ")", "->", "getConfig", "(", "'curl'", ")", "as", "$", "key", "=>", "$", "param", ")", "{", "\\", "curl_setopt", "(", "$", "curlConnection", ",", "$", "key", ",", "$", "param", ")", ";", "}", "}", "}" ]
Called to add additional curl params. @param resource $curlConnection Curl connection
[ "Called", "to", "add", "additional", "curl", "params", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Transport/Http.php#L202-L209
train
ruflin/Elastica
lib/Elastica/Transport/Http.php
Http._getConnection
protected function _getConnection(bool $persistent = true) { if (!$persistent || !self::$_curlConnection) { self::$_curlConnection = \curl_init(); } return self::$_curlConnection; }
php
protected function _getConnection(bool $persistent = true) { if (!$persistent || !self::$_curlConnection) { self::$_curlConnection = \curl_init(); } return self::$_curlConnection; }
[ "protected", "function", "_getConnection", "(", "bool", "$", "persistent", "=", "true", ")", "{", "if", "(", "!", "$", "persistent", "||", "!", "self", "::", "$", "_curlConnection", ")", "{", "self", "::", "$", "_curlConnection", "=", "\\", "curl_init", "(", ")", ";", "}", "return", "self", "::", "$", "_curlConnection", ";", "}" ]
Return Curl resource. @param bool $persistent False if not persistent connection @return resource Connection resource
[ "Return", "Curl", "resource", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Transport/Http.php#L218-L225
train
ruflin/Elastica
lib/Elastica/Task.php
Task.refresh
public function refresh(array $options = []) { $endpoint = new \Elasticsearch\Endpoints\Tasks\Get(); $endpoint->setTaskId($this->_id); $endpoint->setParams($options); $this->_response = $this->_client->requestEndpoint($endpoint); $this->_data = $this->getResponse()->getData(); }
php
public function refresh(array $options = []) { $endpoint = new \Elasticsearch\Endpoints\Tasks\Get(); $endpoint->setTaskId($this->_id); $endpoint->setParams($options); $this->_response = $this->_client->requestEndpoint($endpoint); $this->_data = $this->getResponse()->getData(); }
[ "public", "function", "refresh", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "endpoint", "=", "new", "\\", "Elasticsearch", "\\", "Endpoints", "\\", "Tasks", "\\", "Get", "(", ")", ";", "$", "endpoint", "->", "setTaskId", "(", "$", "this", "->", "_id", ")", ";", "$", "endpoint", "->", "setParams", "(", "$", "options", ")", ";", "$", "this", "->", "_response", "=", "$", "this", "->", "_client", "->", "requestEndpoint", "(", "$", "endpoint", ")", ";", "$", "this", "->", "_data", "=", "$", "this", "->", "getResponse", "(", ")", "->", "getData", "(", ")", ";", "}" ]
Refresh task status. @param array $options Options for endpoint
[ "Refresh", "task", "status", "." ]
9bda1596f79a28534dfd7b3513443478ad152e4e
https://github.com/ruflin/Elastica/blob/9bda1596f79a28534dfd7b3513443478ad152e4e/lib/Elastica/Task.php#L93-L101
train