{"action":"created","comment":{"url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/pulls/comments/54329007","id":54329007,"diff_hunk":"@@ -0,0 +1,161 @@\n+<?php\n+\n+namespace WsSys\\DtoGeneratorBundle\\Generator\\Reader;\n+\n+use WsSys\\DtoGeneratorBundle\\Generator\\Reader;\n+use WsSys\\DtoGeneratorBundle\\Generator\\DataMapper;\n+\n+/**\n+ * Reads Xsd and it's elements\n+ */\n+class XsdReader\n+{\n+    /**\n+     * @var \\DOMDocument \n+     */\n+    protected $dom;\n+    \n+    /**\n+     * @var \\DOMElement \n+     */\n+    protected $start;\n+    \n+    /**\n+     * Reads the XSD from given source\n+     * @param string $source\n+     */\n+    public function read($source)\n+    {\n+        $this->dom = new \\DOMDocument();\n+        $this->dom->load($source);\n+        $this->start = $this->dom->documentElement;\n+    }\n+    \n+    /**\n+     * Return First Element from Xsd\n+     * \n+     * @return Element | null if not found\n+     */\n+    public function getFirstElementWithChildren()\n+    {\n+        $nodes = $this->start->childNodes;\n+        foreach ($nodes as $node) {\n+            if ($node->nodeType === XML_ELEMENT_NODE) {\n+                $element = new Reader\\Xsd\\ComplexTypeElement();\n+                $element->setName($node->getAttribute('name'))\n+                        ->setElementAsFirst(true);\n+                \n+                $this->addChildrenElements($node, $element);\n+\n+                return $element;\n+            }\n+        }\n+        return null;\n+    }\n+    \n+    /**\n+     * Add Children Elements to the given parentElement\n+     * \n+     * @param DOMNode $parentNode\n+     * @param Element $parentElement\n+     */\n+    protected function addChildrenElements($parentNode, &$parentElement) \n+    {\n+        $children = $parentNode->childNodes;\n+\n+        foreach ($children as $node) {\n+            if ($node->nodeType === XML_ELEMENT_NODE) {\n+                switch ($node->localName) {\n+                    case 'complexType':\n+                    case 'all':\n+                    case 'sequence':\n+                        /**\n+                         * Recursively looking at element(localName=element)node\n+                         */\n+                        $this->addChildrenElements($node, $parentElement);\n+                        break;\n+                    case 'element':\n+                        if ($this->isComplexTypeNode($node)) {\n+                            $element = new Reader\\Xsd\\ComplexTypeElement();\n+                            $element->setName($node->getAttribute('name'));\n+                            $this->setComplexTypeChildrenRecursively($node, $element);\n+                            \n+                            $parentElement->addChild($element);\n+                        } else {\n+                            $element = new Reader\\Xsd\\Element();\n+                            $element->setName($node->getAttribute('name'));\n+\n+                            if ($node->getAttribute('type')) {\n+                                $element->setDataType(DataMapper\\DataTypeMapper::XsdToDto($node->getAttribute('type')));\n+                            } else {\n+                                $this->setElementsDataType($node, $element);\n+                            }\n+                            $parentElement->addChild($element);\n+                        }\n+                        break;\n+                    default:\n+                        break;\n+                }\n+            }\n+        }\n+    }\n+    \n+    /**\n+     * Recursively looks at an element which has DataType and sets the type of the element\n+     * \n+     * @param DOMNode $node\n+     * @param Element $element\n+     */\n+    protected function setElementsDataType($node, &$element)\n+    {\n+        $childNodes = $node->childNodes;\n+        \n+        foreach ($childNodes as $childNode) {\n+            $localName = $childNode->localName;\n+            if ($localName == 'simpleType') {","path":"Generator/Reader/XsdReader.php","position":115,"original_position":115,"commit_id":"de4546e15de0a4bab920ec791c5094b6a67f4c11","original_commit_id":"de4546e15de0a4bab920ec791c5094b6a67f4c11","user":{"login":"SvetlinStaevWorldstores","id":17498708,"avatar_url":"https://avatars.githubusercontent.com/u/17498708?v=3","gravatar_id":"","url":"https://api.github.com/users/SvetlinStaevWorldstores","html_url":"https://github.com/SvetlinStaevWorldstores","followers_url":"https://api.github.com/users/SvetlinStaevWorldstores/followers","following_url":"https://api.github.com/users/SvetlinStaevWorldstores/following{/other_user}","gists_url":"https://api.github.com/users/SvetlinStaevWorldstores/gists{/gist_id}","starred_url":"https://api.github.com/users/SvetlinStaevWorldstores/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SvetlinStaevWorldstores/subscriptions","organizations_url":"https://api.github.com/users/SvetlinStaevWorldstores/orgs","repos_url":"https://api.github.com/users/SvetlinStaevWorldstores/repos","events_url":"https://api.github.com/users/SvetlinStaevWorldstores/events{/privacy}","received_events_url":"https://api.github.com/users/SvetlinStaevWorldstores/received_events","type":"User","site_admin":false},"body":"```simpleType``` is ideal for a constant.","created_at":"2016-02-27T05:49:04Z","updated_at":"2016-02-27T05:49:04Z","html_url":"https://github.com/ws-sysdev/symfony-dto-generator/pull/1#discussion_r54329007","pull_request_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/pulls/comments/54329007"},"html":{"href":"https://github.com/ws-sysdev/symfony-dto-generator/pull/1#discussion_r54329007"},"pull_request":{"href":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/pulls/1","id":60549230,"html_url":"https://github.com/ws-sysdev/symfony-dto-generator/pull/1","diff_url":"https://github.com/ws-sysdev/symfony-dto-generator/pull/1.diff","patch_url":"https://github.com/ws-sysdev/symfony-dto-generator/pull/1.patch","issue_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/issues/1","number":1,"state":"open","locked":false,"title":"Dto generator base","user":{"login":"ws-sysdev","id":17271079,"avatar_url":"https://avatars.githubusercontent.com/u/17271079?v=3","gravatar_id":"","url":"https://api.github.com/users/ws-sysdev","html_url":"https://github.com/ws-sysdev","followers_url":"https://api.github.com/users/ws-sysdev/followers","following_url":"https://api.github.com/users/ws-sysdev/following{/other_user}","gists_url":"https://api.github.com/users/ws-sysdev/gists{/gist_id}","starred_url":"https://api.github.com/users/ws-sysdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ws-sysdev/subscriptions","organizations_url":"https://api.github.com/users/ws-sysdev/orgs","repos_url":"https://api.github.com/users/ws-sysdev/repos","events_url":"https://api.github.com/users/ws-sysdev/events{/privacy}","received_events_url":"https://api.github.com/users/ws-sysdev/received_events","type":"User","site_admin":false},"body":"Reads the XSD and generates DTOs.\r\n\r\nToDo: Make sure, all the scenarios are catered.\r\n          Generate Conrollers and Behat Tests","created_at":"2016-02-24T17:47:15Z","updated_at":"2016-02-27T05:49:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"59bdbe93342031128cc627b00d435d69d94a29f4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/pulls/1/commits","review_comments_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/pulls/1/comments","review_comment_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/issues/1/comments","statuses_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/statuses/de4546e15de0a4bab920ec791c5094b6a67f4c11","head":{"label":"ws-sysdev:dto_generator_base","ref":"dto_generator_base","sha":"de4546e15de0a4bab920ec791c5094b6a67f4c11","user":{"login":"ws-sysdev","id":17271079,"avatar_url":"https://avatars.githubusercontent.com/u/17271079?v=3","gravatar_id":"","url":"https://api.github.com/users/ws-sysdev","html_url":"https://github.com/ws-sysdev","followers_url":"https://api.github.com/users/ws-sysdev/followers","following_url":"https://api.github.com/users/ws-sysdev/following{/other_user}","gists_url":"https://api.github.com/users/ws-sysdev/gists{/gist_id}","starred_url":"https://api.github.com/users/ws-sysdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ws-sysdev/subscriptions","organizations_url":"https://api.github.com/users/ws-sysdev/orgs","repos_url":"https://api.github.com/users/ws-sysdev/repos","events_url":"https://api.github.com/users/ws-sysdev/events{/privacy}","received_events_url":"https://api.github.com/users/ws-sysdev/received_events","type":"User","site_admin":false},"repo":{"id":52267669,"name":"symfony-dto-generator","full_name":"ws-sysdev/symfony-dto-generator","owner":{"login":"ws-sysdev","id":17271079,"avatar_url":"https://avatars.githubusercontent.com/u/17271079?v=3","gravatar_id":"","url":"https://api.github.com/users/ws-sysdev","html_url":"https://github.com/ws-sysdev","followers_url":"https://api.github.com/users/ws-sysdev/followers","following_url":"https://api.github.com/users/ws-sysdev/following{/other_user}","gists_url":"https://api.github.com/users/ws-sysdev/gists{/gist_id}","starred_url":"https://api.github.com/users/ws-sysdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ws-sysdev/subscriptions","organizations_url":"https://api.github.com/users/ws-sysdev/orgs","repos_url":"https://api.github.com/users/ws-sysdev/repos","events_url":"https://api.github.com/users/ws-sysdev/events{/privacy}","received_events_url":"https://api.github.com/users/ws-sysdev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ws-sysdev/symfony-dto-generator","description":"DTO Generator Bundly ","fork":false,"url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator","forks_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/forks","keys_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/teams","hooks_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/hooks","issue_events_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/issues/events{/number}","events_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/events","assignees_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/assignees{/user}","branches_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/branches{/branch}","tags_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/tags","blobs_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/git/refs{/sha}","trees_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/statuses/{sha}","languages_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/languages","stargazers_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/stargazers","contributors_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/contributors","subscribers_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/subscribers","subscription_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/subscription","commits_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/commits{/sha}","git_commits_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/git/commits{/sha}","comments_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/comments{/number}","issue_comment_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/issues/comments{/number}","contents_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/contents/{+path}","compare_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/merges","archive_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/downloads","issues_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/issues{/number}","pulls_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/pulls{/number}","milestones_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/milestones{/number}","notifications_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/labels{/name}","releases_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/releases{/id}","deployments_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/deployments","created_at":"2016-02-22T11:05:34Z","updated_at":"2016-02-22T11:05:34Z","pushed_at":"2016-02-26T16:48:49Z","git_url":"git://github.com/ws-sysdev/symfony-dto-generator.git","ssh_url":"git@github.com:ws-sysdev/symfony-dto-generator.git","clone_url":"https://github.com/ws-sysdev/symfony-dto-generator.git","svn_url":"https://github.com/ws-sysdev/symfony-dto-generator","homepage":null,"size":34,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"ws-sysdev:master","ref":"master","sha":"2694bf6907d9d8adaab21790f78d83b7618392bb","user":{"login":"ws-sysdev","id":17271079,"avatar_url":"https://avatars.githubusercontent.com/u/17271079?v=3","gravatar_id":"","url":"https://api.github.com/users/ws-sysdev","html_url":"https://github.com/ws-sysdev","followers_url":"https://api.github.com/users/ws-sysdev/followers","following_url":"https://api.github.com/users/ws-sysdev/following{/other_user}","gists_url":"https://api.github.com/users/ws-sysdev/gists{/gist_id}","starred_url":"https://api.github.com/users/ws-sysdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ws-sysdev/subscriptions","organizations_url":"https://api.github.com/users/ws-sysdev/orgs","repos_url":"https://api.github.com/users/ws-sysdev/repos","events_url":"https://api.github.com/users/ws-sysdev/events{/privacy}","received_events_url":"https://api.github.com/users/ws-sysdev/received_events","type":"User","site_admin":false},"repo":{"id":52267669,"name":"symfony-dto-generator","full_name":"ws-sysdev/symfony-dto-generator","owner":{"login":"ws-sysdev","id":17271079,"avatar_url":"https://avatars.githubusercontent.com/u/17271079?v=3","gravatar_id":"","url":"https://api.github.com/users/ws-sysdev","html_url":"https://github.com/ws-sysdev","followers_url":"https://api.github.com/users/ws-sysdev/followers","following_url":"https://api.github.com/users/ws-sysdev/following{/other_user}","gists_url":"https://api.github.com/users/ws-sysdev/gists{/gist_id}","starred_url":"https://api.github.com/users/ws-sysdev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ws-sysdev/subscriptions","organizations_url":"https://api.github.com/users/ws-sysdev/orgs","repos_url":"https://api.github.com/users/ws-sysdev/repos","events_url":"https://api.github.com/users/ws-sysdev/events{/privacy}","received_events_url":"https://api.github.com/users/ws-sysdev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ws-sysdev/symfony-dto-generator","description":"DTO Generator Bundly ","fork":false,"url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator","forks_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/forks","keys_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/teams","hooks_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/hooks","issue_events_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/issues/events{/number}","events_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/events","assignees_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/assignees{/user}","branches_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/branches{/branch}","tags_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/tags","blobs_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/git/refs{/sha}","trees_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/statuses/{sha}","languages_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/languages","stargazers_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/stargazers","contributors_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/contributors","subscribers_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/subscribers","subscription_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/subscription","commits_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/commits{/sha}","git_commits_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/git/commits{/sha}","comments_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/comments{/number}","issue_comment_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/issues/comments{/number}","contents_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/contents/{+path}","compare_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/merges","archive_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/downloads","issues_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/issues{/number}","pulls_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/pulls{/number}","milestones_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/milestones{/number}","notifications_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/labels{/name}","releases_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/releases{/id}","deployments_url":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/deployments","created_at":"2016-02-22T11:05:34Z","updated_at":"2016-02-22T11:05:34Z","pushed_at":"2016-02-26T16:48:49Z","git_url":"git://github.com/ws-sysdev/symfony-dto-generator.git","ssh_url":"git@github.com:ws-sysdev/symfony-dto-generator.git","clone_url":"https://github.com/ws-sysdev/symfony-dto-generator.git","svn_url":"https://github.com/ws-sysdev/symfony-dto-generator","homepage":null,"size":34,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/pulls/1"},"html":{"href":"https://github.com/ws-sysdev/symfony-dto-generator/pull/1"},"issue":{"href":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/issues/1"},"comments":{"href":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/ws-sysdev/symfony-dto-generator/statuses/de4546e15de0a4bab920ec791c5094b6a67f4c11"}}}}