{"id":19140768,"url":"https://github.com/bestit/odm-param-converter-bundle","last_synced_at":"2026-04-19T02:31:30.480Z","repository":{"id":62493530,"uuid":"96456697","full_name":"bestit/odm-param-converter-bundle","owner":"bestit","description":"Provide param converter for odm","archived":false,"fork":false,"pushed_at":"2020-06-22T11:20:41.000Z","size":20,"stargazers_count":0,"open_issues_count":5,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-11-13T02:04:04.352Z","etag":null,"topics":["commercetools","odm","symfony"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bestit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-06T17:43:59.000Z","updated_at":"2020-06-22T11:19:59.000Z","dependencies_parsed_at":"2022-11-02T11:17:55.507Z","dependency_job_id":null,"html_url":"https://github.com/bestit/odm-param-converter-bundle","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/bestit/odm-param-converter-bundle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestit%2Fodm-param-converter-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestit%2Fodm-param-converter-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestit%2Fodm-param-converter-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestit%2Fodm-param-converter-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bestit","download_url":"https://codeload.github.com/bestit/odm-param-converter-bundle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bestit%2Fodm-param-converter-bundle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31991954,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"online","status_checked_at":"2026-04-19T02:00:07.110Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["commercetools","odm","symfony"],"created_at":"2024-11-09T07:18:43.561Z","updated_at":"2026-04-19T02:31:30.444Z","avatar_url":"https://github.com/bestit.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ODM Param Converter Bundle\n\nThis bundle provides a symfony param converter for the commercetools odm framework - similar to the doctrine param converter. \n\nInstallation\n============\n\nStep 1: Download the Bundle\n---------------------------\n\nOpen a command console, enter your project directory and execute the\nfollowing command to download the latest stable version of this bundle:\n\n```console\n$ composer require bestit/odm-param-converter-bundle\n```\n\nThis command requires you to have Composer installed globally, as explained\nin the [installation chapter](https://getcomposer.org/doc/00-intro.md)\nof the Composer documentation.\n\nStep 2: Enable the Bundle\n-------------------------\n\nThen, enable the bundle by adding it to the list of registered bundles\nin the `app/AppKernel.php` file of your project:\n\n```php\n\u003c?php\n// app/AppKernel.php\n\n// ...\nclass AppKernel extends Kernel\n{\n    public function registerBundles()\n    {\n        $bundles = array(\n            // ...\n\n            new BestIt\\ODMParamConverterBundle\\ODMParamConverterBundle(),\n        );\n\n        // ...\n    }\n\n    // ...\n}\n```\n\nStep 3: Using\n-------------------------\n\nThe shortest usage of the param converter is with a standard `id` field. The converter get the repository of the given class (provided by odm)\nand fetch the item. Just use your commercetools object as parameter type hint and name your route id field `id`.\nInternal, the `findOneBy` method will be executed and throws a `NotFoundException` if not item was found.\n\nExample:\n```\n// YourController.php\n\n/**\n * Get custom item\n *\n * @param CustomObject $customObject\n * @Route(\"/custom/{id}\")\n */\npublic function balanceAction(CustomObject $customObject)\n{\n    // ...\n}\n```\n\nIf the placeholder does not have the same name as the primary key, pass the id option (you have to annotate the param converter now):\n\n```\n// YourController.php\n\n/**\n * Get custom item\n *\n * @param CustomObject $customObject\n * @Route(\"/custom/{your_route_id}\")\n * @ParamConverter(\"customObject\", class=\"Commercetools\\Core\\Model\\CustomObject\\CustomObject\", options={\n *    \"id\" = \"your_route_id\"\n * }) \n */\npublic function balanceAction(CustomObject $customObject)\n{\n    // ...\n}\n```\n\nYou can create a mapping if you have to pass multiple parameters for fetching an item. Just create an key value pair\nat the mapping option. The key is your route name (eg. \"container_key\"), the value your commercetools object field (eg. \"container\"):\n\n```\n// YourController.php\n\n/**\n * Get custom item\n *\n * @param CustomObject $customObject\n * @Route(\"/custom/{container_key}/{item_key}\")\n * @ParamConverter(\"customObject\", class=\"Commercetools\\Core\\Model\\CustomObject\\CustomObject\", options={\n *    \"mapping\": {\"container_key\": \"container\", \"item_key\": \"key\"}\n * }) \n */\npublic function balanceAction(CustomObject $customObject)\n{\n    // ...\n}\n```\n\nIf your route params are identical to your commercetools objects fields, you can skip defining the mapping. The param converter will do this\nas long as you don't have an `id` key on your route or has defined the `id` option:\n\n```\n// YourController.php\n\n/**\n * Get custom item\n *\n * @param CustomObject $customObject\n * @Route(\"/custom/{container}/{key}\")\n */\npublic function balanceAction(CustomObject $customObject)\n{\n    // ...\n}\n```\n\nSometimes, you want to execute a special method of your repository. You can change the repository method easily by setting\nthe name of your method in the options. The converter will execute the method with the value of `id` as method argument.\n\n```\n// YourController.php\n\n/**\n * Get custom item\n *\n * @param CustomObject $customObject\n * @Route(\"/custom/{id}\")\n * @ParamConverter(\"customObject\", class=\"Commercetools\\Core\\Model\\CustomObject\\CustomObject\", options={\n *     \"repository_method\" = \"findByMyOwnId\",\n * }) \n */\npublic function balanceAction(CustomObject $customObject)\n{\n    // ...\n}\n```\n\nNaturally, you can mix the repository method option with your mappings. With the following code, the converter will execute\nthe `findByCriteria`. The values will be passed as one array argument.\n\n```\n// YourController.php\n\n/**\n * Get custom item\n *\n * @param CustomObject $customObject\n * @Route(\"/custom/{container}/{key}\")\n * @ParamConverter(\"customObject\", class=\"Commercetools\\Core\\Model\\CustomObject\\CustomObject\", options={\n *     \"repository_method\" = \"findByCriteria\",\n * }) \n */\npublic function balanceAction(CustomObject $customObject)\n{\n    // ...\n}\n```\n\n... \n\n```\n// YourController.php\n\n/**\n * Get custom item\n *\n * @param CustomObject $customObject\n * @Route(\"/custom/{container_key}/{item_key}\")\n * @ParamConverter(\"customObject\", class=\"Commercetools\\Core\\Model\\CustomObject\\CustomObject\", options={\n *    \"repository_method\" = \"findByCriteria\",\n *    \"mapping\": {\"container_key\": \"container\", \"item_key\": \"key\"}\n */\npublic function balanceAction(CustomObject $customObject)\n{\n    // ...\n}\n```\n\nBut maybe, the repository does not expect an array. As example, the `findByContainerAndKey` of the custom object repository\nexpect a container string + a key string and not an array:\n\n```\n// CustomObjectRepository.php\n\npublic function findByContainerAndKey(string $container, string $key)\n{\n// ...\n}\n```\n\nFor this reason you can pass the `map_method_signature` option. If true, all parameters will be matched with the method arguments.\n\n```\n// YourController.php\n\n/**\n * Get custom item\n *\n * @param CustomObject $customObject\n * @Route(\"/custom/{container}/{key}\")\n * @ParamConverter(\"customObject\", class=\"Commercetools\\Core\\Model\\CustomObject\\CustomObject\", options={\n *     \"repository_method\" = \"findByContainerAndKey\",\n *     \"map_method_signature\" = true\n * }) \n */\npublic function balanceAction(CustomObject $customObject)\n{\n    // ...\n}\n```\n\n... \n\n```\n// YourController.php\n\n/**\n * Get custom item\n *\n * @param CustomObject $customObject\n * @Route(\"/custom/{container_key}/{item_key}\")\n * @ParamConverter(\"customObject\", class=\"Commercetools\\Core\\Model\\CustomObject\\CustomObject\", options={\n *    \"repository_method\" = \"findByContainerAndKey\",\n *    \"mapping\": {\"container_key\": \"container\", \"item_key\": \"key\"},\n *    \"map_method_signature\" = true\n */\npublic function balanceAction(CustomObject $customObject)\n{\n    // ...\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbestit%2Fodm-param-converter-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbestit%2Fodm-param-converter-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbestit%2Fodm-param-converter-bundle/lists"}