Build Status Scrutinizer Quality Score Latest Stable Version Total Downloads

SensioLabsInsight knpbundles.com

Overview

This bundle has been made to ease SonataAdmin installation and configuration for all our projects.

PrestaSonataAdminExtendedBundle-Dashboard

Installation

Get the code

The easiest way is to use composer :

php composer.phar require presta/sonata-admin-extended-bundle --no-update
php composer.phar update presta/sonata-admin-extended-bundle

Update your Kernel

<?php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            ...
            new Presta\SonataAdminExtendedBundle\PrestaSonataAdminExtendedBundle(),
            new Presta\SonataNavigationBundle\PrestaSonataNavigationBundle(),
            new Presta\SonataGedmoDoctrineExtensionsBundle\PrestaSonataGedmoDoctrineExtensionsBundle(),
        );
    }
}

Generate your application bundles

php app/console sonata:easy-extends:generate SonataAdminBundle
php app/console sonata:easy-extends:generate SonataUserBundle
php app/console sonata:easy-extends:generate SonataMediaBundle

-> Update ‘ApplicationSonataAdminBundle’ to extends ‘PrestaSonataAdminExtendedBundle’

<?php
class ApplicationSonataAdminBundle extends Bundle
{
    /**
     * {@inheritdoc}
     */
    public function getParent()
    {
        return 'PrestaSonataAdminExtendedBundle';
    }
}

Update your Kernel

<?php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            ...
            new Application\Sonata\UserBundle\ApplicationSonataUserBundle(),
            new Application\Sonata\AdminBundle\ApplicationSonataAdminBundle(),
            new Application\Sonata\MediaBundle\ApplicationSonataMediaBundle()
        );
    }
}

Make a custom layout

Create src/Application/Sonata/AdminBundle/Resources/layout.html.twig (click to see complete code).

Configuration

Create a new configuration file : app/config/bundles/presta_sonata_admin_extended.yml

First, import all the configuration you need. There are several files so you can easily choose what you really need.

Configure your locales :

  • locale: default for symfony
  • locales : every front locales this is used by gedmo to translation your entities
  • presta_sonata_admin_extended.locales: locales availables for your administration interface
  • presta_sonata_admin_extended.default_locale: your admin default locale

Then add bundles to assetics and update default sonata configuration.

imports:
    - { resource: '@PrestaSonataAdminExtendedBundle/Resources/config/config.yml' }
    - { resource: '@PrestaSonataAdminExtendedBundle/Resources/config/user/config.yml'}
    - { resource: '@PrestaSonataAdminExtendedBundle/Resources/config/user/config_navigation.yml' }
    - { resource: '@PrestaSonataAdminExtendedBundle/Resources/config/user/config_dashboard.yml' }
    - { resource: '@PrestaSonataAdminExtendedBundle/Resources/config/media/config.yml'}
    - { resource: '@PrestaSonataAdminExtendedBundle/Resources/config/media/config_navigation.yml' }
    - { resource: '@PrestaSonataAdminExtendedBundle/Resources/config/media/config_dashboard.yml' }

parameters:
    locale:  en
    locales: [fr, en]
    presta_sonata_admin_extended.locales: [fr, en]
    presta_sonata_admin_extended.default_locale: en

assetic:
    bundles:
        - SonataAdminBundle
        - PrestaSonataAdminExtendedBundle
        - ApplicationSonataAdminBundle

sonata_admin:
    title:      ' '
    title_logo: ./bundles/prestasonataadminextended/img/logo_title.jpg
    templates:
        # default global templates
        layout:  ApplicationSonataAdminBundle::layout.html.twig
        user_block: PrestaSonataAdminExtendedBundle:Core:user_block.html.twig
        dashboard:  PrestaSonataAdminExtendedBundle:Dashboard:two_columns.html.twig

Working example

You should have a look at symfony-prestacms project for a ready to use installation of this bundles.

How to get help and support

If you need help on one of our bundle, please register to our google group and ask you question. You can open issues on github too.


Want do contribute ? Just fork and edit it!