mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
64 lines
1.8 KiB
PHP
64 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Chill\MainBundle\Controller;
|
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
use Chill\MainBundle\Entity\Address;
|
|
use Chill\MainBundle\Entity\AddressReference;
|
|
|
|
/**
|
|
* Class AddressController
|
|
*
|
|
* @package Chill\MainBundle\Controller
|
|
*/
|
|
class AddressController extends AbstractController
|
|
{
|
|
|
|
|
|
/**
|
|
* Get API Data for showing endpoint
|
|
*
|
|
* @Route(
|
|
* "/{_locale}/main/api/1.0/address/{address_id}/show.{_format}",
|
|
* name="chill_main_address_api_show"
|
|
* )
|
|
* @ParamConverter("address", options={"id": "address_id"})
|
|
*/
|
|
public function showAddress(Address $address, $_format): Response
|
|
{
|
|
// TODO check ACL ?
|
|
switch ($_format) {
|
|
case 'json':
|
|
return $this->json($address);
|
|
default:
|
|
throw new BadRequestException('Unsupported format');
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Get API Data for showing endpoint
|
|
*
|
|
* @Route(
|
|
* "/{_locale}/main/api/1.0/address-reference/{address_reference_id}/show.{_format}",
|
|
* name="chill_main_address_reference_api_show"
|
|
* )
|
|
* @ParamConverter("addressReference", options={"id": "address_reference_id"})
|
|
*/
|
|
public function showAddressReference(AddressReference $addressReference, $_format): Response
|
|
{
|
|
// TODO check ACL ?
|
|
switch ($_format) {
|
|
case 'json':
|
|
return $this->json($addressReference);
|
|
default:
|
|
throw new BadRequestException('Unsupported format');
|
|
}
|
|
|
|
}
|
|
}
|