summaryrefslogtreecommitdiffstats
path: root/app/bootstrap_cache.php.cache
diff options
context:
space:
mode:
authorChristophe Coevoet <stof@notk.org>2011-06-07 02:01:21 +0200
committerChristophe Coevoet <stof@notk.org>2011-06-07 02:01:21 +0200
commitdd5f4005639489cc27779778481420520553df9c (patch)
tree10644f03b88c827ebcdcb0440e4fef5047d285b5 /app/bootstrap_cache.php.cache
parent6633957f20c1fe86021f9c0fa1ed8a8648ca3f05 (diff)
Updated vendorsHEADmaster
Diffstat (limited to 'app/bootstrap_cache.php.cache')
-rw-r--r--app/bootstrap_cache.php.cache197
1 files changed, 117 insertions, 80 deletions
diff --git a/app/bootstrap_cache.php.cache b/app/bootstrap_cache.php.cache
index b761d26..19f5ae1 100644
--- a/app/bootstrap_cache.php.cache
+++ b/app/bootstrap_cache.php.cache
@@ -104,6 +104,9 @@ abstract class Kernel implements KernelInterface
}
public function shutdown()
{
+ if (false === $this->booted) {
+ return;
+ }
$this->booted = false;
foreach ($this->getBundles() as $bundle) {
$bundle->shutdown();
@@ -338,6 +341,15 @@ abstract class Kernel implements KernelInterface
}
protected function buildContainer()
{
+ foreach (array('cache' => $this->getCacheDir(), 'logs' => $this->getLogDir()) as $name => $dir) {
+ if (!is_dir($dir)) {
+ if (false === @mkdir($dir, 0777, true)) {
+ throw new \RuntimeException(sprintf("Unable to create the %s directory (%s)\n", $name, dirname($dir)));
+ }
+ } elseif (!is_writable($dir)) {
+ throw new \RuntimeException(sprintf("Unable to write in the %s directory (%s)\n", $name, $dir));
+ }
+ }
$container = new ContainerBuilder(new ParameterBag($this->getKernelParameters()));
$extensions = array();
foreach ($this->bundles as $bundle) {
@@ -355,16 +367,6 @@ abstract class Kernel implements KernelInterface
if (null !== $cont = $this->registerContainerConfiguration($this->getContainerLoader($container))) {
$container->merge($cont);
}
- foreach (array('cache', 'logs') as $name) {
- $dir = $container->getParameter(sprintf('kernel.%s_dir', $name));
- if (!is_dir($dir)) {
- if (false === @mkdir($dir, 0777, true)) {
- exit(sprintf("Unable to create the %s directory (%s)\n", $name, dirname($dir)));
- }
- } elseif (!is_writable($dir)) {
- exit(sprintf("Unable to write in the %s directory (%s)\n", $name, $dir));
- }
- }
$container->addCompilerPass(new AddClassesToCachePass($this));
$container->compile();
$this->addClassesToCache($container->getParameter('kernel.compiled_classes'));
@@ -506,6 +508,7 @@ class HttpCache implements HttpKernelInterface
}
$response->isNotModified($request);
$this->restoreResponseBody($request, $response);
+ $response->setDate(new \DateTime(null, new \DateTimeZone('UTC')));
if (HttpKernelInterface::MASTER_REQUEST === $type && $this->options['debug']) {
$response->headers->set('X-Symfony-Cache', $this->getLog());
}
@@ -559,22 +562,23 @@ class HttpCache implements HttpKernelInterface
}
if (!$this->isFreshEnough($request, $entry)) {
$this->record($request, 'stale');
- return $this->validate($request, $entry);
+ return $this->validate($request, $entry, $catch);
}
$this->record($request, 'fresh');
$entry->headers->set('Age', $entry->getAge());
return $entry;
}
- protected function validate(Request $request, Response $entry)
+ protected function validate(Request $request, Response $entry, $catch = false)
{
$subRequest = clone $request;
$subRequest->setMethod('get');
$subRequest->headers->set('if_modified_since', $entry->headers->get('Last-Modified'));
- $cachedEtags = array($entry->getEtag());
+ $cachedEtags = $entry->getEtag() ? array($entry->getEtag()) : array();
$requestEtags = $request->getEtags();
- $etags = array_unique(array_merge($cachedEtags, $requestEtags));
- $subRequest->headers->set('if_none_match', $etags ? implode(', ', $etags) : '');
- $response = $this->forward($subRequest, false, $entry);
+ if ($etags = array_unique(array_merge($cachedEtags, $requestEtags))) {
+ $subRequest->headers->set('if_none_match', implode(', ', $etags));
+ }
+ $response = $this->forward($subRequest, $catch, $entry);
if (304 == $response->getStatusCode()) {
$this->record($request, 'valid');
$etag = $response->getEtag();
@@ -663,7 +667,9 @@ class HttpCache implements HttpKernelInterface
$entry->setContent($new->getContent());
$entry->setStatusCode($new->getStatusCode());
$entry->setProtocolVersion($new->getProtocolVersion());
- $entry->setCookies($new->getCookies());
+ foreach ($new->headers->getCookies() as $cookie) {
+ $entry->headers->setCookie($cookie);
+ }
} else {
$entry->setStatusCode(503);
$entry->setContent('503 Service Unavailable');
@@ -1115,14 +1121,10 @@ class ParameterBag
{
$this->parameters = array_replace($this->parameters, $parameters);
}
- public function get($key, $default = null)
- {
- return array_key_exists($key, $this->parameters) ? $this->parameters[$key] : $default;
- }
- public function getDeep($path, $default = null)
+ public function get($path, $default = null, $deep = false)
{
- if (false === $pos = strpos($path, '[')) {
- return $this->get($path, $default);
+ if (!$deep || false === $pos = strpos($path, '[')) {
+ return array_key_exists($path, $this->parameters) ? $this->parameters[$path] : $default;
}
$root = substr($path, 0, $pos);
if (!array_key_exists($root, $this->parameters)) {
@@ -1170,21 +1172,21 @@ class ParameterBag
{
unset($this->parameters[$key]);
}
- public function getAlpha($key, $default = '')
+ public function getAlpha($key, $default = '', $deep = false)
{
- return preg_replace('/[^[:alpha:]]/', '', $this->get($key, $default));
+ return preg_replace('/[^[:alpha:]]/', '', $this->get($key, $default, $deep));
}
- public function getAlnum($key, $default = '')
+ public function getAlnum($key, $default = '', $deep = false)
{
- return preg_replace('/[^[:alnum:]]/', '', $this->get($key, $default));
+ return preg_replace('/[^[:alnum:]]/', '', $this->get($key, $default, $deep));
}
- public function getDigits($key, $default = '')
+ public function getDigits($key, $default = '', $deep = false)
{
- return preg_replace('/[^[:digit:]]/', '', $this->get($key, $default));
+ return preg_replace('/[^[:digit:]]/', '', $this->get($key, $default, $deep));
}
- public function getInt($key, $default = 0)
+ public function getInt($key, $default = 0, $deep = false)
{
- return (int) $this->get($key, $default);
+ return (int) $this->get($key, $default, $deep);
}
}
}
@@ -1295,6 +1297,24 @@ class HeaderBag
$this->set($key, $values);
}
}
+ public function __toString()
+ {
+ if (!$this->headers) {
+ return '';
+ }
+ $beautifier = function ($name) {
+ return preg_replace('/\-(.)/e', "'-'.strtoupper('\\1')", ucfirst($name));
+ };
+ $max = max(array_map('strlen', array_keys($this->headers))) + 1;
+ $content = '';
+ ksort($this->headers);
+ foreach ($this->headers as $name => $values) {
+ foreach ($values as $value) {
+ $content .= sprintf("%-{$max}s %s\r\n", $beautifier($name).':', $value);
+ }
+ }
+ return $content;
+ }
public function all()
{
return $this->headers;
@@ -1485,7 +1505,14 @@ class Request
}
static public function createFromGlobals()
{
- return new static($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER);
+ $request = new static($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER);
+ if (0 === strpos($request->server->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded')
+ && in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE'))
+ ) {
+ parse_str($request->getContent(), $data);
+ $request->request = new ParameterBag($data);
+ }
+ return $request;
}
static public function create($uri, $method = 'GET', $parameters = array(), $cookies = array(), $files = array(), $server = array(), $content = null)
{
@@ -1500,6 +1527,7 @@ class Request
'REMOTE_ADDR' => '127.0.0.1',
'SCRIPT_NAME' => '',
'SCRIPT_FILENAME' => '',
+ 'SERVER_PROTOCOL' => 'HTTP/1.1',
);
$components = parse_url($uri);
if (isset($components['host'])) {
@@ -1586,6 +1614,13 @@ class Request
$this->server = clone $this->server;
$this->headers = clone $this->headers;
}
+ public function __toString()
+ {
+ return
+ sprintf('%s %s %s', $this->getMethod(), $this->getRequestUri(), $this->server->get('SERVER_PROTOCOL'))."\r\n".
+ $this->headers."\r\n".
+ $this->getContent();
+ }
public function overrideGlobals()
{
$_GET = $this->query->all();
@@ -1597,18 +1632,22 @@ class Request
}
$_REQUEST = array_merge($_GET, $_POST);
}
- public function get($key, $default = null)
+ public function get($key, $default = null, $deep = false)
{
- return $this->query->get($key, $this->attributes->get($key, $this->request->get($key, $default)));
+ return $this->query->get($key, $this->attributes->get($key, $this->request->get($key, $default, $deep), $deep), $deep);
}
public function getSession()
{
return $this->session;
}
- public function hasSession()
+ public function hasPreviousSession()
{
return $this->cookies->has(session_name()) && null !== $this->session;
}
+ public function hasSession()
+ {
+ return null !== $this->session;
+ }
public function setSession(Session $session)
{
$this->session = $session;
@@ -1659,17 +1698,12 @@ class Request
}
public function getHttpHost()
{
- $host = $this->headers->get('HOST');
- if (!empty($host)) {
- return $host;
- }
$scheme = $this->getScheme();
- $name = $this->server->get('SERVER_NAME');
$port = $this->getPort();
if (('http' == $scheme && $port == 80) || ('https' == $scheme && $port == 443)) {
- return $name;
+ return $this->getHost();
}
- return $name.':'.$port;
+ return $this->getHost().':'.$port;
}
public function getRequestUri()
{
@@ -1745,7 +1779,7 @@ class Request
if (null === $this->method) {
$this->method = strtoupper($this->server->get('REQUEST_METHOD', 'GET'));
if ('POST' === $this->method) {
- $this->method = strtoupper($this->request->get('_method', 'POST'));
+ $this->method = strtoupper($this->server->get('X-HTTP-METHOD-OVERRIDE', $this->request->get('_method', 'POST')));
}
}
return $this->method;
@@ -1976,14 +2010,14 @@ class Request
{
$baseUrl = $this->getBaseUrl();
if (null === ($requestUri = $this->getRequestUri())) {
- return '';
+ return '/';
}
- $pathInfo = '';
+ $pathInfo = '/';
if ($pos = strpos($requestUri, '?')) {
$requestUri = substr($requestUri, 0, $pos);
}
if ((null !== $baseUrl) && (false === ($pathInfo = substr($requestUri, strlen($baseUrl))))) {
- return '';
+ return '/';
} elseif (null === $baseUrl) {
return $requestUri;
}
@@ -2038,6 +2072,14 @@ class ResponseHeaderBag extends HeaderBag
$this->set('cache-control', '');
}
}
+ public function __toString()
+ {
+ $cookies = '';
+ foreach ($this->cookies as $cookie) {
+ $cookies .= 'Set-Cookie: '.$cookie."\r\n";
+ }
+ return parent::__toString().$cookies;
+ }
public function replace(array $headers = array())
{
parent::replace($headers);
@@ -2146,24 +2188,22 @@ class Response
);
public function __construct($content = '', $status = 200, $headers = array())
{
+ $this->headers = new ResponseHeaderBag($headers);
$this->setContent($content);
$this->setStatusCode($status);
$this->setProtocolVersion('1.0');
- $this->headers = new ResponseHeaderBag($headers);
+ if (!$this->headers->has('Date')) {
+ $this->setDate(new \DateTime(null, new \DateTimeZone('UTC')));
+ }
$this->charset = 'UTF-8';
}
public function __toString()
{
- $content = '';
$this->fixContentType();
- $content .= sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText)."\n";
- foreach ($this->headers->all() as $name => $values) {
- foreach ($values as $value) {
- $content .= "$name: $value\n";
- }
- }
- $content .= "\n".$this->getContent();
- return $content;
+ return
+ sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText)."\r\n".
+ $this->headers."\r\n".
+ $this->getContent();
}
public function __clone()
{
@@ -2261,11 +2301,12 @@ class Response
}
public function getDate()
{
- if (null === $date = $this->headers->getDate('Date')) {
- $date = new \DateTime(null, new \DateTimeZone('UTC'));
- $this->headers->set('Date', $date->format('D, d M Y H:i:s').' GMT');
- }
- return $date;
+ return $this->headers->getDate('Date');
+ }
+ public function setDate(\DateTime $date)
+ {
+ $date->setTimezone(new \DateTimeZone('UTC'));
+ $this->headers->set('Date', $date->format('D, d M Y H:i:s').' GMT');
}
public function getAge()
{
@@ -2465,18 +2506,14 @@ class Response
{
return 404 === $this->statusCode;
}
- public function isRedirect()
+ public function isRedirect($location = null)
{
- return in_array($this->statusCode, array(201, 301, 302, 303, 307));
+ return in_array($this->statusCode, array(201, 301, 302, 303, 307)) && (null === $location ?: $location == $this->headers->get('Location'));
}
public function isEmpty()
{
return in_array($this->statusCode, array(201, 204, 304));
}
- public function isRedirected($location)
- {
- return $this->isRedirect() && $location == $this->headers->get('Location');
- }
protected function fixContentType()
{
if (!$this->headers->has('Content-Type')) {
@@ -2493,8 +2530,8 @@ class UniversalClassLoader
{
private $namespaces = array();
private $prefixes = array();
- private $namespaceFallback = array();
- private $prefixFallback = array();
+ private $namespaceFallbacks = array();
+ private $prefixFallbacks = array();
public function getNamespaces()
{
return $this->namespaces;
@@ -2503,21 +2540,21 @@ class UniversalClassLoader
{
return $this->prefixes;
}
- public function getNamespaceFallback()
+ public function getNamespaceFallbacks()
{
- return $this->namespaceFallback;
+ return $this->namespaceFallbacks;
}
- public function getPrefixFallback()
+ public function getPrefixFallbacks()
{
- return $this->prefixFallback;
+ return $this->prefixFallbacks;
}
- public function registerNamespaceFallback($dirs)
+ public function registerNamespaceFallbacks(array $dirs)
{
- $this->namespaceFallback = (array) $dirs;
+ $this->namespaceFallbacks = $dirs;
}
- public function registerPrefixFallback($dirs)
+ public function registerPrefixFallbacks(array $dirs)
{
- $this->prefixFallback = (array) $dirs;
+ $this->prefixFallbacks = $dirs;
}
public function registerNamespaces(array $namespaces)
{
@@ -2567,7 +2604,7 @@ class UniversalClassLoader
}
}
}
- foreach ($this->namespaceFallback as $dir) {
+ foreach ($this->namespaceFallbacks as $dir) {
$file = $dir.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php';
if (file_exists($file)) {
return $file;
@@ -2584,7 +2621,7 @@ class UniversalClassLoader
}
}
}
- foreach ($this->prefixFallback as $dir) {
+ foreach ($this->prefixFallbacks as $dir) {
$file = $dir.DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $class).'.php';
if (file_exists($file)) {
return $file;