Instance of ODM Selector associated with specific document.

@see   Component::staticContainer()
*
@return DocumentSource

@throws ScopeException
337445
public static function source(): DocumentSource
    {
        /**
         * Container to be received via global scope.
         *
         * @var ContainerInterface $container
         */
        //Via global scope
        $container = self::staticContainer();

        if (empty($container)) {
            //Via global scope
            throw new ScopeException(sprintf(
                "Unable to get '%s' source, no container scope is available",
                static::class
            ));
        }

        return $container->get(ODMInterface::class)->source(static::class);
    }
529990
protected function proxy() {
        if (!$this->context) {
            $this->context = new DocumentContext(
                $this->version,
                $this->solution['serviceSid'],
                $this->solution['sid']
            );
        }

        return $this->context;
    }
530999
public static function create(?Client $client = null, ?Configuration $config = null, ?EventManager $eventManager = null) : DocumentManager
    {
        return new static($client, $config, $eventManager);
    }
526320
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];
    }
949652
public function filter($selector)
    {
        $result = $this->createChildInstance();

        if ($this->length > 0) {
            if (\is_callable($selector)) {
                foreach ($this->nodes as $index => $node) {
                    if ($selector($node, $index)) {
                        $result->addDomNode($node);
                    }
                }
            } else {
                $selection = self::create($this->document)->find($selector);

                foreach ($selection as $result_node) {
                    foreach ($this->nodes as $node) {
                        if ($result_node->isSameNode($node)) {
                            $result->addDomNode($node);
                            break 1;
                        }
                    }
                }
            }
        }

        return $result;
    }
100995
protected function makeScope()
    {
        $resource = $this->makeResource();

        if (isset($this->serializer)) {
            $this->fractal->setSerializer($this->serializer);
        }

        return $this->fractal->createData($resource);
    }
939332
private function createReadingDelegate()
    {
        return $this->readDelegate ?: $this->readDelegate = function ($property, PropertyAccessor $propertyAccessor) {
            switch (true) {

                // Public property / accessor case
                case $propertyAccessor->isReadable($this, $property) :
                    return $propertyAccessor->getValue($this, $property);

                // Private property / StdClass
                case property_exists($this, $property) || $this instanceof \StdClass:
                    return $this->$property;
            }

            throw new InvalidScopeException(sprintf(
                'Unable to read "%s" property from a "%s" object, any existing property path to read it in.',
                $property,
                get_class($this)
            ));
        };
    }
815355
public function getContainer()
    {
        $mutex = new Mutex($this->file . '.lock', true);

        $ret = $mutex->run(
            function () {
                if ($this->needsRecompile()) {
                    file_put_contents($this->file, $this->compileContainerCode());
                }
                return include $this->file;
            }
        );

        if (!($ret instanceof Container)) {
            throw new \LogicException("The container must be returned by the compiler");
        }
        foreach ($this->plugins as $plugin) {
            $ret->addPlugin($plugin);
        }
        return $ret;
    }
1261302
public function popScope()
    {
        $upIndex = $this->getUpIndex();

        if ($upIndex !== null) {
            $itemStack = $this->getItemStack();
            $this->overlay = $itemStack[$this->getUpIndex()][SSViewer_Scope::ITEM_OVERLAY];
        }

        return parent::popScope();
    }
1201923
public function includesReferenceTo(object $document) : self
    {
        $this->requiresCurrentField();
        $mapping   = $this->getReferenceMapping();
        $reference = $this->dm->createReference($document, $mapping);
        $storeAs   = $mapping['storeAs'] ?? null;
        $keys      = [];

        switch ($storeAs) {
            case ClassMetadata::REFERENCE_STORE_AS_ID:
                $this->query[$mapping['name']] = $reference;
                return $this;
                break;

            case ClassMetadata::REFERENCE_STORE_AS_REF:
                $keys = ['id' => true];
                break;

            case ClassMetadata::REFERENCE_STORE_AS_DB_REF:
            case ClassMetadata::REFERENCE_STORE_AS_DB_REF_WITH_DB:
                $keys = ['$ref' => true, '$id' => true, '$db' => true];

                if ($storeAs === ClassMetadata::REFERENCE_STORE_AS_DB_REF) {
                    unset($keys['$db']);
                }

                if (isset($mapping['targetDocument'])) {
                    unset($keys['$ref'], $keys['$db']);
                }
                break;

            default:
                throw new InvalidArgumentException(sprintf('Reference type %s is invalid.', $storeAs));
        }

        foreach ($keys as $key => $value) {
            $this->query[$mapping['name']]['$elemMatch'][$key] = $reference[$key];
        }

        return $this;
    }
