src/Zicht/Bundle/AdminBundle/Admin/TreeAdmin.php
public function filterWithChildren($qb, $alias, $field, $value)
    {
        // Check whether it is a numeric value because we could get a string number.
        if (!($value['value'] && is_numeric($value['value']))) {
            return null;
        }

        // Get the parent item
        $parentQb = clone $qb;
        $parentQb->where($parentQb->expr()->eq(sprintf('%s.id', $alias), ':id'));
        $parentQb->setParameter('id', (int)$value['value']);
        $currentItem = $parentQb->getQuery()->getOneOrNullResult();

        if ($currentItem === null) {
            return null;
        }

        $qb->where(
            $qb->expr()->andX(
                $qb->expr()->eq(sprintf('%s.root', $alias), ':root'),
                $qb->expr()->orX(
                    $qb->expr()->andX(
                        $qb->expr()->lt(sprintf('%s.lft', $alias), ':left'),
                        $qb->expr()->gt(sprintf('%s.rgt', $alias), ':right')
                    ),
                    $qb->expr()->between(sprintf('%s.lft', $alias), ':left', ':right')
                )
            )
        );

        $qb->setParameter('root', $currentItem->getRoot());
        $qb->setParameter('left', $currentItem->getLft());
        $qb->setParameter('right', $currentItem->getRgt());

        return true;
    }
public function filterWithChildren($qb, $alias, $field, $value)
    {
        // Check whether it is a numeric value because we could get a string number.
        if (!($value['value'] && is_numeric($value['value']))) {
            return null;
        }

        // Get the parent item
        $parentQb = clone $qb;
        $parentQb->where($parentQb->expr()->eq(sprintf('%s.id', $alias), ':id'));
        $parentQb->setParameter('id', (int)$value['value']);
        $currentItem = $parentQb->getQuery()->getOneOrNullResult();

        if ($currentItem === null) {
            return null;
        }

        $qb->where(
            $qb->expr()->andX(
                $qb->expr()->eq(sprintf('%s.root', $alias), ':root'),
                $qb->expr()->orX(
                    $qb->expr()->andX(
                        $qb->expr()->lt(sprintf('%s.lft', $alias), ':left'),
                        $qb->expr()->gt(sprintf('%s.rgt', $alias), ':right')
                    ),
                    $qb->expr()->between(sprintf('%s.lft', $alias), ':left', ':right')
                )
            )
        );

        $qb->setParameter('root', $currentItem->getRoot());
        $qb->setParameter('left', $currentItem->getLft());
        $qb->setParameter('right', $currentItem->getRgt());

        return true;
    }
public function filterWithChildren ( $ qb , $ alias , $ field , $ value ) { // Check whether it is a numeric value because we could get a string number. if ( ! ( $ value [ 'value' ] && is_numeric ( $ value [ 'value' ] ) ) ) { return null ; } // Get the parent item $ parentQb = clone $ qb ; $ parentQb -> where ( $ parentQb -> expr ( ) -> eq ( sprintf ( '%s.id' , $ alias ) , ':id' ) ) ; $ parentQb -> setParameter ( 'id' , ( int ) $ value [ 'value' ] ) ; $ currentItem = $ parentQb -> getQuery ( ) -> getOneOrNullResult ( ) ; if ( $ currentItem === null ) { return null ; } $ qb -> where ( $ qb -> expr ( ) -> andX ( $ qb -> expr ( ) -> eq ( sprintf ( '%s.root' , $ alias ) , ':root' ) , $ qb -> expr ( ) -> orX ( $ qb -> expr ( ) -> andX ( $ qb -> expr ( ) -> lt ( sprintf ( '%s.lft' , $ alias ) , ':left' ) , $ qb -> expr ( ) -> gt ( sprintf ( '%s.rgt' , $ alias ) , ':right' ) ) , $ qb -> expr ( ) -> between ( sprintf ( '%s.lft' , $ alias ) , ':left' , ':right' ) ) ) ) ; $ qb -> setParameter ( 'root' , $ currentItem -> getRoot ( ) ) ; $ qb -> setParameter ( 'left' , $ currentItem -> getLft ( ) ) ; $ qb -> setParameter ( 'right' , $ currentItem -> getRgt ( ) ) ; return true ; }
Get item plus children

@param \Doctrine\ORM\QueryBuilder $qb
@param string $alias
@param string $field
@param array $value

@return bool|null
Get item plus children