Created
January 29, 2013 22:07
-
-
Save jenkoian/4668398 to your computer and use it in GitHub Desktop.
Abstract parent class for common rest controller methods.
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 | |
namespace Acme\DemoBundle\Controller; | |
use Symfony\Component\HttpFoundation\Response; | |
use FOS\RestBundle\Controller\FOSRestController; | |
use FOS\RestBundle\View\View; | |
use Doctrine\ORM\EntityRepository; | |
abstract class RestController extends FOSRestController | |
{ | |
/** | |
* @var Response | |
*/ | |
protected $lastModifiedResponse; | |
/** | |
* @param \DateTime $lastModified | |
* @return bool | |
*/ | |
public function isNotModified(\DateTime $lastModified) | |
{ | |
$this->lastModifiedResponse = new Response(); | |
$this->lastModifiedResponse->setLastModified($lastModified); | |
$this->lastModifiedResponse->setPublic(); | |
if ($this->lastModifiedResponse->isNotModified($this->getRequest())) { | |
return true; | |
} | |
return false; | |
} | |
/** | |
* @return Response | |
*/ | |
public function getLastModifiedResponse() | |
{ | |
return $this->lastModifiedResponse; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment