Execute reorderings.

@param $documents
774308
private function executeReorders($documents)
    {
        foreach ($documents as $oid => $list) {
            if (!$this->contains($oid)) {
                continue;
            }
            foreach ($list as $value) {
                list($parent, $src, $target, $before) = $value;
                $parentNode = $this->session->getNode($this->getDocumentId($parent));

                // check for src and target ...
                $dest = $target;
                if ($parentNode->hasNode($src) && $parentNode->hasNode($target)) {
                    // there is no orderAfter, so we need to find the child after target to use it in orderBefore
                    if (!$before) {
                        $dest = null;
                        $found = false;
                        foreach ($parentNode->getNodes() as $name => $child) {
                            if ($name === $target) {
                                $found = true;
                            } elseif ($found) {
                                $dest = $name;
                                break;
                            }
                        }
                    }

                    $parentNode->orderBefore($src, $dest);
                    $class = $this->dm->getClassMetadata(get_class($parent));
                    foreach ($class->childrenMappings as $fieldName) {
                        if ($parent instanceof Proxy && $parent->__isInitialized()) {
                            $children = $class->reflFields[$fieldName]->getValue($parent);
                            $children->refresh();
                        }
                    }
                }
            }
        }
    }
531792
public function sort($fields)
    {
        $fields = $this->unitOfWork
            ->getDocumentPersister($this->class->name)
            ->prepareSortOrProjection($fields);

        $this->baseCursor->sort($fields);
        return $this;
    }
529530
public function setOrders($orders)
    {
        foreach ($orders as $order) {
            $this->orders[$order->id] = $order->expose();
        }
    }
728203
public function orderBy($fields)
    {
        if (!is_array($fields)) {
            $fields = $this->splitParts($fields);
        }

        foreach ($fields as $k => $field) {
            if (preg_match('#^(.*?)\s+(asc|desc)$#i', $field, $matches)) {
                $fields[$k] = $this->db->quoteColumn($matches[1]) . ' ' . $matches[2];
            } else {
                $fields[$k] = $this->db->quoteColumn($field);
            }
        }

        $this->query['order'] = implode(',', $fields);

        return $this;
    }
1118092
function( documents ) {
    
    documents = this.map( documents )
    
    for( var key in documents ) {
      this.documents[ key ] = documents[ key ]
    }
    
  }
407388
public function reorder($base = 0)
    {
        //force to integer
        settype($base, 'int');

        $table  = $this->getTable();
        $db     = $table->getDriver();
        $db->execute('SET @order = '.$base);

        $query = $this->getObject('lib:database.query.update')
            ->table($table->getBase())
            ->values('ordering = (@order := @order + 1)')
            ->order('ordering', 'ASC');

        //Build the where query
        $this->_buildQueryWhere($query);

        if ($base) {
            $query->where('ordering >= :ordering')->bind(array(':ordering' => $base));
        }

        $db->update($query);

        return $this;
    }
1447
public function order($fields)
    {
        $data = $this->get();

        // prepare arguments for array_multisort()
        $args = [];
        foreach ($fields as list($field, $desc)) {
            $args[] = array_column($data, $field);
            $args[] = $desc ? SORT_DESC : SORT_ASC;
            //$args[] = SORT_STRING; // SORT_STRING | SORT_NUMERIC | SORT_REGULAR
        }
        $args[] = &$data;

        // call sorting
        call_user_func_array('array_multisort', $args);

        // put data back in generator
        $this->generator = new \ArrayIterator(array_pop($args));

        return $this;
    }
598644
public function refresh($document)
    {
        $query = $this->getQueryForDocument($document);
        $data = $this->collection->findOne($query);
        $data = $this->hydratorFactory->hydrate($document, $data);
        $this->uow->setOriginalDocumentData($document, $data);
    }
187017
public function add($documents)
    {

        $pendingRemove = $this->getRemove();
        if ($this->getRemove()) {
            if ($this->all()) {
                throw new \RuntimeException('Adding to group with pending remove is not permitted');
            } else {
                $this->clearAdd();
                $this->clearRemove();
                $this->saved = array();
            }
        }
        if (!is_array($documents)) {
            $documents = array($documents);
        }

        $add =& $this->getArchive()->getByRef('add', array());
        foreach ($documents as $document) {
            $add[] = $document;
        }
    }
988444
public function reorder()
    {
        $store = $this->getRepository()->getStore();
        $query = $this->getScopedQuery($this->_mixer);
        $store->execute('SET @order = 0');
        $query->update('@col(ordering) = (@order := @order + 1)')->order('ordering', 'ASC');
        $store->execute($query);
    }
1114613
public function remove($documents)
    {
        if (!is_array($documents)) {
            $documents = array($documents);
        }

        $remove =& $this->getArchive()->getByRef('remove', array());
        foreach ($documents as $document) {
            $remove[] = $document;
        }
    }
1154022
private function executeRollBacks(array $migrations) : void
    {
        $this->connection->beginTransaction();

        foreach ($migrations as $migration) {
            $migration->down();
            $this->executedMigrations->delete(get_class($migration));
        }

        $this->connection->commit();
    }
101187
public function reorder($photo_ids)
    {
        if (count($photo_ids) == 1) {
            if ($edge = $this->getService('repos:photos.edge')
                              ->fetch(array(
                                        'set' => $this,
                                        'photo.id' => $photo_ids[0],
                                      ))
            ) {
                $edge->ordering = $this->photos->getTotal();
            }

            return;
        }

        foreach ($photo_ids as $index => $photo_id) {
            if ($edge = $this->getService('repos:photos.edge')
                             ->fetch(array(
                                      'set' => $this,
                                      'photo.id' => $photo_id, ))
            ) {
                $edge->ordering = $index + 1;
            }
        }
    }
1315666
public function add($documents)
    {
        if (!is_array($documents)) {
            $documents = array($documents);
        }

        $add =& Archive::getByRef($this, 'add', array());
        foreach ($documents as $document) {
            $add[] = $document;
        }
    }
255017
public function sortObjects($objects)
    {
        $collection = new HierarchicalCollection($objects, false);
        $collection->sortTree();

        return $collection->all();
    }
519667
public function createDocumentTermCount($documents)
    {
        $termCount = new TermCount($this->getSearchDbHandle(), $documents, $this->filters, $this->storage);
        $termCount->execute();
    }
922775
private function executeStarts(array $indexes): void
    {
        BlockInterpreter::executeStarts(
            $indexes,
            $this->getBlocks(),
            $this->getContext(),
            $this->getErrorAggregator()
        );
    }