{"action":"created","comment":{"url":"https://api.github.com/repos/prooph/event-store/pulls/comments/37706372","id":37706372,"diff_hunk":"@@ -0,0 +1,214 @@\n+<?php\n+/*\n+ * This file is part of the prooph/event-store.\n+ * (c) 2014 - 2015 prooph software GmbH <contact@prooph.de>\n+ *\n+ * For the full copyright and license information, please view the LICENSE\n+ * file that was distributed with this source code.\n+ *\n+ * Date: 31.08.14 - 01:28\n+ */\n+\n+namespace Prooph\\EventStore\\Aggregate;\n+\n+use Assert\\Assertion;\n+use Prooph\\Common\\Messaging\\Message;\n+use Prooph\\EventStore\\Aggregate\\Exception\\AggregateTranslationFailedException;\n+\n+/**\n+ * Class ConfigurableAggregateTranslator\n+ *\n+ * @package Prooph\\EventStore\\Aggregate\n+ * @author Alexander Miertsch <kontakt@codeliner.ws>\n+ */\n+class ConfigurableAggregateTranslator implements AggregateTranslator\n+{\n+    /**\n+     * @var string\n+     */\n+    private $identifierMethodName = 'getId';\n+\n+    /**\n+     * @var string\n+     */\n+    private $popRecordedEventsMethodName = 'popRecordedEvents';\n+\n+    /**\n+     * @var string\n+     */\n+    private $staticReconstituteFromHistoryMethodName = 'reconstituteFromHistory';\n+\n+    /**\n+     * @var null|callable\n+     */\n+    private $eventToMessageCallback = null;\n+\n+    /**\n+     * @var null|callable\n+     */\n+    private $messageToEventCallback = null;\n+\n+    /**\n+     * @param null|string   $identifierMethodName\n+     * @param null|string   $popRecordedEventsMethodName\n+     * @param null|string   $staticReconstituteFromHistoryMethodName\n+     * @param null|callable $eventToMessageCallback\n+     * @param null|callable $messageToEventCallback\n+     */\n+    public function __construct(\n+        $identifierMethodName = null,\n+        $popRecordedEventsMethodName = null,\n+        $staticReconstituteFromHistoryMethodName = null,\n+        $eventToMessageCallback = null,\n+        $messageToEventCallback = null)\n+    {\n+        if (null !== $identifierMethodName) {\n+            Assertion::string($identifierMethodName, 'Identifier method name needs to be a string');\n+            $this->identifierMethodName = $identifierMethodName;\n+        }\n+\n+        if (null !== $popRecordedEventsMethodName) {\n+            Assertion::string($popRecordedEventsMethodName, 'Pop recorded events method name needs to be a string');","path":"src/Aggregate/ConfigurableAggregateTranslator.php","position":71,"original_position":71,"commit_id":"c51bf39409268b343db7ea395e909f89439b5f73","original_commit_id":"c51bf39409268b343db7ea395e909f89439b5f73","user":{"login":"prolic","id":394428,"avatar_url":"https://avatars.githubusercontent.com/u/394428?v=3","gravatar_id":"","url":"https://api.github.com/users/prolic","html_url":"https://github.com/prolic","followers_url":"https://api.github.com/users/prolic/followers","following_url":"https://api.github.com/users/prolic/following{/other_user}","gists_url":"https://api.github.com/users/prolic/gists{/gist_id}","starred_url":"https://api.github.com/users/prolic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prolic/subscriptions","organizations_url":"https://api.github.com/users/prolic/orgs","repos_url":"https://api.github.com/users/prolic/repos","events_url":"https://api.github.com/users/prolic/events{/privacy}","received_events_url":"https://api.github.com/users/prolic/received_events","type":"User","site_admin":false},"body":"same here, Assertion::minLength","created_at":"2015-08-23T14:40:09Z","updated_at":"2015-08-23T14:40:09Z","html_url":"https://github.com/prooph/event-store/pull/85#discussion_r37706372","pull_request_url":"https://api.github.com/repos/prooph/event-store/pulls/85","_links":{"self":{"href":"https://api.github.com/repos/prooph/event-store/pulls/comments/37706372"},"html":{"href":"https://github.com/prooph/event-store/pull/85#discussion_r37706372"},"pull_request":{"href":"https://api.github.com/repos/prooph/event-store/pulls/85"}}},"pull_request":{"url":"https://api.github.com/repos/prooph/event-store/pulls/85","id":43118223,"html_url":"https://github.com/prooph/event-store/pull/85","diff_url":"https://github.com/prooph/event-store/pull/85.diff","patch_url":"https://github.com/prooph/event-store/pull/85.patch","issue_url":"https://api.github.com/repos/prooph/event-store/issues/85","number":85,"state":"open","locked":false,"title":"Configurable aggregate translator","user":{"login":"codeliner","id":5131987,"avatar_url":"https://avatars.githubusercontent.com/u/5131987?v=3","gravatar_id":"","url":"https://api.github.com/users/codeliner","html_url":"https://github.com/codeliner","followers_url":"https://api.github.com/users/codeliner/followers","following_url":"https://api.github.com/users/codeliner/following{/other_user}","gists_url":"https://api.github.com/users/codeliner/gists{/gist_id}","starred_url":"https://api.github.com/users/codeliner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeliner/subscriptions","organizations_url":"https://api.github.com/users/codeliner/orgs","repos_url":"https://api.github.com/users/codeliner/repos","events_url":"https://api.github.com/users/codeliner/events{/privacy}","received_events_url":"https://api.github.com/users/codeliner/received_events","type":"User","site_admin":false},"body":"See #68 \r\n\r\n- Supports configurable method names for extracting\r\n  identifier, pending stream events and reconstitution of the AR\r\n- Forces AR methods to be public available to keep API of\r\n  translator simple\r\n- Offers a way to translate custom events from/to Messages\r\n- AggregateTranslator interface slightly changed to prepare\r\n  support for iterable Stream feature coming in v6.0\r\n\r\nI've decided to not support different method visibility. The translator requires all methods to be public available. If one need more advanced translation logic he or she is asked to use a custom AggregateTranslator.\r\n\r\nAnother feature I added is that the ConfigurableAggregateTranslator takes event translation callbacks as optional arguments to support translation of custom domain events from/to `Prooph\\Common\\Messaging\\Message`s.\r\n\r\nNow the domain model can be fully decoupled from the event store and prooph/event-sourcing plays  only a minor role (should only be used in prooph projects and as an example implementation for other domain models)\r\n\r\nDocumentation will follow in a another PR. I assigned all documentation issues to me and will submit one big docs PR because a lot of things changed and I want to split README to keep it small and focused and move documentation into a `docs` folder.","created_at":"2015-08-23T09:15:39Z","updated_at":"2015-08-23T14:40:09Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5cca00a95c4668c65a4954fced78fa5b8b34f630","assignee":null,"milestone":{"url":"https://api.github.com/repos/prooph/event-store/milestones/3","html_url":"https://github.com/prooph/event-store/milestones/5.0%20Release","labels_url":"https://api.github.com/repos/prooph/event-store/milestones/3/labels","id":1204002,"number":3,"title":"5.0 Release","description":"Get rid of ZF2 hard dependencies","creator":{"login":"codeliner","id":5131987,"avatar_url":"https://avatars.githubusercontent.com/u/5131987?v=3","gravatar_id":"","url":"https://api.github.com/users/codeliner","html_url":"https://github.com/codeliner","followers_url":"https://api.github.com/users/codeliner/followers","following_url":"https://api.github.com/users/codeliner/following{/other_user}","gists_url":"https://api.github.com/users/codeliner/gists{/gist_id}","starred_url":"https://api.github.com/users/codeliner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeliner/subscriptions","organizations_url":"https://api.github.com/users/codeliner/orgs","repos_url":"https://api.github.com/users/codeliner/repos","events_url":"https://api.github.com/users/codeliner/events{/privacy}","received_events_url":"https://api.github.com/users/codeliner/received_events","type":"User","site_admin":false},"open_issues":8,"closed_issues":16,"state":"open","created_at":"2015-07-12T16:08:57Z","updated_at":"2015-08-23T09:15:54Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/prooph/event-store/pulls/85/commits","review_comments_url":"https://api.github.com/repos/prooph/event-store/pulls/85/comments","review_comment_url":"https://api.github.com/repos/prooph/event-store/pulls/comments{/number}","comments_url":"https://api.github.com/repos/prooph/event-store/issues/85/comments","statuses_url":"https://api.github.com/repos/prooph/event-store/statuses/c51bf39409268b343db7ea395e909f89439b5f73","head":{"label":"codeliner:configurable_aggregate_translator","ref":"configurable_aggregate_translator","sha":"c51bf39409268b343db7ea395e909f89439b5f73","user":{"login":"codeliner","id":5131987,"avatar_url":"https://avatars.githubusercontent.com/u/5131987?v=3","gravatar_id":"","url":"https://api.github.com/users/codeliner","html_url":"https://github.com/codeliner","followers_url":"https://api.github.com/users/codeliner/followers","following_url":"https://api.github.com/users/codeliner/following{/other_user}","gists_url":"https://api.github.com/users/codeliner/gists{/gist_id}","starred_url":"https://api.github.com/users/codeliner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeliner/subscriptions","organizations_url":"https://api.github.com/users/codeliner/orgs","repos_url":"https://api.github.com/users/codeliner/repos","events_url":"https://api.github.com/users/codeliner/events{/privacy}","received_events_url":"https://api.github.com/users/codeliner/received_events","type":"User","site_admin":false},"repo":{"id":29202100,"name":"event-store","full_name":"codeliner/event-store","owner":{"login":"codeliner","id":5131987,"avatar_url":"https://avatars.githubusercontent.com/u/5131987?v=3","gravatar_id":"","url":"https://api.github.com/users/codeliner","html_url":"https://github.com/codeliner","followers_url":"https://api.github.com/users/codeliner/followers","following_url":"https://api.github.com/users/codeliner/following{/other_user}","gists_url":"https://api.github.com/users/codeliner/gists{/gist_id}","starred_url":"https://api.github.com/users/codeliner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeliner/subscriptions","organizations_url":"https://api.github.com/users/codeliner/orgs","repos_url":"https://api.github.com/users/codeliner/repos","events_url":"https://api.github.com/users/codeliner/events{/privacy}","received_events_url":"https://api.github.com/users/codeliner/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/codeliner/event-store","description":"PHP 5.4+ EventStore Implementation","fork":true,"url":"https://api.github.com/repos/codeliner/event-store","forks_url":"https://api.github.com/repos/codeliner/event-store/forks","keys_url":"https://api.github.com/repos/codeliner/event-store/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codeliner/event-store/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codeliner/event-store/teams","hooks_url":"https://api.github.com/repos/codeliner/event-store/hooks","issue_events_url":"https://api.github.com/repos/codeliner/event-store/issues/events{/number}","events_url":"https://api.github.com/repos/codeliner/event-store/events","assignees_url":"https://api.github.com/repos/codeliner/event-store/assignees{/user}","branches_url":"https://api.github.com/repos/codeliner/event-store/branches{/branch}","tags_url":"https://api.github.com/repos/codeliner/event-store/tags","blobs_url":"https://api.github.com/repos/codeliner/event-store/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codeliner/event-store/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codeliner/event-store/git/refs{/sha}","trees_url":"https://api.github.com/repos/codeliner/event-store/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codeliner/event-store/statuses/{sha}","languages_url":"https://api.github.com/repos/codeliner/event-store/languages","stargazers_url":"https://api.github.com/repos/codeliner/event-store/stargazers","contributors_url":"https://api.github.com/repos/codeliner/event-store/contributors","subscribers_url":"https://api.github.com/repos/codeliner/event-store/subscribers","subscription_url":"https://api.github.com/repos/codeliner/event-store/subscription","commits_url":"https://api.github.com/repos/codeliner/event-store/commits{/sha}","git_commits_url":"https://api.github.com/repos/codeliner/event-store/git/commits{/sha}","comments_url":"https://api.github.com/repos/codeliner/event-store/comments{/number}","issue_comment_url":"https://api.github.com/repos/codeliner/event-store/issues/comments{/number}","contents_url":"https://api.github.com/repos/codeliner/event-store/contents/{+path}","compare_url":"https://api.github.com/repos/codeliner/event-store/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codeliner/event-store/merges","archive_url":"https://api.github.com/repos/codeliner/event-store/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codeliner/event-store/downloads","issues_url":"https://api.github.com/repos/codeliner/event-store/issues{/number}","pulls_url":"https://api.github.com/repos/codeliner/event-store/pulls{/number}","milestones_url":"https://api.github.com/repos/codeliner/event-store/milestones{/number}","notifications_url":"https://api.github.com/repos/codeliner/event-store/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codeliner/event-store/labels{/name}","releases_url":"https://api.github.com/repos/codeliner/event-store/releases{/id}","created_at":"2015-01-13T17:31:32Z","updated_at":"2015-01-13T17:31:33Z","pushed_at":"2015-08-23T09:00:04Z","git_url":"git://github.com/codeliner/event-store.git","ssh_url":"git@github.com:codeliner/event-store.git","clone_url":"https://github.com/codeliner/event-store.git","svn_url":"https://github.com/codeliner/event-store","homepage":"","size":373,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"prooph:5.0-beta","ref":"5.0-beta","sha":"eef0ceba313de9982f318cc18123f19a3416b1c8","user":{"login":"prooph","id":7341005,"avatar_url":"https://avatars.githubusercontent.com/u/7341005?v=3","gravatar_id":"","url":"https://api.github.com/users/prooph","html_url":"https://github.com/prooph","followers_url":"https://api.github.com/users/prooph/followers","following_url":"https://api.github.com/users/prooph/following{/other_user}","gists_url":"https://api.github.com/users/prooph/gists{/gist_id}","starred_url":"https://api.github.com/users/prooph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prooph/subscriptions","organizations_url":"https://api.github.com/users/prooph/orgs","repos_url":"https://api.github.com/users/prooph/repos","events_url":"https://api.github.com/users/prooph/events{/privacy}","received_events_url":"https://api.github.com/users/prooph/received_events","type":"Organization","site_admin":false},"repo":{"id":18950794,"name":"event-store","full_name":"prooph/event-store","owner":{"login":"prooph","id":7341005,"avatar_url":"https://avatars.githubusercontent.com/u/7341005?v=3","gravatar_id":"","url":"https://api.github.com/users/prooph","html_url":"https://github.com/prooph","followers_url":"https://api.github.com/users/prooph/followers","following_url":"https://api.github.com/users/prooph/following{/other_user}","gists_url":"https://api.github.com/users/prooph/gists{/gist_id}","starred_url":"https://api.github.com/users/prooph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prooph/subscriptions","organizations_url":"https://api.github.com/users/prooph/orgs","repos_url":"https://api.github.com/users/prooph/repos","events_url":"https://api.github.com/users/prooph/events{/privacy}","received_events_url":"https://api.github.com/users/prooph/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/prooph/event-store","description":"PHP 5.5+ EventStore Implementation.","fork":false,"url":"https://api.github.com/repos/prooph/event-store","forks_url":"https://api.github.com/repos/prooph/event-store/forks","keys_url":"https://api.github.com/repos/prooph/event-store/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prooph/event-store/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prooph/event-store/teams","hooks_url":"https://api.github.com/repos/prooph/event-store/hooks","issue_events_url":"https://api.github.com/repos/prooph/event-store/issues/events{/number}","events_url":"https://api.github.com/repos/prooph/event-store/events","assignees_url":"https://api.github.com/repos/prooph/event-store/assignees{/user}","branches_url":"https://api.github.com/repos/prooph/event-store/branches{/branch}","tags_url":"https://api.github.com/repos/prooph/event-store/tags","blobs_url":"https://api.github.com/repos/prooph/event-store/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prooph/event-store/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prooph/event-store/git/refs{/sha}","trees_url":"https://api.github.com/repos/prooph/event-store/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prooph/event-store/statuses/{sha}","languages_url":"https://api.github.com/repos/prooph/event-store/languages","stargazers_url":"https://api.github.com/repos/prooph/event-store/stargazers","contributors_url":"https://api.github.com/repos/prooph/event-store/contributors","subscribers_url":"https://api.github.com/repos/prooph/event-store/subscribers","subscription_url":"https://api.github.com/repos/prooph/event-store/subscription","commits_url":"https://api.github.com/repos/prooph/event-store/commits{/sha}","git_commits_url":"https://api.github.com/repos/prooph/event-store/git/commits{/sha}","comments_url":"https://api.github.com/repos/prooph/event-store/comments{/number}","issue_comment_url":"https://api.github.com/repos/prooph/event-store/issues/comments{/number}","contents_url":"https://api.github.com/repos/prooph/event-store/contents/{+path}","compare_url":"https://api.github.com/repos/prooph/event-store/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prooph/event-store/merges","archive_url":"https://api.github.com/repos/prooph/event-store/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prooph/event-store/downloads","issues_url":"https://api.github.com/repos/prooph/event-store/issues{/number}","pulls_url":"https://api.github.com/repos/prooph/event-store/pulls{/number}","milestones_url":"https://api.github.com/repos/prooph/event-store/milestones{/number}","notifications_url":"https://api.github.com/repos/prooph/event-store/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prooph/event-store/labels{/name}","releases_url":"https://api.github.com/repos/prooph/event-store/releases{/id}","created_at":"2014-04-19T21:00:37Z","updated_at":"2015-08-14T21:08:38Z","pushed_at":"2015-08-23T10:52:54Z","git_url":"git://github.com/prooph/event-store.git","ssh_url":"git@github.com:prooph/event-store.git","clone_url":"https://github.com/prooph/event-store.git","svn_url":"https://github.com/prooph/event-store","homepage":"","size":768,"stargazers_count":23,"watchers_count":23,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":14,"forks":4,"open_issues":14,"watchers":23,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/prooph/event-store/pulls/85"},"html":{"href":"https://github.com/prooph/event-store/pull/85"},"issue":{"href":"https://api.github.com/repos/prooph/event-store/issues/85"},"comments":{"href":"https://api.github.com/repos/prooph/event-store/issues/85/comments"},"review_comments":{"href":"https://api.github.com/repos/prooph/event-store/pulls/85/comments"},"review_comment":{"href":"https://api.github.com/repos/prooph/event-store/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/prooph/event-store/pulls/85/commits"},"statuses":{"href":"https://api.github.com/repos/prooph/event-store/statuses/c51bf39409268b343db7ea395e909f89439b5f73"}}}}