Export/ExportManager.php
public function generate($exportAlias, array $pickedCentersData, array $data, array $formatterData)
    {
        $export = $this->getExport($exportAlias);
        //$qb = $this->em->createQueryBuilder();
        $centers = $this->getPickedCenters($pickedCentersData);
        
        $query = $export->initiateQuery(
                $this->retrieveUsedModifiers($data), 
                $this->buildCenterReachableScopes($centers, $export),
                $data[ExportType::EXPORT_KEY]
                );
        
        if ($query instanceof \Doctrine\ORM\NativeQuery) {
            // throw an error if the export require other modifier, which is 
            // not allowed when the export return a `NativeQuery`
            if (count($export->supportsModifiers()) > 0) {
                throw new \LogicException("The export with alias `$exportAlias` return "
                        . "a `\Doctrine\ORM\NativeQuery` and supports modifiers, which is not "
                        . "allowed. Either the method `supportsModifiers` should return an empty "
                        . "array, or return a `Doctrine\ORM\QueryBuilder`");
            }
        } elseif ($query instanceof QueryBuilder) {
            //handle filters
            $this->handleFilters($export, $query, $data[ExportType::FILTER_KEY], $centers);

            //handle aggregators
            $this->handleAggregators($export, $query, $data[ExportType::AGGREGATOR_KEY], $centers);
            
            $this->logger->debug('current query is '.$query->getDQL(), array(
                'class' => self::class, 'function' => __FUNCTION__
            ));
        } else {
            throw new \UnexpectedValueException("The method `intiateQuery` should return "
                    . "a `\Doctrine\ORM\NativeQuery` or a `Doctrine\ORM\QueryBuilder` "
                    . "object.");
        }
        
        $result = $export->getResult($query, $data[ExportType::EXPORT_KEY]);
        
        if (!is_array($result)) {
            throw new \UnexpectedValueException(
                    sprintf(
                            'The result of the export should be an array, %s given',
                            gettype($result)
                            )
                    );
        }
        
        /* @var $formatter Formatter\CSVFormatter */
        $formatter = $this->getFormatter($this->getFormatterAlias($data));
        $filters = array();
        $aggregatorsData = array();
        
        if ($query instanceof QueryBuilder) {
            $aggregators = $this->retrieveUsedAggregators($data[ExportType::AGGREGATOR_KEY]);
            
            foreach($aggregators as $alias => $aggregator) {
                $aggregatorsData[$alias] = $data[ExportType::AGGREGATOR_KEY][$alias]['form'];
            }
        }
        
        return $formatter->getResponse(
              $result, 
              $formatterData, 
              $exportAlias, 
              $data[ExportType::EXPORT_KEY],
              $filters, 
              $aggregatorsData);
    }
public function generate($exportAlias, array $pickedCentersData, array $data, array $formatterData)
    {
        $export = $this->getExport($exportAlias);
        //$qb = $this->em->createQueryBuilder();
        $centers = $this->getPickedCenters($pickedCentersData);
        
        $query = $export->initiateQuery(
                $this->retrieveUsedModifiers($data), 
                $this->buildCenterReachableScopes($centers, $export),
                $data[ExportType::EXPORT_KEY]
                );
        
        if ($query instanceof \Doctrine\ORM\NativeQuery) {
            // throw an error if the export require other modifier, which is 
            // not allowed when the export return a `NativeQuery`
            if (count($export->supportsModifiers()) > 0) {
                throw new \LogicException("The export with alias `$exportAlias` return "
                        . "a `\Doctrine\ORM\NativeQuery` and supports modifiers, which is not "
                        . "allowed. Either the method `supportsModifiers` should return an empty "
                        . "array, or return a `Doctrine\ORM\QueryBuilder`");
            }
        } elseif ($query instanceof QueryBuilder) {
            //handle filters
            $this->handleFilters($export, $query, $data[ExportType::FILTER_KEY], $centers);

            //handle aggregators
            $this->handleAggregators($export, $query, $data[ExportType::AGGREGATOR_KEY], $centers);
            
            $this->logger->debug('current query is '.$query->getDQL(), array(
                'class' => self::class, 'function' => __FUNCTION__
            ));
        } else {
            throw new \UnexpectedValueException("The method `intiateQuery` should return "
                    . "a `\Doctrine\ORM\NativeQuery` or a `Doctrine\ORM\QueryBuilder` "
                    . "object.");
        }
        
        $result = $export->getResult($query, $data[ExportType::EXPORT_KEY]);
        
        if (!is_array($result)) {
            throw new \UnexpectedValueException(
                    sprintf(
                            'The result of the export should be an array, %s given',
                            gettype($result)
                            )
                    );
        }
        
        /* @var $formatter Formatter\CSVFormatter */
        $formatter = $this->getFormatter($this->getFormatterAlias($data));
        $filters = array();
        $aggregatorsData = array();
        
        if ($query instanceof QueryBuilder) {
            $aggregators = $this->retrieveUsedAggregators($data[ExportType::AGGREGATOR_KEY]);
            
            foreach($aggregators as $alias => $aggregator) {
                $aggregatorsData[$alias] = $data[ExportType::AGGREGATOR_KEY][$alias]['form'];
            }
        }
        
        return $formatter->getResponse(
              $result, 
              $formatterData, 
              $exportAlias, 
              $data[ExportType::EXPORT_KEY],
              $filters, 
              $aggregatorsData);
    }
