{"action":"opened","issue":{"url":"https://api.github.com/repos/magento/magento2/issues/15973","repository_url":"https://api.github.com/repos/magento/magento2","labels_url":"https://api.github.com/repos/magento/magento2/issues/15973/labels{/name}","comments_url":"https://api.github.com/repos/magento/magento2/issues/15973/comments","events_url":"https://api.github.com/repos/magento/magento2/issues/15973/events","html_url":"https://github.com/magento/magento2/issues/15973","id":330886498,"node_id":"MDU6SXNzdWUzMzA4ODY0OTg=","number":15973,"title":"Provide a FactoryInterface","user":{"login":"Swahjak","id":4386577,"node_id":"MDQ6VXNlcjQzODY1Nzc=","avatar_url":"https://avatars2.githubusercontent.com/u/4386577?v=4","gravatar_id":"","url":"https://api.github.com/users/Swahjak","html_url":"https://github.com/Swahjak","followers_url":"https://api.github.com/users/Swahjak/followers","following_url":"https://api.github.com/users/Swahjak/following{/other_user}","gists_url":"https://api.github.com/users/Swahjak/gists{/gist_id}","starred_url":"https://api.github.com/users/Swahjak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Swahjak/subscriptions","organizations_url":"https://api.github.com/users/Swahjak/orgs","repos_url":"https://api.github.com/users/Swahjak/repos","events_url":"https://api.github.com/users/Swahjak/events{/privacy}","received_events_url":"https://api.github.com/users/Swahjak/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-09T13:19:45Z","updated_at":"2018-06-09T13:19:45Z","closed_at":null,"author_association":"NONE","body":"<!---\r\n    Thank you for contributing to Magento.\r\n    To help us process this issue we recommend that you add the following information:\r\n     - Summary of the issue,\r\n     - Information on your environment,\r\n     - Steps to reproduce,\r\n     - Expected and actual results,\r\n\r\n    Please also have a look at our guidelines article before adding a new issue https://github.com/magento/magento2/wiki/Issue-reporting-guidelines\r\n-->\r\n\r\n### Preconditions\r\n<!---\r\n    Please provide as detailed information about your environment as possible.\r\n    For example Magento version, tag, HEAD, PHP & MySQL version, etc..\r\n-->\r\n1. Create a custom factory\r\n\r\n### Steps to reproduce\r\n<!---\r\n    It is important to provide a set of clear steps to reproduce this bug.\r\n    If relevant please include code samples\r\n-->\r\n1. Magento changes the way factories are implemented\r\n\r\n### Expected result\r\n<!--- Tell us what should happen -->\r\n1. I get errors about my factories not applying the correct interface methods\r\n\r\n### Actual result\r\n<!--- Tell us what happens instead -->\r\n1. My code breaks without a warning\r\n\r\nIn my opinion there is no reason for auto generating factories at all. If factories are required they could be easily achieved with a default factory class and a simple configuration (see below). But considering the current situation I guess it's to late to change this. I would like to suggest introducing an ```FactoryInterface``` which all auto generated Factories implement. This way there is a \"contract\" for the Factory which can catch errors in an early development stage more easily.\r\n\r\n```php\r\n/**\r\n * Class FactoryInterface\r\n */\r\ninterface FactoryInterface\r\n{\r\n    /**\r\n     * @param null $data\r\n     */\r\n    public function create($data = null);\r\n}\r\n\r\n```\r\n\r\n```php\r\n/**\r\n * Class Factor\r\n */\r\nclass Factory\r\n{\r\n    /**\r\n     * @var \\Magento\\Framework\\ObjectManagerInterface\r\n     */\r\n    protected $objectManager;\r\n\r\n    /**\r\n     * @var string\r\n     */\r\n    protected $modelClassName;\r\n\r\n    /**\r\n     * @param \\Magento\\Framework\\ObjectManagerInterface $objectManager\r\n     */\r\n    public function __construct(\r\n        \\Magento\\Framework\\ObjectManagerInterface $objectManager,\r\n        string $modelClassName\r\n    )\r\n    {\r\n        $this->objectManager = $objectManager;\r\n        $this->modelClassName = $modelClassName;\r\n    }\r\n\r\n    /**\r\n     * Create model\r\n     *\r\n     * @param array $data\r\n     * @return object\r\n     */\r\n    public function create($data = null)\r\n    {\r\n        return $this->objectManager->create($this->modelClassName, $data);\r\n    }\r\n}\r\n```\r\n"}}
{"actor":{"display_login":"Swahjak"}}