Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions Listener/AbstractSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function onSetInitialState(StateMachineEvent $event)
public function onTestTransition(TransitionEvent $event)
{
$object = $event->getStateMachine()->getObject();
$result = $this->callCallback($object, 'can', $event->getTransition()->getName());
$result = $this->callCallback($object, 'can', $event);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BC-break here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello K-Phoen! Can you please explain a little bit more? Can tell where's the BC-break here. I'm not using that callback on my current use case, so I might have miss something :/


if ($result === false) {
$event->reject();
Expand All @@ -68,13 +68,13 @@ public function onTestTransition(TransitionEvent $event)
public function onPreTransition(TransitionEvent $event)
{
$object = $event->getStateMachine()->getObject();
$this->callCallback($object, 'pre', $event->getTransition()->getName());
$this->callCallback($object, 'pre', $event);
}

public function onPostTransition(TransitionEvent $event)
{
$object = $event->getStateMachine()->getObject();
$this->callCallback($object, 'post', $event->getTransition()->getName());
$this->callCallback($object, 'post', $event);
}

/**
Expand All @@ -85,8 +85,9 @@ public function onPostTransition(TransitionEvent $event)
* @param string $transitionName
* @return mixed
*/
protected function callCallback($object, $callbackPrefix, $transitionName)
protected function callCallback($object, $callbackPrefix, $event)
{
$transitionName = is_string($event) ? 'initialize' : $event->getTransition()->getName();
$camelCasedName = Inflector::camelize($transitionName);
$methodName = $callbackPrefix . $camelCasedName;

Expand All @@ -98,6 +99,6 @@ protected function callCallback($object, $callbackPrefix, $transitionName)
return;
}

return call_user_func(array($this, $methodName), $object);
return call_user_func(array($this, $methodName), $object, $event->getProperties());
}
}