The single pipeline is an or|
is a bitwise OR operator. It compares each bit (a binary digit of 0 or 1) in the integers and returns a new integer with a 1 wherever either numbers had a 1, soand a 0 anywhere else (similar to how the ||
operator campares booleans). So the expression self::ALLOW_ANONYMOUS_LIVE | self::ALLOW_ANONYMOUS_OFFLINE
is the same as 1 | 2
and will evaluate to 3
. Here isare some examples of how the or|
bitwise operator works.:
Source: https://github.com/craftcms/cms/blob/3.2.2/src/web/Controller.php#L75-L96
If the key is a not an integer then the key-value pair is left as is.
Source: https://github.com/craftcms/cms/blob/3.2.2/src/web/Controller.php#L75-L96
Source: https://github.com/craftcms/cms/blob/3.2.2/src/web/Controller.php#L147-L176
The single ampersand is an and&
is a bitwise AND operator. It compares each bit in the integers and returns a new integer with a 1 wherever both numbers have a 1, soand a 0 anywhere else (similar to how the expression $test & $allowAnonymous&&
will evaluate to true only if one or more of their bits intersectoperator campares booleans). Here isare some examples of how the and&
bitwise operator works.:
By enforcing the condition $test & $allowAnonymous
, we can check that $test
(whether the site is live or offline) and $allowAnonymous
(the permissions granted to the specific controller action) overlap.
More on bitwise operators here.
Source: https://github.com/craftcms/cms/blob/3.2.2/src/web/Controller.php#L147-L176
I'm not sure what the specific issue is with your plugin is , but as far as I can tell none of the behaviour fromonly thing that changed in Craft 3.1.x has changed2 was that the ALLOW_ANONYMOUS_OFFLINE
constant was added, rather thanallowing for (but not requiring) more specific values have been addedpermissions on controller actions.