Doctrine\Search\UnitOfWork::sortObjects PHP Method

sortObjects() private method

Prepare entities for commit. Entities scheduled for deletion do not need to be serialized.
private sortObjects ( array $objects, boolean $serialize = true ) : array
$objects array
$serialize boolean
return array
    private function sortObjects(array $objects, $serialize = true)
    {
        $documents = array();
        $serializer = $this->sm->getSerializer();
        foreach ($objects as $object) {
            $document = $serialize ? $serializer->serialize($object) : $object;
            $id = (string) $object->getId();
            if (!$id) {
                throw new DoctrineSearchException('Entity must have an id to be indexed');
            }
            $documents[get_class($object)][$id] = $document;
        }
        return $documents;
    }