Error while trying to register a custom configuration on OroPlatform

208 Views Asked by At

I have an issue when I try to add a custom global configuration on Oro Platform v.4.1.10.

My configuration is well registered in the admin panel when I put it on "ui_only" but it doesn't save the value on the database when I try to define it. And I didn't achieve to set a default value on it.

When I remove the "ui_only" I get this error :

Error while removing ui_only

I defined my custom settings using the following src/Baltimore/Bundle/AppBundle/Resources/config/oro/system_configuration.yml

system_configuration:
  groups:
    baltimore_settings:
      title: app.configuration.baltimore.label
      icon: 'fa-building'
    guarantee_pack_settings:
      title: app.configuration.guarantee_pack.label

  fields:
    app_guarantee_pack.honorary_vat_rate:
      data_type: string
      type: Symfony\Component\Form\Extension\Core\Type\TextType
      # ui_only: true
      options:
        label: app.configuration.guarantee_pack.honorary_vat_rate.label

  tree:
    system_configuration:
      platform:
        children:
          general_setup:
            children:
              baltimore_settings:
                priority: 10000
                children:
                  guarantee_pack_settings:
                    children:
                      - app_guarantee_pack.honorary_vat_rate

And I've created a src/Baltimore/Bundle/AppBundle/DependencyInjection/Configuration.php file but it seems that it is not taken into account

<?php

namespace Baltimore\Bundle\AppBundle\DependencyInjection;

use Oro\Bundle\ConfigBundle\DependencyInjection\SettingsBuilder;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
 * Class Configuration
 * @package Baltimore\Bundle\AppBundle\DependencyInjection
 */
class Configuration implements ConfigurationInterface
{
    /**
     * @return TreeBuilder
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root('app_guarantee_pack');

        // $root->children()->scalarNode('honorary_vat_rate')->defaultValue(1.2)->end();

        SettingsBuilder::append($rootNode, [
            'honorary_vat_rate' => [
                'value' => 'test',
            ]
        ]);

        return $treeBuilder;
    }
}

My bundle is defined the following way so I don't understand why my Configuration file in the DependencyInjection folder is not applied.

# src/Baltimore/Bundle/AppBundle/Resources/config/oro/bundles.yml
bundles:
  - Baltimore\Bundle\AppBundle\BaltimoreAppBundle

I followed the following documentation in order to attempt to implement my custom settings :


Thank you for your help.

1

There are 1 best solutions below

1
On BEST ANSWER

And I've created a src/Baltimore/Bundle/AppBundle/DependencyInjection/Configuration.php file but it seems that it is not taken into account

It's not if you haven't loaded it explicitly with the dependency injection extension:

// src/Acme/SocialBundle/DependencyInjection/AcmeSocialExtension.php
public function load(array $configs, ContainerBuilder $container)
{
    $configuration = new Configuration();

    $config = $this->processConfiguration($configuration, $configs);

    // you now have these 2 config keys
    // $config['twitter']['client_id'] and $config['twitter']['client_secret']
}

https://symfony.com/doc/4.4/bundles/configuration.html#processing-the-configs-array

Looks like Oro documentation must be extended on this topic.