izzum\statemachine\AbstractFactory::getStateMachine PHP Method

getStateMachine() public method

TRICKY: When using this method it could lead to unoptimized creation of different builders/loaders/persistence objects. For example: a Loader can be reused, a databaseloader will only have to access a database once for a specific machine to get all the transitions. When using this method when inside a loop of some sorts where multiple statemachines for different entities are needed, it would be wise to cache/reuse the different loaders, builders and persistence adapters. php's spl_object_hash() method would be a good way to cache a fully loaded statemachine. Furthermore, once a Loader, ReferenceBuilder and Adapter for persistence have been instantiated, they can be cached in a field of this class since they can safely be reused and shared. Or just change the context on a machine to have access to all the same transitions, builders etc. of the machine.
public getStateMachine ( string $id ) : StateMachine
$id string the entity id for the Identifier
return StateMachine a statemachine ready to go
    public function getStateMachine($id)
    {
        $context = $this->createContext(new Identifier($id, $this->getMachineName()));
        $machine = $this->createMachine($context);
        $loader = $this->createLoader();
        $loader->load($machine);
        return $machine;
    }