Created
July 4, 2013 13:06
-
-
Save bramstroker/5927554 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
<?php | |
/** | |
* CampsiteController | |
* | |
* @category AcsiCampsite | |
* @package AcsiCampsite\Api | |
* @copyright 2013 ACSI Holding bv (http://www.acsi.eu) | |
* @version SVN: $Id$ | |
*/ | |
namespace AcsiCampsite\Api\Controller; | |
use AcsiCampsite\Entity\Campsite; | |
use ZfrRest\Mvc\Controller\AbstractRestfulController; | |
use ZfrRest\Resource\ResourceInterface; | |
class CampsiteController extends AbstractRestfulController | |
{ | |
/** | |
* Handle the PATCH verb | |
* | |
* @param ResourceInterface $resource | |
*/ | |
public function handlePatchMethod(ResourceInterface $resource) | |
{ | |
$metadata = $resource->getMetadata(); | |
$data = $this->validateData($metadata->getInputFilterName(), $this->decodeBody()); | |
$data = $this->hydrateData($metadata->getHydratorName(), $data, $resource); | |
return $this->patch($data); | |
} | |
/** | |
* @param Campsite $campsite | |
*/ | |
public function patch(Campsite $campsite) | |
{ | |
$em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default'); | |
$em->persist($campsite); | |
$em->flush(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment