Download the PHP package digipolisgent/setting-bundle without Composer
On this page you can find all versions of the php package digipolisgent/setting-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package setting-bundle
Digipolis Symfony Setting Bundle
Introduction
This library allows you to add extra values for instances of predefined entity types. These extra values and their characteristics are dynamicly defined in other bundles with the usage of data providers. Based on these providers your form will automatically build and do the necessary validations. After saving, these values (strings, integers, array collections, ...) are easily accessible with the services we provide in this bundle so they can be used throughout the project.
Compatibility
This bundle is compatible with all Symfony ^5.0 releases.
Installation
You can use composer to install the bundle in an existing symfony project.
For more information on how to install symfony bundles, please see the Symfony documentation about bundles
There are no routes to register or other mandatory configuration options.
Before reading this documentation
If you are not familiar with symfony we suggest reading the Symfony 5 documentation.
Entity types
Entity types are the the entities we want to assign extra values to. We define these by using the SettingImplementationTrait. This requires the method to be implemented too. We use this name to access the entity types.
The trait will
- Make sure the database is updated using the
- A entity is added to the database
- Extra data can be added to the entity using the
- The adds and processes the extra configuration if the set data is an entity using this trait
Field types
These are the services that will define how an extra configured field behaves in a form and how the data is presented when we want to use it throughout the application.
A service needs to extend from the . As an example we use one of the predefined field types.
The important thing here is the name we give to the service. We will use this name later to add extra config to the entities that are an instance of the entity types we used before.
Once the field type is in its place we define the service and tag it as a
Data types
Data types are the representation of the extra settings you want to add for every entity type. You can define these by adding a . These datatype providers must be registered as a tagged service using the tag and implement the .
All keys are checked
- key : this is the key you can access the extra setting with if you need it at a later time
- label : this is the label that will be used in forms
- field_type: this is the name of the field type that was defined previously
- entity_types: this is a list of all entity type names that you want this to be available to
Loading data types and entity types
For the changes to take effect the database needs to be updated. The following command will fill the database.
Form building
You can add these extra settings to your form by adding an event subscriber to your form builder. This subscriber will make sure the form is built and processed as defined in the field types. If the data set to the form is not an entity type nothing will happen. This way you can also use the subscriber in generic forms.
Data value service
To access these values in other scripts we can use the .
For example. If you want the the value with key from an instance of the class that you previously saved using the form you do the following.
If after some data manipulation you want to update this value and make it visibile in the form you can also store the value.
Advanced field type usage
You can also use the field type to store and manipulate entities since you can inject other services here. This is an example where we make a checkbox list of entities.
Using as a field type in your data type provider will :
- Give a list of checkboxes with all bar entities when you generate a form
- The function in the will give you a list of entities
- The function in the gives you the possibility to save a list of entities
Advantages
- You can have extra properties for the entities that appear and disappear if you activate or deactivate bundles.
- The field types give the possibility to reuse code multiple times.
- You can change the structure in a matter of seconds by changing the dataprovider array
All versions of setting-bundle with dependencies
symfony/config Version ^5.0
symfony/dependency-injection Version ^5.0
symfony/doctrine-bridge Version ^5.3
symfony/http-kernel Version ^5.0
symfony/event-dispatcher Version ^5.0
symfony/form Version ^5.0
symfony/uid Version ^5.3
symfony/validator Version ^5.0
symfony/yaml Version ^5.0
doctrine/orm Version ^2.5
doctrine/doctrine-fixtures-bundle Version ^3.0