Last active
August 29, 2015 14:13
-
-
Save anyt/7811825066efef31cb63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: ~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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