PHP code example of goldbach-algorithms / symfony-entity-exporter

1. Go to this page and download the library: Download goldbach-algorithms/symfony-entity-exporter 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/ */

    

goldbach-algorithms / symfony-entity-exporter example snippets


use GoldbachAlgorithms\SymfonyEntityExporter\SymfonyEntityExporter;

# Instantiate a new Entity Exporter
$entityExporter = new SymfonyEntityExporter;

# Set $data (query return) and entity class
$response = $entityExporter->csv(
            $data,
            User::class,
            UserDataExport::class, # Data Export Template (not 

use GoldbachAlgorithms\SymfonyEntityExporter\SymfonyEntityExporter;

# Instantiate a new Entity Exporter
$entityExporter = new SymfonyEntityExporter;

# Set $data (query return) and entity class
$response = $entityExporter->pdf(
            $data,
            User::class,
            UserDataExport::class, # Data Export Template (not t margin (not 

use GoldbachAlgorithms\SymfonyEntityExporter\SymfonyEntityExporter;

# Instantiate a new Entity Exporter
$entityExporter = new SymfonyEntityExporter;

# Set a content
$content = $this->renderView('content.html.twig', $vars);

# Call the method pdfByHtml()
$response = $entityExporter->pdfByHtml(
            $content,
            'Filename', # File .pdf name (not utf-8', # Char Mode (not 

use EasyCorp\Bundle\EasyAdminBundle\Factory\AdminContextFactory;
use GoldbachAlgorithms\SymfonyEntityExporter\SymfonyEntityExporter;

# Inject the AdminContextFactory and define public

/** @var AdminContextFactory  */
public $adminContextFactory;

public function __construct(AdminContextFactory $adminContextFactory)
{
   $this->adminContextFactory = $adminContextFactory;
}

# Instantiate a new Entity Exporter
$entityExporter = new SymfonyEntityExporter;

# Get the FilterFactory into Controller
$filterFactory = $this->get(FilterFactory::class);

# Use the Entity Exporter builder to EasyAdmin
$data = $entityExporter->getEasyAdminQuery(
            $request,
            $filterFactory,
            $this,
            [
                'id' => 1
            ]
        );

# Set $data (query return) and entity class
$response = $entityExporter->xls($data, User::class);

# File .xls
return $response;