Created
November 16, 2020 16:29
-
-
Save merltron-pa/1fa68aa34d9ef496b5067dff7049d0e4 to your computer and use it in GitHub Desktop.
PHP/JMS Article: Add param converter Lib
This file contains hidden or 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 Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; | |
class TestPuppyController extends AbstractFOSRestController | |
{ | |
/** | |
* @var SerializerInterface | |
*/ | |
private $serializer; | |
public function __construct(SerializerInterface $serializer) | |
{ | |
$this->serializer = $serializer; | |
} | |
/** | |
* @Route("/test/address", methods={"POST"}) | |
* @ParamConverter("address", converter="fos_rest.request_body") | |
*/ | |
public function post(Address $address): Response | |
{ | |
$address->setName('Merlin'); | |
return $this->handleView($this->view($address)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment