PHP code example of idci / exporter-bundle

1. Go to this page and download the library: Download idci/exporter-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

idci / exporter-bundle example snippets



// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new IDCI\Bundle\ExporterBundle\IDCIExporterBundle(),
    );
}

$export = $this->container->get('idci_exporter.manager')->export($entities, $format);

$export->getContent();

$export->getContentType();

/**
 * extractQueryBuilder
 *
 * @param array $params
 * @return QueryBuilder
 */
public function extractQueryBuilder($params)
{
    $qb = $this->createQueryBuilder('cer');

    if(isset($params['id'])) {
        $qb
            ->andWhere('cer.id = :id')
            ->setParameter('id', $params['id'])
        ;
    }

    if(isset($params['category_id'])) {
        $qb
            ->leftJoin('cer.categories', 'c')
            ->andWhere('c.id = :cat_id')
            ->setParameter('cat_id', $params['category_id'])
        ;
    }

    if(isset($params['category_ids'])) {
        $qb
            ->leftJoin('cer.categories', 'cs')
            ->andWhere($qb->expr()->in('cs.id', $params['category_ids']))
        ;
    }

    return $qb;
}

/**
 * extractQuery
 *
 * @param array $params
 * @return Query
 */
public function extractQuery($params)
{
    $qb = $this->extractQueryBuilder($params);

    return is_null($qb) ? $qb : $qb->getQuery();
}

/**
 * extract
 *
 * @param array $params
 * @return DoctrineCollection
 */
public function extract($params)
{
    $q = $this->extractQuery($params);

    return is_null($q) ? array() : $q->getResult();
}
sh
php composer update