Merge pull request #10079 from patricknelson/patch-10

DOC Document the capability of 'envorconstant' to be checked against specific values
This commit is contained in:
Michal Kleiner 2022-01-27 10:34:18 +13:00 committed by GitHub
commit c74f368bf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 7 deletions

View File

@ -334,15 +334,15 @@ rules contained match.
You then list any of the following rules as sub-keys, with informational values as either a single value or a list.
- 'classexists', in which case the value(s) should be classes that must exist
- 'moduleexists', in which case the value(s) should be modules that must exist. This supports either folder
- `classexists`, in which case the value(s) should be classes that must exist
- `moduleexists`, in which case the value(s) should be modules that must exist. This supports either folder
name or composer `vendor/name` format.
- 'environment', in which case the value(s) should be one of "live", "test" or "dev" to indicate the Silverstripe CMS
- `environment`, in which case the value(s) should be one of "live", "test" or "dev" to indicate the Silverstripe CMS
mode the site must be in
- 'envvarset', in which case the value(s) should be environment variables that must be set
- 'constantdefined', in which case the value(s) should be constants that must be defined
- 'envorconstant' A variable which should be defined either via environment vars or constants
- 'extensionloaded', in which case the PHP extension(s) must be loaded
- `envvarset`, in which case the value(s) should be environment variables that must be set
- `constantdefined`, in which case the value(s) should be constants that must be defined
- `envorconstant`, a variable which should be defined either via environment vars or constants (and optionally be set to a specific value)
- `extensionloaded`, in which case the PHP extension(s) must be loaded
For instance, to add a property to "foo" when a module exists, and "bar" otherwise, you could do this:
@ -374,6 +374,18 @@ Only:
---
```
The `envorconstant` rule allows you to get even more specific by also directly comparing values of environment variables
and constants. In this example, both `TEST_ENV` and `TEST_CONST` have to be defined _and_ set to certain values:
```yaml
---
Only:
envorconstant:
TEST_ENV: 'example'
TEST_CONST: true
---
```
[alert]
When you have more than one rule for a nested fragment, they're joined like
`FRAGMENT_INCLUDED = (ONLY && ONLY) && !(EXCEPT && EXCEPT)`.