595736
protected function getContainer()
    {
        if (!$this->objectStore) {
            $this->objectStore = $this->objectStoreFactory->getObjectStore();
        }

        return parent::getContainer();
    }
1173692
public static function create($nome, $documento, $endereco = null, $bairro = null, $cep = null, $cidade = null, $uf = null)
    {
        return new static([
            'nome' => $nome,
            'endereco' => $endereco,
            'bairro' => $bairro,
            'cep' => $cep,
            'uf' => $uf,
            'cidade' => $cidade,
            'documento' => $documento,
        ]);
    }
1091819
public function scopeSearch(Builder $q, $search, $threshold = null, $entireText = false, $entireTextOnly = false)
    {
        return $this->scopeSearchRestricted($q, $search, null, $threshold, $entireText, $entireTextOnly);
    }
903868
public function createDocumentFromSource($source)
    {
        if ($source instanceof \DOMDocument) {
            return $source;
        }

        throw new RuntimeException(RuntimeException::INVALID_DOM_SOURCE_STR, RuntimeException::INVALID_DOM_SOURCE);
    }
183307
public function applyScopes()
	{
		if ( !$this->scopes )
		{
			return $this;
		}

		$builder = clone $this;

		foreach ( $this->scopes as $scope )
		{
			$builder->callScope( function ( Builder $builder ) use ( $scope )
			{
				if ( $scope instanceof Closure )
				{
					$scope( $builder );
				}
				elseif ( $scope instanceof Scope )
				{
					$scope->apply( $builder, $this->getModel() );
				}
			} );
		}

		return $builder;
	}
20938
public function getContainerExtension(): ?ExtensionInterface
    {
        if (null === $this->extension) {
            $extension = $this->createContainerExtension();

            if (null !== $extension) {
                if (!$extension instanceof ExtensionInterface) {
                    throw new \LogicException(sprintf('Extension %s must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.',
                        \get_class($extension)));
                }

                // check naming convention
                $basename      = str_replace(['Component', 'Module', 'Plugin'], ['', '', ''], $this->getIdentifier());
                $expectedAlias = Container::underscore($basename);

                if ($expectedAlias != $extension->getAlias()) {
                    throw new \LogicException(sprintf('Users will expect the alias of the default extension of a bundle to be the underscored version of the bundle name ("%s"). You can override "Bundle::getContainerExtension()" if you want to use "%s" or another alias.',
                        $expectedAlias, $extension->getAlias()));
                }

                $this->extension = $extension;
            }
        }

        return $this->extension;
    }
212753
public function getCollection(string $resourceClass, string $operationName = null, array $context = [])
    {
        /** @var DocumentManager $manager */
        $manager = $this->managerRegistry->getManagerForClass($resourceClass);

        $repository = $manager->getRepository($resourceClass);
        if (!$repository instanceof DocumentRepository) {
            throw new RuntimeException(sprintf('The repository for "%s" must be an instance of "%s".', $resourceClass, DocumentRepository::class));
        }

        $aggregationBuilder = $repository->createAggregationBuilder();
        foreach ($this->collectionExtensions as $extension) {
            $extension->applyToCollection($aggregationBuilder, $resourceClass, $operationName, $context);

            if ($extension instanceof AggregationResultCollectionExtensionInterface && $extension->supportsResult($resourceClass, $operationName, $context)) {
                return $extension->getResult($aggregationBuilder, $resourceClass, $operationName, $context);
            }
        }

        return $aggregationBuilder->hydrate($resourceClass)->execute();
    }