Welcome Guest, Not a member yet? Register   Sign In
.env Property Arrays
#1

(This post was last modified: 10-23-2023, 03:06 AM by donpwinston.)

It would be nice to be able to specify non associative arrays like this:
PHP Code:
contentsecuritypolicy.scriptSrc 'self'

contentsecuritypolicy.scriptSrc 'https://bankruptcynotices.uscourts.gov'

contentsecuritypolicy.scriptSrc 'https://bankruptcynoticestest.uscourts.gov'

contentsecuritypolicy.scriptSrc 'https://stage-bnc4-web7.bsg.na.baesystems.com' 
Which would correspond to:
PHP Code:
public $scriptSrc = [
        'self',
        'https://bankruptcynotices.uscourts.gov',
        'https://bankruptcynoticestest.uscourts.gov',
        'https://stage-bnc4-web7.bsg.na.baesystems.com',
    ]; 

Maybe CI does this already? I haven't actually tried it. If it does then the CI manual should mention it. Maybe contentsecuritypolicy.0 = 'self' and xxxx.1 = 'abcd',  xxxx.2 = 'xyzt' would be necessary.
Simpler is always better
Reply
#2

Yes, if you have the array key in the Config file, you can override it by .env.
See https://codeigniter4.github.io/CodeIgnit...s-for-data

The following way is impossible.
Because we cannot set environment variable like that.

Code:
contentsecuritypolicy.scriptSrc = 'self'
contentsecuritypolicy.scriptSrc = 'https://bankruptcynotices.uscourts.gov'
contentsecuritypolicy.scriptSrc = 'https://bankruptcynoticestest.uscourts.gov'
contentsecuritypolicy.scriptSrc = 'https://stage-bnc4-web7.bsg.na.baesystems.com'

It is equal to
Code:
contentsecuritypolicy.scriptSrc = 'https://stage-bnc4-web7.bsg.na.baesystems.com'
Reply
#3

(This post was last modified: 10-25-2023, 03:02 AM by donpwinston. Edit Reason: typo )

How about:

contentsecuritypolicy.scriptSrc.0 = 'self'
contentsecuritypolicy.scriptSrc.1 = 'https://banruptcynotices.uscourts.gov'

or some sort of macro like syntax?
Simpler is always better
Reply
#4

(10-23-2023, 05:11 PM)kenjis Wrote: Yes, if you have the array key in the Config file, you can override it by .env.
See https://codeigniter4.github.io/CodeIgnit...s-for-data

The following way is impossible.
Because we cannot set environment variable like that.

Code:
contentsecuritypolicy.scriptSrc = 'self'
contentsecuritypolicy.scriptSrc = 'https://bankruptcynotices.uscourts.gov'
contentsecuritypolicy.scriptSrc = 'https://bankruptcynoticestest.uscourts.gov'
contentsecuritypolicy.scriptSrc = 'https://stage-bnc4-web7.bsg.na.baesystems.com'

It is equal to
Code:
contentsecuritypolicy.scriptSrc = 'https://stage-bnc4-web7.bsg.na.baesystems.com'
Code:
contentsecuritypolicy.scriptSrc.0 = 'self'
contentsecuritypolicy.scriptSrc.1 = 'xhfjjfjf'

should be doable.
Simpler is always better
Reply
#5

Yes, you can replace the existing elements in the Config class.
But you cannot add an element in the array.

So the following does not work.
Code:
contentsecuritypolicy.scriptSrc.5 = new_value
Reply




Theme © iAndrew 2016 - Forum software by © MyBB