resolves a dbref array into the actual object

@param string $collection collection name
@param string $id         record id

@return array|null record as array or null
963679
private function resolveObject($collection, $id)
    {
        return $this->connection->selectCollection($this->databaseName, $collection)->findOne(['_id' => $id]);
    }
573664
protected function handleWriteCollection($request, $id = null)
    {
        $collection = $id ? $this->getCollection($id) : null;

        $form = $this->formFactory->createNamed(null, 'sonata_classification_api_form_collection', $collection, [
            'csrf_protection' => false,
        ]);

        FormHelper::removeFields($request->request->all(), $form);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $collection = $form->getData();
            $this->collectionManager->save($collection);

            $context = new Context();
            $context->setGroups(['sonata_api_read']);

            $view = FOSRestView::create($collection);
            $view->setContext($context);

            return $view;
        }

        return $form;
    }
1324244
public function get($collection = "")
		{

			$documents = $this->getCursor($collection);

			$returns = array();

			if ($documents && !empty($documents)) {
				foreach ($documents as $doc) {
					$returns[] = $doc;
				}
			}

			return $returns;
		}
867823
public function getCollection($id)
    {
        if (!isset($this->_collections[$id])) {
            throw new \InvalidArgumentException('Collection not attached: ' . $id);
        }
        return $this->_collections;
    }
176296
private function _getObject($id, $revision = null)
    {
        if ($revision === null) {
            $select = Statement::get(
                'GET_CURRENT_OBJECT',
                [
                    '@collection' => $this->_name,
                    '@id' => $this->_connector->quote($id)
                ]
            );
            $record = $this->_connector->query($select)->fetch();
            if ($record) {
                return json_decode($record['obj']);
            }
        }
        return null;
    }
759337
public function collection($collectionId)
    {
        return new CollectionReference(
            $this->connection,
            $this->valueMapper,
            $this->childPath($this->name, $collectionId)
        );
    }
53317
protected function collection_query( &$collection ) 
	{
		$local_keys = array();
		
		foreach( $collection as $item )
		{
			$local_keys[] = $item->raw( $this->local_key );
		}
		
		// set the correct collection where
		$this->query->wheres = array();
		$this->query->where( $this->foreign_key, 'in', $local_keys );
		$this->query->group_result( $this->foreign_key );
		
		$this->query->limit( null );
	}
565590
public function get($collection)
    {
        $collection = $this->makeCollection($collection);

        $url      = UrlHelper::buildUrl(Urls::URL_COLLECTION, [$collection]);
        $response = $this->getConnection()->get($url);

        $data = $response->getJson();

        return Collection::createFromArray($data);
    }
82276
public function deleteById($collection, $id)
    {
        try {
            $id = new \MongoDB\BSON\ObjectID((string) $id);
        } catch (\Exception $e) {
            return;
        }

        $queryOptions = new QueryOptions();
        $queryOptions->setQueryParams([
            '_id' => $id,
        ]);

        $this->ensureConnection();
        $this->db->$collection->deleteOne($queryOptions->getQueryParams());
    }
391046
protected function doResolve($alias, Collection $collection)
    {
        $result = null;
        switch (strtolower($alias)) {
            case self::LAST:
            case self::LATEST:
                $result = $collection->last();
                break;
            case self::FIRST:
            case self::EARLIEST:
                $result = $collection->first();
                break;
            default:
        }
        return $result;
    }
1068209
public function get_one($collection = "")
	{
		if (empty($collection))
		{
			throw new \Mongo_DbException("In order to retrieve documents from MongoDB you must provide a collection name.");
		}

		if ($this->profiling)
		{
			$query = json_encode(array(
			'type'			=> 'findOne',
			'collection'	=> $collection,
			'select'		=> $this->selects,
			'where'			=> $this->wheres,
			));

			$benchmark = \Profiler::start((string) $this->db, $query);
		}

		$returns = $this->db->{$collection}->findOne($this->wheres, $this->selects);

		if (isset($benchmark))
		{
			\Profiler::stop($benchmark);
		}

		$this->_clear();

		return $returns;
	}
765038
protected function getDeleteSQLParameters(PersistentCollection $collection)
    {
        $association = $collection->getMapping();
        $identifier  = $this->uow->getEntityIdentifier($collection->getOwner());
        $joinTable   = $association->getJoinTable();
        $joinColumns = $joinTable->getJoinColumns();

        // Optimization for single column identifier
        if (count($joinColumns) === 1) {
            return [reset($identifier)];
        }

        // Composite identifier
        $sourceClass = $this->em->getClassMetadata($association->getSourceEntity());
        $params      = [];

        foreach ($joinColumns as $joinColumn) {
            $params[] = $identifier[$sourceClass->fieldNames[$joinColumn->getReferencedColumnName()]];
        }

        return $params;
    }
878395
public function transform($collection)
    {   
        if (!$collection instanceof Collection) {  
            return null; 
        }
        
        $data = array();
        $accessor = PropertyAccess::createPropertyAccessor();
        
        foreach ($collection as $ref){
            if (!$ref instanceof Select2SortableInterface){
                throw new \InvalidArgumentException('Reference class must be instance of Select2SortableInterface');  
            }
            
            $data[] = $accessor->getValue($ref, $this->inversedProperty)->getId();
        }
        
        $this->collection = $collection;
        
        return implode(',', $data);
    }
1364503
protected function getCollection($id)
    {
        $collection = $this->collectionManager->find($id);

        if (null === $collection) {
            throw new NotFoundHttpException(sprintf('Collection (%d) not found', $id));
        }

        return $collection;
    }
1209370
public function getKeys($collection)
    {
        $cursor = $this->server->executeQuery($this->database . '.' . $collection,
            new \MongoDb\Driver\Query([], ['limit' => 1]));

        $result = current($cursor->toArray());

        $this->queriesResultCache[ 'collectionKeys' ][ $collection ] = [];

        foreach (get_object_vars($result) as $key => $value) {
            $this->queriesResultCache[ 'collectionKeys' ][ $collection ][] = $key;
        }

        return $this->queriesResultCache[ 'collectionKeys' ][ $collection ];
    }
859767
public function get($collection = "")
	{
		if ($this->profiling)
		{
			$query = json_encode(array(
			'type'			=> 'find',
			'collection'	=> $collection,
			'select'		=> $this->selects,
			'where'			=> $this->wheres,
			'limit'			=> $this->limit,
			'offset'		=> $this->offset,
			'sort'			=> $this->sorts,
			));

			$benchmark = \Profiler::start((string) $this->db, $query);
		}

		$documents = $this->get_cursor($collection);

		if (isset($benchmark))
		{
			\Profiler::stop($benchmark);
		}

		$returns = array();

		if ($documents and ! empty($documents))
		{
			foreach ($documents as $doc)
			{
				$returns[] = $doc;
			}
		}

		return $returns;
	}
213449
private function resolveParameters(string $id, array $parameters, ContainerInterface $container): array
    {
        $resolved = [];
        foreach ($parameters as $parameter) {
            $resolved[] = $this->getParameterValue($id, $parameter, $container);
        }
        return $resolved;
    }