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']));
}
}