Eccube\Repository\CategoryRepository::up PHP Метод

up() публичный Метод

カテゴリの順位を1上げる.
Устаревший: since 3.0.0, to be removed in 3.1
public up ( Category $Category ) : boolean
$Category Eccube\Entity\Category カテゴリ
Результат boolean 成功した場合 true
    public function up(\Eccube\Entity\Category $Category)
    {
        $em = $this->getEntityManager();
        $em->getConnection()->beginTransaction();
        try {
            $rank = $Category->getRank();
            $Parent = $Category->getParent();
            if ($Parent) {
                $CategoryUp = $this->createQueryBuilder('c')->where('c.rank > :rank AND c.Parent = :Parent')->setParameter('rank', $rank)->setParameter('Parent', $Parent)->orderBy('c.rank', 'ASC')->setMaxResults(1)->getQuery()->getSingleResult();
            } else {
                $CategoryUp = $this->createQueryBuilder('c')->where('c.rank > :rank AND c.Parent IS NULL')->setParameter('rank', $rank)->orderBy('c.rank', 'ASC')->setMaxResults(1)->getQuery()->getSingleResult();
            }
            $this_count = $Category->countBranches();
            $up_count = $CategoryUp->countBranches();
            $Category->calcChildrenRank($em, $up_count);
            $CategoryUp->calcChildrenRank($em, $this_count * -1);
            $em->flush();
            $em->getConnection()->commit();
        } catch (\Exception $e) {
            $em->getConnection()->rollback();
            return false;
        }
        return true;
    }