imanaging-document / check-format-bundle
This bundle allows you to check format, and provide mapping file system
Installs: 8 084
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: ^7.1.3
- symfony/templating: ^5.2
- twig/twig: ^3.3
- viest/php-ext-xlswriter-ide-helper: dev-master
This package is auto-updated.
Last update: 2025-03-08 10:33:15 UTC
README
This bundle is a tool that allows you to check arrays format.
You have to provide a structure, which describe the format you want to check, and the datas you want to check. It can be simple array, or array of array.
A mapping function is available inside this bundle, you have to implement some required interfaces to make it works. You will find more information about how to use it in this readme.
This bundle should be used inside an imanaging-document application.
Install the bundle with:
$ composer require imanaging-document/check-format-bundle
Configuration
You have to create a config/packages/imanaging_check_format.yaml
file:
imanaging_check_format: bar: ~
This configuration is optionnal.
Check Format
Usage
You can access two statics methods named checkFormatFile
and getObjLine
where you need it in your project juste like this :
use Imanaging\CheckFormatBundle\CheckFormatFile; class MyBeautifulService { /** * ... */ public function myBeautifulFunction(...){ ... $result = CheckFormatFile::checkFormatLine($structureDescription, $myLineToCheckFormat)); ... } ... }
Examples
Checking a line structure
$structure = [ // Type, Column Name, Nullable new FieldCheckFormat("string", "Name", false), new FieldCheckFormat("integer", "Age", true), new FieldCheckFormat("integer", "Height", true), new FieldCheckFormat("string", "City", true), ]; $myLine = ['Rémi', '26', '170', 'San Francisco']; $result = CheckFormatFile::checkFormatLine($structure, $myLine)); // In this case, error equals false and the errors list is empty because there is no error // $result['error'] = false; // $result['errors_list'] = [];
Checking a file structure
$structure = [ // Type, Column Name, Nullable new FieldCheckFormat("string", "Name", false), new FieldCheckFormat("integer", "Age", true), new FieldCheckFormat("integer", "Height", true), new FieldCheckFormat("string", "City", true), ]; $lines = [ ['Rémi', '26', '170', 'San Francisco'], ['Antonin', '26', '181', 'Miami'], ]; $result = CheckFormatFile::checkFormatFile($structure, $lines)); // In this case, error equals false and the errors list is empty because there is no error // $result['error'] = false; // $result['errors_list'] = [];
Mapping
Requirements
- Symfony 4
- JQuery
- Bootstrap 4
- FontAwesome
Configuration
Interfaces
You have to implements the following interfaces in your config/packages/doctrine.yaml
file :
Imanaging\CheckFormatBundle\Interfaces\MappingConfigurationInterface: App\Entity\MappingConfiguration Imanaging\CheckFormatBundle\Interfaces\MappingConfigurationTypeInterface: App\Entity\MappingConfigurationType Imanaging\CheckFormatBundle\Interfaces\MappingChampPossibleInterface: App\Entity\MappingChampPossible Imanaging\CheckFormatBundle\Interfaces\MappingConfigurationValueAvanceFileInterface: App\Entity\MappingConfigurationValueAvanceFile Imanaging\CheckFormatBundle\Interfaces\MappingConfigurationValueAvanceInterface: App\Entity\MappingConfigurationValueAvance Imanaging\CheckFormatBundle\Interfaces\MappingConfigurationValueAvanceTextInterface: App\Entity\MappingConfigurationValueAvanceText Imanaging\CheckFormatBundle\Interfaces\MappingConfigurationValueAvanceTypeInterface: App\Entity\MappingConfigurationValueAvanceType Imanaging\CheckFormatBundle\Interfaces\MappingConfigurationValueInterface: App\Entity\MappingConfigurationValue Imanaging\CheckFormatBundle\Interfaces\MappingConfigurationValueTransformationInterface: App\Entity\MappingConfigurationValueTransformation Imanaging\CheckFormatBundle\Interfaces\MappingConfigurationValueTranslationInterface: App\Entity\MappingConfigurationValueTranslation
Usage and examples
You can call a mapping page with an ajax call :
<div id="mappingDiv"> <div class="text-center mt-5"> <h4><i class="fa fa-spinner fa-spin fa-fw"></i>Chargement en cours ...</h4> </div> </div>
let data = {files_directory: '/public/database/attestation/fichier_client*.csv', next_step_route: 'hephaistos_administration_import_fichier_client', mapping_configuration_type: 'integration_client'}; $.ajax({ url: "{{ path('check_format_mapping_page') }}", type: 'POST', data: data, success: function (data) { $("#mappingDiv").html(data); }, error: function () { Toast.fire({type: 'error', title: 'Error'}); } });