Skip to content

TeoGoddet/sonata-admin-extra-export-bundle

 
 

Repository files navigation

SonataAdminExtraExportBundle

[SonataAdminExtraExportBundle][sonata-admin-extra-export-bundle] is a PHP (5.4+) extension for Sonata Admin. By default Sonata Admin has json, xml, csv and xls export formats.

The SonataAdminExtraExportBundle provides a simple integration for your Symfony project with Sonata Admin and adds support of:

Installation

With composer, add:

{
    "require": {
        "whyte624/sonata-admin-extra-export-bundle": "dev-master"
    }
}

Then enable it in your kernel:

// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        //...
        new Whyte624\SonataAdminExtraExportBundle\Whyte624SonataAdminExtraExportBundle(),
        new Knp\Bundle\SnappyBundle\KnpSnappyBundle(),
        //...

Configuration

Configure KnpSnappyBundle.

[SonataAdminExtraExportBundle][sonata-admin-extra-export-bundle] requires you to add traits with export formats to Admin class and extension of export method to CRUDController class.

Add trait to Admin class:

//src/Acme/AcmeBundle/Admin/MyAdmin.php
use Sonata\AdminBundle\Admin\Admin;
use Whyte624\SonataAdminExtraExportBundle\Admin\AdminExtraExportTrait;

class MyAdmin extends Admin
{
    //...
    use AdminExtraExportTrait;
    //...

Add trait to CRUDController class

//src/Acme/AcmeBundle/Controller/MyCRUDController.php
use Sonata\AdminBundle\Controller\CRUDController;
use Whyte624\SonataAdminExtraExportBundle\Controller\CRUDControllerExtraExportTrait;

class MyCRUDController extends CRUDController
{
    //...
    use CRUDControllerExtraExportTrait;
    //...

This will add extra export formats to your admin.

Pdf layout

You can easily add your companies logo to PDF export, by overriding Whyte624SonataAdminExtraExportBundle::html_layout.html.twig. Just make sure, that paths for images and css that you are using are absolute.

Override getPdfOptions class in your CRUDController class to change orientation to landscape.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 75.5%
  • HTML 24.5%