{"action":"created","issue":{"url":"https://api.github.com/repos/yohang/Finite/issues/122","repository_url":"https://api.github.com/repos/yohang/Finite","labels_url":"https://api.github.com/repos/yohang/Finite/issues/122/labels{/name}","comments_url":"https://api.github.com/repos/yohang/Finite/issues/122/comments","events_url":"https://api.github.com/repos/yohang/Finite/issues/122/events","html_url":"https://github.com/yohang/Finite/issues/122","id":161695897,"number":122,"title":"Multiple-graph example doesn't work","user":{"login":"willemo","id":177329,"avatar_url":"https://avatars.githubusercontent.com/u/177329?v=3","gravatar_id":"","url":"https://api.github.com/users/willemo","html_url":"https://github.com/willemo","followers_url":"https://api.github.com/users/willemo/followers","following_url":"https://api.github.com/users/willemo/following{/other_user}","gists_url":"https://api.github.com/users/willemo/gists{/gist_id}","starred_url":"https://api.github.com/users/willemo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willemo/subscriptions","organizations_url":"https://api.github.com/users/willemo/orgs","repos_url":"https://api.github.com/users/willemo/repos","events_url":"https://api.github.com/users/willemo/events{/privacy}","received_events_url":"https://api.github.com/users/willemo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-22T14:19:20Z","updated_at":"2016-06-23T08:45:17Z","closed_at":null,"body":"**Update:**\r\n\r\nIt wasn't my callback that broke the example, the example doesn't work out of the box. So now my question is: how do I get multiple graphs to work?\r\n\r\n**Old question:**\r\n\r\nWhen I add a simple callback to the [multiple-graph example](https://github.com/yohang/Finite/blob/master/examples/multiple-graphs.php), an exception gets thrown because the object doesn't comply with the StatefulInterface.\r\n\r\nTo test I changed the payment loader and added this callback:\r\n\r\n```php\r\n'callbacks' => [\r\n    'before' => [\r\n        [\r\n            'do' => function(Finite\\StatefulInterface $document, Finite\\Event\\TransitionEvent $e) {\r\n                echo sprintf(\r\n                    \"Applying transition \\\"%s\\\"\\n\",\r\n                    $e->getTransition()->getName()\r\n                );\r\n            }\r\n        ],\r\n    ],\r\n],\r\n```\r\n\r\nThe resulting exception is:\r\n\r\n```\r\nPHP Fatal error:  Uncaught exception\r\n'Symfony\\Component\\PropertyAccess\\Exception\\NoSuchPropertyException'\r\nwith message 'Neither the property \"finiteState\" nor one of the methods\r\n\"getFiniteState()\", \"finiteState()\", \"isFiniteState()\", \"hasFiniteState()\", \"__get()\"\r\nexist and have public access in class \"Order\".'\r\nin vendor/symfony/property-access/PropertyAccessor.php:487\r\n```\r\n\r\nI tried removing the type constraints of the callback, but that didn't help. Any idea how I can get callbacks to work when my object has a different property path?"},"comment":{"url":"https://api.github.com/repos/yohang/Finite/issues/comments/227987039","html_url":"https://github.com/yohang/Finite/issues/122#issuecomment-227987039","issue_url":"https://api.github.com/repos/yohang/Finite/issues/122","id":227987039,"user":{"login":"willemo","id":177329,"avatar_url":"https://avatars.githubusercontent.com/u/177329?v=3","gravatar_id":"","url":"https://api.github.com/users/willemo","html_url":"https://github.com/willemo","followers_url":"https://api.github.com/users/willemo/followers","following_url":"https://api.github.com/users/willemo/following{/other_user}","gists_url":"https://api.github.com/users/willemo/gists{/gist_id}","starred_url":"https://api.github.com/users/willemo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/willemo/subscriptions","organizations_url":"https://api.github.com/users/willemo/orgs","repos_url":"https://api.github.com/users/willemo/repos","events_url":"https://api.github.com/users/willemo/events{/privacy}","received_events_url":"https://api.github.com/users/willemo/received_events","type":"User","site_admin":false},"created_at":"2016-06-23T08:45:17Z","updated_at":"2016-06-23T08:45:17Z","body":"I created a possible bugfix (#123), but it could cause problems with custom StateAccessors. I suggest adding a `getStateAccessor` method to StateMachineInterface, adding `getPropertyPath` and `setPropertyPath` methods to the StateAccessorInterface and changing the code in ArrayLoader to something like this:\r\n\r\n```php\r\nif (!$stateMachine->hasStateAccessor()) {\r\n    $stateMachine->setStateAccessor(new PropertyPathStateAccessor($this->config['property_path']));\r\n} elseif ($stateMachine->getStateAccessor()->getPropertyPath() != 'finiteState') {\r\n    $stateMachine->getStateAccessor()->setPropertyPath($this->config['property_path']);\r\n}\r\n```"}}
{"actor":{"display_login":"willemo"}}