{"action":"created","issue":{"url":"https://api.github.com/repos/Sylius/Sylius/issues/2559","labels_url":"https://api.github.com/repos/Sylius/Sylius/issues/2559/labels{/name}","comments_url":"https://api.github.com/repos/Sylius/Sylius/issues/2559/comments","events_url":"https://api.github.com/repos/Sylius/Sylius/issues/2559/events","html_url":"https://github.com/Sylius/Sylius/issues/2559","id":60490989,"number":2559,"title":"[RFC][Resource] Routing","user":{"login":"aRn0D","id":3585922,"avatar_url":"https://avatars.githubusercontent.com/u/3585922?v=3","gravatar_id":"","url":"https://api.github.com/users/aRn0D","html_url":"https://github.com/aRn0D","followers_url":"https://api.github.com/users/aRn0D/followers","following_url":"https://api.github.com/users/aRn0D/following{/other_user}","gists_url":"https://api.github.com/users/aRn0D/gists{/gist_id}","starred_url":"https://api.github.com/users/aRn0D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aRn0D/subscriptions","organizations_url":"https://api.github.com/users/aRn0D/orgs","repos_url":"https://api.github.com/users/aRn0D/repos","events_url":"https://api.github.com/users/aRn0D/events{/privacy}","received_events_url":"https://api.github.com/users/aRn0D/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Sylius/Sylius/labels/ResourceBundle","name":"ResourceBundle","color":"cccccc"},{"url":"https://api.github.com/repos/Sylius/Sylius/labels/RFC","name":"RFC","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-03-10T12:20:47Z","updated_at":"2015-03-11T13:05:34Z","closed_at":null,"body":"Sometime ago, the ApiLoader has been introduced into the resource bundle, it generates the API routes automatically. I think we should use it for the web too because we often write the same routes for simple CRUD.\r\n\r\nI update it for a personal project, now it support two kind of the 'routing' (api and web)\r\n``` php  \r\npublic function supports($resource, $type = null)\r\n    {\r\n        return in_array($type, ['api', 'web']);\r\n    }\r\n```\r\n\r\nit generates these routes (the type is used to generate the key of the route)\r\n``` bash\r\n$ php app/console router:debug | grep theme  \r\napp_web_theme_index            GET       ANY    ANY  /themes/\r\napp_web_theme_show             GET       ANY    ANY  /themes/{id}\r\napp_web_theme_create           POST      ANY    ANY  /themes/\r\napp_web_theme_update           PUT|PATCH ANY    ANY  /themes/{id}\r\napp_web_theme_delete           DELETE    ANY    ANY  /themes/{id}\r\n\r\napp_api_theme_index            GET       ANY    ANY  /themes/\r\napp_api_theme_show             GET       ANY    ANY  /themes/{id}\r\napp_api_theme_create           POST      ANY    ANY  /themes/\r\napp_api_theme_update           PUT|PATCH ANY    ANY  /themes/{id}\r\napp_api_theme_delete           DELETE    ANY    ANY  /themes/{id} \r\n```\r\n\r\nIf you need to use advance feature (like filtering, sorting, define custom repository etc...) you still can overwrite your route.  \r\n\r\n@Sylius/core-team What do you think ?"},"comment":{"url":"https://api.github.com/repos/Sylius/Sylius/issues/comments/78258867","html_url":"https://github.com/Sylius/Sylius/issues/2559#issuecomment-78258867","issue_url":"https://api.github.com/repos/Sylius/Sylius/issues/2559","id":78258867,"user":{"login":"aRn0D","id":3585922,"avatar_url":"https://avatars.githubusercontent.com/u/3585922?v=3","gravatar_id":"","url":"https://api.github.com/users/aRn0D","html_url":"https://github.com/aRn0D","followers_url":"https://api.github.com/users/aRn0D/followers","following_url":"https://api.github.com/users/aRn0D/following{/other_user}","gists_url":"https://api.github.com/users/aRn0D/gists{/gist_id}","starred_url":"https://api.github.com/users/aRn0D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aRn0D/subscriptions","organizations_url":"https://api.github.com/users/aRn0D/orgs","repos_url":"https://api.github.com/users/aRn0D/repos","events_url":"https://api.github.com/users/aRn0D/events{/privacy}","received_events_url":"https://api.github.com/users/aRn0D/received_events","type":"User","site_admin":false},"created_at":"2015-03-11T13:05:34Z","updated_at":"2015-03-11T13:05:34Z","body":"Version 2 : \r\nCreate two route loader : ApiLoader (already exists) and GenericLoader (used for the web)\r\n\r\nApiLoader\r\nType : sylius.api\r\n\r\nGenerated routes :\r\n``` bash\r\n$ php app/console router:debug | grep resource  \r\napp_api_resource_index            GET       ANY    ANY  /resources/\r\napp_api_resource_show             GET       ANY    ANY  /resources/{id}\r\napp_api_resource_create           POST      ANY    ANY  /resources/\r\napp_api_resource_update           PUT|PATCH ANY    ANY  /resources/{id}\r\napp_api_resource_delete           DELETE    ANY    ANY  /resources/{id} \r\n```\r\n`resources` is the plurialized name of the resource\r\n\r\n\r\nGenericLoader\r\nType : sylius\r\n\r\n``` bash\r\n$ php app/console router:debug | grep resource  \r\napp_resource_index                GET       ANY    ANY  /resources/        \r\napp_resource_show                GET       ANY    ANY  /resources/{id}    \r\napp_resource_delete               DELETE    ANY    ANY  /resources/{id}    \r\napp_resource_create               GET|POST  ANY    ANY  /resources/new     \r\napp_resource_update               GET|POST  ANY    ANY  resources/{id}/edit\r\n```\r\n`resources` is the plurialized name of the resource\r\n\r\n`sylius.resource.classes` should be injected in their constructors, they should get all configured resources and build their routes.\r\n\r\nIdea:  A `RouteFactory` should be created for building easily a `Route`"}}