Bundle/QueryBundle/Helper/QueryHelper.php
public function getQueryBuilder(VictoireQueryInterface $containerEntity, EntityManager $em)
    {
        if ($containerEntity === null) {
            throw new \Exception('The container entity parameter must not be null.');
        }

        //the business name of the container entity
        $businessEntityId = $containerEntity->getBusinessEntityId();

        //test that there is a business entity name
        if ($businessEntityId === null || $businessEntityId === '') {
            $containerId = $containerEntity->getId();

            throw new \Exception('The container entity ['.$containerId.'] does not have any businessEntityId.');
        }

        //the business class of the container entity
        $businessEntity = $this->businessEntityHelper->findById(strtolower($businessEntityId));

        //test that there was a businessEntity
        if ($businessEntity === null) {
            throw new \Exception('The business entity was not found for the id:['.$businessEntityId.']');
        }

        $businessClass = $businessEntity->getClass();

        $itemsQueryBuilder = $em
            ->createQueryBuilder()
            ->select('main_item')
            ->from($businessClass, 'main_item')
            ->andWhere('main_item.visibleOnFront = 1');

        $view = null;
        if ($containerEntity instanceof View) {
            $view = $containerEntity;
        } elseif ($containerEntity instanceof Widget) {
            $view = $containerEntity->getCurrentView();
        }

        // when the businessClass is translatable, join translations for the current locale
        if ($view && in_array(Translatable::class, class_uses($businessClass))) {
            $itemsQueryBuilder->join('main_item.translations', 'translation')
                ->andWhere('translation.locale = :locale')
                ->setParameter(':locale', $view->getCurrentLocale());
        }

        $refClass = new \ReflectionClass($businessClass);
        if ($refClass->hasMethod('getDeletedAt')) {
            $itemsQueryBuilder->andWhere('main_item.deletedAt IS NULL');
        }

        return $itemsQueryBuilder;
    }
public function getQueryBuilder(VictoireQueryInterface $containerEntity, EntityManager $em)
    {
        if ($containerEntity === null) {
            throw new \Exception('The container entity parameter must not be null.');
        }

        //the business name of the container entity
        $businessEntityId = $containerEntity->getBusinessEntityId();

        //test that there is a business entity name
        if ($businessEntityId === null || $businessEntityId === '') {
            $containerId = $containerEntity->getId();

            throw new \Exception('The container entity ['.$containerId.'] does not have any businessEntityId.');
        }

        //the business class of the container entity
        $businessEntity = $this->businessEntityHelper->findById(strtolower($businessEntityId));

        //test that there was a businessEntity
        if ($businessEntity === null) {
            throw new \Exception('The business entity was not found for the id:['.$businessEntityId.']');
        }

        $businessClass = $businessEntity->getClass();

        $itemsQueryBuilder = $em
            ->createQueryBuilder()
            ->select('main_item')
            ->from($businessClass, 'main_item')
            ->andWhere('main_item.visibleOnFront = 1');

        $view = null;
        if ($containerEntity instanceof View) {
            $view = $containerEntity;
        } elseif ($containerEntity instanceof Widget) {
            $view = $containerEntity->getCurrentView();
        }

        // when the businessClass is translatable, join translations for the current locale
        if ($view && in_array(Translatable::class, class_uses($businessClass))) {
            $itemsQueryBuilder->join('main_item.translations', 'translation')
                ->andWhere('translation.locale = :locale')
                ->setParameter(':locale', $view->getCurrentLocale());
        }

        $refClass = new \ReflectionClass($businessClass);
        if ($refClass->hasMethod('getDeletedAt')) {
            $itemsQueryBuilder->andWhere('main_item.deletedAt IS NULL');
        }

        return $itemsQueryBuilder;
    }
public function getQueryBuilder ( VictoireQueryInterface $ containerEntity , EntityManager $ em ) { if ( $ containerEntity === null ) { throw new \ Exception ( 'The container entity parameter must not be null.' ) ; } //the business name of the container entity $ businessEntityId = $ containerEntity -> getBusinessEntityId ( ) ; //test that there is a business entity name if ( $ businessEntityId === null || $ businessEntityId === '' ) { $ containerId = $ containerEntity -> getId ( ) ; throw new \ Exception ( 'The container entity [' . $ containerId . '] does not have any businessEntityId.' ) ; } //the business class of the container entity $ businessEntity = $ this -> businessEntityHelper -> findById ( strtolower ( $ businessEntityId ) ) ; //test that there was a businessEntity if ( $ businessEntity === null ) { throw new \ Exception ( 'The business entity was not found for the id:[' . $ businessEntityId . ']' ) ; } $ businessClass = $ businessEntity -> getClass ( ) ; $ itemsQueryBuilder = $ em -> createQueryBuilder ( ) -> select ( 'main_item' ) -> from ( $ businessClass , 'main_item' ) -> andWhere ( 'main_item.visibleOnFront = 1' ) ; $ view = null ; if ( $ containerEntity instanceof View ) { $ view = $ containerEntity ; } elseif ( $ containerEntity instanceof Widget ) { $ view = $ containerEntity -> getCurrentView ( ) ; } // when the businessClass is translatable, join translations for the current locale if ( $ view && in_array ( Translatable :: class , class_uses ( $ businessClass ) ) ) { $ itemsQueryBuilder -> join ( 'main_item.translations' , 'translation' ) -> andWhere ( 'translation.locale = :locale' ) -> setParameter ( ':locale' , $ view -> getCurrentLocale ( ) ) ; } $ refClass = new \ ReflectionClass ( $ businessClass ) ; if ( $ refClass -> hasMethod ( 'getDeletedAt' ) ) { $ itemsQueryBuilder -> andWhere ( 'main_item.deletedAt IS NULL' ) ; } return $ itemsQueryBuilder ; }
Get the query builder base. This makes a "select  from item XXX"
use the item for doing the left join or where dql.

@param \Victoire\Bundle\BusinessPageBundle\Entity\BusinessTemplate $containerEntity

@throws \Exception

@return QueryBuilder
Get the query builder base . This makes a select from item XXX use the item for doing the left join or where dql .