{"action":"created","issue":{"url":"https://api.github.com/repos/magento/magento2/issues/840","labels_url":"https://api.github.com/repos/magento/magento2/issues/840/labels{/name}","comments_url":"https://api.github.com/repos/magento/magento2/issues/840/comments","events_url":"https://api.github.com/repos/magento/magento2/issues/840/events","html_url":"https://github.com/magento/magento2/issues/840","id":52501623,"number":840,"title":"[Theming] setting version and parent in theme.xml vs composer.json","user":{"login":"Vinai","id":72463,"avatar_url":"https://avatars.githubusercontent.com/u/72463?v=3","gravatar_id":"","url":"https://api.github.com/users/Vinai","html_url":"https://github.com/Vinai","followers_url":"https://api.github.com/users/Vinai/followers","following_url":"https://api.github.com/users/Vinai/following{/other_user}","gists_url":"https://api.github.com/users/Vinai/gists{/gist_id}","starred_url":"https://api.github.com/users/Vinai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Vinai/subscriptions","organizations_url":"https://api.github.com/users/Vinai/orgs","repos_url":"https://api.github.com/users/Vinai/repos","events_url":"https://api.github.com/users/Vinai/events{/privacy}","received_events_url":"https://api.github.com/users/Vinai/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/magento/magento2/labels/bug","name":"bug","color":"eb6420"},{"url":"https://api.github.com/repos/magento/magento2/labels/PS","name":"PS","color":"fad8c7"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2014-12-19T16:31:51Z","updated_at":"2015-01-23T21:24:54Z","closed_at":"2015-01-23T21:24:54Z","body":"According to the documentation at http://devdocs.magento.com/guides/v1.0/frontend-dev-guide/themes/theme-create.html#fedg_create_theme_how-to_declare the theme should be registered using a theme.xml file.  \r\nFrom the next paragraph it seems that the theme composer.json file is optional and only required when then theme should be distributed and installable via composer.\r\n\r\nNot too long ago creating a theme with just a theme.xml worked.  \r\nIn the current release Magento ver. 0.42.0-beta1 however both the theme.xml AND the composer.json files are required.  \r\nThere is no indication that is the case however. If one of the two files is missing, the theme simply does not show up in the admin.\r\n\r\nThis happens because the `title` and `media` attributes are read from the theme.xml and the `version` and `parent` are read from the composer.json.  \r\n\r\nHere the excerpt from `\\Magento\\Framework\\Config\\Theme::_extractData()`:\r\n\r\n```{.php}\r\n        if (!empty($configContent)) {\r\n            $dom = new \\DOMDocument();\r\n            $dom->loadXML($configContent);\r\n            // todo: validation of the document\r\n            /** @var $themeNode \\DOMElement */\r\n            $themeNode = $dom->getElementsByTagName('theme')->item(0);\r\n            $data['title'] = $themeNode->getElementsByTagName('title')->item(0)->nodeValue;\r\n            /** @var $mediaNode \\DOMElement */\r\n            $mediaNode = $themeNode->getElementsByTagName('media')->item(0);\r\n            $previewImage = $mediaNode ? $mediaNode->getElementsByTagName('preview_image')->item(0)->nodeValue : '';\r\n            $data['media']['preview_image'] = $previewImage;\r\n        }\r\n\r\n        if (!empty($composerContent)) {\r\n            $json = json_decode($composerContent);\r\n            $package = new Package($json);\r\n            $data['version'] = $package->get('version');\r\n            $parents = (array)$package->get('require', '/.+\\/theme-/');\r\n            $parents = empty($parents) ? null : array_keys($parents);\r\n            $data['parent'] = empty($parents) ? null : array_shift($parents);\r\n        }\r\n```\r\n\r\nI would prefer to simply do a pull request, but I'm unsure about the intended behaviour. Is this a bug or is it the intended behavior?\r\nThe theme.xsd indeed only references the `title` and `media` types.  \r\n\r\nProbably the reasoning behind moving the version and the parent theme into the *composer.json* file was that otherwise both files might become inconsistent. That makes sense, but at least to me it is ugly to require a composer.json file, even if the theme should not be distributed.\r\n\r\nI think the most developer friendly process would be to keep the composer.json optional.  \r\n\r\nPlease allow setting the `version` and the `parent` via the theme.xml file.\r\nThen merge the composer.json settings.\r\nShould the `version` or `parent` be set to a different value in the files, throw an exception.\r\n\r\nThis would be easy to implement, too.\r\n\r\n-----\r\n\r\nOn a side note:\r\nThe validators logging a message\r\n```\r\n'Field can't be empty' in .../app/code/Magento/Core/Model/Theme.php:326\r\n```\r\nis not very helpful without even the **name of the field** that can't be empty....\r\n"},"comment":{"url":"https://api.github.com/repos/magento/magento2/issues/comments/71268513","html_url":"https://github.com/magento/magento2/issues/840#issuecomment-71268513","issue_url":"https://api.github.com/repos/magento/magento2/issues/840","id":71268513,"user":{"login":"muasir","id":593065,"avatar_url":"https://avatars.githubusercontent.com/u/593065?v=3","gravatar_id":"","url":"https://api.github.com/users/muasir","html_url":"https://github.com/muasir","followers_url":"https://api.github.com/users/muasir/followers","following_url":"https://api.github.com/users/muasir/following{/other_user}","gists_url":"https://api.github.com/users/muasir/gists{/gist_id}","starred_url":"https://api.github.com/users/muasir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/muasir/subscriptions","organizations_url":"https://api.github.com/users/muasir/orgs","repos_url":"https://api.github.com/users/muasir/repos","events_url":"https://api.github.com/users/muasir/events{/privacy}","received_events_url":"https://api.github.com/users/muasir/received_events","type":"User","site_admin":false},"created_at":"2015-01-23T21:24:54Z","updated_at":"2015-01-23T21:24:54Z","body":"closed based on @joanhe comment."}}