diff --git a/spec/SM/StateMachine/StateMachineSpec.php b/spec/SM/StateMachine/StateMachineSpec.php index 5324cd0..1b34d61 100644 --- a/spec/SM/StateMachine/StateMachineSpec.php +++ b/spec/SM/StateMachine/StateMachineSpec.php @@ -194,6 +194,16 @@ function it_returns_current_object($object) $this->getObject()->shouldReturn($object); } + function it_returns_current_config() + { + $this->getConfig()->shouldReturn($this->config); + } + + function it_returns_current_config_item() + { + $this->getConfig('graph')->shouldReturn($this->config['graph']); + } + function it_returns_possible_transitions($object, $callbackFactory, CallbackInterface $guard) { $object->getState()->shouldBeCalled()->willReturn('checkout'); diff --git a/src/SM/StateMachine/StateMachine.php b/src/SM/StateMachine/StateMachine.php index 6b785c2..4c6c83e 100644 --- a/src/SM/StateMachine/StateMachine.php +++ b/src/SM/StateMachine/StateMachine.php @@ -168,6 +168,17 @@ public function getObject() return $this->object; } + /** + * {@inheritDoc} + */ + public function getConfig($key = null) + { + if ($key == null) { + return $this->config; + } + return $this->config[$key]; + } + /** * {@inheritDoc} */ diff --git a/src/SM/StateMachine/StateMachineInterface.php b/src/SM/StateMachine/StateMachineInterface.php index b09da5f..1c08a1f 100644 --- a/src/SM/StateMachine/StateMachineInterface.php +++ b/src/SM/StateMachine/StateMachineInterface.php @@ -52,6 +52,13 @@ public function getState(); */ public function getObject(); + /** + * Returns the whole config + * + * @return object + */ + public function getConfig($key = null); + /** * Returns the current graph *