public function generate ( $ exportAlias , array $ pickedCentersData , array $ data , array $ formatterData ) { $ export = $ this -> getExport ( $ exportAlias ) ; //$qb = $this->em->createQueryBuilder(); $ centers = $ this -> getPickedCenters ( $ pickedCentersData ) ; $ query = $ export -> initiateQuery ( $ this -> retrieveUsedModifiers ( $ data ) , $ this -> buildCenterReachableScopes ( $ centers , $ export ) , $ data [ ExportType :: EXPORT_KEY ] ) ; if ( $ query instanceof \ Doctrine \ ORM \ NativeQuery ) { // throw an error if the export require other modifier, which is  // not allowed when the export return a `NativeQuery` if ( count ( $ export -> supportsModifiers ( ) ) > 0 ) { throw new \ LogicException ( "The export with alias `$exportAlias` return " . "a `\Doctrine\ORM\NativeQuery` and supports modifiers, which is not " . "allowed. Either the method `supportsModifiers` should return an empty " . "array, or return a `Doctrine\ORM\QueryBuilder`" ) ; } } elseif ( $ query instanceof QueryBuilder ) { //handle filters $ this -> handleFilters ( $ export , $ query , $ data [ ExportType :: FILTER_KEY ] , $ centers ) ; //handle aggregators $ this -> handleAggregators ( $ export , $ query , $ data [ ExportType :: AGGREGATOR_KEY ] , $ centers ) ; $ this -> logger -> debug ( 'current query is ' . $ query -> getDQL ( ) , array ( 'class' => self :: class , 'function' => __FUNCTION__ ) ) ; } else { throw new \ UnexpectedValueException ( "The method `intiateQuery` should return " . "a `\Doctrine\ORM\NativeQuery` or a `Doctrine\ORM\QueryBuilder` " . "object." ) ; } $ result = $ export -> getResult ( $ query , $ data [ ExportType :: EXPORT_KEY ] ) ; if ( ! is_array ( $ result ) ) { throw new \ UnexpectedValueException ( sprintf ( 'The result of the export should be an array, %s given' , gettype ( $ result ) ) ) ; } /* @var $formatter Formatter\CSVFormatter */ $ formatter = $ this -> getFormatter ( $ this -> getFormatterAlias ( $ data ) ) ; $ filters = array ( ) ; $ aggregatorsData = array ( ) ; if ( $ query instanceof QueryBuilder ) { $ aggregators = $ this -> retrieveUsedAggregators ( $ data [ ExportType :: AGGREGATOR_KEY ] ) ; foreach ( $ aggregators as $ alias => $ aggregator ) { $ aggregatorsData [ $ alias ] = $ data [ ExportType :: AGGREGATOR_KEY ] [ $ alias ] [ 'form' ] ; } } return $ formatter -> getResponse ( $ result , $ formatterData , $ exportAlias , $ data [ ExportType :: EXPORT_KEY ] , $ filters , $ aggregatorsData ) ; }
Generate a response which contains the requested data.

@param string $exportAlias
@param mixed[] $data
@return Response
Generate a response which contains the requested data .