Original file: src/Fsm/Constants.php
The Constants.php file defines a collection of constants used throughout the Finite State Machine (FSM) component of the application. With the use of typed class constants introduced in PHP 8.3, these constants enhance type safety, promote static analysis, and improve IDE support with type inference. This file serves as a centralized location for defining key values and messages that the FSM relies upon, ensuring consistency and reducing the likelihood of hard-coded values scattered throughout the codebase.
public const array SKIP_DISCOVERY_COMMANDS = [
'package:discover',
'config:cache',
'config:clear',
'cache:clear',
'optimize',
'optimize:clear',
'dump-autoload',
];
These constants define a list of commands that should be skipped during FSM discovery. This is important to avoid unnecessary database access during package discovery and bootstrap operations. When executing these commands, the FSM will not engage in discovery processes, allowing for more efficient execution.
public const string EVENT_WILDCARD = '*';
public const string STATE_WILDCARD = '__STATE_WILDCARD__';
public const string TRANSITION_SUCCESS = 'success';
public const string TRANSITION_BLOCKED = 'blocked';
public const string TRANSITION_FAILED = 'failed';
These constants indicate the result of a state transition:
public const string VERBS_AGGREGATE_TYPE = 'fsm_aggregate';
public const string VERBS_EVENT_TYPE = 'fsm_transitioned';
public const int VERBS_DEFAULT_REPLAY_CHUNK_SIZE = 100;
These constants facilitate event sourcing related to the FSM:
public const string OPERATION_TRANSITION = 'transition';
public const string OPERATION_GUARD_CHECK = 'guard_check';
public const string OPERATION_ACTION_EXECUTE = 'action_execute';
public const string OPERATION_CALLBACK_EXECUTE = 'callback_execute';
These constants classify FSM operations:
public const int PRIORITY_HIGH = 100;
public const int PRIORITY_NORMAL = 50;
public const int PRIORITY_LOW = 10;
Priority constants indicate the processing priority of transitions:
public const string CONFIG_LOGGING_ENABLED = 'fsm.logging.enabled';
public const string CONFIG_VERBS_DISPATCH = 'fsm.verbs.dispatch_transitioned_verb';
public const string CONFIG_USE_TRANSACTIONS = 'fsm.use_transactions';
public const string CONFIG_DISCOVERY_PATHS = 'fsm.discovery_paths';
These constants define keys used in the FSM configuration:
public const string META_DISPLAY_NAME = 'display_name';
public const string META_DESCRIPTION = 'description';
public const string META_ICON = 'icon';
public const string META_COLOR = 'color';
public const array META_ALLOWED_KEYS = [
self::META_DISPLAY_NAME,
self::META_DESCRIPTION,
self::META_ICON,
self::META_COLOR,
];
These constants are used for state metadata:
public const string ERROR_INVALID_STATE = 'invalid_state';
public const string ERROR_INVALID_TRANSITION = 'invalid_transition';
public const string ERROR_GUARD_FAILED = 'guard_failed';
public const string ERROR_ACTION_FAILED = 'action_failed';
public const string ERROR_CALLBACK_FAILED = 'callback_failed';
These constants define error types for validation within the FSM:
This documentation provides a comprehensive overview of the Constants class found in Constants.php, outlining the purpose and significance of each constant to aid developers in understanding and utilizing the FSM component effectively.
How can I help you explore Laravel packages today?