Original file: src/Fsm/FsmExtensionRegistry.php
The FsmExtensionRegistry class serves as a central hub for managing the extensions and modular definitions related to Finite State Machines (FSM) in a Laravel application. It is responsible for registering various FSM extensions, state definitions, and transition definitions while ensuring that these components can be efficiently accessed based on their respective models and columns. The registry is designed to load configuration data from a repository, allowing dynamic extension and definition management, which enhances the flexibility of FSM implementations.
registerExtensionpublic function registerExtension(FsmExtension $extension): void
FsmExtension $extension: An object of a class implementing the FsmExtension interface.getName(), and adds it to the internal $extensions array, associating it with its name. This enables the registry to manage multiple FSM extensions for future retrieval.registerStateDefinitionpublic function registerStateDefinition(string $modelClass, string $columnName, ModularStateDefinition $definition): void
string $modelClass: The class name of the model to which the state definition belongs.string $columnName: The specific column of the model for which the state is defined.ModularStateDefinition $definition: An instance of a class implementing the ModularStateDefinition interface, representing the state definition.$stateDefinitions array, facilitating efficient retrieval later.registerTransitionDefinitionpublic function registerTransitionDefinition(string $modelClass, string $columnName, ModularTransitionDefinition $definition): void
string $modelClass: The class name of the model to which the transition definition belongs.string $columnName: The specific column of the model related to the transition.ModularTransitionDefinition $definition: An instance of a class implementing the ModularTransitionDefinition interface.registerStateDefinition, this method creates a key for the transition based on the model class and column name. It then calls makeTransitionKey to create a unique transition key based on the transition definition. The transition definition is stored in the internal $transitionDefinitions array.getExtensionsForpublic function getExtensionsFor(string $modelClass, string $columnName): array
string $modelClass: The class name of the target model.string $columnName: The specific column of the model.FsmExtension objects that are applicable.appliesTo method. These extensions are sorted by priority (higher first), and the function returns them as a numerically indexed array for easy access.getStateDefinitionsForpublic function getStateDefinitionsFor(string $modelClass, string $columnName): array
string $modelClass: The class name of the targeted model.string $columnName: The specific column name of the model.ModularStateDefinition instances.getTransitionDefinitionsForpublic function getTransitionDefinitionsFor(string $modelClass, string $columnName): array
string $modelClass: The class name of the targeted model.string $columnName: The specific column name of the model.ModularTransitionDefinition.getStateDefinitionsFor, this method constructs a key for the model and column, retrieves the definitions, and sorts them by priority before returning the data.loadFromConfigprivate function loadFromConfig(): void
makeKeyprivate function makeKey(string $modelClass, string $columnName): string
string $modelClass: The model's class name.string $columnName: The column of the model.modelClass:columnName).makeTransitionKeyprivate function makeTransitionKey(ModularTransitionDefinition $definition): string
ModularTransitionDefinition $definition: The transition definition object.from state, to state, and the associated event.How can I help you explore Laravel packages today?