Welcome Guest, Not a member yet? Register   Sign In
Registrar: Merge Config arrays
#1

(This post was last modified: 09-30-2024, 11:12 AM by ozornick.)

The current behavior looks incorrect.
If I want to add Filters, supportedLocales, for example, then my settings will overwrite the default data. But it would be logical to combine them.

PHP Code:
// before, globals filters
array(2) {
  ["before"]=>
  array(3) {
    [0]=>
    string(8"honeypot"
    [1]=>
    string(4"csrf"
    [2]=>
    string(12"invalidchars"
  }
  ["after"]=>
  array(1) {
    [0]=>
    string(13"secureheaders"
  }
}

// after Registrar
array(2) {
  ["before"]=>
  array(1) {
    [0]=>
    string(23"some_filter"
  }
  ["after"]=>
  array(0) {
  }

// Expected
array(2) {
  ["before"]=>
  array(4) {
    [0]=>
    string(8"honeypot"
    [1]=>
    string(4"csrf"
    [2]=>
    string(12"invalidchars"
    [3]=>
    string(23"some_filter"
  }
  ["after"]=>
  array(1) {
    [0]=>
    string(13"secureheaders"
  }

Am I wrong? Of course, you can manually combine the previous values with the new ones, but it doesn't look. good. It will probably cause recursion.
Should I change it to array_merge_recursive()

Otherwise, you will have to duplicate all the values manually. This is bad for a modular system where each component changes arrays.
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB