public function postCustomerAddressAction($id, Request $request)
    {
        $customer = $id ? $this->getCustomer($id) : null;

        $form = $this->formFactory->createNamed(null, 'sonata_customer_api_form_address', null, [
            'csrf_protection' => false,
        ]);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $address = $form->getData();
            $address->setCustomer($customer);

            $this->addressManager->save($address);

            return $address;
        }

        return $form;
    }
public function postCustomerAddressAction($id, Request $request)
    {
        $customer = $id ? $this->getCustomer($id) : null;

        $form = $this->formFactory->createNamed(null, 'sonata_customer_api_form_address', null, [
            'csrf_protection' => false,
        ]);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $address = $form->getData();
            $address->setCustomer($customer);

            $this->addressManager->save($address);

            return $address;
        }

        return $form;
    }
public function postCustomerAddressAction ( $ id , Request $ request ) { $ customer = $ id ? $ this -> getCustomer ( $ id ) : null ; $ form = $ this -> formFactory -> createNamed ( null , 'sonata_customer_api_form_address' , null , [ 'csrf_protection' => false , ] ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ address = $ form -> getData ( ) ; $ address -> setCustomer ( $ customer ) ; $ this -> addressManager -> save ( $ address ) ; return $ address ; } return $ form ; }
Adds a customer address.

@ApiDoc(
requirements={
{"name"="id", "dataType"="integer", "requirement"="\d+", "description"="customer id"}
},
input={"class"="sonata_customer_api_form_address", "name"="", "groups"={"sonata_api_write"}},
output={"class"="Sonata\CustomerBundle\Model\Address", "groups"={"sonata_api_read"}},
statusCodes={
200="Returned when successful",
400="Returned when an error has occurred while address creation",
}
)

@View(serializerGroups={"sonata_api_read"}, serializerEnableMaxDepthChecks=true)

@param int     $id      A Customer identifier
@param Request $request A Symfony request

@throws NotFoundHttpException

@return Address
Adds a customer address .