SM\StateMachine\StateMachine::__construct PHP Method

__construct() public method

public __construct ( object $object, array $config, Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher = null, SM\Callback\CallbackFactoryInterface $callbackFactory = null )
$object object Underlying object for the state machine
$config array Config array of the graph
$dispatcher Symfony\Component\EventDispatcher\EventDispatcherInterface EventDispatcher or null not to dispatch events
$callbackFactory SM\Callback\CallbackFactoryInterface CallbackFactory or null to use the default one
    public function __construct($object, array $config, EventDispatcherInterface $dispatcher = null, CallbackFactoryInterface $callbackFactory = null)
    {
        $this->object = $object;
        $this->dispatcher = $dispatcher;
        $this->callbackFactory = $callbackFactory ?: new CallbackFactory('SM\\Callback\\Callback');
        if (!isset($config['property_path'])) {
            $config['property_path'] = 'state';
        }
        $this->config = $config;
        // Test if the given object has the given state property path
        try {
            $this->getState();
        } catch (NoSuchPropertyException $e) {
            throw new SMException(sprintf('Cannot access to configured property path "%s" on object %s with graph "%s"', $config['property_path'], get_class($object), $config['graph']));
        }
    }