PHP code example of bestit / odm-param-converter-bundle
1. Go to this page and download the library: Download bestit/odm-param-converter-bundle library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bestit / odm-param-converter-bundle example snippets
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new BestIt\ODMParamConverterBundle\ODMParamConverterBundle(),
);
// ...
}
// ...
}
// YourController.php
/**
* Get custom item
*
* @param CustomObject $customObject
* @Route("/custom/{id}")
*/
public function balanceAction(CustomObject $customObject)
{
// ...
}
// YourController.php
/**
* Get custom item
*
* @param CustomObject $customObject
* @Route("/custom/{your_route_id}")
* @ParamConverter("customObject", class="Commercetools\Core\Model\CustomObject\CustomObject", options={
* "id" = "your_route_id"
* })
*/
public function balanceAction(CustomObject $customObject)
{
// ...
}
// YourController.php
/**
* Get custom item
*
* @param CustomObject $customObject
* @Route("/custom/{container_key}/{item_key}")
* @ParamConverter("customObject", class="Commercetools\Core\Model\CustomObject\CustomObject", options={
* "mapping": {"container_key": "container", "item_key": "key"}
* })
*/
public function balanceAction(CustomObject $customObject)
{
// ...
}
// YourController.php
/**
* Get custom item
*
* @param CustomObject $customObject
* @Route("/custom/{container}/{key}")
*/
public function balanceAction(CustomObject $customObject)
{
// ...
}
// YourController.php
/**
* Get custom item
*
* @param CustomObject $customObject
* @Route("/custom/{id}")
* @ParamConverter("customObject", class="Commercetools\Core\Model\CustomObject\CustomObject", options={
* "repository_method" = "findByMyOwnId",
* })
*/
public function balanceAction(CustomObject $customObject)
{
// ...
}
// YourController.php
/**
* Get custom item
*
* @param CustomObject $customObject
* @Route("/custom/{container}/{key}")
* @ParamConverter("customObject", class="Commercetools\Core\Model\CustomObject\CustomObject", options={
* "repository_method" = "findByCriteria",
* })
*/
public function balanceAction(CustomObject $customObject)
{
// ...
}
// YourController.php
/**
* Get custom item
*
* @param CustomObject $customObject
* @Route("/custom/{container_key}/{item_key}")
* @ParamConverter("customObject", class="Commercetools\Core\Model\CustomObject\CustomObject", options={
* "repository_method" = "findByCriteria",
* "mapping": {"container_key": "container", "item_key": "key"}
*/
public function balanceAction(CustomObject $customObject)
{
// ...
}
// CustomObjectRepository.php
public function findByContainerAndKey(string $container, string $key)
{
// ...
}
// YourController.php
/**
* Get custom item
*
* @param CustomObject $customObject
* @Route("/custom/{container}/{key}")
* @ParamConverter("customObject", class="Commercetools\Core\Model\CustomObject\CustomObject", options={
* "repository_method" = "findByContainerAndKey",
* "map_method_signature" = true
* })
*/
public function balanceAction(CustomObject $customObject)
{
// ...
}
// YourController.php
/**
* Get custom item
*
* @param CustomObject $customObject
* @Route("/custom/{container_key}/{item_key}")
* @ParamConverter("customObject", class="Commercetools\Core\Model\CustomObject\CustomObject", options={
* "repository_method" = "findByContainerAndKey",
* "mapping": {"container_key": "container", "item_key": "key"},
* "map_method_signature" = true
*/
public function balanceAction(CustomObject $customObject)
{
// ...
}