_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q19800
CacheManager.startProd
train
public static function startProd(&$config) { self::$cacheDirectory = self::initialGetCacheDirectory ( $config ); $cacheDirectory = \ROOT . \DS . self::$cacheDirectory; self::getCacheInstance ( $config, $cacheDirectory, ".cache" ); }
php
{ "resource": "" }
q19801
CacheManager.checkCache
train
public static function checkCache(&$config, $silent = false) { $dirs = self::getCacheDirectories ( $config, $silent ); foreach ( $dirs as $dir ) { self::safeMkdir ( $dir ); } return $dirs; }
php
{ "resource": "" }
q19802
CacheManager.clearCache
train
public static function clearCache(&$config, $type = "all") { $cacheDirectories = self::checkCache ( $config ); $cacheDirs = [ "annotations","controllers","models","queries","views","contents" ]; foreach ( $cacheDirs as $typeRef ) { self::_clearCache ( $cacheDirectories, $type, $typeRef ); } }
php
{ "resource": "" }
q19803
UGitRepository.getModifiedFiles
train
public function getModifiedFiles() { try { return $this->extractFromCommand ( 'git diff --name-status HEAD', function ($array) { $array = trim ( preg_replace ( '!\s+!', ' ', $array ) ); return explode ( ' ', $array ); } ); } catch ( \Cz\Git\GitException $e ) { return [ ]; } }
php
{ "resource": "" }
q19804
UGitRepository.getRemoteUrl
train
public function getRemoteUrl() { try { $values = $this->extractFromCommand ( 'git config --get remote.origin.url', function ($str) { return trim ( $str ); } ); if (isset ( $values )) { return implode ( " ", $values ); } } catch ( \Cz\Git\GitException $e ) { return ""; } return ""; }
php
{ "resource": "" }
q19805
RestBaseController._get
train
public function _get($condition = "1=1", $include = false, $useCache = false) { try { $condition = $this->getCondition ( $condition ); $include = $this->getInclude ( $include ); $useCache = UString::isBooleanTrue ( $useCache ); $datas = DAO::getAll ( $this->model, $condition, $include, null, $useCache ); ...
php
{ "resource": "" }
q19806
AssetsManager.getUrl
train
public static function getUrl($resource, $absolute = false) { if (strpos ( $resource, '//' ) !== false) { return $resource; } if ($absolute) { return self::$siteURL . self::ASSETS_FOLDER . $resource; } return ltrim ( self::ASSETS_FOLDER, '/' ) . $resource; }
php
{ "resource": "" }
q19807
AssetsManager.getThemeUrl
train
public static function getThemeUrl($theme, $resource, $absolute = false) { if ($absolute) { return self::$siteURL . self::ASSETS_FOLDER . $theme . '/' . $resource; } return ltrim ( self::ASSETS_FOLDER, '/' ) . $theme . '/' . $resource; }
php
{ "resource": "" }
q19808
AssetsManager.js
train
public static function js($resource, $attributes = [], $absolute = false) { return self::script ( self::getUrl ( $resource, $absolute ), $attributes ); }
php
{ "resource": "" }
q19809
AssetsManager.css
train
public static function css($resource, $attributes = [], $absolute = false) { return self::stylesheet ( self::getUrl ( $resource, $absolute ), $attributes ); }
php
{ "resource": "" }
q19810
RestServer.connect
train
public function connect() { if (! isset ( $this->apiTokens )) { $this->apiTokens = $this->_loadApiTokens (); } $token = $this->apiTokens->addToken (); $this->_addHeaderToken ( $token ); return [ "access_token" => $token,"token_type" => "Bearer","expires_in" => $this->apiTokens->getDuration () ]; }
php
{ "resource": "" }
q19811
Controller.redirectToRoute
train
public function redirectToRoute($routeName, $parameters = [], $initialize = false, $finalize = false) { $path = Router::getRouteByName ( $routeName, $parameters ); if ($path !== false) { $route = Router::getRoute ( $path, false ); if ($route !== false) { $this->forward ( $route [0], $route [1], \array_sli...
php
{ "resource": "" }
q19812
Database.connect
train
public function connect() { try { $this->_connect (); return true; } catch ( \PDOException $e ) { throw new DBException ( $e->getMessage (), $e->getCode (), $e->getPrevious () ); } }
php
{ "resource": "" }
q19813
RestController.get
train
public function get($condition = "1=1", $included = false, $useCache = false) { $this->_get ( $condition, $included, $useCache ); }
php
{ "resource": "" }
q19814
AuthControllerOverrideTrait.rememberMe
train
protected function rememberMe($connected){ $id= $this->toCookie($connected); if(isset($id)){ UCookie::set($this->_getUserSessionKey(),$id); } }
php
{ "resource": "" }
q19815
UFileSystem.safeMkdir
train
public static function safeMkdir($dir, $mode = 0777, $recursive = true) { if (! \is_dir ( $dir )) return \mkdir ( $dir, $mode, $recursive ); return true; }
php
{ "resource": "" }
q19816
UFileSystem.cleanPathname
train
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 ....
php
{ "resource": "" }
q19817
UFileSystem.cleanFilePathname
train
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
{ "resource": "" }
q19818
UFileSystem.getLines
train
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; $...
php
{ "resource": "" }
q19819
DiManager.init
train
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 = $parse...
php
{ "resource": "" }
q19820
UArray.save
train
public static function save($array, $filename) { $content = "<?php\nreturn " . self::asPhpArray ( $array, "array", 1, true ) . ";"; return UFileSystem::save ( $filename, $content ); }
php
{ "resource": "" }
q19821
Router.getRoute
train
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 ( "@^"...
php
{ "resource": "" }
q19822
Router.url
train
public static function url($name, $parameters = []) { return URequest::getUrl ( self::getRouteByName ( $name, $parameters, false ) ); }
php
{ "resource": "" }
q19823
Router.slashPath
train
public static function slashPath($path) { if (UString::startswith ( $path, "/" ) === false) $path = "/" . $path; if (! UString::endswith ( $path, "/" )) $path = $path . "/"; return $path; }
php
{ "resource": "" }
q19824
ValidatorsManager.validate
train
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 = sel...
php
{ "resource": "" }
q19825
ValidatorsManager.validateInstances
train
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::ini...
php
{ "resource": "" }
q19826
ModelsCacheTrait.getModels
train
public static function getModels(&$config, $silent = false) { $result = [ ]; $files = self::getModelsFiles ( $config, $silent ); foreach ( $files as $file ) { $result [] = ClassUtils::getClassFullNameFromFile ( $file ); } return $result; }
php
{ "resource": "" }
q19827
CRUDController.refresh_
train
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 ( $m...
php
{ "resource": "" }
q19828
CRUDController.edit
train
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
{ "resource": "" }
q19829
CRUDController.newModel
train
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
{ "resource": "" }
q19830
CRUDController.display
train
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 ( "....
php
{ "resource": "" }
q19831
CRUDController.delete
train
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>" . $instanceStr...
php
{ "resource": "" }
q19832
CRUDController.update
train
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->se...
php
{ "resource": "" }
q19833
CRUDController.showDetail
train
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 (); $gr...
php
{ "resource": "" }
q19834
ResponseFormatter.getDatas
train
public function getDatas($objects, &$classname = null) { $objects = \array_map ( function ($o) use (&$classname) { return $this->cleanRestObject ( $o, $classname ); }, $objects ); return \array_values ( $objects ); }
php
{ "resource": "" }
q19835
DAO.connect
train
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 $...
php
{ "resource": "" }
q19836
DAO.isConnected
train
public static function isConnected() { return self::$db !== null && (self::$db instanceof Database) && self::$db->isConnected (); }
php
{ "resource": "" }
q19837
ClassUtils.getNamespaceFromParts
train
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...
php
{ "resource": "" }
q19838
ClassUtils.getClassNameWithNS
train
public static function getClassNameWithNS($defaultNS, $name) { if (\strpos ( $name, "\\" ) === false) { $name = $defaultNS . "\\" . $name; } return $name; }
php
{ "resource": "" }
q19839
UResponse.setContentType
train
public static function setContentType($contentType, $encoding = null) { $value = $contentType; if (isset ( $encoding )) $value .= ' ;charset=' . $encoding; self::header ( 'Content-Type', $value ); }
php
{ "resource": "" }
q19840
USession.addOrRemoveValueFromArray
train
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) ...
php
{ "resource": "" }
q19841
USession.setBoolean
train
public static function setBoolean($key, $value) { $_SESSION [$key] = UString::isBooleanTrue ( $value ); return $_SESSION [$key]; }
php
{ "resource": "" }
q19842
USession.getBoolean
train
public static function getBoolean($key) { self::start (); $ret = false; if (isset ( $_SESSION [$key] )) { $ret = UString::isBooleanTrue ( $_SESSION [$key] ); } return $ret; }
php
{ "resource": "" }
q19843
USession.inc
train
public static function inc($key, $inc = 1) { return self::set ( $key, self::get ( $key, 0 ) + $inc ); }
php
{ "resource": "" }
q19844
USession.dec
train
public static function dec($key, $dec = 1) { return self::set ( $key, self::get ( $key, 0 ) - $dec ); }
php
{ "resource": "" }
q19845
USession.concat
train
public static function concat($key, $str, $default = NULL) { return self::set ( $key, self::get ( $key, $default ) . $str ); }
php
{ "resource": "" }
q19846
USession.apply
train
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 $v...
php
{ "resource": "" }
q19847
USession.Walk
train
public static function Walk($callback, $userData = null) { self::start (); array_walk ( $_SESSION, $callback, $userData ); return $_SESSION; }
php
{ "resource": "" }
q19848
USession.start
train
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
{ "resource": "" }
q19849
USession.init
train
public static function init($key, $value) { if (! isset ( $_SESSION [$key] )) { $_SESSION [$key] = $value; } return $_SESSION [$key]; }
php
{ "resource": "" }
q19850
USession.terminate
train
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"],...
php
{ "resource": "" }
q19851
JsonApiResponseFormatter.addPageLinks
train
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,'pageS...
php
{ "resource": "" }
q19852
CRUDControllerUtilitiesTrait._deleteMultiple
train
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", "Dele...
php
{ "resource": "" }
q19853
ValidatorsManagerInitTrait.initModelsValidators
train
public static function initModelsValidators(&$config) { $models = CacheManager::getModels ( $config, true ); foreach ( $models as $model ) { self::initClassValidators ( $model ); } }
php
{ "resource": "" }
q19854
ModelViewer.getForm
train
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...
php
{ "resource": "" }
q19855
ModelViewer.getFormTitle
train
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" => "Ed...
php
{ "resource": "" }
q19856
ModelViewer.getModelDataElement
train
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->get...
php
{ "resource": "" }
q19857
ModelViewer.getModelDataTable
train
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 ()->get...
php
{ "resource": "" }
q19858
ModelViewer.getDataTableInstance
train
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 ( $grpByFiel...
php
{ "resource": "" }
q19859
ThemesManager.setActiveTheme
train
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 a...
php
{ "resource": "" }
q19860
ThemesManager.getAvailableThemes
train
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
{ "resource": "" }
q19861
URequest.getDatas
train
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 (); ...
php
{ "resource": "" }
q19862
URequest.getBoolean
train
public static function getBoolean($key) { $ret = false; if (isset ( $_REQUEST [$key] )) { $ret = UString::isBooleanTrue ( $_REQUEST [$key] ); } return $ret; }
php
{ "resource": "" }
q19863
URequest.getOrigin
train
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 ...
php
{ "resource": "" }
q19864
PhpFastCacheDriver.fetch
train
public function fetch($key) { $result = $this->cacheInstance->getItem ( $this->getRealKey ( $key ) )->get (); return eval ( $result ); }
php
{ "resource": "" }
q19865
UCookie.set
train
public static function set($name, $value, $duration = 60*60*24, $path = "/", $secure = false, $httpOnly = false) { \setcookie ( $name, $value, \time () + $duration, $path, $secure, $httpOnly ); }
php
{ "resource": "" }
q19866
UCookie.deleteAll
train
public static function deleteAll($path = "/") { foreach ( $_COOKIE as $name => $value ) { self::delete ( $name, $path ); } }
php
{ "resource": "" }
q19867
UCookie.setRaw
train
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
{ "resource": "" }
q19868
UString.pluralize
train
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
{ "resource": "" }
q19869
Client.get
train
public function get($url, array $params = []) { $queryString = '?' . http_build_query($params); $url = $url . $queryString; $request = new Request( $url, 'GET' ); return $this->send($request); }
php
{ "resource": "" }
q19870
Verification.check
train
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
{ "resource": "" }
q19871
Verification.getChecks
train
public function getChecks() { $checks = $this->proxyArrayAccess('checks'); if(!$checks){ return []; } foreach($checks as $i => $check) { $checks[$i] = new Check($check); } return $checks; }
php
{ "resource": "" }
q19872
Call.lazyLoad
train
protected function lazyLoad() { if(!empty($this->data)){ return true; } if(isset($this->id)){ $this->get($this); return true; } return false; }
php
{ "resource": "" }
q19873
Index.getShards
train
public function getShards(): array { $shards = []; foreach ($this->_data['shards'] as $shardNumber => $shard) { $shards[] = new Shard($shardNumber, $shard); } return $shards; }
php
{ "resource": "" }
q19874
FunctionScore.addFunction
train
public function addFunction( string $functionType, $functionParams, AbstractQuery $filter = null, float $weight = null ): self { $function = [ $functionType => $functionParams, ]; if (null !== $filter) { $function['filter'] = $filter; ...
php
{ "resource": "" }
q19875
FunctionScore.addScriptScoreFunction
train
public function addScriptScoreFunction(AbstractScript $script, AbstractQuery $filter = null, float $weight = null) { return $this->addFunction('script_score', $script, $filter, $weight); }
php
{ "resource": "" }
q19876
FunctionScore.addDecayFunction
train
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 ) { $functio...
php
{ "resource": "" }
q19877
FunctionScore.addRandomScoreFunction
train
public function addRandomScoreFunction( int $seed, AbstractQuery $filter = null, float $weight = null, string $field = null ): self { $functionParams = [ 'seed' => $seed, ]; if (null !== $field) { $functionParams['field'] = $field; ...
php
{ "resource": "" }
q19878
FunctionScore.setRandomScore
train
public function setRandomScore(int $seed = null): self { $seedParam = new \stdClass(); if (null !== $seed) { $seedParam->seed = $seed; } return $this->setParam('random_score', $seedParam); }
php
{ "resource": "" }
q19879
Phrase.setHighlight
train
public function setHighlight(string $preTag, string $postTag): Phrase { return $this->setParam('highlight', [ 'pre_tag' => $preTag, 'post_tag' => $postTag, ]); }
php
{ "resource": "" }
q19880
Scroll.next
train
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(...
php
{ "resource": "" }
q19881
Scroll.rewind
train
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...
php
{ "resource": "" }
q19882
Scroll.clear
train
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() r...
php
{ "resource": "" }
q19883
Scroll._setScrollId
train
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...
php
{ "resource": "" }
q19884
Scroll._saveOptions
train
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->getOpt...
php
{ "resource": "" }
q19885
Scroll._revertOptions
train
protected function _revertOptions() { $this->_search->setOption(Search::OPTION_SCROLL, $this->_options[0]); $this->_search->setOption(Search::OPTION_SCROLL_ID, $this->_options[1]); }
php
{ "resource": "" }
q19886
Search.addIndex
train
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
{ "resource": "" }
q19887
Search.addType
train
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
{ "resource": "" }
q19888
Search.getPath
train
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)) { ...
php
{ "resource": "" }
q19889
Search.search
train
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. i...
php
{ "resource": "" }
q19890
Ids.setIds
train
public function setIds($ids): self { if (\is_array($ids)) { $this->_params['values'] = $ids; } else { $this->_params['values'] = [$ids]; } return $this; }
php
{ "resource": "" }
q19891
Status.getIndicesWithAlias
train
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 exi...
php
{ "resource": "" }
q19892
ResponseException.getElasticsearchException
train
public function getElasticsearchException(): ElasticsearchException { $response = $this->getResponse(); return new ElasticsearchException($response->getStatus(), $response->getErrorMessage()); }
php
{ "resource": "" }
q19893
AbstractType.create
train
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
{ "resource": "" }
q19894
AbstractType.search
train
public function search($query = '', $options = null): ResultSet { return $this->getType()->search($query, $options = null); }
php
{ "resource": "" }
q19895
Percentiles.setHdr
train
public function setHdr(string $key, float $value): self { $compression = [$key => $value]; return $this->setParam('hdr', $compression); }
php
{ "resource": "" }
q19896
SpanTerm.setTerm
train
public function setTerm(string $key, $value, float $boost = 1.0): self { return $this->setRawTerm([$key => ['value' => $value, 'boost' => $boost]]); }
php
{ "resource": "" }
q19897
ResultSet.getAggregation
train
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 name...
php
{ "resource": "" }
q19898
Prefix.setPrefix
train
public function setPrefix(string $key, $value, float $boost = 1.0): self { return $this->setRawPrefix([$key => ['value' => $value, 'boost' => $boost]]); }
php
{ "resource": "" }
q19899
Aggregation.sum_bucket
train
public function sum_bucket(string $name, string $bucketsPath = null): SumBucket { return new SumBucket($name, $bucketsPath); }
php
{ "resource": "" }