Magnolia 5.7 reached extended end of life on May 31, 2022. Support for this branch is limited, see End-of-life policy. Please note that to cover the extra maintenance effort, this EEoL period is a paid extension in the life of the branch. Customers who opt for the extended maintenance will need a new license key to run future versions of Magnolia 5.7. If you have any questions or to subscribe to the extended maintenance, please get in touch with your local contact at Magnolia.
Voters are used in Magnolia whenever configuration values are not assigned at startup but instead depend on rules. For example the Cache module has to determine if a requested resource may be cached or not. The rules to determine values should be configurable. The rules are user-defined using voters which evaluate established criteria by determining true or false of each rule. Voters are currently used for:
- Filter configuration: uses voters to determine whether a filter should be executed or bypassed.
- Cache configuration: uses voters to determine whether a file should be cached or not.
The basic concept of voters uses Voter classes which calculate an
int vote value, where positive (1, 2, 3, ...) results are treated as "yes" or "true" and (0, -1, -2, ...) results are treated as "no" or "false". If you have a set of voters, then the result of a voting is the largest absolute result. If there are two voters with the same absolute result, then the one with the higher positive value will be taken.
|Vote results||VoterSet result|
|-3, 0, 2||-3|
|-3, 0, 3||3|
|-3, 0, 4||4|
For most of the "real world" voters only boolean results make sense. These boolean voters return "1" for a "true" and "0" for a "false" result.
|none||Yes||Checks if the current user is authenticated.|
For further information see the voters package.