Skip to content

Latest commit

 

History

History
341 lines (238 loc) · 13.3 KB

general-configuration.md

File metadata and controls

341 lines (238 loc) · 13.3 KB

General configuration

Go back to Table of contents


Default configuration

Below the default configuration is given for this bundle.

admingenerator_generator:
    generate_base_in_project_dir: false
    generate_base_in_project_dir_directory: admin
    use_doctrine_orm: false
    use_doctrine_odm: false
    use_propel: false
    use_jms_security: false
    guess_required: true
    default_required: true
    overwrite_if_exists: false
    throw_exceptions: false
    base_admin_template: '@AdmingeneratorGenerator/base.html.twig'
    knp_menu_alias: ~
    dashboard_route: null
    login_route: null
    logout_route: null
    exit_route: null
    generator_cache: null
    default_action_after_save: edit
    use_doctrine_orm_batch_remove: false
    use_doctrine_odm_batch_remove: false
    use_doctrine_propel_remove: false
    twig:
        use_form_resources: true
        use_localized_date: false
        date_format: Y-m-d
        datetime_format: 'Y-m-d H:i:s'
        localized_date_format: medium
        localized_datetime_format: medium
        number_format:
        	decimal: 0
            decimal_point: .
            thousand_separator: ','
    templates_dirs: {  }
    form_types:
    	doctrine_orm: # Available form types for Doctrine ORM
        doctrine_odm: # Available form types for Doctrine ODM
        propel: { # Available form types for Propel }
    filter_types:
        doctrine_orm: # Available form types for Doctrine ORM
        doctrine_odm: # Available form types for Doctrine ODM
        propel: # Available form types for Propel
    stylesheets: {  }
    javascripts: {  }

Generate in project dir

generate_base_in_project_dir: default: false __type: boolean generate_base_in_project_dir_directory: __default: admin __type: string

Normally, the admingenerator generates the base files in the cache directory, which can have a negative impact on the IDE DX and requires adjustments to autoload the generator classes correctly. If set to true, the admin generator will generate the base admin files in %kernel.project_dir%/admin/Admingenerated instead. You will need to run the admin:generate-base-classes each time you update your configuration, with the advantage of the result being versioned and easily loaded into your project/IDE.

If you need to adjust the default folder (admin), just update the generate_base_in_project_dir_directory parameter.

Also make sure to configure the composer autoloading accordingly, for example:

Use Doctrine ORM/ODM/Propel

use_doctrine_orm: default: false type: boolean use_doctrine_odm: default: false type: boolean use_propel: default: false type: boolean

You must enable at least one of the model managers to be able to use the bundle. Enable the correct one with a simple true.

Use JMS Security Extra bundle

use_jms_security: default: false type: boolean

Set this to true to enable the JMS Security bundle to parse the credentials defined in your model configuration.

Guess required

guess_required: default: true type: boolean

By default, this bundle guesses if a field is required with your model data. This behavior can be disabled by putting false here.

Default required

default_required: default: true type: boolean

By default, all fields are required. This configuration only has effect is the guess is disabled.

Overwrite if exists

overwrite_if_exists: default: false type: boolean

If set to true all files are always regenerated instead of using the already written version if there are no changes.

Throw exceptions

throw_exceptions: default: false type: boolean

By default, the admingenerator tries to catch all exceptions during form handling. This results in a general message for the user. If you have a custom error handling system (which for example mails the error or shows a neat 500 error page), you can set this option to true. The errors will no longer be catched and will be handled by your custom handler.

Note: This works for the new, edit, batch and object actions.

Note: Exceptions will always be thrown if the parameter %kernel.debug% is true.

Base admin template

base_admin_template: default: @AdmingeneratorGenerator/base.html.twig type: string

KnpMenuBundle alias

knp_menu_alias default: ~ type: string

This parameter is used to enable the automatic usage of the KnpMenuBundle in the admin generator templates. You can set it to admingen_sidebar to enable the shipped KnpMenuBundle sidebar menu. For more information about the menu and how to customize it, check the cookbook.

Routes

dashboard_route: default: null type: string login_route: default: null type: string logout_route: default: null type: string exit_route: default: null type: string

Default actions

default_action_after_save: default: edit type: string

Adjust the default action after the save action has been processed successfully. Can be one of new, edit, list, show or a custom name which needs to be created in your controller (which is propably not desirable on a global level).

Use Doctrine ORM/ODM/Propel manager for batch remove

use_doctrine_orm_batch_remove: default: false type: boolean use_doctrine_odm_batch_remove: default: false type: boolean use_prope_batch_removel: default: false type: boolean

By default, this bundle will perform a DELETE query for batch remove action. This reduces the number of queries required for this action, but no lifecycle events are called (eg. for soft-delete).

If set to true, the bundle will iterate over objects, removing them one by one via ObjectManager/DocumentManager/QueryClass remove/delete method.

Twig

twig: type: array

General

twig.use_form_resources: default: true type: boolean

By default, this bundle adds its own form theme to your application based on the files AdmingeneratorGeneratorBundle:Form:fields.html.twig and AdmingeneratorGeneratorBundle:Form:widgets.html.twig. Depending on the value of admingenerator_generator.twig.use_form_resources parameter and twig.form.resources one, you can modify this behavior:

  • If admingenerator_generator.twig.use_form_resources is false, nothing will be changed to the twig.form.resources value
  • If admingenerator_generator.twig.use_form_resources is true and twig.form.resources doesn't contain AdmingeneratorGeneratorBundle:Form:fields.html.twig, resources AdmingeneratorGeneratorBundle:Form:fields.html.twig and AdmingeneratorGeneratorBundle:Form:widgets.html.twig will be merged into twig.form.resources right after form_div_layout.html.twig. If form_div_layout.html.twig is not in twig.form.resources values will be unshifted;
  • If AdmingeneratorGeneratorBundle:Form:fields.html.twig is already in twig.form.resources nothing will be changed;

This permits you to control how this bundle modifies form theming in your application. If you want to use another bundle for form theming (like MopaBoostrapBundle) you should probably define this parameter as false.

Note: take care that if you are in this case, don't forget to add AdmingeneratorGeneratorBundle:Form:widgets.html.twig if you don't provide your own implementation.

Date/time formatting

twig.use_localized_date: default: false type: boolean

Set this to true to enable the LocalizedDate filter from twig, instead of using the static format.

Note: these apply only to list and show builders. These settings have no effect on edit and new forms.

WARNING! Internally localized date is handled by IntlDateFormatter class, which uses ISO 8601 formats instead of PHP date()'s formats. Make sure to set the correct date_format and datetime_format if you enable localized date!

If use_localized_date is enabled, the date(time) field will be rendered as:

{{ my_date|format_date(localized_date_format, pattern=date_format) }}
{{ my_date|format_datetime(localized_datetime_format, localized_datetime_format, pattern=datetime_format) }}

Otherwise the date(time) field will be rendered as:

{{ my_date|date(date_format) }}
{{ my_date|date(datetime_format) }}

Where date_format/datetime_format is equal to format option for that field (if defined) or will fallback to admingenerator_generator.twig.date_format/admingenerator_generator.twig.datetime_format setting.


twig.date_format: default: Y-m-d type: string twig.datetime_format: default: Y-m-d H:i:s type: string

If use_localized_date is false, use formats for PHP's date() function, otherwise use ISO 8601 formats.


twig.localized_date_format: default: medium type: string twig.localized_datetime_format: default: medium type: string

Internally, we're using Twig Intl Extension. Possible options are:

<?php
array(
  'none'    => IntlDateFormatter::NONE,
  'short'   => IntlDateFormatter::SHORT,
  'medium'  => IntlDateFormatter::MEDIUM,
  'long'    => IntlDateFormatter::LONG,
  'full'    => IntlDateFormatter::FULL,
)
Number formatting

twig.number_format.decimal: default: 0 type: string twig.number_format.decimal_point: default: . type: string twig.number_format.thousand_separator: default: , type: string

Configure the default representation of numbers with these configuration parameters.

Template dirs

template_dirs default: {}, type: array

Sometimes, you may want to extend/overwrite some of the generator templates in the Resources/templates dir. This is quite easy, but you will have to do the following steps:

  1. First, you will need to add the template you will be using to the admingenerator config
templates_dirs: [ "%kernel.project_dir%/../app/Resources/AdmingeneratorGeneratorBundle/templates" ]
  1. Keep in mind that you will at least need one dir in the previous specified template directory, namely of the model manager used. This will be one of Doctrine, DoctrineODM or Propel.

WARNING! Without this directory, the specified template directory will not be used for extending/overwriting any of the templates, even in the CommonAdmin dir.

  1. Be free to extend/overwrite any template in the Resources/templates dir!

Please note that your own templates might need adjustment when new releases of the bundle arrive. So if anything breaks after an update and you're using custom templates, please check those first!

Generator cache

generator_cache: default: null type: string (service name extending Symfony\Contracts\Cache\CacheInterface)

By default, for each request matching an Admingenerated controller, the ControllerListener will iterate over the filesystem to find which right generator.yml and the right Generator have to be used to build generated files. This process could take some time. Thanks to this configuration, you can define a cache provider to bypass this process once all files are generated. The service name defined here need to extend the class Symfony\Contracts\Cache\CacheInterface.

Example:

services:
    admingenerator.provider:
        class: %doctrine.orm.cache.apc.class% # This class comes from Doctrine, you can create your own
        public: false
        calls:
            - [ setNamespace, [ 'my_namespace' ] ]

admingenerator_generator:
    generator_cache: admingenerator.provider

Form/Filter types

To be able to guess the correct form type for the attribute of your model as abstracted by your model manager, the bundle contains sensible defaults for most fields. They can be found on the following pages:

Note that the values are different for the new/edit forms and the filter forms.

To add or overwrite a value of the default guess, simply add the following to your config.yml:

form_types:
    doctrine_orm:
        phone_number: text

This add the field type phone_number, which will be rendered with a normal text form type (a textbox). The configuration you add will be merged with the default configuration, such that you only need to add what you want to add or change.

Stylesheets/javascripts

You can use the stylesheets and javascripts config values to add specific js/css files to your admin generator pages. Simply add them as shown in the example below:

stylesheets:
    - { path: path_to_stylesheet, media: all }
javascripts:
    - { path: path_to_javascript, route: route_name, routeparams: [value1, value2] }