Skip to content

Commit

Permalink
[HttpFoundation] added missing code for last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Nov 12, 2010
1 parent 942104a commit 7257571
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Symfony/Component/HttpFoundation/Response.php
Expand Up @@ -535,15 +535,15 @@ public function setEtag($etag = null, $weak = false)
}

/**
* Sets Response cache headers.
* Sets Response cache headers (validation and/or expiration).
*
* Available options are: etag, last_modified, private, and public.
* Available options are: etag, last_modified, max_age, s_maxage, private, and public.
*
* @param array $options An array of cache options
*/
public function setCache(array $options)
{
if ($diff = array_diff_key($options, array('etag', 'last_modified', 'private', 'public'))) {
if ($diff = array_diff_key($options, array('etag', 'last_modified', 'max_age', 's_maxage', 'private', 'public'))) {
throw new \InvalidArgumentException(sprintf('Response does not support the following options: "%s".', implode('", "', array_keys($diff))));
}

Expand All @@ -555,6 +555,14 @@ public function setCache(array $options)
$this->setLastModified($options['last_modified']);
}

if (isset($options['max_age'])) {
$this->setMaxAge($options['max_age']);
}

if (isset($options['s_maxage'])) {
$this->setSharedMaxAge($options['s_maxage']);
}

if (isset($options['public'])) {
if ($options['public']) {
$this->setPublic();
Expand Down

0 comments on commit 7257571

Please sign in to comment.