idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
12,400 | public function prepareAssociatedDocumentValue ( array $ mapping , $ document , $ includeNestedCollections = false ) { if ( isset ( $ mapping [ 'embedded' ] ) ) { return $ this -> prepareEmbeddedDocumentValue ( $ mapping , $ document , $ includeNestedCollections ) ; } if ( isset ( $ mapping [ 'reference' ] ) ) { return $ this -> prepareReferencedDocumentValue ( $ mapping , $ document ) ; } throw new InvalidArgumentException ( 'Mapping is neither embedded nor reference.' ) ; } | Returns the embedded document or reference representation to be stored . |
12,401 | protected function validateIdentifier ( ClassMetadata $ class ) : void { if ( ! $ class -> identifier && ! $ class -> isMappedSuperclass && ! $ class -> isEmbeddedDocument && ! $ class -> isQueryResultDocument ) { throw MappingException :: identifierRequired ( $ class -> name ) ; } } | Validates the identifier mapping . |
12,402 | private function setInheritedShardKey ( ClassMetadata $ subClass , ClassMetadata $ parentClass ) : void { if ( ! $ parentClass -> isSharded ( ) ) { return ; } $ subClass -> setShardKey ( $ parentClass -> shardKey [ 'keys' ] , $ parentClass -> shardKey [ 'options' ] ) ; } | Adds inherited shard key to the subclass mapping . |
12,403 | public function update ( object $ parent , array $ collections , array $ options ) : void { $ setStrategyColls = [ ] ; $ addPushStrategyColls = [ ] ; foreach ( $ collections as $ coll ) { $ mapping = $ coll -> getMapping ( ) ; if ( $ mapping [ 'isInverseSide' ] ) { continue ; } switch ( $ mapping [ 'strategy' ] ) { case ClassMetadata :: STORAGE_STRATEGY_ATOMIC_SET : case ClassMetadata :: STORAGE_STRATEGY_ATOMIC_SET_ARRAY : throw new UnexpectedValueException ( $ mapping [ 'strategy' ] . ' update collection strategy should have been handled by DocumentPersister. Please report a bug in issue tracker' ) ; case ClassMetadata :: STORAGE_STRATEGY_SET : case ClassMetadata :: STORAGE_STRATEGY_SET_ARRAY : $ setStrategyColls [ ] = $ coll ; break ; case ClassMetadata :: STORAGE_STRATEGY_ADD_TO_SET : case ClassMetadata :: STORAGE_STRATEGY_PUSH_ALL : $ addPushStrategyColls [ ] = $ coll ; break ; default : throw new UnexpectedValueException ( 'Unsupported collection strategy: ' . $ mapping [ 'strategy' ] ) ; } } if ( ! empty ( $ setStrategyColls ) ) { $ this -> setCollections ( $ parent , $ setStrategyColls , $ options ) ; } if ( empty ( $ addPushStrategyColls ) ) { return ; } $ this -> deleteElements ( $ parent , $ addPushStrategyColls , $ options ) ; $ this -> insertElements ( $ parent , $ addPushStrategyColls , $ options ) ; } | Updates a list PersistentCollection instances deleting removed rows and inserting new rows . |
12,404 | private function setCollections ( object $ parent , array $ collections , array $ options ) : void { $ pathCollMap = [ ] ; $ paths = [ ] ; foreach ( $ collections as $ coll ) { [ $ propertyPath ] = $ this -> getPathAndParent ( $ coll ) ; $ pathCollMap [ $ propertyPath ] = $ coll ; $ paths [ ] = $ propertyPath ; } $ paths = $ this -> excludeSubPaths ( $ paths ) ; $ setColls = array_intersect_key ( $ pathCollMap , array_flip ( $ paths ) ) ; $ setPayload = [ ] ; foreach ( $ setColls as $ propertyPath => $ coll ) { $ coll -> initialize ( ) ; $ mapping = $ coll -> getMapping ( ) ; $ setData = $ this -> pb -> prepareAssociatedCollectionValue ( $ coll , CollectionHelper :: usesSet ( $ mapping [ 'strategy' ] ) ) ; $ setPayload [ $ propertyPath ] = $ setData ; } if ( empty ( $ setPayload ) ) { return ; } $ query = [ '$set' => $ setPayload ] ; $ this -> executeQuery ( $ parent , $ query , $ options ) ; } | Sets a list of PersistentCollection instances . |
12,405 | private function deleteElements ( object $ parent , array $ collections , array $ options ) : void { $ pathCollMap = [ ] ; $ paths = [ ] ; $ deleteDiffMap = [ ] ; foreach ( $ collections as $ coll ) { $ coll -> initialize ( ) ; if ( ! $ this -> uow -> isCollectionScheduledForUpdate ( $ coll ) ) { continue ; } $ deleteDiff = $ coll -> getDeleteDiff ( ) ; if ( empty ( $ deleteDiff ) ) { continue ; } [ $ propertyPath ] = $ this -> getPathAndParent ( $ coll ) ; $ pathCollMap [ $ propertyPath ] = $ coll ; $ paths [ ] = $ propertyPath ; $ deleteDiffMap [ $ propertyPath ] = $ deleteDiff ; } $ paths = $ this -> excludeSubPaths ( $ paths ) ; $ deleteColls = array_intersect_key ( $ pathCollMap , array_flip ( $ paths ) ) ; $ unsetPayload = [ ] ; $ pullPayload = [ ] ; foreach ( $ deleteColls as $ propertyPath => $ coll ) { $ deleteDiff = $ deleteDiffMap [ $ propertyPath ] ; foreach ( $ deleteDiff as $ key => $ document ) { $ unsetPayload [ $ propertyPath . '.' . $ key ] = true ; } $ pullPayload [ $ propertyPath ] = null ; } if ( ! empty ( $ unsetPayload ) ) { $ this -> executeQuery ( $ parent , [ '$unset' => $ unsetPayload ] , $ options ) ; } if ( empty ( $ pullPayload ) ) { return ; } $ this -> executeQuery ( $ parent , [ '$pull' => $ pullPayload ] , $ options ) ; } | Deletes removed elements from a list of PersistentCollection instances . |
12,406 | private function insertElements ( object $ parent , array $ collections , array $ options ) : void { $ pushAllPathCollMap = [ ] ; $ addToSetPathCollMap = [ ] ; $ pushAllPaths = [ ] ; $ addToSetPaths = [ ] ; $ diffsMap = [ ] ; foreach ( $ collections as $ coll ) { $ coll -> initialize ( ) ; if ( ! $ this -> uow -> isCollectionScheduledForUpdate ( $ coll ) ) { continue ; } $ insertDiff = $ coll -> getInsertDiff ( ) ; if ( empty ( $ insertDiff ) ) { continue ; } $ mapping = $ coll -> getMapping ( ) ; $ strategy = $ mapping [ 'strategy' ] ; [ $ propertyPath ] = $ this -> getPathAndParent ( $ coll ) ; $ diffsMap [ $ propertyPath ] = $ insertDiff ; switch ( $ strategy ) { case ClassMetadata :: STORAGE_STRATEGY_PUSH_ALL : $ pushAllPathCollMap [ $ propertyPath ] = $ coll ; $ pushAllPaths [ ] = $ propertyPath ; break ; case ClassMetadata :: STORAGE_STRATEGY_ADD_TO_SET : $ addToSetPathCollMap [ $ propertyPath ] = $ coll ; $ addToSetPaths [ ] = $ propertyPath ; break ; default : throw new LogicException ( 'Invalid strategy ' . $ strategy . ' given for insertCollections' ) ; } } if ( ! empty ( $ pushAllPaths ) ) { $ this -> pushAllCollections ( $ parent , $ pushAllPaths , $ pushAllPathCollMap , $ diffsMap , $ options ) ; } if ( empty ( $ addToSetPaths ) ) { return ; } $ this -> addToSetCollections ( $ parent , $ addToSetPaths , $ addToSetPathCollMap , $ diffsMap , $ options ) ; } | Inserts new elements for a PersistentCollection instances . |
12,407 | private function pushAllCollections ( object $ parent , array $ collsPaths , array $ pathCollsMap , array $ diffsMap , array $ options ) : void { $ pushAllPaths = $ this -> excludeSubPaths ( $ collsPaths ) ; $ pushAllColls = array_intersect_key ( $ pathCollsMap , array_flip ( $ pushAllPaths ) ) ; $ pushAllPayload = [ ] ; foreach ( $ pushAllColls as $ propertyPath => $ coll ) { $ callback = $ this -> getValuePrepareCallback ( $ coll ) ; $ value = array_values ( array_map ( $ callback , $ diffsMap [ $ propertyPath ] ) ) ; $ pushAllPayload [ $ propertyPath ] = [ '$each' => $ value ] ; } if ( ! empty ( $ pushAllPayload ) ) { $ this -> executeQuery ( $ parent , [ '$push' => $ pushAllPayload ] , $ options ) ; } $ pushAllColls = array_diff_key ( $ pathCollsMap , array_flip ( $ pushAllPaths ) ) ; foreach ( $ pushAllColls as $ propertyPath => $ coll ) { $ callback = $ this -> getValuePrepareCallback ( $ coll ) ; $ value = array_values ( array_map ( $ callback , $ diffsMap [ $ propertyPath ] ) ) ; $ query = [ '$push' => [ $ propertyPath => [ '$each' => $ value ] ] ] ; $ this -> executeQuery ( $ parent , $ query , $ options ) ; } } | Perform collections update for pushAll strategy . |
12,408 | private function addToSetCollections ( object $ parent , array $ collsPaths , array $ pathCollsMap , array $ diffsMap , array $ options ) : void { $ addToSetPaths = $ this -> excludeSubPaths ( $ collsPaths ) ; $ addToSetColls = array_intersect_key ( $ pathCollsMap , array_flip ( $ addToSetPaths ) ) ; $ addToSetPayload = [ ] ; foreach ( $ addToSetColls as $ propertyPath => $ coll ) { $ callback = $ this -> getValuePrepareCallback ( $ coll ) ; $ value = array_values ( array_map ( $ callback , $ diffsMap [ $ propertyPath ] ) ) ; $ addToSetPayload [ $ propertyPath ] = [ '$each' => $ value ] ; } if ( empty ( $ addToSetPayload ) ) { return ; } $ this -> executeQuery ( $ parent , [ '$addToSet' => $ addToSetPayload ] , $ options ) ; } | Perform collections update by addToSet strategy . |
12,409 | private function getValuePrepareCallback ( PersistentCollectionInterface $ coll ) : Closure { $ mapping = $ coll -> getMapping ( ) ; if ( isset ( $ mapping [ 'embedded' ] ) ) { return function ( $ v ) use ( $ mapping ) { return $ this -> pb -> prepareEmbeddedDocumentValue ( $ mapping , $ v ) ; } ; } return function ( $ v ) use ( $ mapping ) { return $ this -> pb -> prepareReferencedDocumentValue ( $ mapping , $ v ) ; } ; } | Return callback instance for specified collection . This callback will prepare values for query from documents that collection contain . |
12,410 | private function excludeSubPaths ( array $ paths ) : array { if ( empty ( $ paths ) ) { return $ paths ; } sort ( $ paths ) ; $ uniquePaths = [ $ paths [ 0 ] ] ; for ( $ i = 1 , $ count = count ( $ paths ) ; $ i < $ count ; ++ $ i ) { $ lastUniquePath = end ( $ uniquePaths ) ; assert ( $ lastUniquePath !== false ) ; if ( strpos ( $ paths [ $ i ] , $ lastUniquePath ) === 0 ) { continue ; } $ uniquePaths [ ] = $ paths [ $ i ] ; } return $ uniquePaths ; } | Remove from passed paths list all sub - paths . |
12,411 | public function near ( $ x , $ y = null ) : self { if ( $ x instanceof Point ) { $ x = $ x -> jsonSerialize ( ) ; } $ this -> near = is_array ( $ x ) ? $ x : [ $ x , $ y ] ; $ this -> spherical = is_array ( $ x ) && isset ( $ x [ 'type' ] ) ; return $ this ; } | The point for which to find the closest documents . |
12,412 | public function getFilter ( string $ name ) : BsonFilter { if ( ! $ this -> isEnabled ( $ name ) ) { throw new InvalidArgumentException ( "Filter '" . $ name . "' is not enabled." ) ; } return $ this -> enabledFilters [ $ name ] ; } | Get an enabled filter from the collection . |
12,413 | public function connectToField ( string $ connectToField ) : self { $ this -> connectToField = $ this -> convertTargetFieldName ( $ connectToField ) ; return $ this ; } | Field name in other documents against which to match the value of the field specified by the connectFromField parameter . |
12,414 | public function concat ( $ expression1 , $ expression2 , ... $ expressions ) : self { $ this -> expr -> concat ( ... func_get_args ( ) ) ; return $ this ; } | Concatenates strings and returns the concatenated string . |
12,415 | public function concatArrays ( $ array1 , $ array2 , ... $ arrays ) : self { $ this -> expr -> concatArrays ( ... func_get_args ( ) ) ; return $ this ; } | Concatenates arrays to return the concatenated array . |
12,416 | public function dateToString ( $ format , $ expression ) : self { $ this -> expr -> dateToString ( $ format , $ expression ) ; return $ this ; } | Converts a date object to a string according to a user - specified format . |
12,417 | public function divide ( $ expression1 , $ expression2 ) : self { $ this -> expr -> divide ( $ expression1 , $ expression2 ) ; return $ this ; } | Divides one number by another and returns the result . The first argument is divided by the second argument . |
12,418 | public function eq ( $ expression1 , $ expression2 ) : self { $ this -> expr -> eq ( $ expression1 , $ expression2 ) ; return $ this ; } | Compares two values and returns whether they are equivalent . |
12,419 | public function in ( $ expression , $ arrayExpression ) : self { $ this -> expr -> in ( $ expression , $ arrayExpression ) ; return $ this ; } | Returns a boolean indicating whether a specified value is in an array . |
12,420 | public function ifNull ( $ expression , $ replacementExpression ) : self { $ this -> expr -> ifNull ( $ expression , $ replacementExpression ) ; return $ this ; } | Evaluates an expression and returns the value of the expression if the expression evaluates to a non - null value . If the expression evaluates to a null value including instances of undefined values or missing fields returns the value of the replacement expression . |
12,421 | public function let ( $ vars , $ in ) : self { $ this -> expr -> let ( $ vars , $ in ) ; return $ this ; } | Binds variables for use in the specified expression and returns the result of the expression . |
12,422 | public function log ( $ number , $ base ) : self { $ this -> expr -> log ( $ number , $ base ) ; return $ this ; } | Calculates the log of a number in the specified base and returns the result as a double . |
12,423 | public function mod ( $ expression1 , $ expression2 ) : self { $ this -> expr -> mod ( $ expression1 , $ expression2 ) ; return $ this ; } | Divides one number by another and returns the remainder . The first argument is divided by the second argument . |
12,424 | public function multiply ( $ expression1 , $ expression2 , ... $ expressions ) : self { $ this -> expr -> multiply ( ... func_get_args ( ) ) ; return $ this ; } | Multiplies numbers together and returns the result . |
12,425 | public function pow ( $ number , $ exponent ) : self { $ this -> expr -> pow ( $ number , $ exponent ) ; return $ this ; } | Raises a number to the specified exponent and returns the result . |
12,426 | public function setDifference ( $ expression1 , $ expression2 ) : self { $ this -> expr -> setDifference ( $ expression1 , $ expression2 ) ; return $ this ; } | Takes two sets and returns an array containing the elements that only exist in the first set . |
12,427 | public function setEquals ( $ expression1 , $ expression2 , ... $ expressions ) : self { $ this -> expr -> setEquals ( ... func_get_args ( ) ) ; return $ this ; } | Compares two or more arrays and returns true if they have the same distinct elements and false otherwise . |
12,428 | public function setIntersection ( $ expression1 , $ expression2 , ... $ expressions ) : self { $ this -> expr -> setIntersection ( ... func_get_args ( ) ) ; return $ this ; } | Takes two or more arrays and returns an array that contains the elements that appear in every input array . |
12,429 | public function setIsSubset ( $ expression1 , $ expression2 ) : self { $ this -> expr -> setIsSubset ( $ expression1 , $ expression2 ) ; return $ this ; } | Takes two arrays and returns true when the first array is a subset of the second including when the first array equals the second array and false otherwise . |
12,430 | public function setUnion ( $ expression1 , $ expression2 , ... $ expressions ) : self { $ this -> expr -> setUnion ( ... func_get_args ( ) ) ; return $ this ; } | Takes two or more arrays and returns an array containing the elements that appear in any input array . |
12,431 | public function split ( $ string , $ delimiter ) : self { $ this -> expr -> split ( $ string , $ delimiter ) ; return $ this ; } | Divides a string into an array of substrings based on a delimiter . |
12,432 | public function subtract ( $ expression1 , $ expression2 ) : self { $ this -> expr -> subtract ( $ expression1 , $ expression2 ) ; return $ this ; } | Subtracts two numbers to return the difference . The second argument is subtracted from the first argument . |
12,433 | public function pipeline ( $ builder ) : self { if ( ! $ this -> field ) { throw new LogicException ( __METHOD__ . ' requires you set a current field using field().' ) ; } if ( $ builder instanceof Stage ) { $ builder = $ builder -> builder ; } if ( ! $ builder instanceof Builder ) { throw new InvalidArgumentException ( __METHOD__ . ' expects either an aggregation builder or an aggregation stage.' ) ; } $ this -> pipelines [ $ this -> field ] = $ builder ; return $ this ; } | Use the given pipeline for the current field . |
12,434 | public static function getDateTime ( $ value ) : DateTimeInterface { $ datetime = false ; $ exception = null ; if ( $ value instanceof DateTimeInterface ) { return $ value ; } elseif ( $ value instanceof UTCDateTime ) { $ datetime = $ value -> toDateTime ( ) ; $ datetime -> setTimezone ( new DateTimeZone ( date_default_timezone_get ( ) ) ) ; } elseif ( is_numeric ( $ value ) ) { $ value = ( float ) $ value ; $ seconds = ( int ) $ value ; $ microseconds = abs ( round ( $ value - $ seconds , 6 ) ) ; $ microseconds *= 1000000 ; $ datetime = static :: craftDateTime ( $ seconds , ( int ) $ microseconds ) ; } elseif ( is_string ( $ value ) ) { try { $ datetime = new DateTime ( $ value ) ; } catch ( Throwable $ e ) { $ exception = $ e ; } } if ( $ datetime === false ) { throw new InvalidArgumentException ( sprintf ( 'Could not convert %s to a date value' , is_scalar ( $ value ) ? '"' . $ value . '"' : gettype ( $ value ) ) , 0 , $ exception ) ; } return $ datetime ; } | Converts a value to a DateTime . Supports microseconds |
12,435 | private function doRemove ( $ offset , $ arrayAccess ) { $ this -> initialize ( ) ; if ( $ arrayAccess ) { $ this -> coll -> offsetUnset ( $ offset ) ; $ removed = true ; } else { $ removed = $ this -> coll -> remove ( $ offset ) ; } if ( ! $ removed && ! $ arrayAccess ) { return $ removed ; } $ this -> changed ( ) ; return $ removed ; } | Actual logic for removing element by its key . |
12,436 | private function doSet ( $ offset , $ value , $ arrayAccess ) { $ arrayAccess ? $ this -> coll -> offsetSet ( $ offset , $ value ) : $ this -> coll -> set ( $ offset , $ value ) ; if ( $ this -> uow !== null && $ this -> isOrphanRemovalEnabled ( ) && $ value !== null ) { $ this -> uow -> unscheduleOrphanRemoval ( $ value ) ; } $ this -> changed ( ) ; } | Actual logic for setting an element in the collection . |
12,437 | public function debug ( ? string $ name = null ) { return $ name !== null ? $ this -> query [ $ name ] : $ this -> query ; } | Return an array of information about the query structure for debugging . |
12,438 | private function makeIterator ( Traversable $ cursor ) : Iterator { if ( $ this -> hydrate ) { $ cursor = new HydratingIterator ( $ cursor , $ this -> dm -> getUnitOfWork ( ) , $ this -> class , $ this -> unitOfWorkHints ) ; } $ cursor = new CachingIterator ( $ cursor ) ; if ( ! empty ( $ this -> primers ) ) { $ referencePrimer = new ReferencePrimer ( $ this -> dm , $ this -> dm -> getUnitOfWork ( ) ) ; $ cursor = new PrimingIterator ( $ cursor , $ this -> class , $ referencePrimer , $ this -> primers , $ this -> unitOfWorkHints ) ; } return $ cursor ; } | Decorate the cursor with caching hydration and priming behavior . |
12,439 | public function find ( $ id , int $ lockMode = LockMode :: NONE , ? int $ lockVersion = null ) : ? object { if ( $ id === null ) { return null ; } if ( is_array ( $ id ) ) { [ $ identifierFieldName ] = $ this -> class -> getIdentifierFieldNames ( ) ; if ( isset ( $ id [ $ identifierFieldName ] ) ) { $ id = $ id [ $ identifierFieldName ] ; } } $ document = $ this -> uow -> tryGetById ( $ id , $ this -> class ) ; if ( $ document ) { if ( $ lockMode !== LockMode :: NONE ) { $ this -> dm -> lock ( $ document , $ lockMode , $ lockVersion ) ; } return $ document ; } $ criteria = [ '_id' => $ id ] ; if ( $ lockMode === LockMode :: NONE ) { return $ this -> getDocumentPersister ( ) -> load ( $ criteria ) ; } if ( $ lockMode === LockMode :: OPTIMISTIC ) { if ( ! $ this -> class -> isVersioned ) { throw LockException :: notVersioned ( $ this -> documentName ) ; } $ document = $ this -> getDocumentPersister ( ) -> load ( $ criteria ) ; if ( $ document ) { $ this -> uow -> lock ( $ document , $ lockMode , $ lockVersion ) ; } return $ document ; } return $ this -> getDocumentPersister ( ) -> load ( $ criteria , null , [ ] , $ lockMode ) ; } | Finds a document matching the specified identifier . Optionally a lock mode and expected version may be specified . |
12,440 | public function getPersistenceBuilder ( ) : PersistenceBuilder { if ( ! $ this -> persistenceBuilder ) { $ this -> persistenceBuilder = new PersistenceBuilder ( $ this -> dm , $ this ) ; } return $ this -> persistenceBuilder ; } | Factory for returning new PersistenceBuilder instances used for preparing data into queries for insert persistence . |
12,441 | public function getCollectionPersister ( ) : CollectionPersister { if ( ! isset ( $ this -> collectionPersister ) ) { $ pb = $ this -> getPersistenceBuilder ( ) ; $ this -> collectionPersister = new Persisters \ CollectionPersister ( $ this -> dm , $ pb , $ this ) ; } return $ this -> collectionPersister ; } | Get the collection persister instance . |
12,442 | public function setDocumentPersister ( string $ documentName , Persisters \ DocumentPersister $ persister ) : void { $ this -> persisters [ $ documentName ] = $ persister ; } | Set the document persister instance to use for the given document name |
12,443 | private function getClassesForCommitAction ( array $ documents , bool $ includeEmbedded = false ) : array { if ( empty ( $ documents ) ) { return [ ] ; } $ divided = [ ] ; $ embeds = [ ] ; foreach ( $ documents as $ oid => $ d ) { $ className = get_class ( $ d ) ; if ( isset ( $ embeds [ $ className ] ) ) { continue ; } if ( isset ( $ divided [ $ className ] ) ) { $ divided [ $ className ] [ 1 ] [ $ oid ] = $ d ; continue ; } $ class = $ this -> dm -> getClassMetadata ( $ className ) ; if ( $ class -> isEmbeddedDocument && ! $ includeEmbedded ) { $ embeds [ $ className ] = true ; continue ; } if ( empty ( $ divided [ $ class -> name ] ) ) { $ divided [ $ class -> name ] = [ $ class , [ $ oid => $ d ] ] ; } else { $ divided [ $ class -> name ] [ 1 ] [ $ oid ] = $ d ; } } return $ divided ; } | Groups a list of scheduled documents by their class . |
12,444 | private function computeScheduleInsertsChangeSets ( ) : void { foreach ( $ this -> documentInsertions as $ document ) { $ class = $ this -> dm -> getClassMetadata ( get_class ( $ document ) ) ; if ( $ class -> isEmbeddedDocument ) { continue ; } $ this -> computeChangeSet ( $ class , $ document ) ; } } | Compute changesets of all documents scheduled for insertion . |
12,445 | private function computeScheduleUpsertsChangeSets ( ) : void { foreach ( $ this -> documentUpserts as $ document ) { $ class = $ this -> dm -> getClassMetadata ( get_class ( $ document ) ) ; if ( $ class -> isEmbeddedDocument ) { continue ; } $ this -> computeChangeSet ( $ class , $ document ) ; } } | Compute changesets of all documents scheduled for upsert . |
12,446 | public function setDocumentChangeSet ( object $ document , array $ changeset ) : void { $ this -> documentChangeSets [ spl_object_hash ( $ document ) ] = $ changeset ; } | Sets the changeset for a document . |
12,447 | public function scheduleForInsert ( ClassMetadata $ class , object $ document ) : void { $ oid = spl_object_hash ( $ document ) ; if ( isset ( $ this -> documentUpdates [ $ oid ] ) ) { throw new InvalidArgumentException ( 'Dirty document can not be scheduled for insertion.' ) ; } if ( isset ( $ this -> documentDeletions [ $ oid ] ) ) { throw new InvalidArgumentException ( 'Removed document can not be scheduled for insertion.' ) ; } if ( isset ( $ this -> documentInsertions [ $ oid ] ) ) { throw new InvalidArgumentException ( 'Document can not be scheduled for insertion twice.' ) ; } $ this -> documentInsertions [ $ oid ] = $ document ; if ( ! isset ( $ this -> documentIdentifiers [ $ oid ] ) ) { return ; } $ this -> addToIdentityMap ( $ document ) ; } | Schedules a document for insertion into the database . If the document already has an identifier it will be added to the identity map . |
12,448 | public function scheduleForUpsert ( ClassMetadata $ class , object $ document ) : void { $ oid = spl_object_hash ( $ document ) ; if ( $ class -> isEmbeddedDocument ) { throw new InvalidArgumentException ( 'Embedded document can not be scheduled for upsert.' ) ; } if ( isset ( $ this -> documentUpdates [ $ oid ] ) ) { throw new InvalidArgumentException ( 'Dirty document can not be scheduled for upsert.' ) ; } if ( isset ( $ this -> documentDeletions [ $ oid ] ) ) { throw new InvalidArgumentException ( 'Removed document can not be scheduled for upsert.' ) ; } if ( isset ( $ this -> documentUpserts [ $ oid ] ) ) { throw new InvalidArgumentException ( 'Document can not be scheduled for upsert twice.' ) ; } $ this -> documentUpserts [ $ oid ] = $ document ; $ this -> documentIdentifiers [ $ oid ] = $ class -> getIdentifierValue ( $ document ) ; $ this -> addToIdentityMap ( $ document ) ; } | Schedules a document for upsert into the database and adds it to the identity map |
12,449 | public function isScheduledForSynchronization ( object $ document ) : bool { $ class = $ this -> dm -> getClassMetadata ( get_class ( $ document ) ) ; return isset ( $ this -> scheduledForSynchronization [ $ class -> name ] [ spl_object_hash ( $ document ) ] ) ; } | Checks whether a document is registered to be checked in the unit of work . |
12,450 | public function scheduleForDelete ( object $ document ) : void { $ oid = spl_object_hash ( $ document ) ; if ( isset ( $ this -> documentInsertions [ $ oid ] ) ) { if ( $ this -> isInIdentityMap ( $ document ) ) { $ this -> removeFromIdentityMap ( $ document ) ; } unset ( $ this -> documentInsertions [ $ oid ] ) ; return ; } if ( ! $ this -> isInIdentityMap ( $ document ) ) { return ; } $ this -> removeFromIdentityMap ( $ document ) ; $ this -> documentStates [ $ oid ] = self :: STATE_REMOVED ; if ( isset ( $ this -> documentUpdates [ $ oid ] ) ) { unset ( $ this -> documentUpdates [ $ oid ] ) ; } if ( isset ( $ this -> documentDeletions [ $ oid ] ) ) { return ; } $ this -> documentDeletions [ $ oid ] = $ document ; } | Schedules a document for deletion . |
12,451 | public function isDocumentScheduled ( object $ document ) : bool { $ oid = spl_object_hash ( $ document ) ; return isset ( $ this -> documentInsertions [ $ oid ] ) || isset ( $ this -> documentUpserts [ $ oid ] ) || isset ( $ this -> documentUpdates [ $ oid ] ) || isset ( $ this -> documentDeletions [ $ oid ] ) ; } | Checks whether a document is scheduled for insertion update or deletion . |
12,452 | public function addToIdentityMap ( object $ document ) : bool { $ class = $ this -> dm -> getClassMetadata ( get_class ( $ document ) ) ; $ id = $ this -> getIdForIdentityMap ( $ document ) ; if ( isset ( $ this -> identityMap [ $ class -> name ] [ $ id ] ) ) { return false ; } $ this -> identityMap [ $ class -> name ] [ $ id ] = $ document ; if ( $ document instanceof NotifyPropertyChanged && ( ! $ document instanceof GhostObjectInterface || $ document -> isProxyInitialized ( ) ) ) { $ document -> addPropertyChangedListener ( $ this ) ; } return true ; } | Registers a document in the identity map . |
12,453 | public function tryGetById ( $ id , ClassMetadata $ class ) { if ( ! $ class -> identifier ) { throw new InvalidArgumentException ( sprintf ( 'Class "%s" does not have an identifier' , $ class -> name ) ) ; } $ serializedId = serialize ( $ class -> getDatabaseIdentifierValue ( $ id ) ) ; return $ this -> identityMap [ $ class -> name ] [ $ serializedId ] ?? false ; } | Tries to get a document by its identifier hash . If no document is found for the given hash FALSE is returned . |
12,454 | public function containsId ( $ id , string $ rootClassName ) : bool { return isset ( $ this -> identityMap [ $ rootClassName ] [ serialize ( $ id ) ] ) ; } | Checks whether an identifier exists in the identity map . |
12,455 | public function persist ( object $ document ) : void { $ class = $ this -> dm -> getClassMetadata ( get_class ( $ document ) ) ; if ( $ class -> isMappedSuperclass || $ class -> isQueryResultDocument ) { throw MongoDBException :: cannotPersistMappedSuperclass ( $ class -> name ) ; } $ visited = [ ] ; $ this -> doPersist ( $ document , $ visited ) ; } | Persists a document as part of the current unit of work . |
12,456 | public function unscheduleOrphanRemoval ( object $ document ) : void { $ oid = spl_object_hash ( $ document ) ; unset ( $ this -> orphanRemovals [ $ oid ] ) ; } | Unschedules an embedded or referenced object for removal . |
12,457 | public function scheduleCollectionDeletion ( PersistentCollectionInterface $ coll ) : void { $ oid = spl_object_hash ( $ coll ) ; unset ( $ this -> collectionUpdates [ $ oid ] ) ; if ( isset ( $ this -> collectionDeletions [ $ oid ] ) ) { return ; } $ this -> collectionDeletions [ $ oid ] = $ coll ; $ this -> scheduleCollectionOwner ( $ coll ) ; } | Schedules a complete collection for removal when this UnitOfWork commits . |
12,458 | public function unscheduleCollectionDeletion ( PersistentCollectionInterface $ coll ) : void { if ( $ coll -> getOwner ( ) === null ) { return ; } $ oid = spl_object_hash ( $ coll ) ; if ( ! isset ( $ this -> collectionDeletions [ $ oid ] ) ) { return ; } $ topmostOwner = $ this -> getOwningDocument ( $ coll -> getOwner ( ) ) ; unset ( $ this -> collectionDeletions [ $ oid ] ) ; unset ( $ this -> hasScheduledCollections [ spl_object_hash ( $ topmostOwner ) ] [ $ oid ] ) ; } | Unschedules a collection from being deleted when this UnitOfWork commits . |
12,459 | public function scheduleCollectionUpdate ( PersistentCollectionInterface $ coll ) : void { $ mapping = $ coll -> getMapping ( ) ; if ( CollectionHelper :: usesSet ( $ mapping [ 'strategy' ] ) ) { $ this -> unscheduleCollectionDeletion ( $ coll ) ; } $ oid = spl_object_hash ( $ coll ) ; if ( isset ( $ this -> collectionUpdates [ $ oid ] ) ) { return ; } $ this -> collectionUpdates [ $ oid ] = $ coll ; $ this -> scheduleCollectionOwner ( $ coll ) ; } | Schedules a collection for update when this UnitOfWork commits . |
12,460 | public function unscheduleCollectionUpdate ( PersistentCollectionInterface $ coll ) : void { if ( $ coll -> getOwner ( ) === null ) { return ; } $ oid = spl_object_hash ( $ coll ) ; if ( ! isset ( $ this -> collectionUpdates [ $ oid ] ) ) { return ; } $ topmostOwner = $ this -> getOwningDocument ( $ coll -> getOwner ( ) ) ; unset ( $ this -> collectionUpdates [ $ oid ] ) ; unset ( $ this -> hasScheduledCollections [ spl_object_hash ( $ topmostOwner ) ] [ $ oid ] ) ; } | Unschedules a collection from being updated when this UnitOfWork commits . |
12,461 | public function setOriginalDocumentProperty ( string $ oid , string $ property , $ value ) : void { $ this -> originalDocumentData [ $ oid ] [ $ property ] = $ value ; } | Sets a property value of the original data array of a document . |
12,462 | public function foreignField ( string $ foreignField ) : self { $ this -> foreignField = $ this -> prepareFieldName ( $ foreignField , $ this -> targetClass ) ; return $ this ; } | Specifies the field from the documents in the from collection . |
12,463 | private static function getReferencePrefix ( string $ storeAs ) : string { if ( ! in_array ( $ storeAs , [ self :: REFERENCE_STORE_AS_REF , self :: REFERENCE_STORE_AS_DB_REF , self :: REFERENCE_STORE_AS_DB_REF_WITH_DB ] ) ) { throw new LogicException ( 'Can only get a reference prefix for DBRef and reference arrays' ) ; } return $ storeAs === self :: REFERENCE_STORE_AS_REF ? '' : '$' ; } | Returns the reference prefix used for a reference |
12,464 | public static function getReferenceFieldName ( string $ storeAs , string $ pathPrefix = '' ) : string { if ( $ storeAs === self :: REFERENCE_STORE_AS_ID ) { return $ pathPrefix ; } return ( $ pathPrefix ? $ pathPrefix . '.' : '' ) . static :: getReferencePrefix ( $ storeAs ) . 'id' ; } | Returns a fully qualified field name for a given reference |
12,465 | public function setDefaultDiscriminatorValue ( ? string $ defaultDiscriminatorValue ) : void { if ( $ this -> isFile ) { throw MappingException :: discriminatorNotAllowedForGridFS ( $ this -> name ) ; } if ( $ defaultDiscriminatorValue === null ) { $ this -> defaultDiscriminatorValue = null ; return ; } if ( ! array_key_exists ( $ defaultDiscriminatorValue , $ this -> discriminatorMap ) ) { throw MappingException :: invalidDiscriminatorValue ( $ defaultDiscriminatorValue , $ this -> name ) ; } $ this -> defaultDiscriminatorValue = $ defaultDiscriminatorValue ; } | Sets the default discriminator value to be used for this class Used for SINGLE_TABLE inheritance mapping strategies if the document has no discriminator value |
12,466 | public function addIndex ( array $ keys , array $ options = [ ] ) : void { $ this -> indexes [ ] = [ 'keys' => array_map ( static function ( $ value ) { if ( $ value === 1 || $ value === - 1 ) { return $ value ; } if ( is_string ( $ value ) ) { $ lower = strtolower ( $ value ) ; if ( $ lower === 'asc' ) { return 1 ; } if ( $ lower === 'desc' ) { return - 1 ; } } return $ value ; } , $ keys ) , 'options' => $ options , ] ; } | Add a index for this Document . |
12,467 | public function setReadPreference ( ? string $ readPreference , array $ tags ) : void { $ this -> readPreference = $ readPreference ; $ this -> readPreferenceTags = $ tags ; } | Sets the read preference used by this class . |
12,468 | public function setCollection ( $ name ) : void { if ( is_array ( $ name ) ) { if ( ! isset ( $ name [ 'name' ] ) ) { throw new InvalidArgumentException ( 'A name key is required when passing an array to setCollection()' ) ; } $ this -> collectionCapped = $ name [ 'capped' ] ?? false ; $ this -> collectionSize = $ name [ 'size' ] ?? 0 ; $ this -> collectionMax = $ name [ 'max' ] ?? 0 ; $ this -> collection = $ name [ 'name' ] ; } else { $ this -> collection = $ name ; } } | Sets the collection this Document is mapped to . |
12,469 | private function applyStorageStrategy ( array & $ mapping ) : void { if ( ! isset ( $ mapping [ 'type' ] ) || isset ( $ mapping [ 'id' ] ) ) { return ; } switch ( true ) { case $ mapping [ 'type' ] === 'int' : case $ mapping [ 'type' ] === 'float' : $ defaultStrategy = self :: STORAGE_STRATEGY_SET ; $ allowedStrategies = [ self :: STORAGE_STRATEGY_SET , self :: STORAGE_STRATEGY_INCREMENT ] ; break ; case $ mapping [ 'type' ] === 'many' : $ defaultStrategy = CollectionHelper :: DEFAULT_STRATEGY ; $ allowedStrategies = [ self :: STORAGE_STRATEGY_PUSH_ALL , self :: STORAGE_STRATEGY_ADD_TO_SET , self :: STORAGE_STRATEGY_SET , self :: STORAGE_STRATEGY_SET_ARRAY , self :: STORAGE_STRATEGY_ATOMIC_SET , self :: STORAGE_STRATEGY_ATOMIC_SET_ARRAY , ] ; break ; default : $ defaultStrategy = self :: STORAGE_STRATEGY_SET ; $ allowedStrategies = [ self :: STORAGE_STRATEGY_SET ] ; } if ( ! isset ( $ mapping [ 'strategy' ] ) ) { $ mapping [ 'strategy' ] = $ defaultStrategy ; } if ( ! in_array ( $ mapping [ 'strategy' ] , $ allowedStrategies ) ) { throw MappingException :: invalidStorageStrategy ( $ this -> name , $ mapping [ 'fieldName' ] , $ mapping [ 'type' ] , $ mapping [ 'strategy' ] ) ; } if ( isset ( $ mapping [ 'reference' ] ) && $ mapping [ 'type' ] === 'many' && $ mapping [ 'isOwningSide' ] && ! empty ( $ mapping [ 'sort' ] ) && ! CollectionHelper :: usesSet ( $ mapping [ 'strategy' ] ) ) { throw MappingException :: referenceManySortMustNotBeUsedWithNonSetCollectionStrategy ( $ this -> name , $ mapping [ 'fieldName' ] , $ mapping [ 'strategy' ] ) ; } } | Validates the storage strategy of a mapping for consistency |
12,470 | public function getPHPIdentifierValue ( $ id ) { $ idType = $ this -> fieldMappings [ $ this -> identifier ] [ 'type' ] ; return Type :: getType ( $ idType ) -> convertToPHPValue ( $ id ) ; } | Casts the identifier to its portable PHP type . |
12,471 | public function getDatabaseIdentifierValue ( $ id ) { $ idType = $ this -> fieldMappings [ $ this -> identifier ] [ 'type' ] ; return Type :: getType ( $ idType ) -> convertToDatabaseValue ( $ id ) ; } | Casts the identifier to its database type . |
12,472 | public function getFieldMappingByDbFieldName ( string $ dbFieldName ) : array { foreach ( $ this -> fieldMappings as $ mapping ) { if ( $ mapping [ 'name' ] === $ dbFieldName ) { return $ mapping ; } } throw MappingException :: mappingNotFoundByDbName ( $ this -> name , $ dbFieldName ) ; } | Gets the field mapping by its DB name . E . g . it returns identifier s mapping when called with _id . |
12,473 | public function isNullable ( string $ fieldName ) : bool { $ mapping = $ this -> getFieldMapping ( $ fieldName ) ; return isset ( $ mapping [ 'nullable' ] ) && $ mapping [ 'nullable' ] === true ; } | Check if the field is not null . |
12,474 | public function getAssociationCollectionClass ( string $ assocName ) : string { if ( ! isset ( $ this -> associationMappings [ $ assocName ] ) ) { throw new InvalidArgumentException ( "Association name expected, '" . $ assocName . "' is not an association." ) ; } if ( ! array_key_exists ( 'collectionClass' , $ this -> associationMappings [ $ assocName ] ) ) { throw new InvalidArgumentException ( "collectionClass can only be applied to 'embedMany' and 'referenceMany' associations." ) ; } return $ this -> associationMappings [ $ assocName ] [ 'collectionClass' ] ; } | Retrieve the collectionClass associated with an association |
12,475 | public function buckets ( int $ buckets ) : Stage \ BucketAuto { assert ( $ this -> bucket instanceof Stage \ BucketAuto ) ; return $ this -> bucket -> buckets ( $ buckets ) ; } | A positive 32 - bit integer that specifies the number of buckets into which input documents are grouped . |
12,476 | public function granularity ( string $ granularity ) : Stage \ BucketAuto { assert ( $ this -> bucket instanceof Stage \ BucketAuto ) ; return $ this -> bucket -> granularity ( $ granularity ) ; } | A string that specifies the preferred number series to use to ensure that the calculated boundary edges end on preferred round numbers or their powers of 10 . |
12,477 | public function boundaries ( ... $ boundaries ) { assert ( $ this -> bucket instanceof Stage \ Bucket ) ; return $ this -> bucket -> boundaries ( ... $ boundaries ) ; } | An array of values based on the groupBy expression that specify the boundaries for each bucket . |
12,478 | private function isEquivalentIndexKeys ( IndexInfo $ mongoIndex , array $ documentIndex ) : bool { $ mongoIndexKeys = $ mongoIndex [ 'key' ] ; $ documentIndexKeys = $ documentIndex [ 'keys' ] ; if ( isset ( $ mongoIndexKeys [ '_fts' ] ) && $ mongoIndexKeys [ '_fts' ] === 'text' ) { unset ( $ mongoIndexKeys [ '_fts' ] , $ mongoIndexKeys [ '_ftsx' ] ) ; $ documentIndexKeys = array_filter ( $ documentIndexKeys , static function ( $ type ) { return $ type !== 'text' ; } ) ; } return $ mongoIndexKeys == $ documentIndexKeys ; } | Determine if the keys for a MongoDB index can be considered equivalent to those for an index in class metadata . |
12,479 | private function indexOptionsAreMissing ( array $ mongoIndexOptions , array $ documentIndexOptions ) : bool { foreach ( self :: ALLOWED_MISSING_INDEX_OPTIONS as $ option ) { unset ( $ mongoIndexOptions [ $ option ] , $ documentIndexOptions [ $ option ] ) ; } return array_diff_key ( $ mongoIndexOptions , $ documentIndexOptions ) !== [ ] || array_diff_key ( $ documentIndexOptions , $ mongoIndexOptions ) !== [ ] ; } | Checks if any index options are missing . |
12,480 | private function isEquivalentTextIndexWeights ( IndexInfo $ mongoIndex , array $ documentIndex ) : bool { $ mongoIndexWeights = $ mongoIndex [ 'weights' ] ; $ documentIndexWeights = $ documentIndex [ 'options' ] [ 'weights' ] ?? [ ] ; foreach ( $ documentIndex [ 'keys' ] as $ key => $ type ) { if ( $ type !== 'text' || isset ( $ documentIndexWeights [ $ key ] ) ) { continue ; } $ documentIndexWeights [ $ key ] = 1 ; } ksort ( $ mongoIndexWeights ) ; ksort ( $ documentIndexWeights ) ; return $ mongoIndexWeights == $ documentIndexWeights ; } | Determine if the text index weights for a MongoDB index can be considered equivalent to those for an index in class metadata . |
12,481 | public function getDocumentCollection ( string $ className ) : Collection { $ className = $ this -> classNameResolver -> getRealClass ( $ className ) ; $ metadata = $ this -> metadataFactory -> getMetadataFor ( $ className ) ; assert ( $ metadata instanceof ClassMetadata ) ; if ( $ metadata -> isFile ) { return $ this -> getDocumentBucket ( $ className ) -> getFilesCollection ( ) ; } $ collectionName = $ metadata -> getCollection ( ) ; if ( ! $ collectionName ) { throw MongoDBException :: documentNotMappedToCollection ( $ className ) ; } if ( ! isset ( $ this -> documentCollections [ $ className ] ) ) { $ db = $ this -> getDocumentDatabase ( $ className ) ; $ options = [ ] ; if ( $ metadata -> readPreference !== null ) { $ options [ 'readPreference' ] = new ReadPreference ( $ metadata -> readPreference , $ metadata -> readPreferenceTags ) ; } $ this -> documentCollections [ $ className ] = $ db -> selectCollection ( $ collectionName , $ options ) ; } return $ this -> documentCollections [ $ className ] ; } | Returns the collection instance for a class . |
12,482 | public function getDocumentBucket ( string $ className ) : Bucket { $ className = $ this -> classNameResolver -> getRealClass ( $ className ) ; $ metadata = $ this -> metadataFactory -> getMetadataFor ( $ className ) ; if ( ! $ metadata -> isFile ) { throw MongoDBException :: documentBucketOnlyAvailableForGridFSFiles ( $ className ) ; } $ bucketName = $ metadata -> getBucketName ( ) ; if ( ! $ bucketName ) { throw MongoDBException :: documentNotMappedToCollection ( $ className ) ; } if ( ! isset ( $ this -> documentBuckets [ $ className ] ) ) { $ db = $ this -> getDocumentDatabase ( $ className ) ; $ options = [ 'bucketName' => $ bucketName ] ; if ( $ metadata -> readPreference !== null ) { $ options [ 'readPreference' ] = new ReadPreference ( $ metadata -> readPreference , $ metadata -> readPreferenceTags ) ; } $ this -> documentBuckets [ $ className ] = $ db -> selectGridFSBucket ( $ options ) ; } return $ this -> documentBuckets [ $ className ] ; } | Returns the bucket instance for a class . |
12,483 | public function find ( $ documentName , $ identifier , $ lockMode = LockMode :: NONE , $ lockVersion = null ) : ? object { $ repository = $ this -> getRepository ( $ documentName ) ; if ( $ repository instanceof DocumentRepository ) { return $ repository -> find ( $ identifier , $ lockMode , $ lockVersion ) ; } return $ repository -> find ( $ identifier ) ; } | Finds a Document by its identifier . |
12,484 | public function createReference ( object $ document , array $ referenceMapping ) { $ class = $ this -> getClassMetadata ( get_class ( $ document ) ) ; $ id = $ this -> unitOfWork -> getDocumentIdentifier ( $ document ) ; if ( $ id === null ) { throw new RuntimeException ( sprintf ( 'Cannot create a DBRef for class %s without an identifier. Have you forgotten to persist/merge the document first?' , $ class -> name ) ) ; } $ storeAs = $ referenceMapping [ 'storeAs' ] ?? null ; switch ( $ storeAs ) { case ClassMetadata :: REFERENCE_STORE_AS_ID : if ( $ class -> inheritanceType === ClassMetadata :: INHERITANCE_TYPE_SINGLE_COLLECTION ) { throw MappingException :: simpleReferenceMustNotTargetDiscriminatedDocument ( $ referenceMapping [ 'targetDocument' ] ) ; } return $ class -> getDatabaseIdentifierValue ( $ id ) ; break ; case ClassMetadata :: REFERENCE_STORE_AS_REF : $ reference = [ 'id' => $ class -> getDatabaseIdentifierValue ( $ id ) ] ; break ; case ClassMetadata :: REFERENCE_STORE_AS_DB_REF : $ reference = [ '$ref' => $ class -> getCollection ( ) , '$id' => $ class -> getDatabaseIdentifierValue ( $ id ) , ] ; break ; case ClassMetadata :: REFERENCE_STORE_AS_DB_REF_WITH_DB : $ reference = [ '$ref' => $ class -> getCollection ( ) , '$id' => $ class -> getDatabaseIdentifierValue ( $ id ) , '$db' => $ this -> getDocumentDatabase ( $ class -> name ) -> getDatabaseName ( ) , ] ; break ; default : throw new InvalidArgumentException ( sprintf ( 'Reference type %s is invalid.' , $ storeAs ) ) ; } return $ reference + $ this -> getDiscriminatorData ( $ referenceMapping , $ class ) ; } | Returns a reference to the supplied document . |
12,485 | private function getDiscriminatorData ( array $ referenceMapping , ClassMetadata $ class ) : array { $ discriminatorField = null ; $ discriminatorValue = null ; $ discriminatorMap = null ; if ( isset ( $ referenceMapping [ 'discriminatorField' ] ) ) { $ discriminatorField = $ referenceMapping [ 'discriminatorField' ] ; if ( isset ( $ referenceMapping [ 'discriminatorMap' ] ) ) { $ discriminatorMap = $ referenceMapping [ 'discriminatorMap' ] ; } } else { $ discriminatorField = $ class -> discriminatorField ; $ discriminatorValue = $ class -> discriminatorValue ; $ discriminatorMap = $ class -> discriminatorMap ; } if ( $ discriminatorField === null ) { return [ ] ; } if ( $ discriminatorValue === null ) { if ( ! empty ( $ discriminatorMap ) ) { $ pos = array_search ( $ class -> name , $ discriminatorMap ) ; if ( $ pos !== false ) { $ discriminatorValue = $ pos ; } } else { $ discriminatorValue = $ class -> name ; } } if ( $ discriminatorValue === null ) { throw MappingException :: unlistedClassInDiscriminatorMap ( $ class -> name ) ; } return [ $ discriminatorField => $ discriminatorValue ] ; } | Build discriminator portion of reference for specified reference mapping and class metadata . |
12,486 | public function expr ( ) : Expr { $ expr = new Expr ( $ this -> dm ) ; $ expr -> setClassMetadata ( $ this -> class ) ; return $ expr ; } | Create a new Expr instance that can be used as an expression with the Builder |
12,487 | public function field ( string $ field ) : self { $ this -> currentField = $ field ; $ this -> expr -> field ( $ field ) ; return $ this ; } | Set the current field to operate on . |
12,488 | public function find ( ? string $ documentName = null ) : self { $ this -> setDocumentName ( $ documentName ) ; $ this -> query [ 'type' ] = Query :: TYPE_FIND ; return $ this ; } | Change the query type to find and optionally set and change the class being queried . |
12,489 | public function selectMeta ( string $ fieldName , string $ metaDataKeyword ) : self { $ this -> query [ 'select' ] [ $ fieldName ] = [ '$meta' => $ metaDataKeyword ] ; return $ this ; } | Select a metadata field for the query projection . |
12,490 | private function getDiscriminatorValues ( $ classNames ) : array { $ discriminatorValues = [ ] ; $ collections = [ ] ; foreach ( $ classNames as $ className ) { $ class = $ this -> dm -> getClassMetadata ( $ className ) ; $ discriminatorValues [ ] = $ class -> discriminatorValue ; $ key = $ this -> dm -> getDocumentDatabase ( $ className ) -> getDatabaseName ( ) . '.' . $ class -> getCollection ( ) ; $ collections [ $ key ] = $ key ; } if ( count ( $ collections ) > 1 ) { throw new InvalidArgumentException ( 'Documents involved are not all mapped to the same database collection.' ) ; } return $ discriminatorValues ; } | Get Discriminator Values |
12,491 | public function generate ( DocumentManager $ dm , object $ document ) { $ uuid = $ this -> generateV4 ( ) ; return $ this -> generateV5 ( $ uuid , $ this -> salt ? : php_uname ( 'n' ) ) ; } | Generates a new UUID |
12,492 | public function bucket ( ) : Stage \ Bucket { $ stage = new Stage \ Bucket ( $ this , $ this -> dm , $ this -> class ) ; $ this -> addStage ( $ stage ) ; return $ stage ; } | Categorizes incoming documents into groups called buckets based on a specified expression and bucket boundaries . |
12,493 | public function bucketAuto ( ) : Stage \ BucketAuto { $ stage = new Stage \ BucketAuto ( $ this , $ this -> dm , $ this -> class ) ; $ this -> addStage ( $ stage ) ; return $ stage ; } | Categorizes incoming documents into a specific number of groups called buckets based on a specified expression . |
12,494 | public function collStats ( ) : Stage \ CollStats { $ stage = new Stage \ CollStats ( $ this ) ; $ this -> addStage ( $ stage ) ; return $ stage ; } | Returns statistics regarding a collection or view . |
12,495 | public function count ( string $ fieldName ) : Stage \ Count { $ stage = new Stage \ Count ( $ this , $ fieldName ) ; $ this -> addStage ( $ stage ) ; return $ stage ; } | Returns a document that contains a count of the number of documents input to the stage . |
12,496 | public function execute ( array $ options = [ ] ) : Iterator { $ options = array_merge ( $ options , [ 'cursor' => true ] ) ; $ cursor = $ this -> collection -> aggregate ( $ this -> getPipeline ( ) , $ options ) ; assert ( $ cursor instanceof Cursor ) ; return $ this -> prepareIterator ( $ cursor ) ; } | Executes the aggregation pipeline |
12,497 | public function facet ( ) : Stage \ Facet { $ stage = new Stage \ Facet ( $ this ) ; $ this -> addStage ( $ stage ) ; return $ stage ; } | Processes multiple aggregation pipelines within a single stage on the same set of input documents . |
12,498 | public function getPipeline ( ) : array { $ pipeline = array_map ( static function ( Stage $ stage ) { return $ stage -> getExpression ( ) ; } , $ this -> stages ) ; if ( $ this -> getStage ( 0 ) instanceof Stage \ GeoNear ) { $ pipeline [ 0 ] [ '$geoNear' ] [ 'query' ] = $ this -> applyFilters ( $ pipeline [ 0 ] [ '$geoNear' ] [ 'query' ] ) ; } elseif ( $ this -> getStage ( 0 ) instanceof Stage \ IndexStats ) { return $ pipeline ; } else { $ matchExpression = $ this -> applyFilters ( [ ] ) ; if ( $ matchExpression !== [ ] ) { array_unshift ( $ pipeline , [ '$match' => $ matchExpression ] ) ; } } return $ pipeline ; } | Returns the assembled aggregation pipeline |
12,499 | public function graphLookup ( string $ from ) : Stage \ GraphLookup { $ stage = new Stage \ GraphLookup ( $ this , $ from , $ this -> dm , $ this -> class ) ; $ this -> addStage ( $ stage ) ; return $ stage ; } | Performs a recursive search on a collection with options for restricting the search by recursion depth and query filter . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.