idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
2,300 | public function users ( array $ data = [ ] ) { $ response = $ this -> request -> get ( "me/following/users" , $ data ) ; return new Collection ( $ this -> master , $ response , "User" ) ; } | Get the authenticated user s following users |
2,301 | public function boards ( array $ data = [ ] ) { $ response = $ this -> request -> get ( "me/following/boards" , $ data ) ; return new Collection ( $ this -> master , $ response , "Board" ) ; } | Get the authenticated user s following boards |
2,302 | public function interests ( array $ data = [ ] ) { $ response = $ this -> request -> get ( "me/following/interests" , $ data ) ; return new Collection ( $ this -> master , $ response , "Interest" ) ; } | Get the authenticated user s following interest |
2,303 | public function getLoginUrl ( $ redirect_uri , $ scopes = array ( "read_public" ) , $ response_type = "code" ) { $ queryparams = array ( "response_type" => $ response_type , "redirect_uri" => $ redirect_uri , "client_id" => $ this -> client_id , "client_secret" => $ this -> client_secret , "scope" => implode ( "," , $ ... | Returns the login url |
2,304 | public function getOAuthToken ( $ code ) { $ data = array ( "grant_type" => "authorization_code" , "client_id" => $ this -> client_id , "client_secret" => $ this -> client_secret , "code" => $ code ) ; $ response = $ this -> request -> post ( "oauth/token" , $ data ) ; return $ response ; } | Change the code for an access_token |
2,305 | public function get ( $ board_id , array $ data = [ ] ) { $ response = $ this -> request -> get ( sprintf ( "boards/%s" , $ board_id ) , $ data ) ; return new Board ( $ this -> master , $ response ) ; } | Find the provided board |
2,306 | public function create ( array $ data ) { $ response = $ this -> request -> post ( "boards" , $ data ) ; return new Board ( $ this -> master , $ response ) ; } | Create a new board |
2,307 | public function edit ( $ board_id , array $ data , $ fields = null ) { $ query = ( ! $ fields ) ? array ( ) : array ( "fields" => $ fields ) ; $ response = $ this -> request -> update ( sprintf ( "boards/%s" , $ board_id ) , $ data , $ query ) ; return new Board ( $ this -> master , $ response ) ; } | Edit a board |
2,308 | public function get ( $ endpoint , array $ parameters = array ( ) ) { if ( ! empty ( $ parameters ) ) { $ path = sprintf ( "%s/?%s" , $ endpoint , http_build_query ( $ parameters ) ) ; } else { $ path = $ endpoint ; } return $ this -> execute ( "GET" , sprintf ( "%s%s" , $ this -> host , $ path ) ) ; } | Make a get request to the given endpoint |
2,309 | public function post ( $ endpoint , array $ parameters = array ( ) ) { return $ this -> execute ( "POST" , sprintf ( "%s%s" , $ this -> host , $ endpoint ) , $ parameters ) ; } | Make a post request to the given endpoint |
2,310 | public function delete ( $ endpoint , array $ parameters = array ( ) ) { return $ this -> execute ( "DELETE" , sprintf ( "%s%s" , $ this -> host , $ endpoint ) . "/" , $ parameters ) ; } | Make a delete request to the given endpoint |
2,311 | public function update ( $ endpoint , array $ parameters = array ( ) , array $ queryparameters = array ( ) ) { if ( ! empty ( $ queryparameters ) ) { $ path = sprintf ( "%s/?%s" , $ endpoint , http_build_query ( $ queryparameters ) ) ; } else { $ path = $ endpoint ; } return $ this -> execute ( "PATCH" , sprintf ( "%s%... | Make an update request to the given endpoint |
2,312 | public function execute ( $ method , $ apiCall , array $ parameters = array ( ) , $ headers = array ( ) ) { if ( $ this -> access_token != null ) { $ headers = array_merge ( $ headers , array ( "Authorization: Bearer " . $ this -> access_token , ) ) ; } $ headers = array_merge ( $ headers , array ( "Expect:" , ) ) ; $ ... | Execute the http request |
2,313 | public function find ( $ username , array $ data = [ ] ) { $ response = $ this -> request -> get ( sprintf ( "users/%s" , $ username ) , $ data ) ; return new User ( $ this -> master , $ response ) ; } | Get the provided user |
2,314 | public function getMePins ( array $ data = [ ] ) { $ response = $ this -> request -> get ( "me/pins" , $ data ) ; return new Collection ( $ this -> master , $ response , "Pin" ) ; } | Get the authenticated user s pins |
2,315 | public function searchMePins ( $ query , array $ data = [ ] ) { $ data [ "query" ] = $ query ; $ response = $ this -> request -> get ( "me/search/pins" , $ data ) ; return new Collection ( $ this -> master , $ response , "Pin" ) ; } | Search in the user s pins |
2,316 | public function getMeBoards ( array $ data = [ ] ) { $ response = $ this -> request -> get ( "me/boards" , $ data ) ; return new Collection ( $ this -> master , $ response , "Board" ) ; } | Get the authenticated user s boards |
2,317 | public function getMeLikes ( array $ data = [ ] ) { $ response = $ this -> request -> get ( "me/likes" , $ data ) ; return new Collection ( $ this -> master , $ response , "Pin" ) ; } | Get the authenticated user s likes |
2,318 | public function getMeFollowers ( array $ data = [ ] ) { $ response = $ this -> request -> get ( "me/followers" , $ data ) ; return new Collection ( $ this -> master , $ response , "User" ) ; } | Get the authenticated user s followers |
2,319 | public function get ( $ pin_id , array $ data = [ ] ) { $ response = $ this -> request -> get ( sprintf ( "pins/%s" , $ pin_id ) , $ data ) ; return new Pin ( $ this -> master , $ response ) ; } | Get a pin object |
2,320 | public function fromBoard ( $ board_id , array $ data = [ ] ) { $ response = $ this -> request -> get ( sprintf ( "boards/%s/pins" , $ board_id ) , $ data ) ; return new Collection ( $ this -> master , $ response , "Pin" ) ; } | Get all pins from the given board |
2,321 | public function create ( array $ data ) { if ( array_key_exists ( "image" , $ data ) ) { if ( class_exists ( '\CURLFile' ) ) { $ data [ "image" ] = new \ CURLFile ( $ data [ 'image' ] ) ; } else { $ data [ "image" ] = '@' . $ data [ 'image' ] ; } } $ response = $ this -> request -> post ( "pins" , $ data ) ; return new... | Create a pin |
2,322 | public function edit ( $ pin_id , array $ data , $ fields = null ) { $ query = ( ! $ fields ) ? array ( ) : array ( "fields" => $ fields ) ; $ response = $ this -> request -> update ( sprintf ( "pins/%s/" , $ pin_id ) , $ data , $ query ) ; return new Pin ( $ this -> master , $ response ) ; } | Edit a pin |
2,323 | private function buildCollectionModels ( array $ items ) { $ modelcollection = [ ] ; foreach ( $ items as $ item ) { $ class = new \ ReflectionClass ( "\\DirkGroenen\\Pinterest\\Models\\" . $ this -> model ) ; $ modelcollection [ ] = $ class -> newInstanceArgs ( [ $ this -> master , $ item ] ) ; } return $ modelcollect... | Transform each raw item into a model |
2,324 | public function having ( $ annotation ) { $ methods = [ ] ; foreach ( $ this -> reflectInto ( $ this -> reference ) as $ method ) { if ( $ this -> hasAnnotation ( $ annotation , $ method ) ) { $ methods [ ] = $ method -> getName ( ) ; } } return array_reverse ( $ methods ) ; } | Get method names for the referenced object which contain the given annotation . |
2,325 | protected function getDbAdapter ( ) { if ( ! $ this -> db ) { try { $ config = $ this -> getPackageConfig ( 'pdo' ) ; } catch ( IntegratedException $ e ) { throw new IntegratedException ( "Thank you for riding Johnny Cab. To input your destination (and use the database adapter with Selenium), " . "you must specify your... | Get the adapter to the database . |
2,326 | protected function seeRowsWereReturned ( $ table , $ data ) { if ( isset ( $ this -> app ) || in_array ( 'Laracasts\Integrated\Services\Laravel\Application' , class_uses ( $ this ) ) ) { return $ this -> app [ 'db' ] -> table ( $ table ) -> where ( $ data ) -> count ( ) ; } return $ this -> getDbAdapter ( ) -> table ( ... | Get the number of rows that match the given condition . |
2,327 | public function baseUrl ( ) { if ( isset ( $ this -> baseUrl ) ) { return $ this -> baseUrl ; } $ config = $ this -> getPackageConfig ( ) ; if ( isset ( $ config [ 'baseUrl' ] ) ) { return $ config [ 'baseUrl' ] ; } return 'http://localhost:8888' ; } | Get the base url for all requests . |
2,328 | public function whereExists ( array $ data ) { $ this -> parseConstraints ( $ data ) ; $ query = $ this -> connection -> getPdo ( ) -> prepare ( $ this -> getSelectQuery ( ) ) ; return $ this -> execute ( $ query ) -> fetch ( ) ; } | See if the table contains records that match the given data . |
2,329 | protected function parseConstraints ( array $ wheres ) { foreach ( $ wheres as $ column => $ value ) { $ this -> wheres [ ] = "{$column} = ?" ; $ this -> bindings [ ] = $ value ; } } | Parse the where constraints . |
2,330 | public function put ( $ path , $ contents ) { $ this -> makeDirectory ( dirname ( $ path ) ) ; return file_put_contents ( $ path , $ contents ) ; } | Put to a file path . |
2,331 | public function visit ( $ uri ) { $ this -> currentPage = $ this -> prepareUrl ( $ uri ) ; $ this -> makeRequest ( 'GET' , $ this -> currentPage ) ; return $ this ; } | Make a GET request to the given uri . |
2,332 | protected function prepareUrl ( $ url ) { if ( Str :: startsWith ( $ url , '/' ) ) { $ url = substr ( $ url , 1 ) ; } if ( ! Str :: startsWith ( $ url , 'http' ) ) { $ url = sprintf ( "%s/%s" , $ this -> baseUrl ( ) , $ url ) ; } return trim ( $ url , '/' ) ; } | Prepare the relative URL given by the user . |
2,333 | protected function assertSee ( $ text , $ message , $ negate = false ) { try { $ text = preg_quote ( $ text , '/' ) ; $ method = $ negate ? 'assertNotRegExp' : 'assertRegExp' ; $ this -> $ method ( "/{$text}/i" , $ this -> response ( ) , $ message ) ; } catch ( PHPUnitException $ e ) { $ this -> logLatestContent ( ) ; ... | Assert that the page contains the given text . |
2,334 | public function notSee ( $ text ) { return $ this -> assertSee ( $ text , sprintf ( "Could not find '%s' on the page, '%s'." , $ text , $ this -> currentPage ) , true ) ; } | Assert that the page does not contain the given text . |
2,335 | public function assertPageIs ( $ uri , $ message , $ negate = false ) { $ this -> assertPageLoaded ( $ uri = $ this -> prepareUrl ( $ uri ) ) ; $ method = $ negate ? 'assertNotEquals' : 'assertEquals' ; $ this -> $ method ( $ uri , $ this -> currentPage ( ) , $ message ) ; return $ this ; } | Assert that the page URI matches the given uri . |
2,336 | protected function storeInput ( $ name , $ value ) { $ this -> assertFilterProducedResults ( $ name ) ; $ name = str_replace ( '#' , '' , $ name ) ; $ this -> inputs [ $ name ] = $ value ; return $ this ; } | Store a form input . |
2,337 | protected function fillForm ( $ buttonText , $ formData = [ ] ) { if ( ! is_string ( $ buttonText ) ) { $ formData = $ buttonText ; $ buttonText = null ; } return $ this -> getForm ( $ buttonText ) -> setValues ( $ formData ) ; } | Fill out the form using the given data . |
2,338 | protected function getForm ( $ button = null ) { try { if ( $ button ) { return $ this -> crawler -> selectButton ( $ button ) -> form ( ) ; } return $ this -> crawler -> filter ( 'form' ) -> form ( ) ; } catch ( InvalidArgumentException $ e ) { throw new InvalidArgumentException ( "Couldn't find a form that contains a... | Get the form from the DOM . |
2,339 | protected function assertPageLoaded ( $ uri , $ message = null ) { $ status = $ this -> statusCode ( ) ; try { $ this -> assertEquals ( 200 , $ status ) ; } catch ( PHPUnitException $ e ) { $ message = $ message ? : "A GET request to '{$uri}' failed. Got a {$status} code instead." ; $ this -> logLatestContent ( ) ; if ... | Assert that a 200 status code was returned from the last call . |
2,340 | protected function assertFilterProducedResults ( $ filter ) { $ crawler = $ this -> filterByNameOrId ( $ filter ) ; if ( ! count ( $ crawler ) ) { $ message = "Nothing matched the '{$filter}' CSS query provided for {$this->currentPage}." ; throw new InvalidArgumentException ( $ message ) ; } } | Assert that the filtered Crawler contains nodes . |
2,341 | public function assertInDatabase ( $ table , array $ data , $ message , $ negate = false ) { $ count = $ this -> seeRowsWereReturned ( $ table , $ data ) ; $ method = $ negate ? 'assertEquals' : 'assertGreaterThan' ; $ this -> $ method ( 0 , $ count , $ message ) ; return $ this ; } | Assert that a record is contained in the database . |
2,342 | public function seeInDatabase ( $ table , array $ data ) { return $ this -> assertInDatabase ( $ table , $ data , sprintf ( "Didn't see row in the '%s' table that matched the attributes '%s'." , $ table , json_encode ( $ data ) ) ) ; } | Ensure that a database table contains a row with the given data . |
2,343 | public function notSeeInDatabase ( $ table , array $ data ) { return $ this -> assertInDatabase ( $ table , $ data , sprintf ( "Found row(s) in the '%s' table that matched the attributes '%s', but did not expect to." , $ table , json_encode ( $ data ) ) , true ) ; } | Ensure that a database table does not contain a row with the given data . |
2,344 | protected function getPackageConfig ( $ key = null ) { if ( ! file_exists ( 'integrated.json' ) && ! file_exists ( 'integrated.php' ) ) { return [ ] ; } if ( ! $ this -> packageConfig ) { $ this -> loadPreferredConfigFile ( ) ; } if ( $ key ) { if ( ! isset ( $ this -> packageConfig [ $ key ] ) ) { throw new Integrated... | Fetch the user - provided package configuration . |
2,345 | protected function loadPreferredConfigFile ( ) { if ( file_exists ( 'integrated.php' ) ) { return $ this -> packageConfig = require ( 'integrated.php' ) ; } if ( file_exists ( 'integrated.json' ) ) { $ this -> packageConfig = json_decode ( file_get_contents ( 'integrated.json' ) , true ) ; } } | Load the configuration file . |
2,346 | public function click ( $ name ) { $ page = $ this -> currentPage ( ) ; try { $ link = $ this -> findByBody ( $ name ) -> click ( ) ; } catch ( InvalidArgumentException $ e ) { $ link = $ this -> findByNameOrId ( $ name ) -> click ( ) ; } $ this -> updateCurrentUrl ( ) ; $ this -> assertPageLoaded ( $ page , "Successfu... | Click a link with the given body . |
2,347 | protected function findByNameOrId ( $ name , $ element = '*' ) { $ name = str_replace ( '#' , '' , $ name ) ; try { return $ this -> session -> element ( 'css selector' , "#{$name}, *[name={$name}]" ) ; } catch ( NoSuchElement $ e ) { throw new InvalidArgumentException ( "Couldn't find an element, '{$element}', with a ... | Filter according to an element s name or id attribute . |
2,348 | protected function findByValue ( $ value , $ element = 'input' ) { try { return $ this -> session -> element ( 'css selector' , "{$element}[value='{$value}']" ) ; } catch ( NoSuchElement $ e ) { try { return $ this -> session -> element ( 'xpath' , "//button[contains(text(),'{$value}')]" ) ; } catch ( NoSuchElement $ e... | Find an element by its value attribute . |
2,349 | public function type ( $ text , $ element ) { $ value = [ 'value' => [ $ text ] ] ; $ this -> findByNameOrId ( $ element , $ text ) -> postValue ( $ value ) ; return $ this ; } | Fill in an input with the given text . |
2,350 | public function seeInAlert ( $ text , $ accept = true ) { try { $ alert = $ this -> session -> alert_text ( ) ; } catch ( \ WebDriver \ Exception \ NoAlertOpenError $ e ) { throw new PHPUnitException ( "Could not see '{$text}' because no alert box was shown." ) ; } catch ( \ WebDriver \ Exception \ UnknownError $ e ) {... | Assert that an alert box is displayed and contains the given text . |
2,351 | public function acceptAlert ( ) { try { $ this -> session -> accept_alert ( ) ; } catch ( \ WebDriver \ Exception \ NoAlertOpenError $ e ) { throw new PHPUnitException ( "Well, tried to accept the alert, but there wasn't one. Dangit." ) ; } return $ this ; } | Accept an alert . |
2,352 | public function snap ( $ destination = null ) { $ destination = $ destination ? : './tests/logs/screenshot.png' ; $ this -> files ( ) -> put ( $ destination , base64_decode ( $ this -> session -> screenshot ( ) ) ) ; return $ this ; } | Take a snapshot of the current page . |
2,353 | public function waitForElement ( $ element , $ timeout = 5000 ) { $ this -> session -> timeouts ( ) -> postImplicit_wait ( [ 'ms' => $ timeout ] ) ; try { $ this -> findByNameOrId ( $ element ) ; } catch ( InvalidArgumentException $ e ) { throw new InvalidArgumentException ( "Hey, what's happening... Look, I waited {$t... | Continuously poll the page until you find an element with the given name or id . |
2,354 | protected function newSession ( ) { $ config = $ this -> getPackageConfig ( ) ; $ host = isset ( $ config [ 'selenium' ] [ 'host' ] ) ? $ config [ 'selenium' ] [ 'host' ] : 'http://localhost:4444/wd/hub' ; $ this -> webDriver = new WebDriver ( $ host ) ; $ capabilities = [ ] ; return $ this -> session = $ this -> webDr... | Create a new WebDriver session . |
2,355 | protected function get ( $ uri , array $ params = [ ] ) { $ this -> call ( 'GET' , $ uri , $ params , [ ] , $ this -> cookies , $ this -> headers ) ; return $ this ; } | Make a GET request to an API endpoint . |
2,356 | protected function post ( $ uri , array $ data ) { $ this -> call ( 'POST' , $ uri , $ data , $ this -> cookies , [ ] , $ this -> headers ) ; return $ this ; } | Make a POST request to an API endpoint . |
2,357 | protected function put ( $ uri , array $ data ) { $ this -> call ( 'PUT' , $ uri , $ data , $ this -> cookies , [ ] , $ this -> headers ) ; return $ this ; } | Make a PUT request to an API endpoint . |
2,358 | protected function patch ( $ uri , array $ data ) { $ this -> call ( 'PATCH' , $ uri , $ data , $ this -> cookies , [ ] , $ this -> headers ) ; return $ this ; } | Make a PATCH request to an API endpoint . |
2,359 | protected function delete ( $ uri , array $ data = [ ] ) { $ this -> call ( 'DELETE' , $ uri , $ data , $ this -> cookies , [ ] , $ this -> headers ) ; return $ this ; } | Make a DELETE request to an API endpoint . |
2,360 | protected function seeJsonEquals ( $ expected ) { if ( is_array ( $ expected ) ) { $ expected = json_encode ( $ expected ) ; } $ this -> assertJsonStringEqualsJsonString ( $ expected , $ this -> response ( ) ) ; return $ this ; } | Assert that an API response equals the provided array or json - encoded array . |
2,361 | protected function seeJsonContains ( $ expected ) { $ response = json_decode ( $ this -> response ( ) , true ) ; $ this -> sortJson ( $ expected ) ; $ this -> sortJson ( $ response ) ; foreach ( $ expected as $ key => $ value ) { if ( ! str_contains ( json_encode ( $ response ) , trim ( json_encode ( [ $ key => $ value... | Assert that an API response matches the provided array . |
2,362 | protected function sortJson ( & $ array ) { foreach ( $ array as & $ value ) { if ( is_array ( $ value ) && isset ( $ value [ 0 ] ) ) { sort ( $ value ) ; } elseif ( is_array ( $ value ) ) { $ this -> sortJson ( $ value ) ; } } return ksort ( $ array ) ; } | Sort a JSON response for easy assertions and comparisons . |
2,363 | protected function withHeaders ( array $ headers ) { $ clean = [ ] ; foreach ( $ headers as $ key => $ value ) { if ( ! Str :: startsWith ( $ key , [ 'HTTP_' , 'CONTENT_' ] ) ) { $ key = 'HTTP_' . $ key ; } $ clean [ $ key ] = $ value ; } $ this -> headers = array_merge ( $ this -> headers , $ clean ) ; return $ this ;... | An array of headers to pass along with the request |
2,364 | public function getRepository ( $ className ) { if ( ! is_string ( $ className ) ) { throw new \ InvalidArgumentException ( 'Document class must be a string.' ) ; } $ directory = null ; if ( strpos ( $ className , ':' ) ) { $ bundle = explode ( ':' , $ className ) [ 0 ] ; if ( isset ( $ this -> config [ 'mappings' ] [ ... | Returns repository by document class . |
2,365 | public function search ( array $ types , array $ query , array $ queryStringParams = [ ] ) { $ params = [ ] ; $ params [ 'index' ] = $ this -> getIndexName ( ) ; $ resolvedTypes = [ ] ; foreach ( $ types as $ type ) { $ resolvedTypes [ ] = $ this -> resolveTypeName ( $ type ) ; } if ( ! empty ( $ resolvedTypes ) ) { $ ... | Executes search query in the index . |
2,366 | public function persist ( $ document ) { $ documentArray = $ this -> converter -> convertToArray ( $ document ) ; $ type = $ this -> getMetadataCollector ( ) -> getDocumentType ( get_class ( $ document ) ) ; $ this -> bulk ( 'index' , $ type , $ documentArray ) ; } | Adds document to next flush . |
2,367 | public function remove ( $ document ) { $ data = $ this -> converter -> convertToArray ( $ document , [ ] , [ '_id' , '_routing' ] ) ; if ( ! isset ( $ data [ '_id' ] ) ) { throw new \ LogicException ( 'In order to use remove() method document class must have property with @Id annotation.' ) ; } $ type = $ this -> getM... | Adds document for removal . |
2,368 | public function flush ( array $ params = [ ] ) { return $ this -> client -> indices ( ) -> flush ( array_merge ( [ 'index' => $ this -> getIndexName ( ) ] , $ params ) ) ; } | Flushes elasticsearch index . |
2,369 | public function refresh ( array $ params = [ ] ) { return $ this -> client -> indices ( ) -> refresh ( array_merge ( [ 'index' => $ this -> getIndexName ( ) ] , $ params ) ) ; } | Refreshes elasticsearch index . |
2,370 | public function commit ( array $ params = [ ] ) { if ( ! empty ( $ this -> bulkQueries ) ) { $ bulkQueries = array_merge ( $ this -> bulkQueries , $ this -> bulkParams ) ; $ bulkQueries [ 'index' ] [ '_index' ] = $ this -> getIndexName ( ) ; $ this -> eventDispatcher -> dispatch ( Events :: PRE_COMMIT , new CommitEvent... | Inserts the current query container to the index used for bulk queries execution . |
2,371 | public function bulk ( $ operation , $ type , array $ query ) { if ( ! in_array ( $ operation , [ 'index' , 'create' , 'update' , 'delete' ] ) ) { throw new \ InvalidArgumentException ( 'Wrong bulk operation selected' ) ; } $ this -> eventDispatcher -> dispatch ( Events :: BULK , new BulkEvent ( $ operation , $ type , ... | Adds query to bulk queries container . |
2,372 | public function createIndex ( $ noMapping = false ) { if ( $ noMapping ) { unset ( $ this -> indexSettings [ 'body' ] [ 'mappings' ] ) ; } return $ this -> getClient ( ) -> indices ( ) -> create ( $ this -> indexSettings ) ; } | Creates fresh elasticsearch index . |
2,373 | public function dropAndCreateIndex ( $ noMapping = false ) { try { if ( $ this -> indexExists ( ) ) { $ this -> dropIndex ( ) ; } } catch ( \ Exception $ e ) { } return $ this -> createIndex ( $ noMapping ) ; } | Tries to drop and create fresh elasticsearch index . |
2,374 | public function find ( $ className , $ id , $ routing = null ) { $ type = $ this -> resolveTypeName ( $ className ) ; $ params = [ 'index' => $ this -> getIndexName ( ) , 'type' => $ type , 'id' => $ id , ] ; if ( $ routing ) { $ params [ 'routing' ] = $ routing ; } try { $ result = $ this -> getClient ( ) -> get ( $ p... | Returns a single document by ID . Returns NULL if document was not found . |
2,375 | public function scroll ( $ scrollId , $ scrollDuration = '5m' ) { $ results = $ this -> getClient ( ) -> scroll ( [ 'scroll_id' => $ scrollId , 'scroll' => $ scrollDuration ] ) ; return $ results ; } | Fetches next set of results . |
2,376 | private function resolveTypeName ( $ className ) { if ( strpos ( $ className , ':' ) !== false || strpos ( $ className , '\\' ) !== false ) { return $ this -> getMetadataCollector ( ) -> getDocumentType ( $ className ) ; } return $ className ; } | Resolves type name by class name . |
2,377 | private function stopwatch ( $ action , $ name ) { if ( isset ( $ this -> stopwatch ) ) { $ this -> stopwatch -> $ action ( 'ongr_es: ' . $ name , 'ongr_es' ) ; } } | Starts and stops an event in the stopwatch |
2,378 | public function exportIndex ( Manager $ manager , $ filename , $ types , $ chunkSize , OutputInterface $ output , $ maxLinesInFile = 300000 ) { $ search = new Search ( ) ; $ search -> addQuery ( new MatchAllQuery ( ) ) ; $ search -> setSize ( $ chunkSize ) ; $ search -> addSort ( new FieldSort ( '_doc' ) ) ; $ queryPar... | Exports es index to provided file . |
2,379 | public function getMappings ( array $ bundles ) { $ output = [ ] ; foreach ( $ bundles as $ name => $ bundleConfig ) { if ( ! is_array ( $ bundleConfig ) ) { $ name = $ bundleConfig ; $ bundleConfig = [ ] ; } $ mappings = $ this -> getBundleMapping ( $ name , $ bundleConfig ) ; $ alreadyDefinedTypes = array_intersect_k... | Fetches bundles mapping from documents . |
2,380 | public function getBundleMapping ( $ name , $ config = [ ] ) { if ( ! is_string ( $ name ) ) { throw new \ LogicException ( 'getBundleMapping() in the Metadata collector expects a string argument only!' ) ; } $ cacheName = 'ongr.metadata.mapping.' . md5 ( $ name . serialize ( $ config ) ) ; $ this -> enableCache && $ m... | Searches for documents in the bundle and tries to read them . |
2,381 | public function getClientMapping ( array $ bundles ) { $ typesMapping = null ; $ mappings = $ this -> getMappings ( $ bundles ) ; foreach ( $ mappings as $ type => $ mapping ) { if ( ! empty ( $ mapping [ 'properties' ] ) ) { $ typesMapping [ $ type ] = array_filter ( array_merge ( [ 'properties' => $ mapping [ 'proper... | Retrieves prepared mapping to sent to the elasticsearch client . |
2,382 | public function getClientAnalysis ( array $ bundles , $ analysisConfig = [ ] ) { $ cacheName = 'ongr.metadata.analysis.' . md5 ( serialize ( $ bundles ) ) ; $ this -> enableCache && $ typesAnalysis = $ this -> cache -> fetch ( $ cacheName ) ; if ( isset ( $ typesAnalysis ) && false !== $ typesAnalysis ) { return $ type... | Prepares analysis node for Elasticsearch client . |
2,383 | private function getAnalysisNodeConfiguration ( $ type , $ analyzer , $ analysisConfig , $ container = [ ] ) { if ( isset ( $ analyzer [ $ type ] ) ) { if ( is_array ( $ analyzer [ $ type ] ) ) { foreach ( $ analyzer [ $ type ] as $ filter ) { if ( isset ( $ analysisConfig [ $ type ] [ $ filter ] ) ) { $ container [ $ ... | Prepares analysis node content for Elasticsearch client . |
2,384 | public function getMapping ( $ namespace ) { $ cacheName = 'ongr.metadata.document.' . md5 ( $ namespace ) ; $ namespace = $ this -> getClassName ( $ namespace ) ; $ this -> enableCache && $ mapping = $ this -> cache -> fetch ( $ cacheName ) ; if ( isset ( $ mapping ) && false !== $ mapping ) { return $ mapping ; } $ m... | Returns single document mapping metadata . |
2,385 | public function convertToDocument ( $ rawData , Manager $ manager ) { $ types = $ this -> metadataCollector -> getMappings ( $ manager -> getConfig ( ) [ 'mappings' ] ) ; if ( isset ( $ types [ $ rawData [ '_type' ] ] ) ) { $ metadata = $ types [ $ rawData [ '_type' ] ] ; } else { throw new \ LogicException ( "Got docu... | Converts raw array to document . |
2,386 | public function assignArrayToObject ( array $ array , $ object , array $ aliases ) { foreach ( $ array as $ name => $ value ) { if ( ! isset ( $ aliases [ $ name ] ) ) { continue ; } if ( isset ( $ aliases [ $ name ] [ 'type' ] ) ) { switch ( $ aliases [ $ name ] [ 'type' ] ) { case 'date' : if ( is_null ( $ value ) ||... | Assigns all properties to object . |
2,387 | public function convertToArray ( $ object , $ aliases = [ ] , $ fields = [ ] ) { if ( empty ( $ aliases ) ) { $ aliases = $ this -> getAlias ( $ object ) ; if ( count ( $ fields ) > 0 ) { $ aliases = array_intersect_key ( $ aliases , array_flip ( $ fields ) ) ; } } $ array = [ ] ; foreach ( $ aliases as $ name => $ ali... | Converts object to an array . |
2,388 | private function checkVariableType ( $ object , array $ expectedClasses ) { if ( ! is_object ( $ object ) ) { $ msg = 'Expected variable of type object, got ' . gettype ( $ object ) . ". (field isn't multiple)" ; throw new \ InvalidArgumentException ( $ msg ) ; } $ classes = class_parents ( $ object ) ; $ classes [ ] =... | Check if class matches the expected one . |
2,389 | private function isCollection ( $ property , $ value ) { if ( ! $ value instanceof Collection ) { $ got = is_object ( $ value ) ? get_class ( $ value ) : gettype ( $ value ) ; throw new \ InvalidArgumentException ( sprintf ( 'Value of "%s" property must be an instance of Collection, got %s.' , $ property , $ got ) ) ; ... | Check if value is instance of Collection . |
2,390 | public function createManager ( $ managerName , $ connection , $ analysis , $ managerConfig ) { $ mappings = $ this -> metadataCollector -> getClientMapping ( $ managerConfig [ 'mappings' ] ) ; $ client = ClientBuilder :: create ( ) ; $ client -> setHosts ( $ connection [ 'hosts' ] ) ; $ client -> setTracer ( $ this ->... | Factory function to create a manager instance . |
2,391 | private function handleRecords ( $ route , $ records ) { $ this -> count += count ( $ records ) / 2 ; $ queryBody = '' ; foreach ( $ records as $ record ) { if ( ! empty ( $ record [ 'context' ] ) ) { $ this -> time += $ record [ 'context' ] [ 'duration' ] ; $ this -> addQuery ( $ route , $ record , $ queryBody ) ; } e... | Handles passed records . |
2,392 | private function addQuery ( $ route , $ record , $ queryBody ) { parse_str ( parse_url ( $ record [ 'context' ] [ 'uri' ] , PHP_URL_QUERY ) , $ httpParameters ) ; $ body = json_decode ( trim ( $ queryBody , " '\r\t\n" ) ) ; $ this -> queries [ $ route ] [ ] = array_merge ( [ 'body' => $ body !== null ? json_encode ( $ ... | Adds query to collected data array . |
2,393 | private function getRoute ( Request $ request ) { $ route = $ request -> attributes -> get ( '_route' ) ; return empty ( $ route ) ? self :: UNDEFINED_ROUTE : $ route ; } | Returns route name from request . |
2,394 | public function getAggregation ( $ name ) { if ( isset ( $ this -> aggregations [ $ name ] ) ) { return $ this -> aggregations [ $ name ] ; } return null ; } | Returns specific aggregation by name . |
2,395 | protected function getDocument ( $ key ) { if ( ! $ this -> documentExists ( $ key ) ) { return null ; } return $ this -> convertDocument ( $ this -> documents [ $ key ] ) ; } | Gets document array from the container . |
2,396 | protected function advanceKey ( ) { if ( $ this -> isScrollable ( ) && ( $ this -> documents [ $ this -> key ( ) ] == end ( $ this -> documents ) ) ) { $ this -> page ( ) ; } else { $ this -> key ++ ; } return $ this ; } | Advances key . |
2,397 | protected function page ( ) { if ( $ this -> key ( ) == $ this -> count ( ) || ! $ this -> isScrollable ( ) ) { return $ this ; } $ raw = $ this -> manager -> getClient ( ) -> scroll ( [ 'scroll' => $ this -> scrollDuration , 'scroll_id' => $ this -> scrollId , ] ) ; $ this -> rewind ( ) ; $ this -> scrollId = $ raw [ ... | Advances scan page . |
2,398 | public function getDocumentScore ( ) { if ( ! $ this -> valid ( ) ) { throw new \ LogicException ( 'Document score is available only while iterating over results.' ) ; } if ( ! isset ( $ this -> documents [ $ this -> key ] [ '_score' ] ) ) { return null ; } return $ this -> documents [ $ this -> key ] [ '_score' ] ; } | Returns score of current hit . |
2,399 | public function getDocumentSort ( ) { if ( ! $ this -> valid ( ) ) { throw new \ LogicException ( 'Document sort is available only while iterating over results.' ) ; } if ( ! isset ( $ this -> documents [ $ this -> key ] [ 'sort' ] ) ) { return null ; } return $ this -> documents [ $ this -> key ] [ 'sort' ] [ 0 ] ; } | Returns sort of current hit . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.