idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
50,000
protected function bootComponentDrivers ( ) { $ this -> addRedisSentinelBroadcaster ( ) ; $ this -> addRedisSentinelCacheStore ( ) ; if ( ! $ this -> config -> shouldIntegrateHorizon ) { $ this -> addRedisSentinelQueueConnector ( ) ; } if ( $ this -> config -> supportsSessions ) { $ this -> addRedisSentinelSessionHandler ( ) ; } }
Extend each of the Laravel services this package supports with the corresponding redis - sentinel driver .
50,001
protected function removeDeferredRedisServices ( ) { if ( $ this -> config -> isLumen ) { return ; } $ deferredServices = $ this -> app -> getDeferredServices ( ) ; unset ( $ deferredServices [ 'redis' ] ) ; unset ( $ deferredServices [ 'redis.connection' ] ) ; $ this -> app -> setDeferredServices ( $ deferredServices ) ; }
Remove the standard Laravel Redis service from the bound deferred services so they don t overwrite Redis Sentinel registrations .
50,002
protected function addRedisSentinelBroadcaster ( ) { $ this -> app -> make ( BroadcastFactory :: class ) -> extend ( 'redis-sentinel' , function ( $ app , $ conf ) { $ redis = $ app -> make ( 'redis-sentinel.manager' ) ; $ connection = Arr :: get ( $ conf , 'connection' , 'default' ) ; return new RedisBroadcaster ( $ redis , $ connection ) ; } ) ; }
Add redis - sentinel as an available broadcaster option to the Laravel event broadcasting manager .
50,003
protected function addRedisSentinelCacheStore ( ) { $ cache = $ this -> app -> make ( 'cache' ) ; $ cache -> extend ( 'redis-sentinel' , function ( $ app , $ conf ) use ( $ cache ) { $ redis = $ app -> make ( 'redis-sentinel.manager' ) ; $ prefix = $ app -> make ( 'config' ) -> get ( 'cache.prefix' ) ; $ connection = Arr :: get ( $ conf , 'connection' , 'default' ) ; $ store = new RedisStore ( $ redis , $ prefix , $ connection ) ; return $ cache -> repository ( $ store ) ; } ) ; }
Add redis - sentinel as an available cache store option to the Laravel cache manager .
50,004
protected function addRedisSentinelSessionHandler ( ) { $ this -> app -> make ( 'session' ) -> extend ( 'redis-sentinel' , function ( $ app ) { $ cacheDriver = clone $ app -> make ( 'cache' ) -> driver ( 'redis-sentinel' ) ; $ minutes = $ this -> config -> get ( 'session.lifetime' ) ; $ connection = $ this -> config -> get ( 'session.connection' ) ; $ cacheDriver -> getStore ( ) -> setConnection ( $ connection ) ; return new CacheBasedSessionHandler ( $ cacheDriver , $ minutes ) ; } ) ; }
Add redis - sentinel as an available driver option to the Laravel session manager .
50,005
protected function addRedisSentinelQueueConnector ( ) { $ this -> app -> make ( 'queue' ) -> extend ( 'redis-sentinel' , function ( ) { $ redis = $ this -> app -> make ( 'redis-sentinel.manager' ) ; return new RedisConnector ( $ redis ) ; } ) ; }
Add redis - sentinel as an available queue connection driver option to the Laravel queue manager .
50,006
public function connect ( array $ server , array $ options = [ ] ) { $ clientOpts = array_merge ( $ options , Arr :: pull ( $ server , 'options' , [ ] ) ) ; $ clientOpts [ 'replication' ] = 'sentinel' ; $ sentinelOpts = array_intersect_key ( $ clientOpts , $ this -> sentinelKeys ) ; $ clientOpts = array_diff_key ( $ clientOpts , $ this -> sentinelKeys ) ; return new PredisConnection ( new Client ( $ server , $ clientOpts ) , $ sentinelOpts ) ; }
Create a new Redis Sentinel connection from the provided configuration options
50,007
public function setRetryLimit ( $ attempts ) { $ this -> retryLimit = ( int ) $ attempts ; $ this -> client -> getConnection ( ) -> setRetryLimit ( $ attempts ) ; return $ this ; }
Set the default number of attempts to retry a command when the client fails to connect to a Redis instance behind Sentinel .
50,008
public function setRetryWait ( $ milliseconds ) { $ this -> retryWait = ( int ) $ milliseconds ; $ this -> client -> getConnection ( ) -> setRetryWait ( $ milliseconds ) ; return $ this ; }
Set the time to wait before retrying a command after a connection attempt failed .
50,009
protected function retryOnFailure ( callable $ callback ) { $ attempts = 0 ; do { try { return $ callback ( ) ; } catch ( CommunicationException $ exception ) { $ exception -> getConnection ( ) -> disconnect ( ) ; $ this -> client -> getConnection ( ) -> querySentinel ( ) ; usleep ( $ this -> retryWait * 1000 ) ; $ attempts ++ ; } } while ( $ attempts <= $ this -> retryLimit ) ; throw $ exception ; }
Attempt to retry the provided operation when the client fails to connect to a Redis server .
50,010
protected function getRandomSlave ( $ fallbackToMaster = true ) { $ slaves = $ this -> client -> getConnection ( ) -> getSlaves ( ) ; if ( count ( $ slaves ) > 0 ) { $ slave = $ slaves [ rand ( 1 , count ( $ slaves ) ) - 1 ] ; return $ this -> client -> getClientFor ( $ slave -> getParameters ( ) -> alias ) ; } if ( $ fallbackToMaster ) { return $ this -> getMaster ( ) ; } throw new RuntimeException ( 'No slave present on connection.' ) ; }
Get a Predis client instance for a random slave .
50,011
public function loadConfiguration ( ) { if ( $ this -> shouldLoadConfiguration ( ) ) { $ this -> loadPackageConfiguration ( ) ; } $ redisDriver = $ this -> config -> get ( 'database.redis.driver' ) ; $ this -> shouldOverrideLaravelRedisApi = $ redisDriver === 'redis-sentinel' || $ redisDriver === 'sentinel' ; $ this -> shouldIntegrateHorizon = $ this -> horizonAvailable && $ this -> config -> get ( 'horizon.driver' ) === 'redis-sentinel' ; }
Load the package configuration .
50,012
public function loadHorizonConfiguration ( ) { if ( $ this -> config -> get ( 'redis-sentinel.load_horizon' , true ) !== true ) { return ; } $ horizonConfig = $ this -> getSelectedHorizonConnectionConfiguration ( ) ; $ options = Arr :: get ( $ horizonConfig , 'options' , [ ] ) ; $ options [ 'prefix' ] = $ this -> config -> get ( 'horizon.prefix' , 'horizon:' ) ; $ horizonConfig [ 'options' ] = $ options ; $ this -> config -> set ( 'database.redis-sentinel.horizon' , $ horizonConfig ) ; $ this -> config -> set ( 'redis-sentinel.load_horizon' , false ) ; }
Sets the Horizon Redis Sentinel connection configuration .
50,013
public function getApplicationVersion ( ) { if ( $ this -> isLumen ) { return substr ( $ this -> app -> version ( ) , 7 , 3 ) ; } return \ Illuminate \ Foundation \ Application :: VERSION ; }
Get the version number of the current Laravel or Lumen application .
50,014
protected function shouldLoadConfiguration ( ) { if ( $ this -> isLumen ) { $ this -> app -> configure ( 'redis-sentinel' ) ; } return $ this -> config -> get ( 'redis-sentinel.load_config' , true ) === true ; }
Determine if the package should automatically configure itself .
50,015
protected function configureLumenComponents ( ) { $ this -> app -> configure ( 'database' ) ; $ this -> app -> configure ( 'broadcasting' ) ; $ this -> app -> configure ( 'cache' ) ; $ this -> app -> configure ( 'queue' ) ; }
Configure the Lumen components that this package depends on .
50,016
protected function getSelectedHorizonConnectionConfiguration ( ) { $ use = $ this -> config -> get ( 'horizon.use' , 'default' ) ; $ connectionConfig = $ this -> config -> get ( "database.redis-sentinel.$use" ) ; if ( $ connectionConfig === null ) { throw new UnexpectedValueException ( "The Horizon Redis Sentinel connection [$use] is not defined." ) ; } return $ connectionConfig ; }
Copy the Redis Sentinel connection configuration to use for Horizon connections from the connection specified by horizon . use .
50,017
protected function loadPackageConfiguration ( ) { if ( $ this -> isLumen ) { $ this -> configureLumenComponents ( ) ; } $ this -> setConfigurationFor ( 'database.redis-sentinel' ) ; $ this -> setConfigurationFor ( 'database.redis.driver' ) ; $ this -> setConfigurationFor ( 'broadcasting.connections.redis-sentinel' ) ; $ this -> setConfigurationFor ( 'cache.stores.redis-sentinel' ) ; $ this -> setConfigurationFor ( 'queue.connections.redis-sentinel' ) ; $ this -> setSessionConfiguration ( ) ; $ this -> normalizeHosts ( ) ; $ this -> cleanPackageConfiguration ( ) ; }
Reconcile the package configuration and use it to set the appropriate configuration values for other application components .
50,018
protected function setConfigurationFor ( $ configKey , $ checkExists = true ) { if ( $ checkExists && $ this -> config -> has ( $ configKey ) ) { return ; } $ config = $ this -> getPackageConfigurationFor ( $ configKey ) ; $ this -> config -> set ( $ configKey , $ config ) ; }
Set the application configuration value for the specified key with the value from the package configuration .
50,019
protected function setSessionConfiguration ( ) { if ( ! $ this -> supportsSessions || $ this -> config -> get ( 'session.driver' ) !== 'redis-sentinel' || $ this -> config -> get ( 'session.connection' ) !== null ) { return ; } $ this -> setConfigurationFor ( 'session.connection' , false ) ; }
Set the application session configuration as specified by the package s configuration if the app supports sessions .
50,020
protected function getPackageConfigurationFor ( $ configKey ) { if ( $ this -> packageConfig === null ) { $ this -> mergePackageConfiguration ( ) ; } return Arr :: get ( $ this -> packageConfig , $ configKey ) ; }
Get the package configuration for the specified key .
50,021
protected function mergePackageConfiguration ( ) { $ defaultConfig = require self :: CONFIG_PATH ; $ currentConfig = $ this -> config -> get ( 'redis-sentinel' , [ ] ) ; $ this -> packageConfig = array_merge ( $ defaultConfig , $ currentConfig ) ; }
Merge the package s default configuration with the override config file supplied by the developer if any .
50,022
protected function normalizeHosts ( ) { $ connections = $ this -> config -> get ( 'database.redis-sentinel' ) ; if ( ! is_array ( $ connections ) ) { return ; } $ this -> config -> set ( 'database.redis-sentinel' , HostNormalizer :: normalizeConnections ( $ connections ) ) ; }
Parse Redis Sentinel connection host definitions to create single host entries for host definitions that specify multiple hosts .
50,023
protected function cleanPackageConfiguration ( ) { $ this -> packageConfig = null ; if ( $ this -> config -> get ( 'redis-sentinel.clean_config' , true ) === true ) { $ this -> config -> set ( 'redis-sentinel' , [ 'Config merged. Set redis-sentinel.clean_config=false to keep.' , ] ) ; } $ this -> config -> set ( 'redis-sentinel.load_config' , false ) ; }
Remove the package s configuration from the application configuration repository .
50,024
public static function normalizeConnections ( array $ connections ) { foreach ( $ connections as $ name => $ connection ) { if ( $ name === 'options' || $ name === 'clusters' ) { continue ; } $ connections [ $ name ] = static :: normalizeConnection ( $ connection ) ; } return $ connections ; }
Create single host entries for any host definitions that specify multiple hosts in the provided set of connection configurations .
50,025
public static function normalizeConnection ( array $ connection ) { $ normal = [ ] ; if ( array_key_exists ( 'options' , $ connection ) ) { $ normal [ 'options' ] = $ connection [ 'options' ] ; unset ( $ connection [ 'options' ] ) ; } foreach ( $ connection as $ host ) { $ normal = array_merge ( $ normal , static :: normalizeHost ( $ host ) ) ; } return $ normal ; }
Create single host entries for any host definitions that specify multiple hosts in the provided connection configuration .
50,026
public static function normalizeHost ( $ host ) { if ( is_array ( $ host ) ) { return static :: normalizeHostArray ( $ host ) ; } if ( is_string ( $ host ) ) { return static :: normalizeHostString ( $ host ) ; } return [ $ host ] ; }
Parse the provided host definition into multiple host definitions if it specifies more than one host .
50,027
protected static function normalizeHostArray ( array $ hostArray ) { if ( ! array_key_exists ( 'host' , $ hostArray ) ) { return [ $ hostArray ] ; } $ port = Arr :: get ( $ hostArray , 'port' , 26379 ) ; return static :: normalizeHostString ( $ hostArray [ 'host' ] , $ port ) ; }
Parse a host definition in the form of an array into multiple host definitions if it specifies more than one host .
50,028
protected static function normalizeHostString ( $ hostString , $ port = 26379 ) { $ hosts = [ ] ; foreach ( explode ( ',' , $ hostString ) as $ host ) { $ host = trim ( $ host ) ; if ( Str :: contains ( $ host , ':' ) ) { $ hosts [ ] = $ host ; } else { $ hosts [ ] = [ 'host' => $ host , 'port' => $ port ] ; } } return $ hosts ; }
Parse a host definition in the form of a string into multiple host definitions it it specifies more than one host .
50,029
private function checkOptions ( $ options ) { if ( empty ( $ options [ 'username' ] ) ) { throw new \ Exception ( 'Username is not set' , 2301 ) ; } if ( empty ( $ options [ 'password' ] ) ) { throw new \ Exception ( 'Password or hash is not set' , 2302 ) ; } if ( empty ( $ options [ 'host' ] ) ) { throw new \ Exception ( 'CPanel Host is not set' , 2303 ) ; } return $ this ; }
checking options for username password and host . If they are not set some exception will be thrown .
50,030
public function setAuthorization ( $ username , $ password ) { $ this -> username = $ username ; $ this -> password = $ password ; return $ this ; }
set authorization for access . It only set username and password .
50,031
private function createHeader ( ) { $ headers = $ this -> headers ; $ username = $ this -> getUsername ( ) ; $ auth_type = $ this -> getAuthType ( ) ; if ( 'hash' == $ auth_type ) { $ headers [ 'Authorization' ] = 'WHM ' . $ username . ':' . preg_replace ( "'(\r|\n|\s|\t)'" , '' , $ this -> getPassword ( ) ) ; } elseif ( 'password' == $ auth_type ) { $ headers [ 'Authorization' ] = 'Basic ' . base64_encode ( $ username . ':' . $ this -> getPassword ( ) ) ; } return $ headers ; }
Extend HTTP headers that will be sent .
50,032
protected function runQuery ( $ action , $ arguments , $ throw = false ) { $ host = $ this -> getHost ( ) ; $ client = new Client ( [ 'base_uri' => $ host ] ) ; try { $ response = $ client -> post ( '/json-api/' . $ action , [ 'headers' => $ this -> createHeader ( ) , 'verify' => false , 'query' => $ arguments , 'timeout' => $ this -> getTimeout ( ) , 'connect_timeout' => $ this -> getConnectionTimeout ( ) ] ) ; return ( string ) $ response -> getBody ( ) ; } catch ( \ GuzzleHttp \ Exception \ ClientException $ e ) { if ( $ throw ) { throw $ e ; } return $ e -> getMessage ( ) ; } }
The executor . It will run API function and get the data .
50,033
public function cpanel ( $ module , $ function , $ username , $ params = array ( ) ) { $ action = 'cpanel' ; $ params = array_merge ( $ params , [ 'cpanel_jsonapi_version' => 2 , 'cpanel_jsonapi_module' => $ module , 'cpanel_jsonapi_func' => $ function , 'cpanel_jsonapi_user' => $ username , ] ) ; $ response = $ this -> runQuery ( $ action , $ params ) ; return $ response ; }
Use a cPanel API
50,034
public function execute_action ( $ api , $ module , $ function , $ username , $ params = array ( ) ) { $ action = 'cpanel' ; $ params = array_merge ( $ params , [ 'cpanel_jsonapi_apiversion' => $ api , 'cpanel_jsonapi_module' => $ module , 'cpanel_jsonapi_func' => $ function , 'cpanel_jsonapi_user' => $ username , ] ) ; $ response = $ this -> runQuery ( $ action , $ params ) ; return $ response ; }
Use cPanel API 1 or use cPanel API 2 or use UAPI .
50,035
public function changeEmailPassword ( $ username , $ email , $ password ) { list ( $ account , $ domain ) = $ this -> split_email ( $ email ) ; return $ this -> emailAction ( 'passwdpop' , $ username , $ password , $ domain , $ account ) ; }
Change the password for an email account in cPanel
50,036
public function checkConnection ( ) { try { $ this -> runQuery ( '' , [ ] , true ) ; } catch ( \ Exception $ e ) { if ( $ e -> hasResponse ( ) ) { switch ( $ e -> getResponse ( ) -> getStatusCode ( ) ) { case 403 : return [ 'status' => 0 , 'error' => 'auth_error' , 'verbose' => 'Check Username and Password/Access Key.' ] ; default : return [ 'status' => 0 , 'error' => 'unknown' , 'verbose' => 'An unknown error has occurred. Server replied with: ' . $ e -> getResponse ( ) -> getStatusCode ( ) ] ; } } else { return [ 'status' => 0 , 'error' => 'conn_error' , 'verbose' => 'Check CSF or hostname/port.' ] ; } return false ; } return [ 'status' => 1 , 'error' => false , 'verbose' => 'Everything is working.' ] ; }
Runs a blank API Request to pull cPanel s response .
50,037
private function emailAction ( $ action , $ username , $ password , $ domain , $ account ) { return $ this -> cpanel ( 'Email' , $ action , $ username , [ 'domain' => $ domain , 'email' => $ account , 'password' => $ password , ] ) ; }
Perform an email action
50,038
protected function stringViewInstance ( $ view , $ data ) { return new StringView ( $ this , $ this -> engines -> resolve ( 'stringblade' ) , $ view , null , $ data ) ; }
Create a new string view instance from the given arguments .
50,039
public function setEscapeTags ( $ openTag , $ closeTag , $ escaped = true ) { $ this -> escapedTags = [ preg_quote ( $ openTag ) , preg_quote ( $ closeTag ) ] ; }
Sets the escape tags used for the compiler .
50,040
public function registerStringBladeEngine ( $ resolver ) { $ app = $ this -> app ; $ app -> singleton ( 'stringblade.compiler' , function ( $ app ) { $ cache = $ app [ 'config' ] [ 'view.compiled' ] ; return new StringBladeCompiler ( $ app [ 'files' ] , $ cache ) ; } ) ; $ resolver -> register ( 'stringblade' , function ( ) use ( $ app ) { return new CompilerEngine ( $ app [ 'stringblade.compiler' ] ) ; } ) ; }
Register the StringBlade engine implementation .
50,041
public function isCached ( $ key ) { if ( false != $ this -> _loadCache ( ) ) { $ cachedData = $ this -> _loadCache ( ) ; return isset ( $ cachedData [ $ key ] [ 'data' ] ) ; } }
Check whether data accociated with a key
50,042
public function erase ( $ key ) { $ cacheData = $ this -> _loadCache ( ) ; if ( true === is_array ( $ cacheData ) ) { if ( true === isset ( $ cacheData [ $ key ] ) ) { unset ( $ cacheData [ $ key ] ) ; $ cacheData = json_encode ( $ cacheData ) ; file_put_contents ( $ this -> getCacheDir ( ) , $ cacheData ) ; } else { throw new Exception ( "Error: erase() - Key '{$key}' not found." ) ; } } return $ this ; }
Erase cached entry by its key
50,043
public function eraseAll ( ) { $ cacheDir = $ this -> getCacheDir ( ) ; if ( true === file_exists ( $ cacheDir ) ) { $ cacheFile = fopen ( $ cacheDir , 'w' ) ; fclose ( $ cacheFile ) ; } return $ this ; }
Erase all cached entries
50,044
private function _loadCache ( ) { if ( true === file_exists ( $ this -> getCacheDir ( ) ) ) { $ file = file_get_contents ( $ this -> getCacheDir ( ) ) ; return json_decode ( $ file , true ) ; } else { return false ; } }
Load appointed cache
50,045
private function _checkExpired ( $ timestamp , $ expiration ) { $ result = false ; if ( $ expiration !== 0 ) { $ timeDiff = time ( ) - $ timestamp ; ( $ timeDiff > $ expiration ) ? $ result = true : $ result = false ; } return $ result ; }
Check whether a timestamp is still in the duration
50,046
public function getKey ( ) : string { if ( $ this -> key ) { return $ this -> key ; } if ( $ this -> config -> has ( 'key' ) ) { $ key = Key :: validate ( $ this -> config -> get ( 'key' ) , 'group' ) ; $ this -> key = $ key ; return $ key ; } $ this -> key = Key :: sanitize ( $ this -> config -> get ( 'title' ) ) ; return $ this -> key ; }
Get the group key .
50,047
public function toArray ( ) : array { $ config = [ 'fields' => $ this -> getFields ( ) , ] ; if ( $ this -> config -> has ( 'key' ) ) { $ config [ 'key' ] = $ this -> getKey ( ) ; } else { $ config [ 'key' ] = Key :: generate ( $ this -> getKey ( ) , 'group' ) ; } return array_merge ( $ this -> config -> toArray ( ) , $ config ) ; }
Return the group as array .
50,048
public static function generate ( string $ key , string $ prefix ) : string { $ key = sprintf ( '%s_%s' , $ prefix , static :: hash ( $ key ) ) ; static :: validate ( $ key , $ prefix ) ; static :: $ keys [ ] = $ key ; return $ key ; }
Generate a new field group or layout key .
50,049
public static function validate ( string $ key , string $ prefix ) : string { if ( in_array ( $ key , self :: $ keys ) ) { throw new InvalidArgumentException ( "The key [$key] is not unique." ) ; } if ( strpos ( $ key , $ prefix ) === false ) { throw new InvalidArgumentException ( "The key must be prefixed with [$prefix]." ) ; } return $ key ; }
Validate a given key s uniqness .
50,050
public function getKey ( ) : string { if ( $ this -> key ) { return $ this -> key ; } if ( $ this -> config -> has ( 'key' ) ) { $ key = Key :: validate ( $ this -> config -> get ( 'key' ) , 'field' ) ; $ this -> key = $ key ; return $ key ; } if ( ! $ this -> config -> has ( 'name' ) && in_array ( $ this -> getType ( ) , [ 'accordion' , 'message' , 'tab' ] ) ) { $ key = $ this -> config -> get ( 'label' ) ; } else { $ key = $ this -> config -> get ( 'name' ) ; } $ key = sprintf ( '%s_%s' , $ this -> parentKey , Key :: sanitize ( $ key ) ) ; $ this -> key = $ key ; return $ key ; }
Get the field key .
50,051
public function getConditionalLogic ( ) : array { $ conditionals = [ ] ; foreach ( $ this -> config -> get ( 'conditional_logic' ) as $ rules ) { $ conditional = new Conditional ( $ rules , $ this -> parentKey ) ; $ conditionals [ ] = $ conditional -> toArray ( ) ; } return $ conditionals ; }
Get the conditional logic .
50,052
public function getLayouts ( ) : array { $ layouts = [ ] ; foreach ( $ this -> config -> get ( 'layouts' ) as $ layout ) { $ layout -> setParentKey ( $ this -> getKey ( ) ) ; $ layouts [ ] = $ layout -> toArray ( ) ; } return $ layouts ; }
Get the flexible content layouts .
50,053
public function getSubFields ( ) : array { $ fields = [ ] ; foreach ( $ this -> config -> get ( 'sub_fields' ) as $ field ) { $ field -> setParentKey ( $ this -> getKey ( ) ) ; $ fields [ ] = $ field -> toArray ( ) ; } return $ fields ; }
Get the sub fields .
50,054
public function toArray ( ) : array { $ config = [ ] ; if ( $ this -> config -> has ( 'key' ) ) { $ config [ 'key' ] = $ this -> getKey ( ) ; } else { $ config [ 'key' ] = Key :: generate ( $ this -> getKey ( ) , 'field' ) ; } if ( $ this -> config -> has ( 'conditional_logic' ) ) { $ config [ 'conditional_logic' ] = $ this -> getConditionalLogic ( ) ; } if ( $ this -> config -> has ( 'layouts' ) ) { $ config [ 'layouts' ] = $ this -> getLayouts ( ) ; } if ( $ this -> config -> has ( 'sub_fields' ) ) { $ config [ 'sub_fields' ] = $ this -> getSubFields ( ) ; } return array_merge ( $ this -> config -> toArray ( ) , $ config ) ; }
Return the field as array .
50,055
public function toArray ( ) : array { $ groups = [ ] ; foreach ( $ this -> groups as $ group ) { $ key = Key :: sanitize ( $ group [ 'name' ] ) ; $ key = sprintf ( '%s_%s' , $ this -> parentKey , $ key ) ; $ group = [ 'field' => sprintf ( 'field_%s' , Key :: hash ( $ key ) ) , 'operator' => $ group [ 'operator' ] , 'value' => $ group [ 'value' ] , ] ; $ groups [ ] = $ group ; } return $ groups ; }
Return the conditional as array .
50,056
protected function addValidators ( ) { foreach ( config ( 'countries.validation.rules' ) as $ ruleName => $ countryAttribute ) { if ( is_int ( $ ruleName ) ) { $ ruleName = $ countryAttribute ; } Validator :: extend ( $ ruleName , function ( $ attribute , $ value ) use ( $ countryAttribute ) { return ! CountriesFacade :: where ( $ countryAttribute , $ value ) -> isEmpty ( ) ; } , 'The :attribute must be a valid ' . $ ruleName . '.' ) ; } }
Add validators .
50,057
private function findCountryByCca3 ( $ cca3 ) { if ( is_null ( $ country = CountriesFacade :: where ( 'cca3' , upper ( $ cca3 ) ) ) ) { abort ( 404 ) ; } return $ country -> first ( ) -> hydrateFlag ( ) ; }
Find a country by its cca3 code and hydrate flag .
50,058
public function setCredentials ( $ username , $ password ) { $ this -> connectOptions [ 'username' ] = $ username ; $ this -> connectOptions [ 'password' ] = $ password ; return $ this ; }
Set credentials to auth on db specified in connect options or dsn . If not specified - auth on admin db
50,059
public function getMongoClient ( ) { if ( $ this -> mongoClient ) { return $ this -> mongoClient ; } $ this -> mongoClient = new \ MongoClient ( $ this -> dsn , $ this -> connectOptions ) ; return $ this -> mongoClient ; }
Get mongo connection instance
50,060
public function getDatabase ( $ name = null ) { if ( empty ( $ name ) ) { $ name = $ this -> getCurrentDatabaseName ( ) ; } if ( ! isset ( $ this -> databasePool [ $ name ] ) ) { $ database = new Database ( $ this , $ name ) ; if ( isset ( $ this -> mapping [ $ name ] ) ) { $ database -> map ( $ this -> mapping [ $ name ] ) ; } $ this -> databasePool [ $ name ] = $ database ; } return $ this -> databasePool [ $ name ] ; }
Get database instance
50,061
public function setWriteConcern ( $ w , $ timeout = 10000 ) { if ( ! $ this -> getMongoClient ( ) -> setWriteConcern ( $ w , ( int ) $ timeout ) ) { throw new Exception ( 'Error setting write concern' ) ; } return $ this ; }
Define write concern on whole requests
50,062
public function map ( $ name , $ classDefinition = null ) { if ( $ classDefinition ) { return $ this -> defineCollection ( $ name , $ classDefinition ) ; } if ( is_array ( $ name ) ) { foreach ( $ name as $ collectionName => $ classDefinition ) { $ this -> defineCollection ( $ collectionName , $ classDefinition ) ; } return $ this ; } $ this -> defineCollection ( '*' , array ( 'class' => $ name , ) ) ; return $ this ; }
Map collection name to class
50,063
private function defineCollection ( $ name , $ definition ) { if ( false === ( $ definition instanceof Definition ) ) { if ( is_string ( $ definition ) ) { $ definition = new Definition ( array ( 'class' => $ definition ) ) ; } elseif ( is_array ( $ definition ) ) { $ definition = new Definition ( $ definition ) ; } else { throw new Exception ( sprintf ( 'Wrong definition passed for collection %s' , $ name ) ) ; } } if ( '/' !== substr ( $ name , 0 , 1 ) ) { $ this -> mapping [ $ name ] = $ definition ; } else { $ this -> regexpMapping [ $ name ] = $ definition ; } return $ this ; }
Define collection through array or Definition instance
50,064
private function getCollectionDefinition ( $ name , array $ defaultDefinition = null ) { if ( isset ( $ this -> mapping [ $ name ] ) ) { $ classDefinition = $ this -> mapping [ $ name ] ; } elseif ( $ this -> regexpMapping ) { foreach ( $ this -> regexpMapping as $ collectionNamePattern => $ regexpMappingClassDefinition ) { if ( preg_match ( $ collectionNamePattern , $ name , $ matches ) ) { $ classDefinition = clone $ regexpMappingClassDefinition ; $ classDefinition -> setOption ( 'regexp' , $ matches ) ; break ; } } } if ( ! isset ( $ classDefinition ) ) { if ( ! empty ( $ this -> mapping [ '*' ] ) ) { $ classDefinition = clone $ this -> mapping [ '*' ] ; $ collectionClass = $ classDefinition -> getClass ( ) . '\\' . implode ( '\\' , array_map ( 'ucfirst' , explode ( '.' , $ name ) ) ) ; $ classDefinition -> setClass ( $ collectionClass ) ; } else { $ classDefinition = new Definition ( ) ; if ( $ defaultDefinition ) { $ classDefinition -> merge ( $ defaultDefinition ) ; } } } if ( ! class_exists ( $ classDefinition -> getClass ( ) ) ) { throw new Exception ( 'Class ' . $ classDefinition -> getClass ( ) . ' not found while map collection name to class' ) ; } return $ classDefinition ; }
Get class name mapped to collection
50,065
public function getGridFS ( $ name = 'fs' ) { if ( $ this -> collectionPoolEnabled && isset ( $ this -> collectionPool [ $ name ] ) ) { return $ this -> collectionPool [ $ name ] ; } $ classDefinition = $ this -> getCollectionDefinition ( $ name , array ( 'gridfs' => true ) ) ; $ className = $ classDefinition -> getClass ( ) ; $ collection = new $ className ( $ this , $ name , $ classDefinition ) ; if ( ! $ collection instanceof \ Sokil \ Mongo \ GridFS ) { throw new Exception ( 'Must be instance of \Sokil\Mongo\GridFS' ) ; } if ( $ this -> collectionPoolEnabled ) { $ this -> collectionPool [ $ name ] = $ collection ; } return $ collection ; }
Get instance of GridFS
50,066
public function setWriteConcern ( $ w , $ timeout = 10000 ) { if ( ! $ this -> getMongoDB ( ) -> setWriteConcern ( $ w , ( int ) $ timeout ) ) { throw new Exception ( 'Error setting write concern' ) ; } return $ this ; }
Define write concern . May be used only if mongo extension version > = 1 . 5
50,067
public function slice ( $ field , $ limit , $ skip = null ) { $ limit = ( int ) $ limit ; $ skip = ( int ) $ skip ; if ( $ skip ) { $ this -> projection [ $ field ] = array ( '$slice' => array ( $ skip , $ limit ) ) ; } else { $ this -> projection [ $ field ] = array ( '$slice' => $ limit ) ; } $ this -> skipDocumentPool ( ) ; return $ this ; }
Paginate list of sub - documents
50,068
public function elemMatch ( $ field , $ expression ) { $ this -> projection [ $ field ] = array ( '$elemMatch' => Expression :: convertToArray ( $ expression ) , ) ; $ this -> skipDocumentPool ( ) ; return $ this ; }
Filter list of sub - documents
50,069
public function limitedCount ( ) { if ( version_compare ( \ MongoClient :: VERSION , '1.0.7' , '<' ) ) { throw new FeatureNotSupportedException ( 'Limit and skip not supported in ext-mongo versions prior to 1.0.7' ) ; } return ( int ) $ this -> collection -> getMongoCollection ( ) -> count ( $ this -> expression -> toArray ( ) , $ this -> limit , $ this -> skip ) ; }
Count documents in result with applying limit and offset
50,070
public function one ( ) { try { $ mongoDocument = $ this -> collection -> getMongoCollection ( ) -> findOne ( $ this -> expression -> toArray ( ) , $ this -> projection ) ; } catch ( \ Exception $ e ) { throw new CursorException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } if ( empty ( $ mongoDocument ) ) { return null ; } if ( true === $ this -> isResultAsArray ) { return $ mongoDocument ; } return $ this -> collection -> hydrate ( $ mongoDocument , $ this -> isDocumentPoolUsed ( ) ) ; }
Find one document which correspond to expression .
50,071
public function random ( ) { $ count = $ this -> count ( ) ; switch ( $ count ) { case 0 : return null ; case 1 : return $ this -> one ( ) ; default : $ cursor = $ this -> skip ( mt_rand ( 0 , $ count - 1 ) ) -> limit ( 1 ) ; $ cursor -> rewind ( ) ; return $ cursor -> current ( ) ; } }
Get random document
50,072
public function pluck ( $ fieldName ) { $ isEmbeddedDocumentField = false !== strpos ( $ fieldName , '.' ) ; $ valueList = array ( ) ; if ( $ isEmbeddedDocumentField ) { if ( $ this -> isResultAsArray ) { $ cursor = clone $ this ; $ documentObjectList = $ cursor -> asObject ( ) -> findAll ( ) ; unset ( $ cursor ) ; } else { $ documentObjectList = $ this -> findAll ( ) ; } foreach ( $ documentObjectList as $ key => $ documentObject ) { $ valueList [ $ key ] = $ documentObject -> get ( $ fieldName ) ; } } else { if ( $ this -> isResultAsArray ) { $ documentArrayList = $ this -> findAll ( ) ; } else { $ cursor = clone $ this ; $ documentArrayList = $ cursor -> asArray ( ) -> findAll ( ) ; unset ( $ cursor ) ; } $ valueList = array_column ( $ documentArrayList , $ fieldName , '_id' ) ; } return $ valueList ; }
Return the values from a single field in the result set of documents
50,073
public function findAndRemove ( ) { $ mongoDocument = $ this -> collection -> getMongoCollection ( ) -> findAndModify ( $ this -> expression -> toArray ( ) , null , $ this -> projection , array ( 'remove' => true , 'sort' => $ this -> sort , ) ) ; if ( empty ( $ mongoDocument ) ) { return null ; } return $ this -> collection -> hydrate ( $ mongoDocument , $ this -> isDocumentPoolUsed ( ) ) ; }
Get document instance and remove it from collection
50,074
public function findAndUpdate ( Operator $ operator , $ upsert = false , $ returnUpdated = true ) { $ mongoDocument = $ this -> collection -> getMongoCollection ( ) -> findAndModify ( $ this -> expression -> toArray ( ) , $ operator ? $ operator -> toArray ( ) : null , $ this -> projection , array ( 'new' => $ returnUpdated , 'sort' => $ this -> sort , 'upsert' => $ upsert , ) ) ; if ( empty ( $ mongoDocument ) ) { return null ; } return $ this -> collection -> hydrate ( $ mongoDocument , $ this -> isDocumentPoolUsed ( ) ) ; }
Find first document and update it
50,075
public function map ( $ handler ) { $ result = array ( ) ; foreach ( $ this as $ id => $ document ) { $ result [ $ id ] = $ handler ( $ document ) ; } return $ result ; }
Apply callable to all documents in cursor
50,076
public function filter ( $ handler ) { $ result = array ( ) ; foreach ( $ this as $ id => $ document ) { if ( ! $ handler ( $ document ) ) { continue ; } $ result [ $ id ] = $ document ; } return $ result ; }
Filter documents in cursor by condition in callable
50,077
public function rewind ( ) { if ( $ this -> cursor !== null ) { $ this -> cursor -> rewind ( ) ; return ; } $ this -> cursor = $ this -> collection -> getMongoCollection ( ) -> find ( $ this -> expression -> toArray ( ) , $ this -> projection ) ; if ( $ this -> skip ) { $ this -> cursor -> skip ( $ this -> skip ) ; } if ( $ this -> limit ) { $ this -> cursor -> limit ( $ this -> limit ) ; } if ( $ this -> options [ 'batchSize' ] ) { $ this -> cursor -> batchSize ( $ this -> options [ 'batchSize' ] ) ; } if ( $ this -> options [ 'clientTimeout' ] ) { $ this -> cursor -> timeout ( $ this -> options [ 'clientTimeout' ] ) ; } if ( $ this -> options [ 'serverTimeout' ] ) { $ this -> cursor -> maxTimeMS ( $ this -> options [ 'clientTimeout' ] ) ; } if ( ! empty ( $ this -> sort ) ) { $ this -> cursor -> sort ( $ this -> sort ) ; } if ( $ this -> hint ) { $ this -> cursor -> hint ( $ this -> hint ) ; } if ( ! empty ( $ this -> readPreference ) ) { $ this -> cursor -> setReadPreference ( $ this -> readPreference [ 'type' ] , $ this -> readPreference [ 'tagsets' ] ) ; } $ this -> cursor -> rewind ( ) ; }
Returns the cursor to the beginning of the result set .
50,078
public function copyToCollection ( $ targetCollectionName , $ targetDatabaseName = null , $ batchLimit = 100 ) { if ( empty ( $ targetDatabaseName ) ) { $ database = $ this -> collection -> getDatabase ( ) ; } else { $ database = $ this -> client -> getDatabase ( $ targetDatabaseName ) ; } $ targetMongoCollection = $ database -> getCollection ( $ targetCollectionName ) -> getMongoCollection ( ) ; $ this -> rewind ( ) ; $ inProgress = true ; while ( $ inProgress ) { $ documentList = array ( ) ; for ( $ i = 0 ; $ i < $ batchLimit ; $ i ++ ) { if ( ! $ this -> cursor -> valid ( ) ) { $ inProgress = false ; if ( ! empty ( $ documentList ) ) { break ; } else { break ( 2 ) ; } } $ documentList [ ] = $ this -> cursor -> current ( ) ; $ this -> cursor -> next ( ) ; } $ result = $ targetMongoCollection -> batchInsert ( $ documentList ) ; if ( is_array ( $ result ) ) { if ( $ result [ 'ok' ] != 1 ) { throw new WriteException ( 'Batch insert error: ' . $ result [ 'err' ] ) ; } } elseif ( false === $ result ) { throw new WriteException ( 'Batch insert error' ) ; } } return $ this ; }
Copy selected documents to another collection
50,079
public function moveToCollection ( $ targetCollectionName , $ targetDatabaseName = null , $ batchLimit = 100 ) { $ this -> copyToCollection ( $ targetCollectionName , $ targetDatabaseName , $ batchLimit ) ; $ this -> collection -> batchDelete ( $ this -> expression ) ; }
Move selected documents to another collection . Documents will be removed from source collection only after copying them to target collection .
50,080
public function getHash ( ) { $ hash = array ( ) ; $ hash [ ] = json_encode ( $ this -> expression -> toArray ( ) ) ; if ( ! empty ( $ this -> sort ) ) { $ sort = $ this -> sort ; ksort ( $ sort ) ; $ hash [ ] = implode ( '' , array_merge ( array_keys ( $ sort ) , array_values ( $ sort ) ) ) ; } if ( ! empty ( $ this -> projection ) ) { $ fields = $ this -> projection ; ksort ( $ fields ) ; $ hash [ ] = implode ( '' , array_merge ( array_keys ( $ fields ) , array_values ( $ fields ) ) ) ; } $ hash [ ] = $ this -> skip ; $ hash [ ] = $ this -> limit ; return md5 ( implode ( ':' , $ hash ) ) ; }
Used to get hash that uniquely identifies current query
50,081
public static function mixedToMongoIdList ( array $ list ) { return array_map ( function ( $ element ) { if ( $ element instanceof \ MongoId ) { return $ element ; } if ( $ element instanceof Document ) { return $ element -> getId ( ) ; } if ( is_array ( $ element ) ) { if ( ! isset ( $ element [ '_id' ] ) ) { throw new \ InvalidArgumentException ( 'Array must have _id key' ) ; } return $ element [ '_id' ] ; } if ( is_string ( $ element ) ) { try { return new \ MongoId ( $ element ) ; } catch ( \ MongoException $ e ) { return $ element ; } } if ( is_int ( $ element ) ) { return $ element ; } throw new \ InvalidArgumentException ( 'Must be \MongoId, \Sokil\Mongo\Document, array with _id key, string or integer' ) ; } , array_values ( $ list ) ) ; }
Get list of MongoId objects from array of strings MongoId s and Document s
50,082
public static function isInternalType ( $ value ) { if ( ! is_object ( $ value ) ) { return false ; } if ( class_exists ( '\MongoDB\BSON\Type' ) ) { return $ value instanceof \ MongoDB \ BSON \ Type ; } else { $ mongoTypes = array ( 'MongoId' , 'MongoCode' , 'MongoDate' , 'MongoRegex' , 'MongoBinData' , 'MongoInt32' , 'MongoInt64' , 'MongoDBRef' , 'MongoMinKey' , 'MongoMaxKey' , 'MongoTimestamp' ) ; return in_array ( get_class ( $ value ) , $ mongoTypes ) ; } }
Check if value belongs to internal Mongo type converted by driver to scalars
50,083
public static function convertToArray ( $ mixed ) { if ( is_callable ( $ mixed ) ) { $ callable = $ mixed ; $ mixed = new self ( ) ; call_user_func ( $ callable , $ mixed ) ; } if ( $ mixed instanceof ArrayableInterface && $ mixed instanceof self ) { $ mixed = $ mixed -> toArray ( ) ; } elseif ( ! is_array ( $ mixed ) ) { throw new Exception ( 'Mixed must be instance of Operator' ) ; } return $ mixed ; }
Transform operator in different formats to canonical array form
50,084
public function persist ( Document $ document ) { $ this -> pool -> attach ( $ document , self :: STATE_SAVE ) ; return $ this ; }
Add document to watching pool for save
50,085
public function remove ( Document $ document ) { $ this -> pool -> attach ( $ document , self :: STATE_REMOVE ) ; return $ this ; }
Add document to watching pool for remove
50,086
public function addConnection ( $ name , $ dsn = null , array $ mapping = null , $ defaultDatabase = null , array $ connectOptions = null ) { $ this -> configuration [ $ name ] = array ( 'dsn' => $ dsn , 'connectOptions' => $ connectOptions , 'defaultDatabase' => $ defaultDatabase , 'mapping' => $ mapping , ) ; return $ this ; }
Add connection to pool
50,087
public function get ( $ name ) { if ( isset ( $ this -> pool [ $ name ] ) ) { return $ this -> pool [ $ name ] ; } if ( ! isset ( $ this -> configuration [ $ name ] ) ) { throw new Exception ( 'Connection with name ' . $ name . ' not found' ) ; } if ( ! isset ( $ this -> configuration [ $ name ] [ 'dsn' ] ) ) { $ this -> configuration [ $ name ] [ 'dsn' ] = null ; } if ( empty ( $ this -> configuration [ $ name ] [ 'connectOptions' ] ) ) { $ this -> configuration [ $ name ] [ 'connectOptions' ] = null ; } $ client = new Client ( $ this -> configuration [ $ name ] [ 'dsn' ] , $ this -> configuration [ $ name ] [ 'connectOptions' ] ) ; if ( isset ( $ this -> configuration [ $ name ] [ 'mapping' ] ) ) { $ client -> map ( $ this -> configuration [ $ name ] [ 'mapping' ] ) ; } if ( isset ( $ this -> configuration [ $ name ] [ 'defaultDatabase' ] ) ) { $ client -> useDatabase ( $ this -> configuration [ $ name ] [ 'defaultDatabase' ] ) ; } $ this -> pool [ $ name ] = $ client ; return $ client ; }
Get instance of connection
50,088
public function whereEmpty ( $ field ) { return $ this -> where ( '$or' , array ( array ( $ field => null ) , array ( $ field => '' ) , array ( $ field => array ( ) ) , array ( $ field => array ( '$exists' => false ) ) ) ) ; }
Filter empty field
50,089
public function whereElemMatch ( $ field , $ expression ) { if ( is_callable ( $ expression ) ) { $ expression = call_user_func ( $ expression , $ this -> expression ( ) ) ; } if ( $ expression instanceof Expression ) { $ expression = $ expression -> toArray ( ) ; } elseif ( ! is_array ( $ expression ) ) { throw new Exception ( 'Wrong expression passed' ) ; } return $ this -> where ( $ field , array ( '$elemMatch' => $ expression ) ) ; }
Matches documents in a collection that contain an array field with at least one element that matches all the specified query criteria .
50,090
public function whereElemNotMatch ( $ field , $ expression ) { return $ this -> whereNot ( $ this -> expression ( ) -> whereElemMatch ( $ field , $ expression ) ) ; }
Matches documents in a collection that contain an array field with elements that do not matches all the specified query criteria .
50,091
public function whereOr ( $ expressions = null ) { if ( $ expressions instanceof Expression ) { $ expressions = func_get_args ( ) ; } return $ this -> where ( '$or' , array_map ( function ( Expression $ expression ) { return $ expression -> toArray ( ) ; } , $ expressions ) ) ; }
Selects the documents that satisfy at least one of the expressions
50,092
public function whereText ( $ search , $ language = null , $ caseSensitive = null , $ diacriticSensitive = null ) { $ this -> _expression [ '$text' ] = array ( '$search' => $ search , ) ; if ( $ language ) { $ this -> _expression [ '$text' ] [ '$language' ] = $ language ; } if ( $ caseSensitive ) { $ this -> _expression [ '$text' ] [ '$caseSensitive' ] = ( bool ) $ caseSensitive ; } if ( $ diacriticSensitive ) { $ this -> _expression [ '$text' ] [ '$diacriticSensitive' ] = ( bool ) $ diacriticSensitive ; } return $ this ; }
Perform fulltext search
50,093
public function nearPoint ( $ field , $ longitude , $ latitude , $ distance ) { $ point = new \ GeoJson \ Geometry \ Point ( array ( ( float ) $ longitude , ( float ) $ latitude ) ) ; $ near = array ( '$geometry' => $ point -> jsonSerialize ( ) , ) ; if ( is_array ( $ distance ) ) { if ( ! empty ( $ distance [ 0 ] ) ) { $ near [ '$minDistance' ] = ( int ) $ distance [ 0 ] ; } if ( ! empty ( $ distance [ 1 ] ) ) { $ near [ '$maxDistance' ] = ( int ) $ distance [ 1 ] ; } } else { $ near [ '$maxDistance' ] = ( int ) $ distance ; } $ this -> where ( $ field , array ( '$near' => $ near ) ) ; return $ this ; }
Find document near points in flat surface
50,094
public function nearPointSpherical ( $ field , $ longitude , $ latitude , $ distance ) { $ point = new Point ( array ( ( float ) $ longitude , ( float ) $ latitude ) ) ; $ near = array ( '$geometry' => $ point -> jsonSerialize ( ) , ) ; if ( is_array ( $ distance ) ) { if ( ! empty ( $ distance [ 0 ] ) ) { $ near [ '$minDistance' ] = ( int ) $ distance [ 0 ] ; } if ( ! empty ( $ distance [ 1 ] ) ) { $ near [ '$maxDistance' ] = ( int ) $ distance [ 1 ] ; } } else { $ near [ '$maxDistance' ] = ( int ) $ distance ; } $ this -> where ( $ field , array ( '$nearSphere' => $ near ) ) ; return $ this ; }
Find document near points in spherical surface
50,095
public function intersects ( $ field , Geometry $ geometry ) { $ this -> where ( $ field , array ( '$geoIntersects' => array ( '$geometry' => $ geometry -> jsonSerialize ( ) , ) , ) ) ; return $ this ; }
Selects documents whose geospatial data intersects with a specified GeoJSON object ; i . e . where the intersection of the data and the specified object is non - empty . This includes cases where the data and the specified object share an edge . Uses spherical geometry .
50,096
public function within ( $ field , Geometry $ geometry ) { $ this -> where ( $ field , array ( '$geoWithin' => array ( '$geometry' => $ geometry -> jsonSerialize ( ) , ) , ) ) ; return $ this ; }
Selects documents with geospatial data that exists entirely within a specified shape .
50,097
public function withinCircle ( $ field , $ longitude , $ latitude , $ radius ) { $ this -> where ( $ field , array ( '$geoWithin' => array ( '$center' => array ( array ( $ longitude , $ latitude ) , $ radius , ) , ) , ) ) ; return $ this ; }
Select documents with geospatial data within circle defined by center point and radius in flat surface
50,098
public function withinCircleSpherical ( $ field , $ longitude , $ latitude , $ radiusInRadians ) { $ this -> where ( $ field , array ( '$geoWithin' => array ( '$centerSphere' => array ( array ( $ longitude , $ latitude ) , $ radiusInRadians , ) , ) , ) ) ; return $ this ; }
Select documents with geospatial data within circle defined by center point and radius in spherical surface
50,099
public function withinBox ( $ field , array $ bottomLeftCoordinate , array $ upperRightCoordinate ) { $ this -> where ( $ field , array ( '$geoWithin' => array ( '$box' => array ( $ bottomLeftCoordinate , $ upperRightCoordinate , ) , ) , ) ) ; return $ this ; }
Return documents that are within the bounds of the rectangle according to their point - based location data .