Skip to content

Instantly share code, notes, and snippets.

@anyt
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anyt/7811825066efef31cb63 to your computer and use it in GitHub Desktop.
Save anyt/7811825066efef31cb63 to your computer and use it in GitHub Desktop.
fos_rest:
param_fetcher_listener: true
body_converter:
enabled: false
service:
serializer: jms_serializer.serializer
view:
formats:
json: true
xml: false
html: false
view_response_listener: force
failed_validation: HTTP_BAD_REQUEST
access_denied_listener:
json: true
# format_listener: false
routing_loader:
include_format: false
default_format: json
body_listener:
decoders:
json: fos_rest.decoder.json
exception:
messages:
Symfony\Component\HttpKernel\Exception\HttpException: true
jms_serializer:
metadata:
directories:
- { path: %kernel.root_dir%/Resources/FOSUserBundle/serializer, namespace_prefix: 'FOS\UserBundle' }
nelmio_api_doc: ~
<?php
use FOS\RestBundle\Controller\Annotations\View;
use FOS\RestBundle\Controller\Annotations\Post;
use FOS\RestBundle\Controller\Annotations\Get;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
class Controller {
/**
* @ApiDoc(
* resource=true,
* description="get hospital affiliations list."
* )
* @Get("/get.affiliations")
* @View(StatusCode=200)
*/
public function getAffiliationsAction()
{
$em = $this->getDoctrine()->getManager();
$affiliations = $em->getRepository('FSMyOnCallDocBundle:HospitalAffiliation')->findAll();
return array_map(
function ($affiliation) {
return $affiliation->getName();
},
$affiliations
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment