src/Model/SortableHelper.php
public function getNextSortOrder (array $where = []) : int
    {
        $queryBuild = $this->repository->createQueryBuilder("t")
            ->select("MAX(t.sortOrder)");

        // apply the where clauses
        if (0 < \count($completeWhere = $this->getCompleteWhere($where)))
        {
            $queryParts = [];
            $index = 0;

            foreach ($completeWhere as $key => $value)
            {
                if (null === $value)
                {
                    $queryParts[] = "t.{$key} IS NULL";
                }
                else
                {
                    $queryParts[] = "t.{$key} = :where_value_{$index}";
                    $queryBuild->setParameter("where_value_{$index}", $value);
                }

                ++$index;
            }

            $queryBuild->where(\implode(" AND ", $queryParts));
        }

        $currentMaxValue = $queryBuild
            ->getQuery()
            ->getSingleScalarResult();

        return null !== $currentMaxValue
            ? 1 + (int) $currentMaxValue
            : 0;
    }
public function getNextSortOrder (array $where = []) : int
    {
        $queryBuild = $this->repository->createQueryBuilder("t")
            ->select("MAX(t.sortOrder)");

        // apply the where clauses
        if (0 < \count($completeWhere = $this->getCompleteWhere($where)))
        {
            $queryParts = [];
            $index = 0;

            foreach ($completeWhere as $key => $value)
            {
                if (null === $value)
                {
                    $queryParts[] = "t.{$key} IS NULL";
                }
                else
                {
                    $queryParts[] = "t.{$key} = :where_value_{$index}";
                    $queryBuild->setParameter("where_value_{$index}", $value);
                }

                ++$index;
            }

            $queryBuild->where(\implode(" AND ", $queryParts));
        }

        $currentMaxValue = $queryBuild
            ->getQuery()
            ->getSingleScalarResult();

        return null !== $currentMaxValue
            ? 1 + (int) $currentMaxValue
            : 0;
    }
public function getNextSortOrder ( array $ where = [ ] ) : int { $ queryBuild = $ this -> repository -> createQueryBuilder ( "t" ) -> select ( "MAX(t.sortOrder)" ) ; // apply the where clauses if ( 0 < \ count ( $ completeWhere = $ this -> getCompleteWhere ( $ where ) ) ) { $ queryParts = [ ] ; $ index = 0 ; foreach ( $ completeWhere as $ key => $ value ) { if ( null === $ value ) { $ queryParts [ ] = "t.{$key} IS NULL" ; } else { $ queryParts [ ] = "t.{$key} = :where_value_{$index}" ; $ queryBuild -> setParameter ( "where_value_{$index}" , $ value ) ; } ++ $ index ; } $ queryBuild -> where ( \ implode ( " AND " , $ queryParts ) ) ; } $ currentMaxValue = $ queryBuild -> getQuery ( ) -> getSingleScalarResult ( ) ; return null !== $ currentMaxValue ? 1 + ( int ) $ currentMaxValue : 0 ; }
Returns the next sort order value.

@param array $where

@return int
Returns the next sort order value .