Allows you to create configurations that can be used in your project (Twig and Controller services) and manage them through an admin panel divided into two parts:
- Configuration forms divided in category and fieldset to edit values of your configs:
- Create Category, Fieldset and Configuration field for you forms
Open a command console, enter your project directory and execute:
$ composer require navalex/config-bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require navalex/config-bundle
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
new Navalex\ConfigBundle\NavalexConfigBundle(),
);
// ...
}
// ...
}
To make the plugin work, you need to update database table by entering the following command:
$ php bin/console doctrine:schema:update --force
Open app/config/routing.yml
and add:
# app/config/routing.yml
navalex.config_bundle:
resource: '@NavalexConfigBundle/Resources/config/routing.yml'
If you want to restrict access to the panel to a specific role you can something like that (restrict access for ROLE_ADMIN only) in app/config/security.yml
:
# app/config/security.yml
security:
# ...
role_hierarchy:
# ...
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
access_control:
# ...
- { path: ^/admin/, role: ROLE_ADMIN }
Once evrything is done, update symfony cache to access to the panel
$ php bin/console cache:clear
or
$ php bin/console cache:clear --env=prod
Go to http://<your_website>/admin/config/admin/config/conf
Here you can create Form Category, then give it fieldsets to organize your form, and finaly create configuration. Here a detail of configuration fields:
- Name: Admin form label for this configuration
- Code: Unique code to call the configuration in Twig and Controller
- Category/Field: Select form and fieldset for this configuration
- Type: What kind of field will be the configuration By default, the bundle give the value "data" to every new configuration.
You'll now see your configurations category form appear on the navbar of the panel. Just go on it and enjoy !
$configs = $this->get('navalex_config.config');
$configs->get('<your_configuration_code>');
{{ getConfig('<your_configuration_code>') }}
- Translation domain for configuration label
- New complexe field types:
- Array (with text inputs added with ajax button)
- Image (with automatique upload and naming)
- Complete Navapanel Dashboard
- Order Form Category in the panel
- Get config from ajax with API url like http://<your_website>/config/<code> and JSON return
- Customize field types in symfony configuration
- ...
This bundle is under the MIT license. See the complete license in the bundle