repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Persisters/PersistenceBuilder.php
PersistenceBuilder.prepareAssociatedDocumentValue
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.'); }
php
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.'); }
[ "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. @param array $mapping @param object $document @param bool $includeNestedCollections @return array|object|null @throws InvalidArgumentException If the mapping is neither embedded nor reference.
[ "Returns", "the", "embedded", "document", "or", "reference", "representation", "to", "be", "stored", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Persisters/PersistenceBuilder.php#L460-L471
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php
ClassMetadataFactory.validateIdentifier
protected function validateIdentifier(ClassMetadata $class) : void { if (! $class->identifier && ! $class->isMappedSuperclass && ! $class->isEmbeddedDocument && ! $class->isQueryResultDocument) { throw MappingException::identifierRequired($class->name); } }
php
protected function validateIdentifier(ClassMetadata $class) : void { if (! $class->identifier && ! $class->isMappedSuperclass && ! $class->isEmbeddedDocument && ! $class->isQueryResultDocument) { throw MappingException::identifierRequired($class->name); } }
[ "protected", "function", "validateIdentifier", "(", "ClassMetadata", "$", "class", ")", ":", "void", "{", "if", "(", "!", "$", "class", "->", "identifier", "&&", "!", "$", "class", "->", "isMappedSuperclass", "&&", "!", "$", "class", "->", "isEmbeddedDocument", "&&", "!", "$", "class", "->", "isQueryResultDocument", ")", "{", "throw", "MappingException", "::", "identifierRequired", "(", "$", "class", "->", "name", ")", ";", "}", "}" ]
Validates the identifier mapping. @throws MappingException
[ "Validates", "the", "identifier", "mapping", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php#L222-L227
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php
ClassMetadataFactory.setInheritedShardKey
private function setInheritedShardKey(ClassMetadata $subClass, ClassMetadata $parentClass) : void { if (! $parentClass->isSharded()) { return; } $subClass->setShardKey( $parentClass->shardKey['keys'], $parentClass->shardKey['options'] ); }
php
private function setInheritedShardKey(ClassMetadata $subClass, ClassMetadata $parentClass) : void { if (! $parentClass->isSharded()) { return; } $subClass->setShardKey( $parentClass->shardKey['keys'], $parentClass->shardKey['options'] ); }
[ "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.
[ "Adds", "inherited", "shard", "key", "to", "the", "subclass", "mapping", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadataFactory.php#L361-L371
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php
CollectionPersister.update
public function update(object $parent, array $collections, array $options) : void { $setStrategyColls = []; $addPushStrategyColls = []; foreach ($collections as $coll) { $mapping = $coll->getMapping(); if ($mapping['isInverseSide']) { continue; // ignore inverse side } 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); }
php
public function update(object $parent, array $collections, array $options) : void { $setStrategyColls = []; $addPushStrategyColls = []; foreach ($collections as $coll) { $mapping = $coll->getMapping(); if ($mapping['isInverseSide']) { continue; // ignore inverse side } 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); }
[ "public", "function", "update", "(", "object", "$", "parent", ",", "array", "$", "collections", ",", "array", "$", "options", ")", ":", "void", "{", "$", "setStrategyColls", "=", "[", "]", ";", "$", "addPushStrategyColls", "=", "[", "]", ";", "foreach", "(", "$", "collections", "as", "$", "coll", ")", "{", "$", "mapping", "=", "$", "coll", "->", "getMapping", "(", ")", ";", "if", "(", "$", "mapping", "[", "'isInverseSide'", "]", ")", "{", "continue", ";", "// ignore inverse side", "}", "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. @param PersistentCollectionInterface[] $collections @param array $options
[ "Updates", "a", "list", "PersistentCollection", "instances", "deleting", "removed", "rows", "and", "inserting", "new", "rows", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php#L102-L142
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php
CollectionPersister.setCollections
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); /** @var PersistentCollectionInterface[] $setColls */ $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); }
php
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); /** @var PersistentCollectionInterface[] $setColls */ $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); }
[ "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", ")", ";", "/** @var PersistentCollectionInterface[] $setColls */", "$", "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. This method is intended to be used with the "set" or "setArray" strategies. The "setArray" strategy will ensure that the collections is set as a BSON array, which means the collections elements will be reindexed numerically before storage. @param PersistentCollectionInterface[] $collections @param array $options
[ "Sets", "a", "list", "of", "PersistentCollection", "instances", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php#L155-L184
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php
CollectionPersister.deleteElements
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; } /** * @todo This is a hack right now because we don't have a proper way to * remove an element from an array by its key. Unsetting the key results * in the element being left in the array as null so we have to pull * null values. */ $this->executeQuery($parent, ['$pull' => $pullPayload], $options); }
php
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; } /** * @todo This is a hack right now because we don't have a proper way to * remove an element from an array by its key. Unsetting the key results * in the element being left in the array as null so we have to pull * null values. */ $this->executeQuery($parent, ['$pull' => $pullPayload], $options); }
[ "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", ";", "}", "/**\n * @todo This is a hack right now because we don't have a proper way to\n * remove an element from an array by its key. Unsetting the key results\n * in the element being left in the array as null so we have to pull\n * null values.\n */", "$", "this", "->", "executeQuery", "(", "$", "parent", ",", "[", "'$pull'", "=>", "$", "pullPayload", "]", ",", "$", "options", ")", ";", "}" ]
Deletes removed elements from a list of PersistentCollection instances. This method is intended to be used with the "pushAll" and "addToSet" strategies. @param PersistentCollectionInterface[] $collections @param array $options
[ "Deletes", "removed", "elements", "from", "a", "list", "of", "PersistentCollection", "instances", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php#L194-L243
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php
CollectionPersister.insertElements
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 ); }
php
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 ); }
[ "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. This method is intended to be used with the "pushAll" and "addToSet" strategies. @param PersistentCollectionInterface[] $collections @param array $options
[ "Inserts", "new", "elements", "for", "a", "PersistentCollection", "instances", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php#L253-L314
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php
CollectionPersister.pushAllCollections
private function pushAllCollections(object $parent, array $collsPaths, array $pathCollsMap, array $diffsMap, array $options) : void { $pushAllPaths = $this->excludeSubPaths($collsPaths); /** @var PersistentCollectionInterface[] $pushAllColls */ $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); } }
php
private function pushAllCollections(object $parent, array $collsPaths, array $pathCollsMap, array $diffsMap, array $options) : void { $pushAllPaths = $this->excludeSubPaths($collsPaths); /** @var PersistentCollectionInterface[] $pushAllColls */ $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); } }
[ "private", "function", "pushAllCollections", "(", "object", "$", "parent", ",", "array", "$", "collsPaths", ",", "array", "$", "pathCollsMap", ",", "array", "$", "diffsMap", ",", "array", "$", "options", ")", ":", "void", "{", "$", "pushAllPaths", "=", "$", "this", "->", "excludeSubPaths", "(", "$", "collsPaths", ")", ";", "/** @var PersistentCollectionInterface[] $pushAllColls */", "$", "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. @param object $parent Parent object to which passed collections is belong. @param array $collsPaths Paths of collections that is passed. @param array $pathCollsMap List of collections indexed by their paths. @param array $diffsMap List of collection diffs indexed by collections paths. @param array $options
[ "Perform", "collections", "update", "for", "pushAll", "strategy", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php#L325-L348
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php
CollectionPersister.addToSetCollections
private function addToSetCollections(object $parent, array $collsPaths, array $pathCollsMap, array $diffsMap, array $options) : void { $addToSetPaths = $this->excludeSubPaths($collsPaths); /** @var PersistentCollectionInterface[] $addToSetColls */ $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); }
php
private function addToSetCollections(object $parent, array $collsPaths, array $pathCollsMap, array $diffsMap, array $options) : void { $addToSetPaths = $this->excludeSubPaths($collsPaths); /** @var PersistentCollectionInterface[] $addToSetColls */ $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); }
[ "private", "function", "addToSetCollections", "(", "object", "$", "parent", ",", "array", "$", "collsPaths", ",", "array", "$", "pathCollsMap", ",", "array", "$", "diffsMap", ",", "array", "$", "options", ")", ":", "void", "{", "$", "addToSetPaths", "=", "$", "this", "->", "excludeSubPaths", "(", "$", "collsPaths", ")", ";", "/** @var PersistentCollectionInterface[] $addToSetColls */", "$", "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. @param object $parent Parent object to which passed collections is belong. @param array $collsPaths Paths of collections that is passed. @param array $pathCollsMap List of collections indexed by their paths. @param array $diffsMap List of collection diffs indexed by collections paths. @param array $options
[ "Perform", "collections", "update", "by", "addToSet", "strategy", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php#L359-L377
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php
CollectionPersister.getValuePrepareCallback
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); }; }
php
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); }; }
[ "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.
[ "Return", "callback", "instance", "for", "specified", "collection", ".", "This", "callback", "will", "prepare", "values", "for", "query", "from", "documents", "that", "collection", "contain", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php#L383-L395
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php
CollectionPersister.excludeSubPaths
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; }
php
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; }
[ "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. @param string[] $paths @return string[]
[ "Remove", "from", "passed", "paths", "list", "all", "sub", "-", "paths", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Persisters/CollectionPersister.php#L455-L474
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GeoNear.php
GeoNear.near
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; }
php
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; }
[ "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. A GeoJSON point may be provided as the first and only argument for 2dsphere queries. This single parameter may be a GeoJSON point object or an array corresponding to the point's JSON representation. If GeoJSON is used, the "spherical" option will default to true. @param float|array|Point $x @param float $y
[ "The", "point", "for", "which", "to", "find", "the", "closest", "documents", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GeoNear.php#L152-L162
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Query/FilterCollection.php
FilterCollection.getFilter
public function getFilter(string $name) : BsonFilter { if (! $this->isEnabled($name)) { throw new InvalidArgumentException("Filter '" . $name . "' is not enabled."); } return $this->enabledFilters[$name]; }
php
public function getFilter(string $name) : BsonFilter { if (! $this->isEnabled($name)) { throw new InvalidArgumentException("Filter '" . $name . "' is not enabled."); } return $this->enabledFilters[$name]; }
[ "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. @throws InvalidArgumentException If the filter is not enabled.
[ "Get", "an", "enabled", "filter", "from", "the", "collection", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Query/FilterCollection.php#L112-L118
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup.php
GraphLookup.connectToField
public function connectToField(string $connectToField) : self { $this->connectToField = $this->convertTargetFieldName($connectToField); return $this; }
php
public function connectToField(string $connectToField) : self { $this->connectToField = $this->convertTargetFieldName($connectToField); return $this; }
[ "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.
[ "Field", "name", "in", "other", "documents", "against", "which", "to", "match", "the", "value", "of", "the", "field", "specified", "by", "the", "connectFromField", "parameter", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/GraphLookup.php#L119-L123
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.concat
public function concat($expression1, $expression2, ...$expressions) : self { $this->expr->concat(...func_get_args()); return $this; }
php
public function concat($expression1, $expression2, ...$expressions) : self { $this->expr->concat(...func_get_args()); return $this; }
[ "public", "function", "concat", "(", "$", "expression1", ",", "$", "expression2", ",", "...", "$", "expressions", ")", ":", "self", "{", "$", "this", "->", "expr", "->", "concat", "(", "...", "func_get_args", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Concatenates strings and returns the concatenated string. The arguments can be any valid expression as long as they resolve to strings. If the argument resolves to a value of null or refers to a field that is missing, $concat returns null. @see http://docs.mongodb.org/manual/reference/operator/aggregation/concat/ @see Expr::concat @param mixed|Expr $expression1 @param mixed|Expr $expression2 @param mixed|Expr ...$expressions Additional expressions
[ "Concatenates", "strings", "and", "returns", "the", "concatenated", "string", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L221-L226
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.concatArrays
public function concatArrays($array1, $array2, ...$arrays) : self { $this->expr->concatArrays(...func_get_args()); return $this; }
php
public function concatArrays($array1, $array2, ...$arrays) : self { $this->expr->concatArrays(...func_get_args()); return $this; }
[ "public", "function", "concatArrays", "(", "$", "array1", ",", "$", "array2", ",", "...", "$", "arrays", ")", ":", "self", "{", "$", "this", "->", "expr", "->", "concatArrays", "(", "...", "func_get_args", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Concatenates arrays to return the concatenated array. The <array> expressions can be any valid expression as long as they resolve to an array. @see https://docs.mongodb.org/manual/reference/operator/aggregation/concatArrays/ @see Expr::concatArrays @param mixed|Expr $array1 @param mixed|Expr $array2 @param mixed|Expr ...$arrays Additional expressions
[ "Concatenates", "arrays", "to", "return", "the", "concatenated", "array", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L241-L246
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.dateToString
public function dateToString($format, $expression) : self { $this->expr->dateToString($format, $expression); return $this; }
php
public function dateToString($format, $expression) : self { $this->expr->dateToString($format, $expression); return $this; }
[ "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. The format string can be any string literal, containing 0 or more format specifiers. The date argument can be any expression as long as it resolves to a date. @see http://docs.mongodb.org/manual/reference/operator/aggregation/dateToString/ @see Expr::dateToString @param string $format @param mixed|Expr $expression
[ "Converts", "a", "date", "object", "to", "a", "string", "according", "to", "a", "user", "-", "specified", "format", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L281-L286
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.divide
public function divide($expression1, $expression2) : self { $this->expr->divide($expression1, $expression2); return $this; }
php
public function divide($expression1, $expression2) : self { $this->expr->divide($expression1, $expression2); return $this; }
[ "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. The arguments can be any valid expression as long as the resolve to numbers. @see http://docs.mongodb.org/manual/reference/operator/aggregation/divide/ @see Expr::divide @param mixed|Expr $expression1 @param mixed|Expr $expression2
[ "Divides", "one", "number", "by", "another", "and", "returns", "the", "result", ".", "The", "first", "argument", "is", "divided", "by", "the", "second", "argument", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L352-L357
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.eq
public function eq($expression1, $expression2) : self { $this->expr->eq($expression1, $expression2); return $this; }
php
public function eq($expression1, $expression2) : self { $this->expr->eq($expression1, $expression2); return $this; }
[ "public", "function", "eq", "(", "$", "expression1", ",", "$", "expression2", ")", ":", "self", "{", "$", "this", "->", "expr", "->", "eq", "(", "$", "expression1", ",", "$", "expression2", ")", ";", "return", "$", "this", ";", "}" ]
Compares two values and returns whether they are equivalent. @see http://docs.mongodb.org/manual/reference/operator/aggregation/eq/ @see Expr::eq @param mixed|Expr $expression1 @param mixed|Expr $expression2
[ "Compares", "two", "values", "and", "returns", "whether", "they", "are", "equivalent", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L368-L373
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.in
public function in($expression, $arrayExpression) : self { $this->expr->in($expression, $arrayExpression); return $this; }
php
public function in($expression, $arrayExpression) : self { $this->expr->in($expression, $arrayExpression); return $this; }
[ "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. Unlike the $in query operator, the aggregation $in operator does not support matching by regular expressions. @see https://docs.mongodb.com/manual/reference/operator/aggregation/in/ @see Expr::in @param mixed|Expr $expression @param mixed|Expr $arrayExpression
[ "Returns", "a", "boolean", "indicating", "whether", "a", "specified", "value", "is", "in", "an", "array", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L523-L528
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.ifNull
public function ifNull($expression, $replacementExpression) : self { $this->expr->ifNull($expression, $replacementExpression); return $this; }
php
public function ifNull($expression, $replacementExpression) : self { $this->expr->ifNull($expression, $replacementExpression); return $this; }
[ "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. The arguments can be any valid expression. @see http://docs.mongodb.org/manual/reference/operator/aggregation/ifNull/ @see Expr::ifNull @param mixed|Expr $expression @param mixed|Expr $replacementExpression
[ "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", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L602-L607
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.let
public function let($vars, $in) : self { $this->expr->let($vars, $in); return $this; }
php
public function let($vars, $in) : self { $this->expr->let($vars, $in); return $this; }
[ "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. @see http://docs.mongodb.org/manual/reference/operator/aggregation/let/ @see Expr::let @param mixed|Expr $vars Assignment block for the variables accessible in the in expression. To assign a variable, specify a string for the variable name and assign a valid expression for the value. @param mixed|Expr $in The expression to evaluate.
[ "Binds", "variables", "for", "use", "in", "the", "specified", "expression", "and", "returns", "the", "result", "of", "the", "expression", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L691-L696
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.log
public function log($number, $base) : self { $this->expr->log($number, $base); return $this; }
php
public function log($number, $base) : self { $this->expr->log($number, $base); return $this; }
[ "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. The <number> expression can be any valid expression as long as it resolves to a non-negative number. The <base> expression can be any valid expression as long as it resolves to a positive number greater than 1. @see https://docs.mongodb.org/manual/reference/operator/aggregation/log/ @see Expr::log @param mixed|Expr $number @param mixed|Expr $base
[ "Calculates", "the", "log", "of", "a", "number", "in", "the", "specified", "base", "and", "returns", "the", "result", "as", "a", "double", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L748-L753
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.mod
public function mod($expression1, $expression2) : self { $this->expr->mod($expression1, $expression2); return $this; }
php
public function mod($expression1, $expression2) : self { $this->expr->mod($expression1, $expression2); return $this; }
[ "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. The arguments can be any valid expression as long as they resolve to numbers. @see http://docs.mongodb.org/manual/reference/operator/aggregation/mod/ @see Expr::mod @param mixed|Expr $expression1 @param mixed|Expr $expression2
[ "Divides", "one", "number", "by", "another", "and", "returns", "the", "remainder", ".", "The", "first", "argument", "is", "divided", "by", "the", "second", "argument", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L890-L895
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.multiply
public function multiply($expression1, $expression2, ...$expressions) : self { $this->expr->multiply(...func_get_args()); return $this; }
php
public function multiply($expression1, $expression2, ...$expressions) : self { $this->expr->multiply(...func_get_args()); return $this; }
[ "public", "function", "multiply", "(", "$", "expression1", ",", "$", "expression2", ",", "...", "$", "expressions", ")", ":", "self", "{", "$", "this", "->", "expr", "->", "multiply", "(", "...", "func_get_args", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Multiplies numbers together and returns the result. The arguments can be any valid expression as long as they resolve to numbers. @see http://docs.mongodb.org/manual/reference/operator/aggregation/multiply/ @see Expr::multiply @param mixed|Expr $expression1 @param mixed|Expr $expression2 @param mixed|Expr ...$expressions Additional expressions
[ "Multiplies", "numbers", "together", "and", "returns", "the", "result", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L926-L931
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.pow
public function pow($number, $exponent) : self { $this->expr->pow($number, $exponent); return $this; }
php
public function pow($number, $exponent) : self { $this->expr->pow($number, $exponent); return $this; }
[ "public", "function", "pow", "(", "$", "number", ",", "$", "exponent", ")", ":", "self", "{", "$", "this", "->", "expr", "->", "pow", "(", "$", "number", ",", "$", "exponent", ")", ";", "return", "$", "this", ";", "}" ]
Raises a number to the specified exponent and returns the result. The <number> expression can be any valid expression as long as it resolves to a non-negative number. The <exponent> expression can be any valid expression as long as it resolves to a number. @see https://docs.mongodb.org/manual/reference/operator/aggregation/pow/ @see Expr::pow @param mixed|Expr $number @param mixed|Expr $exponent
[ "Raises", "a", "number", "to", "the", "specified", "exponent", "and", "returns", "the", "result", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L980-L985
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.setDifference
public function setDifference($expression1, $expression2) : self { $this->expr->setDifference($expression1, $expression2); return $this; }
php
public function setDifference($expression1, $expression2) : self { $this->expr->setDifference($expression1, $expression2); return $this; }
[ "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. The arguments can be any valid expression as long as they each resolve to an array. @see http://docs.mongodb.org/manual/reference/operator/aggregation/setDifference/ @see Expr::setDifference @param mixed|Expr $expression1 @param mixed|Expr $expression2
[ "Takes", "two", "sets", "and", "returns", "an", "array", "containing", "the", "elements", "that", "only", "exist", "in", "the", "first", "set", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L1070-L1075
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.setEquals
public function setEquals($expression1, $expression2, ...$expressions) : self { $this->expr->setEquals(...func_get_args()); return $this; }
php
public function setEquals($expression1, $expression2, ...$expressions) : self { $this->expr->setEquals(...func_get_args()); return $this; }
[ "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. The arguments can be any valid expression as long as they each resolve to an array. @see http://docs.mongodb.org/manual/reference/operator/aggregation/setEquals/ @see Expr::setEquals @param mixed|Expr $expression1 @param mixed|Expr $expression2 @param mixed|Expr ...$expressions Additional sets @return $this
[ "Compares", "two", "or", "more", "arrays", "and", "returns", "true", "if", "they", "have", "the", "same", "distinct", "elements", "and", "false", "otherwise", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L1092-L1097
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.setIntersection
public function setIntersection($expression1, $expression2, ...$expressions) : self { $this->expr->setIntersection(...func_get_args()); return $this; }
php
public function setIntersection($expression1, $expression2, ...$expressions) : self { $this->expr->setIntersection(...func_get_args()); return $this; }
[ "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. The arguments can be any valid expression as long as they each resolve to an array. @see http://docs.mongodb.org/manual/reference/operator/aggregation/setIntersection/ @see Expr::setIntersection @param mixed|Expr $expression1 @param mixed|Expr $expression2 @param mixed|Expr ...$expressions Additional sets
[ "Takes", "two", "or", "more", "arrays", "and", "returns", "an", "array", "that", "contains", "the", "elements", "that", "appear", "in", "every", "input", "array", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L1112-L1117
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.setIsSubset
public function setIsSubset($expression1, $expression2) : self { $this->expr->setIsSubset($expression1, $expression2); return $this; }
php
public function setIsSubset($expression1, $expression2) : self { $this->expr->setIsSubset($expression1, $expression2); return $this; }
[ "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. The arguments can be any valid expression as long as they each resolve to an array. @see http://docs.mongodb.org/manual/reference/operator/aggregation/setIsSubset/ @see Expr::setIsSubset @param mixed|Expr $expression1 @param mixed|Expr $expression2
[ "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", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L1132-L1137
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.setUnion
public function setUnion($expression1, $expression2, ...$expressions) : self { $this->expr->setUnion(...func_get_args()); return $this; }
php
public function setUnion($expression1, $expression2, ...$expressions) : self { $this->expr->setUnion(...func_get_args()); return $this; }
[ "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. The arguments can be any valid expression as long as they each resolve to an array. @see http://docs.mongodb.org/manual/reference/operator/aggregation/setUnion/ @see Expr::setUnion @param mixed|Expr $expression1 @param mixed|Expr $expression2 @param mixed|Expr ...$expressions Additional sets
[ "Takes", "two", "or", "more", "arrays", "and", "returns", "an", "array", "containing", "the", "elements", "that", "appear", "in", "any", "input", "array", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L1152-L1157
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.split
public function split($string, $delimiter) : self { $this->expr->split($string, $delimiter); return $this; }
php
public function split($string, $delimiter) : self { $this->expr->split($string, $delimiter); return $this; }
[ "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. $split removes the delimiter and returns the resulting substrings as elements of an array. If the delimiter is not found in the string, $split returns the original string as the only element of an array. @see https://docs.mongodb.com/manual/reference/operator/aggregation/split/ @param mixed|Expr $string The string to be split. Can be any valid expression as long as it resolves to a string. @param mixed|Expr $delimiter The delimiter to use when splitting the string expression. Can be any valid expression as long as it resolves to a string.
[ "Divides", "a", "string", "into", "an", "array", "of", "substrings", "based", "on", "a", "delimiter", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L1205-L1210
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php
Operator.subtract
public function subtract($expression1, $expression2) : self { $this->expr->subtract($expression1, $expression2); return $this; }
php
public function subtract($expression1, $expression2) : self { $this->expr->subtract($expression1, $expression2); return $this; }
[ "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. The arguments can be any valid expression as long as they resolve to numbers and/or dates. @see http://docs.mongodb.org/manual/reference/operator/aggregation/subtract/ @see Expr::subtract @param mixed|Expr $expression1 @param mixed|Expr $expression2
[ "Subtracts", "two", "numbers", "to", "return", "the", "difference", ".", "The", "second", "argument", "is", "subtracted", "from", "the", "first", "argument", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Operator.php#L1352-L1357
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Facet.php
Facet.pipeline
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; }
php
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; }
[ "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. @param Builder|Stage $builder
[ "Use", "the", "given", "pipeline", "for", "the", "current", "field", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Facet.php#L50-L66
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Types/DateType.php
DateType.getDateTime
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; }
php
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; }
[ "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 @param mixed $value \DateTimeInterface|\MongoDB\BSON\UTCDateTime|int|float @throws InvalidArgumentException If $value is invalid.
[ "Converts", "a", "value", "to", "a", "DateTime", ".", "Supports", "microseconds" ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Types/DateType.php#L37-L67
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/PersistentCollection/PersistentCollectionTrait.php
PersistentCollectionTrait.doRemove
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; }
php
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; }
[ "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. @param mixed $offset @param bool $arrayAccess @return bool
[ "Actual", "logic", "for", "removing", "element", "by", "its", "key", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/PersistentCollection/PersistentCollectionTrait.php#L710-L727
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/PersistentCollection/PersistentCollectionTrait.php
PersistentCollectionTrait.doSet
private function doSet($offset, $value, $arrayAccess) { $arrayAccess ? $this->coll->offsetSet($offset, $value) : $this->coll->set($offset, $value); // Handle orphanRemoval if ($this->uow !== null && $this->isOrphanRemovalEnabled() && $value !== null) { $this->uow->unscheduleOrphanRemoval($value); } $this->changed(); }
php
private function doSet($offset, $value, $arrayAccess) { $arrayAccess ? $this->coll->offsetSet($offset, $value) : $this->coll->set($offset, $value); // Handle orphanRemoval if ($this->uow !== null && $this->isOrphanRemovalEnabled() && $value !== null) { $this->uow->unscheduleOrphanRemoval($value); } $this->changed(); }
[ "private", "function", "doSet", "(", "$", "offset", ",", "$", "value", ",", "$", "arrayAccess", ")", "{", "$", "arrayAccess", "?", "$", "this", "->", "coll", "->", "offsetSet", "(", "$", "offset", ",", "$", "value", ")", ":", "$", "this", "->", "coll", "->", "set", "(", "$", "offset", ",", "$", "value", ")", ";", "// Handle orphanRemoval", "if", "(", "$", "this", "->", "uow", "!==", "null", "&&", "$", "this", "->", "isOrphanRemovalEnabled", "(", ")", "&&", "$", "value", "!==", "null", ")", "{", "$", "this", "->", "uow", "->", "unscheduleOrphanRemoval", "(", "$", "value", ")", ";", "}", "$", "this", "->", "changed", "(", ")", ";", "}" ]
Actual logic for setting an element in the collection. @param mixed $offset @param mixed $value @param bool $arrayAccess
[ "Actual", "logic", "for", "setting", "an", "element", "in", "the", "collection", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/PersistentCollection/PersistentCollectionTrait.php#L736-L746
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Query/Query.php
Query.debug
public function debug(?string $name = null) { return $name !== null ? $this->query[$name] : $this->query; }
php
public function debug(?string $name = null) { return $name !== null ? $this->query[$name] : $this->query; }
[ "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. The $name parameter may be used to return a specific key from the internal $query array property. If omitted, the entire array will be returned.
[ "Return", "an", "array", "of", "information", "about", "the", "query", "structure", "for", "debugging", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Query/Query.php#L167-L170
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Query/Query.php
Query.makeIterator
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; }
php
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; }
[ "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. Note: while this method could strictly take a MongoDB\Driver\Cursor, we accept Traversable for testing purposes since Cursor cannot be mocked. HydratingIterator and CachingIterator both expect a Traversable so this should not have any adverse effects.
[ "Decorate", "the", "cursor", "with", "caching", "hydration", "and", "priming", "behavior", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Query/Query.php#L349-L363
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Repository/DocumentRepository.php
DocumentRepository.find
public function find($id, int $lockMode = LockMode::NONE, ?int $lockVersion = null) : ?object { if ($id === null) { return null; } /* TODO: What if the ID object has a field with the same name as the * class' mapped identifier field name? */ if (is_array($id)) { [$identifierFieldName] = $this->class->getIdentifierFieldNames(); if (isset($id[$identifierFieldName])) { $id = $id[$identifierFieldName]; } } // Check identity map first $document = $this->uow->tryGetById($id, $this->class); if ($document) { if ($lockMode !== LockMode::NONE) { $this->dm->lock($document, $lockMode, $lockVersion); } return $document; // Hit! } $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); }
php
public function find($id, int $lockMode = LockMode::NONE, ?int $lockVersion = null) : ?object { if ($id === null) { return null; } /* TODO: What if the ID object has a field with the same name as the * class' mapped identifier field name? */ if (is_array($id)) { [$identifierFieldName] = $this->class->getIdentifierFieldNames(); if (isset($id[$identifierFieldName])) { $id = $id[$identifierFieldName]; } } // Check identity map first $document = $this->uow->tryGetById($id, $this->class); if ($document) { if ($lockMode !== LockMode::NONE) { $this->dm->lock($document, $lockMode, $lockVersion); } return $document; // Hit! } $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); }
[ "public", "function", "find", "(", "$", "id", ",", "int", "$", "lockMode", "=", "LockMode", "::", "NONE", ",", "?", "int", "$", "lockVersion", "=", "null", ")", ":", "?", "object", "{", "if", "(", "$", "id", "===", "null", ")", "{", "return", "null", ";", "}", "/* TODO: What if the ID object has a field with the same name as the\n * class' mapped identifier field name?\n */", "if", "(", "is_array", "(", "$", "id", ")", ")", "{", "[", "$", "identifierFieldName", "]", "=", "$", "this", "->", "class", "->", "getIdentifierFieldNames", "(", ")", ";", "if", "(", "isset", "(", "$", "id", "[", "$", "identifierFieldName", "]", ")", ")", "{", "$", "id", "=", "$", "id", "[", "$", "identifierFieldName", "]", ";", "}", "}", "// Check identity map first", "$", "document", "=", "$", "this", "->", "uow", "->", "tryGetById", "(", "$", "id", ",", "$", "this", "->", "class", ")", ";", "if", "(", "$", "document", ")", "{", "if", "(", "$", "lockMode", "!==", "LockMode", "::", "NONE", ")", "{", "$", "this", "->", "dm", "->", "lock", "(", "$", "document", ",", "$", "lockMode", ",", "$", "lockVersion", ")", ";", "}", "return", "$", "document", ";", "// Hit!", "}", "$", "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. @param mixed $id Identifier. @throws MappingException @throws LockException
[ "Finds", "a", "document", "matching", "the", "specified", "identifier", ".", "Optionally", "a", "lock", "mode", "and", "expected", "version", "may", "be", "specified", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Repository/DocumentRepository.php#L96-L143
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.getPersistenceBuilder
public function getPersistenceBuilder() : PersistenceBuilder { if (! $this->persistenceBuilder) { $this->persistenceBuilder = new PersistenceBuilder($this->dm, $this); } return $this->persistenceBuilder; }
php
public function getPersistenceBuilder() : PersistenceBuilder { if (! $this->persistenceBuilder) { $this->persistenceBuilder = new PersistenceBuilder($this->dm, $this); } return $this->persistenceBuilder; }
[ "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. @internal
[ "Factory", "for", "returning", "new", "PersistenceBuilder", "instances", "used", "for", "preparing", "data", "into", "queries", "for", "insert", "persistence", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L281-L287
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.getCollectionPersister
public function getCollectionPersister() : CollectionPersister { if (! isset($this->collectionPersister)) { $pb = $this->getPersistenceBuilder(); $this->collectionPersister = new Persisters\CollectionPersister($this->dm, $pb, $this); } return $this->collectionPersister; }
php
public function getCollectionPersister() : CollectionPersister { if (! isset($this->collectionPersister)) { $pb = $this->getPersistenceBuilder(); $this->collectionPersister = new Persisters\CollectionPersister($this->dm, $pb, $this); } return $this->collectionPersister; }
[ "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.
[ "Get", "the", "collection", "persister", "instance", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L331-L338
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.setDocumentPersister
public function setDocumentPersister(string $documentName, Persisters\DocumentPersister $persister) : void { $this->persisters[$documentName] = $persister; }
php
public function setDocumentPersister(string $documentName, Persisters\DocumentPersister $persister) : void { $this->persisters[$documentName] = $persister; }
[ "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 @internal
[ "Set", "the", "document", "persister", "instance", "to", "use", "for", "the", "given", "document", "name" ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L345-L348
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.getClassesForCommitAction
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; }
php
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; }
[ "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.
[ "Groups", "a", "list", "of", "scheduled", "documents", "by", "their", "class", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L445-L473
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.computeScheduleInsertsChangeSets
private function computeScheduleInsertsChangeSets() : void { foreach ($this->documentInsertions as $document) { $class = $this->dm->getClassMetadata(get_class($document)); if ($class->isEmbeddedDocument) { continue; } $this->computeChangeSet($class, $document); } }
php
private function computeScheduleInsertsChangeSets() : void { foreach ($this->documentInsertions as $document) { $class = $this->dm->getClassMetadata(get_class($document)); if ($class->isEmbeddedDocument) { continue; } $this->computeChangeSet($class, $document); } }
[ "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. Embedded documents will not be processed.
[ "Compute", "changesets", "of", "all", "documents", "scheduled", "for", "insertion", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L480-L490
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.computeScheduleUpsertsChangeSets
private function computeScheduleUpsertsChangeSets() : void { foreach ($this->documentUpserts as $document) { $class = $this->dm->getClassMetadata(get_class($document)); if ($class->isEmbeddedDocument) { continue; } $this->computeChangeSet($class, $document); } }
php
private function computeScheduleUpsertsChangeSets() : void { foreach ($this->documentUpserts as $document) { $class = $this->dm->getClassMetadata(get_class($document)); if ($class->isEmbeddedDocument) { continue; } $this->computeChangeSet($class, $document); } }
[ "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. Embedded documents will not be processed.
[ "Compute", "changesets", "of", "all", "documents", "scheduled", "for", "upsert", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L497-L507
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.setDocumentChangeSet
public function setDocumentChangeSet(object $document, array $changeset) : void { $this->documentChangeSets[spl_object_hash($document)] = $changeset; }
php
public function setDocumentChangeSet(object $document, array $changeset) : void { $this->documentChangeSets[spl_object_hash($document)] = $changeset; }
[ "public", "function", "setDocumentChangeSet", "(", "object", "$", "document", ",", "array", "$", "changeset", ")", ":", "void", "{", "$", "this", "->", "documentChangeSets", "[", "spl_object_hash", "(", "$", "document", ")", "]", "=", "$", "changeset", ";", "}" ]
Sets the changeset for a document. @internal
[ "Sets", "the", "changeset", "for", "a", "document", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L526-L529
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.scheduleForInsert
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); }
php
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); }
[ "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. @internal @throws InvalidArgumentException
[ "Schedules", "a", "document", "for", "insertion", "into", "the", "database", ".", "If", "the", "document", "already", "has", "an", "identifier", "it", "will", "be", "added", "to", "the", "identity", "map", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L1157-L1178
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.scheduleForUpsert
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); }
php
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); }
[ "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 @internal @throws InvalidArgumentException
[ "Schedules", "a", "document", "for", "upsert", "into", "the", "database", "and", "adds", "it", "to", "the", "identity", "map" ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L1188-L1208
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.isScheduledForSynchronization
public function isScheduledForSynchronization(object $document) : bool { $class = $this->dm->getClassMetadata(get_class($document)); return isset($this->scheduledForSynchronization[$class->name][spl_object_hash($document)]); }
php
public function isScheduledForSynchronization(object $document) : bool { $class = $this->dm->getClassMetadata(get_class($document)); return isset($this->scheduledForSynchronization[$class->name][spl_object_hash($document)]); }
[ "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.
[ "Checks", "whether", "a", "document", "is", "registered", "to", "be", "checked", "in", "the", "unit", "of", "work", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L1266-L1270
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.scheduleForDelete
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; // document has not been persisted yet, so nothing more to do. } if (! $this->isInIdentityMap($document)) { return; // ignore } $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; }
php
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; // document has not been persisted yet, so nothing more to do. } if (! $this->isInIdentityMap($document)) { return; // ignore } $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; }
[ "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", ";", "// document has not been persisted yet, so nothing more to do.", "}", "if", "(", "!", "$", "this", "->", "isInIdentityMap", "(", "$", "document", ")", ")", "{", "return", ";", "// ignore", "}", "$", "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. @internal
[ "Schedules", "a", "document", "for", "deletion", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L1277-L1304
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.isDocumentScheduled
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]); }
php
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]); }
[ "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. @internal
[ "Checks", "whether", "a", "document", "is", "scheduled", "for", "insertion", "update", "or", "deletion", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L1320-L1327
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.addToIdentityMap
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; }
php
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; }
[ "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. Note that documents in a hierarchy are registered with the class name of the root document. Identifiers are serialized before being used as array keys to allow differentiation of equal, but not identical, values. @internal
[ "Registers", "a", "document", "in", "the", "identity", "map", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L1338-L1355
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.tryGetById
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; }
php
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; }
[ "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. @internal @param mixed $id Document identifier @return mixed The found document or FALSE. @throws InvalidArgumentException If the class does not have an identifier.
[ "Tries", "to", "get", "a", "document", "by", "its", "identifier", "hash", ".", "If", "no", "document", "is", "found", "for", "the", "given", "hash", "FALSE", "is", "returned", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L1477-L1486
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.containsId
public function containsId($id, string $rootClassName) : bool { return isset($this->identityMap[$rootClassName][serialize($id)]); }
php
public function containsId($id, string $rootClassName) : bool { return isset($this->identityMap[$rootClassName][serialize($id)]); }
[ "public", "function", "containsId", "(", "$", "id", ",", "string", "$", "rootClassName", ")", ":", "bool", "{", "return", "isset", "(", "$", "this", "->", "identityMap", "[", "$", "rootClassName", "]", "[", "serialize", "(", "$", "id", ")", "]", ")", ";", "}" ]
Checks whether an identifier exists in the identity map. @internal
[ "Checks", "whether", "an", "identifier", "exists", "in", "the", "identity", "map", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L1537-L1540
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.persist
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); }
php
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); }
[ "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. @internal @throws MongoDBException If trying to persist MappedSuperclass. @throws InvalidArgumentException If there is something wrong with document's identifier.
[ "Persists", "a", "document", "as", "part", "of", "the", "current", "unit", "of", "work", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L1550-L1558
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.unscheduleOrphanRemoval
public function unscheduleOrphanRemoval(object $document) : void { $oid = spl_object_hash($document); unset($this->orphanRemovals[$oid]); }
php
public function unscheduleOrphanRemoval(object $document) : void { $oid = spl_object_hash($document); unset($this->orphanRemovals[$oid]); }
[ "public", "function", "unscheduleOrphanRemoval", "(", "object", "$", "document", ")", ":", "void", "{", "$", "oid", "=", "spl_object_hash", "(", "$", "document", ")", ";", "unset", "(", "$", "this", "->", "orphanRemovals", "[", "$", "oid", "]", ")", ";", "}" ]
Unschedules an embedded or referenced object for removal. @internal
[ "Unschedules", "an", "embedded", "or", "referenced", "object", "for", "removal", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L2232-L2236
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.scheduleCollectionDeletion
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); }
php
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); }
[ "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. @internal
[ "Schedules", "a", "complete", "collection", "for", "removal", "when", "this", "UnitOfWork", "commits", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L2271-L2281
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.unscheduleCollectionDeletion
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]); }
php
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]); }
[ "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. @internal
[ "Unschedules", "a", "collection", "from", "being", "deleted", "when", "this", "UnitOfWork", "commits", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L2298-L2312
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.scheduleCollectionUpdate
public function scheduleCollectionUpdate(PersistentCollectionInterface $coll) : void { $mapping = $coll->getMapping(); if (CollectionHelper::usesSet($mapping['strategy'])) { /* There is no need to $unset collection if it will be $set later * This is NOP if collection is not scheduled for deletion */ $this->unscheduleCollectionDeletion($coll); } $oid = spl_object_hash($coll); if (isset($this->collectionUpdates[$oid])) { return; } $this->collectionUpdates[$oid] = $coll; $this->scheduleCollectionOwner($coll); }
php
public function scheduleCollectionUpdate(PersistentCollectionInterface $coll) : void { $mapping = $coll->getMapping(); if (CollectionHelper::usesSet($mapping['strategy'])) { /* There is no need to $unset collection if it will be $set later * This is NOP if collection is not scheduled for deletion */ $this->unscheduleCollectionDeletion($coll); } $oid = spl_object_hash($coll); if (isset($this->collectionUpdates[$oid])) { return; } $this->collectionUpdates[$oid] = $coll; $this->scheduleCollectionOwner($coll); }
[ "public", "function", "scheduleCollectionUpdate", "(", "PersistentCollectionInterface", "$", "coll", ")", ":", "void", "{", "$", "mapping", "=", "$", "coll", "->", "getMapping", "(", ")", ";", "if", "(", "CollectionHelper", "::", "usesSet", "(", "$", "mapping", "[", "'strategy'", "]", ")", ")", "{", "/* There is no need to $unset collection if it will be $set later\n * This is NOP if collection is not scheduled for deletion\n */", "$", "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. @internal
[ "Schedules", "a", "collection", "for", "update", "when", "this", "UnitOfWork", "commits", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L2319-L2335
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.unscheduleCollectionUpdate
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]); }
php
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]); }
[ "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. @internal
[ "Unschedules", "a", "collection", "from", "being", "updated", "when", "this", "UnitOfWork", "commits", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L2342-L2356
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/UnitOfWork.php
UnitOfWork.setOriginalDocumentProperty
public function setOriginalDocumentProperty(string $oid, string $property, $value) : void { $this->originalDocumentData[$oid][$property] = $value; }
php
public function setOriginalDocumentProperty(string $oid, string $property, $value) : void { $this->originalDocumentData[$oid][$property] = $value; }
[ "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. @internal @param mixed $value
[ "Sets", "a", "property", "value", "of", "the", "original", "data", "array", "of", "a", "document", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/UnitOfWork.php#L2649-L2652
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Lookup.php
Lookup.foreignField
public function foreignField(string $foreignField) : self { $this->foreignField = $this->prepareFieldName($foreignField, $this->targetClass); return $this; }
php
public function foreignField(string $foreignField) : self { $this->foreignField = $this->prepareFieldName($foreignField, $this->targetClass); return $this; }
[ "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. $lookup performs an equality match on the foreignField to the localField from the input documents. If a document in the from collection does not contain the foreignField, the $lookup treats the value as null for matching purposes.
[ "Specifies", "the", "field", "from", "the", "documents", "in", "the", "from", "collection", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Lookup.php#L134-L138
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
ClassMetadata.getReferencePrefix
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 ? '' : '$'; }
php
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 ? '' : '$'; }
[ "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
[ "Returns", "the", "reference", "prefix", "used", "for", "a", "reference" ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php#L534-L541
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
ClassMetadata.getReferenceFieldName
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'; }
php
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'; }
[ "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 @internal @param string $pathPrefix The field path prefix
[ "Returns", "a", "fully", "qualified", "field", "name", "for", "a", "given", "reference" ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php#L550-L557
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
ClassMetadata.setDefaultDiscriminatorValue
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; }
php
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; }
[ "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 @throws MappingException
[ "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" ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php#L812-L829
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
ClassMetadata.addIndex
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, ]; }
php
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, ]; }
[ "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.
[ "Add", "a", "index", "for", "this", "Document", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php#L851-L872
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
ClassMetadata.setReadPreference
public function setReadPreference(?string $readPreference, array $tags) : void { $this->readPreference = $readPreference; $this->readPreferenceTags = $tags; }
php
public function setReadPreference(?string $readPreference, array $tags) : void { $this->readPreference = $readPreference; $this->readPreferenceTags = $tags; }
[ "public", "function", "setReadPreference", "(", "?", "string", "$", "readPreference", ",", "array", "$", "tags", ")", ":", "void", "{", "$", "this", "->", "readPreference", "=", "$", "readPreference", ";", "$", "this", "->", "readPreferenceTags", "=", "$", "tags", ";", "}" ]
Sets the read preference used by this class.
[ "Sets", "the", "read", "preference", "used", "by", "this", "class", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php#L956-L960
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
ClassMetadata.setCollection
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; } }
php
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; } }
[ "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. @param array|string $name @throws InvalidArgumentException
[ "Sets", "the", "collection", "this", "Document", "is", "mapped", "to", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php#L1075-L1088
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
ClassMetadata.applyStorageStrategy
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']); } }
php
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']); } }
[ "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 @throws MappingException
[ "Validates", "the", "storage", "strategy", "of", "a", "mapping", "for", "consistency" ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php#L1172-L1214
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
ClassMetadata.getPHPIdentifierValue
public function getPHPIdentifierValue($id) { $idType = $this->fieldMappings[$this->identifier]['type']; return Type::getType($idType)->convertToPHPValue($id); }
php
public function getPHPIdentifierValue($id) { $idType = $this->fieldMappings[$this->identifier]['type']; return Type::getType($idType)->convertToPHPValue($id); }
[ "public", "function", "getPHPIdentifierValue", "(", "$", "id", ")", "{", "$", "idType", "=", "$", "this", "->", "fieldMappings", "[", "$", "this", "->", "identifier", "]", "[", "'type'", "]", ";", "return", "Type", "::", "getType", "(", "$", "idType", ")", "->", "convertToPHPValue", "(", "$", "id", ")", ";", "}" ]
Casts the identifier to its portable PHP type. @param mixed $id @return mixed $id
[ "Casts", "the", "identifier", "to", "its", "portable", "PHP", "type", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php#L1389-L1393
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
ClassMetadata.getDatabaseIdentifierValue
public function getDatabaseIdentifierValue($id) { $idType = $this->fieldMappings[$this->identifier]['type']; return Type::getType($idType)->convertToDatabaseValue($id); }
php
public function getDatabaseIdentifierValue($id) { $idType = $this->fieldMappings[$this->identifier]['type']; return Type::getType($idType)->convertToDatabaseValue($id); }
[ "public", "function", "getDatabaseIdentifierValue", "(", "$", "id", ")", "{", "$", "idType", "=", "$", "this", "->", "fieldMappings", "[", "$", "this", "->", "identifier", "]", "[", "'type'", "]", ";", "return", "Type", "::", "getType", "(", "$", "idType", ")", "->", "convertToDatabaseValue", "(", "$", "id", ")", ";", "}" ]
Casts the identifier to its database type. @param mixed $id @return mixed $id
[ "Casts", "the", "identifier", "to", "its", "database", "type", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php#L1402-L1406
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
ClassMetadata.getFieldMappingByDbFieldName
public function getFieldMappingByDbFieldName(string $dbFieldName) : array { foreach ($this->fieldMappings as $mapping) { if ($mapping['name'] === $dbFieldName) { return $mapping; } } throw MappingException::mappingNotFoundByDbName($this->name, $dbFieldName); }
php
public function getFieldMappingByDbFieldName(string $dbFieldName) : array { foreach ($this->fieldMappings as $mapping) { if ($mapping['name'] === $dbFieldName) { return $mapping; } } throw MappingException::mappingNotFoundByDbName($this->name, $dbFieldName); }
[ "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. @throws MappingException
[ "Gets", "the", "field", "mapping", "by", "its", "DB", "name", ".", "E", ".", "g", ".", "it", "returns", "identifier", "s", "mapping", "when", "called", "with", "_id", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php#L1515-L1524
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
ClassMetadata.isNullable
public function isNullable(string $fieldName) : bool { $mapping = $this->getFieldMapping($fieldName); return isset($mapping['nullable']) && $mapping['nullable'] === true; }
php
public function isNullable(string $fieldName) : bool { $mapping = $this->getFieldMapping($fieldName); return isset($mapping['nullable']) && $mapping['nullable'] === true; }
[ "public", "function", "isNullable", "(", "string", "$", "fieldName", ")", ":", "bool", "{", "$", "mapping", "=", "$", "this", "->", "getFieldMapping", "(", "$", "fieldName", ")", ";", "return", "isset", "(", "$", "mapping", "[", "'nullable'", "]", ")", "&&", "$", "mapping", "[", "'nullable'", "]", "===", "true", ";", "}" ]
Check if the field is not null.
[ "Check", "if", "the", "field", "is", "not", "null", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php#L1529-L1533
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php
ClassMetadata.getAssociationCollectionClass
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']; }
php
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']; }
[ "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
[ "Retrieve", "the", "collectionClass", "associated", "with", "an", "association" ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Mapping/ClassMetadata.php#L1756-L1767
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/BucketAutoOutput.php
BucketAutoOutput.buckets
public function buckets(int $buckets) : Stage\BucketAuto { assert($this->bucket instanceof Stage\BucketAuto); return $this->bucket->buckets($buckets); }
php
public function buckets(int $buckets) : Stage\BucketAuto { assert($this->bucket instanceof Stage\BucketAuto); return $this->bucket->buckets($buckets); }
[ "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.
[ "A", "positive", "32", "-", "bit", "integer", "that", "specifies", "the", "number", "of", "buckets", "into", "which", "input", "documents", "are", "grouped", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/BucketAutoOutput.php#L34-L38
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/BucketAutoOutput.php
BucketAutoOutput.granularity
public function granularity(string $granularity) : Stage\BucketAuto { assert($this->bucket instanceof Stage\BucketAuto); return $this->bucket->granularity($granularity); }
php
public function granularity(string $granularity) : Stage\BucketAuto { assert($this->bucket instanceof Stage\BucketAuto); return $this->bucket->granularity($granularity); }
[ "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.
[ "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", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/BucketAutoOutput.php#L45-L49
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/BucketOutput.php
BucketOutput.boundaries
public function boundaries(...$boundaries) { assert($this->bucket instanceof Stage\Bucket); return $this->bucket->boundaries(...$boundaries); }
php
public function boundaries(...$boundaries) { assert($this->bucket instanceof Stage\Bucket); return $this->bucket->boundaries(...$boundaries); }
[ "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. Each adjacent pair of values acts as the inclusive lower boundary and the exclusive upper boundary for the bucket. You must specify at least two boundaries. The specified values must be in ascending order and all of the same type. The exception is if the values are of mixed numeric types. @param array ...$boundaries @return Stage\Bucket
[ "An", "array", "of", "values", "based", "on", "the", "groupBy", "expression", "that", "specify", "the", "boundaries", "for", "each", "bucket", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Stage/Bucket/BucketOutput.php#L49-L53
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/SchemaManager.php
SchemaManager.isEquivalentIndexKeys
private function isEquivalentIndexKeys(IndexInfo $mongoIndex, array $documentIndex) : bool { $mongoIndexKeys = $mongoIndex['key']; $documentIndexKeys = $documentIndex['keys']; /* If we are dealing with text indexes, we need to unset internal fields * from the MongoDB index and filter out text fields from the document * index. This will leave only non-text fields, which we can compare as * normal. Any text fields in the document index will be compared later * with isEquivalentTextIndexWeights(). */ if (isset($mongoIndexKeys['_fts']) && $mongoIndexKeys['_fts'] === 'text') { unset($mongoIndexKeys['_fts'], $mongoIndexKeys['_ftsx']); $documentIndexKeys = array_filter($documentIndexKeys, static function ($type) { return $type !== 'text'; }); } /* Avoid a strict equality check here. The numeric type returned by * MongoDB may differ from the document index without implying that the * indexes themselves are inequivalent. */ // phpcs:disable SlevomatCodingStandard.ControlStructures.DisallowEqualOperators.DisallowedEqualOperator return $mongoIndexKeys == $documentIndexKeys; }
php
private function isEquivalentIndexKeys(IndexInfo $mongoIndex, array $documentIndex) : bool { $mongoIndexKeys = $mongoIndex['key']; $documentIndexKeys = $documentIndex['keys']; /* If we are dealing with text indexes, we need to unset internal fields * from the MongoDB index and filter out text fields from the document * index. This will leave only non-text fields, which we can compare as * normal. Any text fields in the document index will be compared later * with isEquivalentTextIndexWeights(). */ if (isset($mongoIndexKeys['_fts']) && $mongoIndexKeys['_fts'] === 'text') { unset($mongoIndexKeys['_fts'], $mongoIndexKeys['_ftsx']); $documentIndexKeys = array_filter($documentIndexKeys, static function ($type) { return $type !== 'text'; }); } /* Avoid a strict equality check here. The numeric type returned by * MongoDB may differ from the document index without implying that the * indexes themselves are inequivalent. */ // phpcs:disable SlevomatCodingStandard.ControlStructures.DisallowEqualOperators.DisallowedEqualOperator return $mongoIndexKeys == $documentIndexKeys; }
[ "private", "function", "isEquivalentIndexKeys", "(", "IndexInfo", "$", "mongoIndex", ",", "array", "$", "documentIndex", ")", ":", "bool", "{", "$", "mongoIndexKeys", "=", "$", "mongoIndex", "[", "'key'", "]", ";", "$", "documentIndexKeys", "=", "$", "documentIndex", "[", "'keys'", "]", ";", "/* If we are dealing with text indexes, we need to unset internal fields\n * from the MongoDB index and filter out text fields from the document\n * index. This will leave only non-text fields, which we can compare as\n * normal. Any text fields in the document index will be compared later\n * with isEquivalentTextIndexWeights(). */", "if", "(", "isset", "(", "$", "mongoIndexKeys", "[", "'_fts'", "]", ")", "&&", "$", "mongoIndexKeys", "[", "'_fts'", "]", "===", "'text'", ")", "{", "unset", "(", "$", "mongoIndexKeys", "[", "'_fts'", "]", ",", "$", "mongoIndexKeys", "[", "'_ftsx'", "]", ")", ";", "$", "documentIndexKeys", "=", "array_filter", "(", "$", "documentIndexKeys", ",", "static", "function", "(", "$", "type", ")", "{", "return", "$", "type", "!==", "'text'", ";", "}", ")", ";", "}", "/* Avoid a strict equality check here. The numeric type returned by\n * MongoDB may differ from the document index without implying that the\n * indexes themselves are inequivalent. */", "// phpcs:disable SlevomatCodingStandard.ControlStructures.DisallowEqualOperators.DisallowedEqualOperator", "return", "$", "mongoIndexKeys", "==", "$", "documentIndexKeys", ";", "}" ]
Determine if the keys for a MongoDB index can be considered equivalent to those for an index in class metadata.
[ "Determine", "if", "the", "keys", "for", "a", "MongoDB", "index", "can", "be", "considered", "equivalent", "to", "those", "for", "an", "index", "in", "class", "metadata", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/SchemaManager.php#L418-L441
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/SchemaManager.php
SchemaManager.indexOptionsAreMissing
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) !== []; }
php
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) !== []; }
[ "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. Options added to the ALLOWED_MISSING_INDEX_OPTIONS constant are ignored and are expected to be checked later
[ "Checks", "if", "any", "index", "options", "are", "missing", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/SchemaManager.php#L514-L521
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/SchemaManager.php
SchemaManager.isEquivalentTextIndexWeights
private function isEquivalentTextIndexWeights(IndexInfo $mongoIndex, array $documentIndex) : bool { $mongoIndexWeights = $mongoIndex['weights']; $documentIndexWeights = $documentIndex['options']['weights'] ?? []; // If not specified, assign a default weight for text fields foreach ($documentIndex['keys'] as $key => $type) { if ($type !== 'text' || isset($documentIndexWeights[$key])) { continue; } $documentIndexWeights[$key] = 1; } /* MongoDB returns the weights sorted by field name, but we'll sort both * arrays in case that is internal behavior not to be relied upon. */ ksort($mongoIndexWeights); ksort($documentIndexWeights); /* Avoid a strict equality check here. The numeric type returned by * MongoDB may differ from the document index without implying that the * indexes themselves are inequivalent. */ // phpcs:disable SlevomatCodingStandard.ControlStructures.DisallowEqualOperators.DisallowedEqualOperator return $mongoIndexWeights == $documentIndexWeights; }
php
private function isEquivalentTextIndexWeights(IndexInfo $mongoIndex, array $documentIndex) : bool { $mongoIndexWeights = $mongoIndex['weights']; $documentIndexWeights = $documentIndex['options']['weights'] ?? []; // If not specified, assign a default weight for text fields foreach ($documentIndex['keys'] as $key => $type) { if ($type !== 'text' || isset($documentIndexWeights[$key])) { continue; } $documentIndexWeights[$key] = 1; } /* MongoDB returns the weights sorted by field name, but we'll sort both * arrays in case that is internal behavior not to be relied upon. */ ksort($mongoIndexWeights); ksort($documentIndexWeights); /* Avoid a strict equality check here. The numeric type returned by * MongoDB may differ from the document index without implying that the * indexes themselves are inequivalent. */ // phpcs:disable SlevomatCodingStandard.ControlStructures.DisallowEqualOperators.DisallowedEqualOperator return $mongoIndexWeights == $documentIndexWeights; }
[ "private", "function", "isEquivalentTextIndexWeights", "(", "IndexInfo", "$", "mongoIndex", ",", "array", "$", "documentIndex", ")", ":", "bool", "{", "$", "mongoIndexWeights", "=", "$", "mongoIndex", "[", "'weights'", "]", ";", "$", "documentIndexWeights", "=", "$", "documentIndex", "[", "'options'", "]", "[", "'weights'", "]", "??", "[", "]", ";", "// If not specified, assign a default weight for text fields", "foreach", "(", "$", "documentIndex", "[", "'keys'", "]", "as", "$", "key", "=>", "$", "type", ")", "{", "if", "(", "$", "type", "!==", "'text'", "||", "isset", "(", "$", "documentIndexWeights", "[", "$", "key", "]", ")", ")", "{", "continue", ";", "}", "$", "documentIndexWeights", "[", "$", "key", "]", "=", "1", ";", "}", "/* MongoDB returns the weights sorted by field name, but we'll sort both\n * arrays in case that is internal behavior not to be relied upon. */", "ksort", "(", "$", "mongoIndexWeights", ")", ";", "ksort", "(", "$", "documentIndexWeights", ")", ";", "/* Avoid a strict equality check here. The numeric type returned by\n * MongoDB may differ from the document index without implying that the\n * indexes themselves are inequivalent. */", "// phpcs:disable SlevomatCodingStandard.ControlStructures.DisallowEqualOperators.DisallowedEqualOperator", "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.
[ "Determine", "if", "the", "text", "index", "weights", "for", "a", "MongoDB", "index", "can", "be", "considered", "equivalent", "to", "those", "for", "an", "index", "in", "class", "metadata", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/SchemaManager.php#L527-L551
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/DocumentManager.php
DocumentManager.getDocumentCollection
public function getDocumentCollection(string $className) : Collection { $className = $this->classNameResolver->getRealClass($className); /** @var ClassMetadata $metadata */ $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]; }
php
public function getDocumentCollection(string $className) : Collection { $className = $this->classNameResolver->getRealClass($className); /** @var ClassMetadata $metadata */ $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]; }
[ "public", "function", "getDocumentCollection", "(", "string", "$", "className", ")", ":", "Collection", "{", "$", "className", "=", "$", "this", "->", "classNameResolver", "->", "getRealClass", "(", "$", "className", ")", ";", "/** @var ClassMetadata $metadata */", "$", "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. @throws MongoDBException When the $className param is not mapped to a collection.
[ "Returns", "the", "collection", "instance", "for", "a", "class", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/DocumentManager.php#L324-L353
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/DocumentManager.php
DocumentManager.getDocumentBucket
public function getDocumentBucket(string $className) : Bucket { $className = $this->classNameResolver->getRealClass($className); /** @var ClassMetadata $metadata */ $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]; }
php
public function getDocumentBucket(string $className) : Bucket { $className = $this->classNameResolver->getRealClass($className); /** @var ClassMetadata $metadata */ $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]; }
[ "public", "function", "getDocumentBucket", "(", "string", "$", "className", ")", ":", "Bucket", "{", "$", "className", "=", "$", "this", "->", "classNameResolver", "->", "getRealClass", "(", "$", "className", ")", ";", "/** @var ClassMetadata $metadata */", "$", "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. @throws MongoDBException When the $className param is not mapped to a collection.
[ "Returns", "the", "bucket", "instance", "for", "a", "class", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/DocumentManager.php#L360-L388
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/DocumentManager.php
DocumentManager.find
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); }
php
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); }
[ "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. This is just a convenient shortcut for getRepository($documentName)->find($id). @param string $documentName @param mixed $identifier @param int $lockMode @param int $lockVersion
[ "Finds", "a", "Document", "by", "its", "identifier", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/DocumentManager.php#L633-L641
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/DocumentManager.php
DocumentManager.createReference
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); }
php
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); }
[ "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. @return mixed The reference for the document in question, according to the desired mapping @throws MappingException @throws RuntimeException
[ "Returns", "a", "reference", "to", "the", "supplied", "document", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/DocumentManager.php#L702-L747
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/DocumentManager.php
DocumentManager.getDiscriminatorData
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]; }
php
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]; }
[ "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. @param array $referenceMapping Mappings of reference for which discriminator data is created. @param ClassMetadata $class Metadata of reference document class. @return array with next structure [{discriminator field} => {discriminator value}] @throws MappingException When discriminator map is present and reference class in not registered in it.
[ "Build", "discriminator", "portion", "of", "reference", "for", "specified", "reference", "mapping", "and", "class", "metadata", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/DocumentManager.php#L759-L798
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Query/Builder.php
Builder.expr
public function expr() : Expr { $expr = new Expr($this->dm); $expr->setClassMetadata($this->class); return $expr; }
php
public function expr() : Expr { $expr = new Expr($this->dm); $expr->setClassMetadata($this->class); return $expr; }
[ "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
[ "Create", "a", "new", "Expr", "instance", "that", "can", "be", "used", "as", "an", "expression", "with", "the", "Builder" ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Query/Builder.php#L472-L478
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Query/Builder.php
Builder.field
public function field(string $field) : self { $this->currentField = $field; $this->expr->field($field); return $this; }
php
public function field(string $field) : self { $this->currentField = $field; $this->expr->field($field); return $this; }
[ "public", "function", "field", "(", "string", "$", "field", ")", ":", "self", "{", "$", "this", "->", "currentField", "=", "$", "field", ";", "$", "this", "->", "expr", "->", "field", "(", "$", "field", ")", ";", "return", "$", "this", ";", "}" ]
Set the current field to operate on.
[ "Set", "the", "current", "field", "to", "operate", "on", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Query/Builder.php#L483-L489
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Query/Builder.php
Builder.find
public function find(?string $documentName = null) : self { $this->setDocumentName($documentName); $this->query['type'] = Query::TYPE_FIND; return $this; }
php
public function find(?string $documentName = null) : self { $this->setDocumentName($documentName); $this->query['type'] = Query::TYPE_FIND; return $this; }
[ "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.
[ "Change", "the", "query", "type", "to", "find", "and", "optionally", "set", "and", "change", "the", "class", "being", "queried", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Query/Builder.php#L494-L500
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Query/Builder.php
Builder.selectMeta
public function selectMeta(string $fieldName, string $metaDataKeyword) : self { $this->query['select'][$fieldName] = ['$meta' => $metaDataKeyword]; return $this; }
php
public function selectMeta(string $fieldName, string $metaDataKeyword) : self { $this->query['select'][$fieldName] = ['$meta' => $metaDataKeyword]; return $this; }
[ "public", "function", "selectMeta", "(", "string", "$", "fieldName", ",", "string", "$", "metaDataKeyword", ")", ":", "self", "{", "$", "this", "->", "query", "[", "'select'", "]", "[", "$", "fieldName", "]", "=", "[", "'$meta'", "=>", "$", "metaDataKeyword", "]", ";", "return", "$", "this", ";", "}" ]
Select a metadata field for the query projection. @see http://docs.mongodb.org/master/reference/operator/projection/meta/
[ "Select", "a", "metadata", "field", "for", "the", "query", "projection", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Query/Builder.php#L1228-L1232
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Query/Builder.php
Builder.getDiscriminatorValues
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; }
php
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; }
[ "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 @param string[] $classNames @throws InvalidArgumentException If the number of found collections > 1.
[ "Get", "Discriminator", "Values" ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Query/Builder.php#L1503-L1517
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Id/UuidGenerator.php
UuidGenerator.generate
public function generate(DocumentManager $dm, object $document) { $uuid = $this->generateV4(); return $this->generateV5($uuid, $this->salt ?: php_uname('n')); }
php
public function generate(DocumentManager $dm, object $document) { $uuid = $this->generateV4(); return $this->generateV5($uuid, $this->salt ?: php_uname('n')); }
[ "public", "function", "generate", "(", "DocumentManager", "$", "dm", ",", "object", "$", "document", ")", "{", "$", "uuid", "=", "$", "this", "->", "generateV4", "(", ")", ";", "return", "$", "this", "->", "generateV5", "(", "$", "uuid", ",", "$", "this", "->", "salt", "?", ":", "php_uname", "(", "'n'", ")", ")", ";", "}" ]
Generates a new UUID @param DocumentManager $dm Not used. @param object $document Not used. @return string UUID @throws Exception
[ "Generates", "a", "new", "UUID" ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Id/UuidGenerator.php#L69-L73
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php
Builder.bucket
public function bucket() : Stage\Bucket { $stage = new Stage\Bucket($this, $this->dm, $this->class); $this->addStage($stage); return $stage; }
php
public function bucket() : Stage\Bucket { $stage = new Stage\Bucket($this, $this->dm, $this->class); $this->addStage($stage); return $stage; }
[ "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. Each bucket is represented as a document in the output. The document for each bucket contains an _id field, whose value specifies the inclusive lower bound of the bucket and a count field that contains the number of documents in the bucket. The count field is included by default when the output is not specified. @see https://docs.mongodb.com/manual/reference/operator/aggregation/bucket/
[ "Categorizes", "incoming", "documents", "into", "groups", "called", "buckets", "based", "on", "a", "specified", "expression", "and", "bucket", "boundaries", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php#L100-L106
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php
Builder.bucketAuto
public function bucketAuto() : Stage\BucketAuto { $stage = new Stage\BucketAuto($this, $this->dm, $this->class); $this->addStage($stage); return $stage; }
php
public function bucketAuto() : Stage\BucketAuto { $stage = new Stage\BucketAuto($this, $this->dm, $this->class); $this->addStage($stage); return $stage; }
[ "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. Bucket boundaries are automatically determined in an attempt to evenly distribute the documents into the specified number of buckets. Each bucket is represented as a document in the output. The document for each bucket contains an _id field, whose value specifies the inclusive lower bound and the exclusive upper bound for the bucket, and a count field that contains the number of documents in the bucket. The count field is included by default when the output is not specified. @see https://docs.mongodb.com/manual/reference/operator/aggregation/bucketAuto/
[ "Categorizes", "incoming", "documents", "into", "a", "specific", "number", "of", "groups", "called", "buckets", "based", "on", "a", "specified", "expression", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php#L122-L128
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php
Builder.collStats
public function collStats() : Stage\CollStats { $stage = new Stage\CollStats($this); $this->addStage($stage); return $stage; }
php
public function collStats() : Stage\CollStats { $stage = new Stage\CollStats($this); $this->addStage($stage); return $stage; }
[ "public", "function", "collStats", "(", ")", ":", "Stage", "\\", "CollStats", "{", "$", "stage", "=", "new", "Stage", "\\", "CollStats", "(", "$", "this", ")", ";", "$", "this", "->", "addStage", "(", "$", "stage", ")", ";", "return", "$", "stage", ";", "}" ]
Returns statistics regarding a collection or view. $collStats must be the first stage in an aggregation pipeline, or else the pipeline returns an error. @see http://docs.mongodb.org/manual/reference/operator/aggregation/collStats/
[ "Returns", "statistics", "regarding", "a", "collection", "or", "view", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php#L138-L144
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php
Builder.count
public function count(string $fieldName) : Stage\Count { $stage = new Stage\Count($this, $fieldName); $this->addStage($stage); return $stage; }
php
public function count(string $fieldName) : Stage\Count { $stage = new Stage\Count($this, $fieldName); $this->addStage($stage); return $stage; }
[ "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. @see https://docs.mongodb.com/manual/reference/operator/aggregation/count/
[ "Returns", "a", "document", "that", "contains", "a", "count", "of", "the", "number", "of", "documents", "input", "to", "the", "stage", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php#L152-L158
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php
Builder.execute
public function execute(array $options = []) : Iterator { // Force cursor to be used $options = array_merge($options, ['cursor' => true]); $cursor = $this->collection->aggregate($this->getPipeline(), $options); assert($cursor instanceof Cursor); return $this->prepareIterator($cursor); }
php
public function execute(array $options = []) : Iterator { // Force cursor to be used $options = array_merge($options, ['cursor' => true]); $cursor = $this->collection->aggregate($this->getPipeline(), $options); assert($cursor instanceof Cursor); return $this->prepareIterator($cursor); }
[ "public", "function", "execute", "(", "array", "$", "options", "=", "[", "]", ")", ":", "Iterator", "{", "// Force cursor to be used", "$", "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
[ "Executes", "the", "aggregation", "pipeline" ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php#L163-L172
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php
Builder.facet
public function facet() : Stage\Facet { $stage = new Stage\Facet($this); $this->addStage($stage); return $stage; }
php
public function facet() : Stage\Facet { $stage = new Stage\Facet($this); $this->addStage($stage); return $stage; }
[ "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. Each sub-pipeline has its own field in the output document where its results are stored as an array of documents.
[ "Processes", "multiple", "aggregation", "pipelines", "within", "a", "single", "stage", "on", "the", "same", "set", "of", "input", "documents", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php#L186-L192
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php
Builder.getPipeline
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) { // Don't apply any filters when using an IndexStats stage: since it // needs to be the first pipeline stage, prepending a match stage // with discriminator information will not work return $pipeline; } else { $matchExpression = $this->applyFilters([]); if ($matchExpression !== []) { array_unshift($pipeline, ['$match' => $matchExpression]); } } return $pipeline; }
php
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) { // Don't apply any filters when using an IndexStats stage: since it // needs to be the first pipeline stage, prepending a match stage // with discriminator information will not work return $pipeline; } else { $matchExpression = $this->applyFilters([]); if ($matchExpression !== []) { array_unshift($pipeline, ['$match' => $matchExpression]); } } return $pipeline; }
[ "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", ")", "{", "// Don't apply any filters when using an IndexStats stage: since it", "// needs to be the first pipeline stage, prepending a match stage", "// with discriminator information will not work", "return", "$", "pipeline", ";", "}", "else", "{", "$", "matchExpression", "=", "$", "this", "->", "applyFilters", "(", "[", "]", ")", ";", "if", "(", "$", "matchExpression", "!==", "[", "]", ")", "{", "array_unshift", "(", "$", "pipeline", ",", "[", "'$match'", "=>", "$", "matchExpression", "]", ")", ";", "}", "}", "return", "$", "pipeline", ";", "}" ]
Returns the assembled aggregation pipeline For pipelines where the first stage is a $geoNear stage, it will apply the document filters and discriminator queries to the query portion of the geoNear operation. For all other pipelines, it prepends a $match stage containing the required query.
[ "Returns", "the", "assembled", "aggregation", "pipeline" ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php#L225-L250
train
doctrine/mongodb-odm
lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php
Builder.graphLookup
public function graphLookup(string $from) : Stage\GraphLookup { $stage = new Stage\GraphLookup($this, $from, $this->dm, $this->class); $this->addStage($stage); return $stage; }
php
public function graphLookup(string $from) : Stage\GraphLookup { $stage = new Stage\GraphLookup($this, $from, $this->dm, $this->class); $this->addStage($stage); return $stage; }
[ "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. @see https://docs.mongodb.org/manual/reference/operator/aggregation/graphLookup/ @param string $from Target collection for the $graphLookup operation to search, recursively matching the connectFromField to the connectToField.
[ "Performs", "a", "recursive", "search", "on", "a", "collection", "with", "options", "for", "restricting", "the", "search", "by", "recursion", "depth", "and", "query", "filter", "." ]
e4971557a8200456d87e2f1def8bde7fb07bbb3f
https://github.com/doctrine/mongodb-odm/blob/e4971557a8200456d87e2f1def8bde7fb07bbb3f/lib/Doctrine/ODM/MongoDB/Aggregation/Builder.php#L273-L279
train