POSPreset.php
60 lines
| 1 | <?php |
| 2 | declare( strict_types = 1 ); |
| 3 | |
| 4 | namespace Automattic\WooCommerce\Internal\POS; |
| 5 | |
| 6 | defined( 'ABSPATH' ) || exit; |
| 7 | |
| 8 | /** |
| 9 | * Enum-style class for the assignable POS staff presets. |
| 10 | * |
| 11 | * Presets are UI-curated bundles of `woocommerce_pos_*` capabilities (Cashier / Manager / |
| 12 | * Admin); see Capabilities::capabilities_for_preset(). Kept under the POS |
| 13 | * namespace rather than the shared `Enums` namespace because presets are a |
| 14 | * UI-level grouping that may change as the granular-caps model matures, not a |
| 15 | * stable store-wide vocabulary. |
| 16 | * |
| 17 | * Constant class rather than a native PHP enum so it stays within WooCommerce's |
| 18 | * PHP 7.4 minimum. |
| 19 | * |
| 20 | * @since 11.0.0 |
| 21 | * @internal |
| 22 | */ |
| 23 | final class POSPreset { |
| 24 | /** |
| 25 | * Cashier preset. |
| 26 | * |
| 27 | * @var string |
| 28 | */ |
| 29 | public const CASHIER = 'pos_cashier'; |
| 30 | |
| 31 | /** |
| 32 | * Manager preset. |
| 33 | * |
| 34 | * @var string |
| 35 | */ |
| 36 | public const MANAGER = 'pos_manager'; |
| 37 | |
| 38 | /** |
| 39 | * Admin preset. |
| 40 | * |
| 41 | * @var string |
| 42 | */ |
| 43 | public const ADMIN = 'pos_admin'; |
| 44 | |
| 45 | /** |
| 46 | * All assignable presets, in ascending capability order. |
| 47 | * |
| 48 | * @return string[] |
| 49 | * |
| 50 | * @since 11.0.0 |
| 51 | */ |
| 52 | public static function get_all(): array { |
| 53 | return array( |
| 54 | self::CASHIER, |
| 55 | self::MANAGER, |
| 56 | self::ADMIN, |
| 57 | ); |
| 58 | } |
| 59 | } |
| 60 |